Cesium3DTileStyle.js 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737
  1. import clone from "../Core/clone.js";
  2. import defaultValue from "../Core/defaultValue.js";
  3. import defined from "../Core/defined.js";
  4. import DeveloperError from "../Core/DeveloperError.js";
  5. import Resource from "../Core/Resource.js";
  6. import when from "../ThirdParty/when.js";
  7. import ConditionsExpression from "./ConditionsExpression.js";
  8. import Expression from "./Expression.js";
  9. /**
  10. * A style that is applied to a {@link Cesium3DTileset}.
  11. * <p>
  12. * Evaluates an expression defined using the
  13. * {@link https://github.com/CesiumGS/3d-tiles/tree/master/specification/Styling|3D Tiles Styling language}.
  14. * </p>
  15. *
  16. * @alias Cesium3DTileStyle
  17. * @constructor
  18. *
  19. * @param {Resource|String|Object} [style] The url of a style or an object defining a style.
  20. *
  21. * @example
  22. * tileset.style = new Cesium.Cesium3DTileStyle({
  23. * color : {
  24. * conditions : [
  25. * ['${Height} >= 100', 'color("purple", 0.5)'],
  26. * ['${Height} >= 50', 'color("red")'],
  27. * ['true', 'color("blue")']
  28. * ]
  29. * },
  30. * show : '${Height} > 0',
  31. * meta : {
  32. * description : '"Building id ${id} has height ${Height}."'
  33. * }
  34. * });
  35. *
  36. * @example
  37. * tileset.style = new Cesium.Cesium3DTileStyle({
  38. * color : 'vec4(${Temperature})',
  39. * pointSize : '${Temperature} * 2.0'
  40. * });
  41. *
  42. * @see {@link https://github.com/CesiumGS/3d-tiles/tree/master/specification/Styling|3D Tiles Styling language}
  43. */
  44. function Cesium3DTileStyle(style) {
  45. this._style = {};
  46. this._ready = false;
  47. this._show = undefined;
  48. this._color = undefined;
  49. this._pointSize = undefined;
  50. this._pointOutlineColor = undefined;
  51. this._pointOutlineWidth = undefined;
  52. this._labelColor = undefined;
  53. this._labelOutlineColor = undefined;
  54. this._labelOutlineWidth = undefined;
  55. this._font = undefined;
  56. this._labelStyle = undefined;
  57. this._labelText = undefined;
  58. this._backgroundColor = undefined;
  59. this._backgroundPadding = undefined;
  60. this._backgroundEnabled = undefined;
  61. this._scaleByDistance = undefined;
  62. this._translucencyByDistance = undefined;
  63. this._distanceDisplayCondition = undefined;
  64. this._heightOffset = undefined;
  65. this._anchorLineEnabled = undefined;
  66. this._anchorLineColor = undefined;
  67. this._image = undefined;
  68. this._disableDepthTestDistance = undefined;
  69. this._horizontalOrigin = undefined;
  70. this._verticalOrigin = undefined;
  71. this._labelHorizontalOrigin = undefined;
  72. this._labelVerticalOrigin = undefined;
  73. this._meta = undefined;
  74. this._colorShaderFunction = undefined;
  75. this._showShaderFunction = undefined;
  76. this._pointSizeShaderFunction = undefined;
  77. this._colorShaderFunctionReady = false;
  78. this._showShaderFunctionReady = false;
  79. this._pointSizeShaderFunctionReady = false;
  80. this._colorShaderTranslucent = false;
  81. var promise;
  82. if (typeof style === "string" || style instanceof Resource) {
  83. var resource = Resource.createIfNeeded(style);
  84. promise = resource.fetchJson(style);
  85. } else {
  86. promise = when.resolve(style);
  87. }
  88. var that = this;
  89. this._readyPromise = promise.then(function (styleJson) {
  90. setup(that, styleJson);
  91. return that;
  92. });
  93. }
  94. function setup(that, styleJson) {
  95. styleJson = defaultValue(clone(styleJson, true), that._style);
  96. that._style = styleJson;
  97. that.show = styleJson.show;
  98. that.color = styleJson.color;
  99. that.pointSize = styleJson.pointSize;
  100. that.pointOutlineColor = styleJson.pointOutlineColor;
  101. that.pointOutlineWidth = styleJson.pointOutlineWidth;
  102. that.labelColor = styleJson.labelColor;
  103. that.labelOutlineColor = styleJson.labelOutlineColor;
  104. that.labelOutlineWidth = styleJson.labelOutlineWidth;
  105. that.labelStyle = styleJson.labelStyle;
  106. that.font = styleJson.font;
  107. that.labelText = styleJson.labelText;
  108. that.backgroundColor = styleJson.backgroundColor;
  109. that.backgroundPadding = styleJson.backgroundPadding;
  110. that.backgroundEnabled = styleJson.backgroundEnabled;
  111. that.scaleByDistance = styleJson.scaleByDistance;
  112. that.translucencyByDistance = styleJson.translucencyByDistance;
  113. that.distanceDisplayCondition = styleJson.distanceDisplayCondition;
  114. that.heightOffset = styleJson.heightOffset;
  115. that.anchorLineEnabled = styleJson.anchorLineEnabled;
  116. that.anchorLineColor = styleJson.anchorLineColor;
  117. that.image = styleJson.image;
  118. that.disableDepthTestDistance = styleJson.disableDepthTestDistance;
  119. that.horizontalOrigin = styleJson.horizontalOrigin;
  120. that.verticalOrigin = styleJson.verticalOrigin;
  121. that.labelHorizontalOrigin = styleJson.labelHorizontalOrigin;
  122. that.labelVerticalOrigin = styleJson.labelVerticalOrigin;
  123. var meta = {};
  124. if (defined(styleJson.meta)) {
  125. var defines = styleJson.defines;
  126. var metaJson = defaultValue(styleJson.meta, defaultValue.EMPTY_OBJECT);
  127. for (var property in metaJson) {
  128. if (metaJson.hasOwnProperty(property)) {
  129. meta[property] = new Expression(metaJson[property], defines);
  130. }
  131. }
  132. }
  133. that._meta = meta;
  134. that._ready = true;
  135. }
  136. function getExpression(tileStyle, value) {
  137. var defines = defaultValue(tileStyle._style, defaultValue.EMPTY_OBJECT)
  138. .defines;
  139. if (!defined(value)) {
  140. return undefined;
  141. } else if (typeof value === "boolean" || typeof value === "number") {
  142. return new Expression(String(value));
  143. } else if (typeof value === "string") {
  144. return new Expression(value, defines);
  145. } else if (defined(value.conditions)) {
  146. return new ConditionsExpression(value, defines);
  147. }
  148. return value;
  149. }
  150. function getJsonFromExpression(expression) {
  151. if (!defined(expression)) {
  152. return undefined;
  153. } else if (defined(expression.expression)) {
  154. return expression.expression;
  155. } else if (defined(expression.conditionsExpression)) {
  156. return clone(expression.conditionsExpression, true);
  157. }
  158. return expression;
  159. }
  160. Object.defineProperties(Cesium3DTileStyle.prototype, {
  161. /**
  162. * Gets the object defining the style using the
  163. * {@link https://github.com/CesiumGS/3d-tiles/tree/master/specification/Styling|3D Tiles Styling language}.
  164. *
  165. * @memberof Cesium3DTileStyle.prototype
  166. *
  167. * @type {Object}
  168. * @readonly
  169. *
  170. * @default {}
  171. *
  172. * @exception {DeveloperError} The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true.
  173. */
  174. style: {
  175. get: function () {
  176. //>>includeStart('debug', pragmas.debug);
  177. if (!this._ready) {
  178. throw new DeveloperError(
  179. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  180. );
  181. }
  182. //>>includeEnd('debug');
  183. return this._style;
  184. },
  185. },
  186. /**
  187. * When <code>true</code>, the style is ready and its expressions can be evaluated. When
  188. * a style is constructed with an object, as opposed to a url, this is <code>true</code> immediately.
  189. *
  190. * @memberof Cesium3DTileStyle.prototype
  191. *
  192. * @type {Boolean}
  193. * @readonly
  194. *
  195. * @default false
  196. */
  197. ready: {
  198. get: function () {
  199. return this._ready;
  200. },
  201. },
  202. /**
  203. * Gets the promise that will be resolved when the the style is ready and its expressions can be evaluated.
  204. *
  205. * @memberof Cesium3DTileStyle.prototype
  206. *
  207. * @type {Promise.<Cesium3DTileStyle>}
  208. * @readonly
  209. */
  210. readyPromise: {
  211. get: function () {
  212. return this._readyPromise;
  213. },
  214. },
  215. /**
  216. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>show</code> property. Alternatively a boolean, string, or object defining a show style can be used.
  217. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  218. * <p>
  219. * The expression must return or convert to a <code>Boolean</code>.
  220. * </p>
  221. * <p>
  222. * This expression is applicable to all tile formats.
  223. * </p>
  224. *
  225. * @memberof Cesium3DTileStyle.prototype
  226. *
  227. * @type {StyleExpression}
  228. *
  229. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  230. *
  231. * @example
  232. * var style = new Cesium3DTileStyle({
  233. * show : '(regExp("^Chest").test(${County})) && (${YearBuilt} >= 1970)'
  234. * });
  235. * style.show.evaluate(feature); // returns true or false depending on the feature's properties
  236. *
  237. * @example
  238. * var style = new Cesium.Cesium3DTileStyle();
  239. * // Override show expression with a custom function
  240. * style.show = {
  241. * evaluate : function(feature) {
  242. * return true;
  243. * }
  244. * };
  245. *
  246. * @example
  247. * var style = new Cesium.Cesium3DTileStyle();
  248. * // Override show expression with a boolean
  249. * style.show = true;
  250. * };
  251. *
  252. * @example
  253. * var style = new Cesium.Cesium3DTileStyle();
  254. * // Override show expression with a string
  255. * style.show = '${Height} > 0';
  256. * };
  257. *
  258. * @example
  259. * var style = new Cesium.Cesium3DTileStyle();
  260. * // Override show expression with a condition
  261. * style.show = {
  262. * conditions: [
  263. * ['${height} > 2', 'false'],
  264. * ['true', 'true']
  265. * ];
  266. * };
  267. */
  268. show: {
  269. get: function () {
  270. //>>includeStart('debug', pragmas.debug);
  271. if (!this._ready) {
  272. throw new DeveloperError(
  273. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  274. );
  275. }
  276. //>>includeEnd('debug');
  277. return this._show;
  278. },
  279. set: function (value) {
  280. this._show = getExpression(this, value);
  281. this._style.show = getJsonFromExpression(this._show);
  282. this._showShaderFunctionReady = false;
  283. },
  284. },
  285. /**
  286. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>color</code> property. Alternatively a string or object defining a color style can be used.
  287. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  288. * <p>
  289. * The expression must return a <code>Color</code>.
  290. * </p>
  291. * <p>
  292. * This expression is applicable to all tile formats.
  293. * </p>
  294. *
  295. * @memberof Cesium3DTileStyle.prototype
  296. *
  297. * @type {StyleExpression}
  298. *
  299. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  300. *
  301. * @example
  302. * var style = new Cesium3DTileStyle({
  303. * color : '(${Temperature} > 90) ? color("red") : color("white")'
  304. * });
  305. * style.color.evaluateColor(feature, result); // returns a Cesium.Color object
  306. *
  307. * @example
  308. * var style = new Cesium.Cesium3DTileStyle();
  309. * // Override color expression with a custom function
  310. * style.color = {
  311. * evaluateColor : function(feature, result) {
  312. * return Cesium.Color.clone(Cesium.Color.WHITE, result);
  313. * }
  314. * };
  315. *
  316. * @example
  317. * var style = new Cesium.Cesium3DTileStyle();
  318. * // Override color expression with a string
  319. * style.color = 'color("blue")';
  320. *
  321. * @example
  322. * var style = new Cesium.Cesium3DTileStyle();
  323. * // Override color expression with a condition
  324. * style.color = {
  325. * conditions : [
  326. * ['${height} > 2', 'color("cyan")'],
  327. * ['true', 'color("blue")']
  328. * ]
  329. * };
  330. */
  331. color: {
  332. get: function () {
  333. //>>includeStart('debug', pragmas.debug);
  334. if (!this._ready) {
  335. throw new DeveloperError(
  336. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  337. );
  338. }
  339. //>>includeEnd('debug');
  340. return this._color;
  341. },
  342. set: function (value) {
  343. this._color = getExpression(this, value);
  344. this._style.color = getJsonFromExpression(this._color);
  345. this._colorShaderFunctionReady = false;
  346. },
  347. },
  348. /**
  349. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>pointSize</code> property. Alternatively a string or object defining a point size style can be used.
  350. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  351. * <p>
  352. * The expression must return a <code>Number</code>.
  353. * </p>
  354. * <p>
  355. * This expression is only applicable to point features in a Vector tile or a Point Cloud tile.
  356. * </p>
  357. *
  358. * @memberof Cesium3DTileStyle.prototype
  359. *
  360. * @type {StyleExpression}
  361. *
  362. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  363. *
  364. * @example
  365. * var style = new Cesium3DTileStyle({
  366. * pointSize : '(${Temperature} > 90) ? 2.0 : 1.0'
  367. * });
  368. * style.pointSize.evaluate(feature); // returns a Number
  369. *
  370. * @example
  371. * var style = new Cesium.Cesium3DTileStyle();
  372. * // Override pointSize expression with a custom function
  373. * style.pointSize = {
  374. * evaluate : function(feature) {
  375. * return 1.0;
  376. * }
  377. * };
  378. *
  379. * @example
  380. * var style = new Cesium.Cesium3DTileStyle();
  381. * // Override pointSize expression with a number
  382. * style.pointSize = 1.0;
  383. *
  384. * @example
  385. * var style = new Cesium.Cesium3DTileStyle();
  386. * // Override pointSize expression with a string
  387. * style.pointSize = '${height} / 10';
  388. *
  389. * @example
  390. * var style = new Cesium.Cesium3DTileStyle();
  391. * // Override pointSize expression with a condition
  392. * style.pointSize = {
  393. * conditions : [
  394. * ['${height} > 2', '1.0'],
  395. * ['true', '2.0']
  396. * ]
  397. * };
  398. */
  399. pointSize: {
  400. get: function () {
  401. //>>includeStart('debug', pragmas.debug);
  402. if (!this._ready) {
  403. throw new DeveloperError(
  404. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  405. );
  406. }
  407. //>>includeEnd('debug');
  408. return this._pointSize;
  409. },
  410. set: function (value) {
  411. this._pointSize = getExpression(this, value);
  412. this._style.pointSize = getJsonFromExpression(this._pointSize);
  413. this._pointSizeShaderFunctionReady = false;
  414. },
  415. },
  416. /**
  417. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>pointOutlineColor</code> property. Alternatively a string or object defining a color style can be used.
  418. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  419. * <p>
  420. * The expression must return a <code>Color</code>.
  421. * </p>
  422. * <p>
  423. * This expression is only applicable to point features in a Vector tile.
  424. * </p>
  425. *
  426. * @memberof Cesium3DTileStyle.prototype
  427. *
  428. * @type {StyleExpression}
  429. *
  430. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  431. *
  432. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  433. *
  434. * @example
  435. * var style = new Cesium.Cesium3DTileStyle();
  436. * // Override pointOutlineColor expression with a string
  437. * style.pointOutlineColor = 'color("blue")';
  438. *
  439. * @example
  440. * var style = new Cesium.Cesium3DTileStyle();
  441. * // Override pointOutlineColor expression with a condition
  442. * style.pointOutlineColor = {
  443. * conditions : [
  444. * ['${height} > 2', 'color("cyan")'],
  445. * ['true', 'color("blue")']
  446. * ]
  447. * };
  448. */
  449. pointOutlineColor: {
  450. get: function () {
  451. //>>includeStart('debug', pragmas.debug);
  452. if (!this._ready) {
  453. throw new DeveloperError(
  454. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  455. );
  456. }
  457. //>>includeEnd('debug');
  458. return this._pointOutlineColor;
  459. },
  460. set: function (value) {
  461. this._pointOutlineColor = getExpression(this, value);
  462. this._style.pointOutlineColor = getJsonFromExpression(
  463. this._pointOutlineColor
  464. );
  465. },
  466. },
  467. /**
  468. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>pointOutlineWidth</code> property. Alternatively a string or object defining a number style can be used.
  469. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  470. * <p>
  471. * The expression must return a <code>Number</code>.
  472. * </p>
  473. * <p>
  474. * This expression is only applicable to point features in a Vector tile.
  475. * </p>
  476. *
  477. * @memberof Cesium3DTileStyle.prototype
  478. *
  479. * @type {StyleExpression}
  480. *
  481. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  482. *
  483. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  484. *
  485. * @example
  486. * var style = new Cesium.Cesium3DTileStyle();
  487. * // Override pointOutlineWidth expression with a string
  488. * style.pointOutlineWidth = '5';
  489. *
  490. * @example
  491. * var style = new Cesium.Cesium3DTileStyle();
  492. * // Override pointOutlineWidth expression with a condition
  493. * style.pointOutlineWidth = {
  494. * conditions : [
  495. * ['${height} > 2', '5'],
  496. * ['true', '0']
  497. * ]
  498. * };
  499. */
  500. pointOutlineWidth: {
  501. get: function () {
  502. //>>includeStart('debug', pragmas.debug);
  503. if (!this._ready) {
  504. throw new DeveloperError(
  505. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  506. );
  507. }
  508. //>>includeEnd('debug');
  509. return this._pointOutlineWidth;
  510. },
  511. set: function (value) {
  512. this._pointOutlineWidth = getExpression(this, value);
  513. this._style.pointOutlineWidth = getJsonFromExpression(
  514. this._pointOutlineWidth
  515. );
  516. },
  517. },
  518. /**
  519. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>labelColor</code> property. Alternatively a string or object defining a color style can be used.
  520. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  521. * <p>
  522. * The expression must return a <code>Color</code>.
  523. * </p>
  524. * <p>
  525. * This expression is only applicable to point features in a Vector tile.
  526. * </p>
  527. *
  528. * @memberof Cesium3DTileStyle.prototype
  529. *
  530. * @type {StyleExpression}
  531. *
  532. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  533. *
  534. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  535. *
  536. * @example
  537. * var style = new Cesium.Cesium3DTileStyle();
  538. * // Override labelColor expression with a string
  539. * style.labelColor = 'color("blue")';
  540. *
  541. * @example
  542. * var style = new Cesium.Cesium3DTileStyle();
  543. * // Override labelColor expression with a condition
  544. * style.labelColor = {
  545. * conditions : [
  546. * ['${height} > 2', 'color("cyan")'],
  547. * ['true', 'color("blue")']
  548. * ]
  549. * };
  550. */
  551. labelColor: {
  552. get: function () {
  553. //>>includeStart('debug', pragmas.debug);
  554. if (!this._ready) {
  555. throw new DeveloperError(
  556. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  557. );
  558. }
  559. //>>includeEnd('debug');
  560. return this._labelColor;
  561. },
  562. set: function (value) {
  563. this._labelColor = getExpression(this, value);
  564. this._style.labelColor = getJsonFromExpression(this._labelColor);
  565. },
  566. },
  567. /**
  568. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>labelOutlineColor</code> property. Alternatively a string or object defining a color style can be used.
  569. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  570. * <p>
  571. * The expression must return a <code>Color</code>.
  572. * </p>
  573. * <p>
  574. * This expression is only applicable to point features in a Vector tile.
  575. * </p>
  576. *
  577. * @memberof Cesium3DTileStyle.prototype
  578. *
  579. * @type {StyleExpression}
  580. *
  581. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  582. *
  583. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  584. *
  585. * @example
  586. * var style = new Cesium.Cesium3DTileStyle();
  587. * // Override labelOutlineColor expression with a string
  588. * style.labelOutlineColor = 'color("blue")';
  589. *
  590. * @example
  591. * var style = new Cesium.Cesium3DTileStyle();
  592. * // Override labelOutlineColor expression with a condition
  593. * style.labelOutlineColor = {
  594. * conditions : [
  595. * ['${height} > 2', 'color("cyan")'],
  596. * ['true', 'color("blue")']
  597. * ]
  598. * };
  599. */
  600. labelOutlineColor: {
  601. get: function () {
  602. //>>includeStart('debug', pragmas.debug);
  603. if (!this._ready) {
  604. throw new DeveloperError(
  605. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  606. );
  607. }
  608. //>>includeEnd('debug');
  609. return this._labelOutlineColor;
  610. },
  611. set: function (value) {
  612. this._labelOutlineColor = getExpression(this, value);
  613. this._style.labelOutlineColor = getJsonFromExpression(
  614. this._labelOutlineColor
  615. );
  616. },
  617. },
  618. /**
  619. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>labelOutlineWidth</code> property. Alternatively a string or object defining a number style can be used.
  620. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  621. * <p>
  622. * The expression must return a <code>Number</code>.
  623. * </p>
  624. * <p>
  625. * This expression is only applicable to point features in a Vector tile.
  626. * </p>
  627. *
  628. * @memberof Cesium3DTileStyle.prototype
  629. *
  630. * @type {StyleExpression}
  631. *
  632. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  633. *
  634. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  635. *
  636. * @example
  637. * var style = new Cesium.Cesium3DTileStyle();
  638. * // Override labelOutlineWidth expression with a string
  639. * style.labelOutlineWidth = '5';
  640. *
  641. * @example
  642. * var style = new Cesium.Cesium3DTileStyle();
  643. * // Override labelOutlineWidth expression with a condition
  644. * style.labelOutlineWidth = {
  645. * conditions : [
  646. * ['${height} > 2', '5'],
  647. * ['true', '0']
  648. * ]
  649. * };
  650. */
  651. labelOutlineWidth: {
  652. get: function () {
  653. //>>includeStart('debug', pragmas.debug);
  654. if (!this._ready) {
  655. throw new DeveloperError(
  656. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  657. );
  658. }
  659. //>>includeEnd('debug');
  660. return this._labelOutlineWidth;
  661. },
  662. set: function (value) {
  663. this._labelOutlineWidth = getExpression(this, value);
  664. this._style.labelOutlineWidth = getJsonFromExpression(
  665. this._labelOutlineWidth
  666. );
  667. },
  668. },
  669. /**
  670. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>font</code> property. Alternatively a string or object defining a string style can be used.
  671. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  672. * <p>
  673. * The expression must return a <code>String</code>.
  674. * </p>
  675. * <p>
  676. * This expression is only applicable to point features in a Vector tile.
  677. * </p>
  678. *
  679. * @memberof Cesium3DTileStyle.prototype
  680. *
  681. * @type {StyleExpression}
  682. *
  683. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  684. *
  685. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  686. *
  687. * @example
  688. * var style = new Cesium3DTileStyle({
  689. * font : '(${Temperature} > 90) ? "30px Helvetica" : "24px Helvetica"'
  690. * });
  691. * style.font.evaluate(feature); // returns a String
  692. *
  693. * @example
  694. * var style = new Cesium.Cesium3DTileStyle();
  695. * // Override font expression with a custom function
  696. * style.font = {
  697. * evaluate : function(feature) {
  698. * return '24px Helvetica';
  699. * }
  700. * };
  701. */
  702. font: {
  703. get: function () {
  704. //>>includeStart('debug', pragmas.debug);
  705. if (!this._ready) {
  706. throw new DeveloperError(
  707. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  708. );
  709. }
  710. //>>includeEnd('debug');
  711. return this._font;
  712. },
  713. set: function (value) {
  714. this._font = getExpression(this, value);
  715. this._style.font = getJsonFromExpression(this._font);
  716. },
  717. },
  718. /**
  719. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>label style</code> property. Alternatively a string or object defining a number style can be used.
  720. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  721. * <p>
  722. * The expression must return a <code>LabelStyle</code>.
  723. * </p>
  724. * <p>
  725. * This expression is only applicable to point features in a Vector tile.
  726. * </p>
  727. *
  728. * @memberof Cesium3DTileStyle.prototype
  729. *
  730. * @type {StyleExpression}
  731. *
  732. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  733. *
  734. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  735. *
  736. * @example
  737. * var style = new Cesium3DTileStyle({
  738. * labelStyle : '(${Temperature} > 90) ? ' + LabelStyle.FILL_AND_OUTLINE + ' : ' + LabelStyle.FILL
  739. * });
  740. * style.labelStyle.evaluate(feature); // returns a LabelStyle
  741. *
  742. * @example
  743. * var style = new Cesium.Cesium3DTileStyle();
  744. * // Override labelStyle expression with a custom function
  745. * style.labelStyle = {
  746. * evaluate : function(feature) {
  747. * return LabelStyle.FILL;
  748. * }
  749. * };
  750. */
  751. labelStyle: {
  752. get: function () {
  753. //>>includeStart('debug', pragmas.debug);
  754. if (!this._ready) {
  755. throw new DeveloperError(
  756. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  757. );
  758. }
  759. //>>includeEnd('debug');
  760. return this._labelStyle;
  761. },
  762. set: function (value) {
  763. this._labelStyle = getExpression(this, value);
  764. this._style.labelStyle = getJsonFromExpression(this._labelStyle);
  765. },
  766. },
  767. /**
  768. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>labelText</code> property. Alternatively a string or object defining a string style can be used.
  769. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  770. * <p>
  771. * The expression must return a <code>String</code>.
  772. * </p>
  773. * <p>
  774. * This expression is only applicable to point features in a Vector tile.
  775. * </p>
  776. *
  777. * @memberof Cesium3DTileStyle.prototype
  778. *
  779. * @type {StyleExpression}
  780. *
  781. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  782. *
  783. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  784. *
  785. * @example
  786. * var style = new Cesium3DTileStyle({
  787. * labelText : '(${Temperature} > 90) ? ">90" : "<=90"'
  788. * });
  789. * style.labelText.evaluate(feature); // returns a String
  790. *
  791. * @example
  792. * var style = new Cesium.Cesium3DTileStyle();
  793. * // Override labelText expression with a custom function
  794. * style.labelText = {
  795. * evaluate : function(feature) {
  796. * return 'Example label text';
  797. * }
  798. * };
  799. */
  800. labelText: {
  801. get: function () {
  802. //>>includeStart('debug', pragmas.debug);
  803. if (!this._ready) {
  804. throw new DeveloperError(
  805. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  806. );
  807. }
  808. //>>includeEnd('debug');
  809. return this._labelText;
  810. },
  811. set: function (value) {
  812. this._labelText = getExpression(this, value);
  813. this._style.labelText = getJsonFromExpression(this._labelText);
  814. },
  815. },
  816. /**
  817. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>backgroundColor</code> property. Alternatively a string or object defining a color style can be used.
  818. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  819. * <p>
  820. * The expression must return a <code>Color</code>.
  821. * </p>
  822. * <p>
  823. * This expression is only applicable to point features in a Vector tile.
  824. * </p>
  825. *
  826. * @memberof Cesium3DTileStyle.prototype
  827. *
  828. * @type {StyleExpression}
  829. *
  830. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  831. *
  832. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  833. *
  834. * @example
  835. * var style = new Cesium.Cesium3DTileStyle();
  836. * // Override backgroundColor expression with a string
  837. * style.backgroundColor = 'color("blue")';
  838. *
  839. * @example
  840. * var style = new Cesium.Cesium3DTileStyle();
  841. * // Override backgroundColor expression with a condition
  842. * style.backgroundColor = {
  843. * conditions : [
  844. * ['${height} > 2', 'color("cyan")'],
  845. * ['true', 'color("blue")']
  846. * ]
  847. * };
  848. */
  849. backgroundColor: {
  850. get: function () {
  851. //>>includeStart('debug', pragmas.debug);
  852. if (!this._ready) {
  853. throw new DeveloperError(
  854. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  855. );
  856. }
  857. //>>includeEnd('debug');
  858. return this._backgroundColor;
  859. },
  860. set: function (value) {
  861. this._backgroundColor = getExpression(this, value);
  862. this._style.backgroundColor = getJsonFromExpression(
  863. this._backgroundColor
  864. );
  865. },
  866. },
  867. /**
  868. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>backgroundPadding</code> property. Alternatively a string or object defining a vec2 style can be used.
  869. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  870. * <p>
  871. * The expression must return a <code>Cartesian2</code>.
  872. * </p>
  873. * <p>
  874. * This expression is only applicable to point features in a Vector tile.
  875. * </p>
  876. *
  877. * @memberof Cesium3DTileStyle.prototype
  878. *
  879. * @type {StyleExpression}
  880. *
  881. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  882. *
  883. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  884. *
  885. * @example
  886. * var style = new Cesium.Cesium3DTileStyle();
  887. * // Override backgroundPadding expression with a string
  888. * style.backgroundPadding = 'vec2(5.0, 7.0)';
  889. * style.backgroundPadding.evaluate(feature); // returns a Cartesian2
  890. */
  891. backgroundPadding: {
  892. get: function () {
  893. //>>includeStart('debug', pragmas.debug);
  894. if (!this._ready) {
  895. throw new DeveloperError(
  896. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  897. );
  898. }
  899. //>>includeEnd('debug');
  900. return this._backgroundPadding;
  901. },
  902. set: function (value) {
  903. this._backgroundPadding = getExpression(this, value);
  904. this._style.backgroundPadding = getJsonFromExpression(
  905. this._backgroundPadding
  906. );
  907. },
  908. },
  909. /**
  910. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>backgroundEnabled</code> property. Alternatively a string or object defining a boolean style can be used.
  911. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  912. * <p>
  913. * The expression must return a <code>Boolean</code>.
  914. * </p>
  915. * <p>
  916. * This expression is only applicable to point features in a Vector tile.
  917. * </p>
  918. *
  919. * @memberof Cesium3DTileStyle.prototype
  920. *
  921. * @type {StyleExpression}
  922. *
  923. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  924. *
  925. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  926. *
  927. * @example
  928. * var style = new Cesium.Cesium3DTileStyle();
  929. * // Override backgroundEnabled expression with a string
  930. * style.backgroundEnabled = 'true';
  931. *
  932. * @example
  933. * var style = new Cesium.Cesium3DTileStyle();
  934. * // Override backgroundEnabled expression with a condition
  935. * style.backgroundEnabled = {
  936. * conditions : [
  937. * ['${height} > 2', 'true'],
  938. * ['true', 'false']
  939. * ]
  940. * };
  941. */
  942. backgroundEnabled: {
  943. get: function () {
  944. //>>includeStart('debug', pragmas.debug);
  945. if (!this._ready) {
  946. throw new DeveloperError(
  947. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  948. );
  949. }
  950. //>>includeEnd('debug');
  951. return this._backgroundEnabled;
  952. },
  953. set: function (value) {
  954. this._backgroundEnabled = getExpression(this, value);
  955. this._style.backgroundEnabled = getJsonFromExpression(
  956. this._backgroundEnabled
  957. );
  958. },
  959. },
  960. /**
  961. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>scaleByDistance</code> property. Alternatively a string or object defining a vec4 style can be used.
  962. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  963. * <p>
  964. * The expression must return a <code>Cartesian4</code>.
  965. * </p>
  966. * <p>
  967. * This expression is only applicable to point features in a Vector tile.
  968. * </p>
  969. *
  970. * @memberof Cesium3DTileStyle.prototype
  971. *
  972. * @type {StyleExpression}
  973. *
  974. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  975. *
  976. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  977. *
  978. * @example
  979. * var style = new Cesium.Cesium3DTileStyle();
  980. * // Override scaleByDistance expression with a string
  981. * style.scaleByDistance = 'vec4(1.5e2, 2.0, 1.5e7, 0.5)';
  982. * style.scaleByDistance.evaluate(feature); // returns a Cartesian4
  983. */
  984. scaleByDistance: {
  985. get: function () {
  986. //>>includeStart('debug', pragmas.debug);
  987. if (!this._ready) {
  988. throw new DeveloperError(
  989. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  990. );
  991. }
  992. //>>includeEnd('debug');
  993. return this._scaleByDistance;
  994. },
  995. set: function (value) {
  996. this._scaleByDistance = getExpression(this, value);
  997. this._style.scaleByDistance = getJsonFromExpression(
  998. this._scaleByDistance
  999. );
  1000. },
  1001. },
  1002. /**
  1003. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>translucencyByDistance</code> property. Alternatively a string or object defining a vec4 style can be used.
  1004. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1005. * <p>
  1006. * The expression must return a <code>Cartesian4</code>.
  1007. * </p>
  1008. * <p>
  1009. * This expression is only applicable to point features in a Vector tile.
  1010. * </p>
  1011. *
  1012. * @memberof Cesium3DTileStyle.prototype
  1013. *
  1014. * @type {StyleExpression}
  1015. *
  1016. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1017. *
  1018. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1019. *
  1020. * @example
  1021. * var style = new Cesium.Cesium3DTileStyle();
  1022. * // Override translucencyByDistance expression with a string
  1023. * style.translucencyByDistance = 'vec4(1.5e2, 1.0, 1.5e7, 0.2)';
  1024. * style.translucencyByDistance.evaluate(feature); // returns a Cartesian4
  1025. */
  1026. translucencyByDistance: {
  1027. get: function () {
  1028. //>>includeStart('debug', pragmas.debug);
  1029. if (!this._ready) {
  1030. throw new DeveloperError(
  1031. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1032. );
  1033. }
  1034. //>>includeEnd('debug');
  1035. return this._translucencyByDistance;
  1036. },
  1037. set: function (value) {
  1038. this._translucencyByDistance = getExpression(this, value);
  1039. this._style.translucencyByDistance = getJsonFromExpression(
  1040. this._translucencyByDistance
  1041. );
  1042. },
  1043. },
  1044. /**
  1045. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>distanceDisplayCondition</code> property. Alternatively a string or object defining a vec2 style can be used.
  1046. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1047. * <p>
  1048. * The expression must return a <code>Cartesian2</code>.
  1049. * </p>
  1050. * <p>
  1051. * This expression is only applicable to point features in a Vector tile.
  1052. * </p>
  1053. *
  1054. * @memberof Cesium3DTileStyle.prototype
  1055. *
  1056. * @type {StyleExpression}
  1057. *
  1058. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1059. *
  1060. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1061. *
  1062. * @example
  1063. * var style = new Cesium.Cesium3DTileStyle();
  1064. * // Override distanceDisplayCondition expression with a string
  1065. * style.distanceDisplayCondition = 'vec2(0.0, 5.5e6)';
  1066. * style.distanceDisplayCondition.evaluate(feature); // returns a Cartesian2
  1067. */
  1068. distanceDisplayCondition: {
  1069. get: function () {
  1070. //>>includeStart('debug', pragmas.debug);
  1071. if (!this._ready) {
  1072. throw new DeveloperError(
  1073. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1074. );
  1075. }
  1076. //>>includeEnd('debug');
  1077. return this._distanceDisplayCondition;
  1078. },
  1079. set: function (value) {
  1080. this._distanceDisplayCondition = getExpression(this, value);
  1081. this._style.distanceDisplayCondition = getJsonFromExpression(
  1082. this._distanceDisplayCondition
  1083. );
  1084. },
  1085. },
  1086. /**
  1087. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>heightOffset</code> property. Alternatively a string or object defining a number style can be used.
  1088. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1089. * <p>
  1090. * The expression must return a <code>Number</code>.
  1091. * </p>
  1092. * <p>
  1093. * This expression is only applicable to point features in a Vector tile.
  1094. * </p>
  1095. *
  1096. * @memberof Cesium3DTileStyle.prototype
  1097. *
  1098. * @type {StyleExpression}
  1099. *
  1100. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1101. *
  1102. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1103. *
  1104. * @example
  1105. * var style = new Cesium.Cesium3DTileStyle();
  1106. * // Override heightOffset expression with a string
  1107. * style.heightOffset = '2.0';
  1108. *
  1109. * @example
  1110. * var style = new Cesium.Cesium3DTileStyle();
  1111. * // Override heightOffset expression with a condition
  1112. * style.heightOffset = {
  1113. * conditions : [
  1114. * ['${height} > 2', '4.0'],
  1115. * ['true', '2.0']
  1116. * ]
  1117. * };
  1118. */
  1119. heightOffset: {
  1120. get: function () {
  1121. //>>includeStart('debug', pragmas.debug);
  1122. if (!this._ready) {
  1123. throw new DeveloperError(
  1124. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1125. );
  1126. }
  1127. //>>includeEnd('debug');
  1128. return this._heightOffset;
  1129. },
  1130. set: function (value) {
  1131. this._heightOffset = getExpression(this, value);
  1132. this._style.heightOffset = getJsonFromExpression(this._heightOffset);
  1133. },
  1134. },
  1135. /**
  1136. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>anchorLineEnabled</code> property. Alternatively a string or object defining a boolean style can be used.
  1137. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1138. * <p>
  1139. * The expression must return a <code>Boolean</code>.
  1140. * </p>
  1141. * <p>
  1142. * This expression is only applicable to point features in a Vector tile.
  1143. * </p>
  1144. *
  1145. * @memberof Cesium3DTileStyle.prototype
  1146. *
  1147. * @type {StyleExpression}
  1148. *
  1149. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1150. *
  1151. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1152. *
  1153. * @example
  1154. * var style = new Cesium.Cesium3DTileStyle();
  1155. * // Override anchorLineEnabled expression with a string
  1156. * style.anchorLineEnabled = 'true';
  1157. *
  1158. * @example
  1159. * var style = new Cesium.Cesium3DTileStyle();
  1160. * // Override anchorLineEnabled expression with a condition
  1161. * style.anchorLineEnabled = {
  1162. * conditions : [
  1163. * ['${height} > 2', 'true'],
  1164. * ['true', 'false']
  1165. * ]
  1166. * };
  1167. */
  1168. anchorLineEnabled: {
  1169. get: function () {
  1170. //>>includeStart('debug', pragmas.debug);
  1171. if (!this._ready) {
  1172. throw new DeveloperError(
  1173. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1174. );
  1175. }
  1176. //>>includeEnd('debug');
  1177. return this._anchorLineEnabled;
  1178. },
  1179. set: function (value) {
  1180. this._anchorLineEnabled = getExpression(this, value);
  1181. this._style.anchorLineEnabled = getJsonFromExpression(
  1182. this._anchorLineEnabled
  1183. );
  1184. },
  1185. },
  1186. /**
  1187. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>anchorLineColor</code> property. Alternatively a string or object defining a color style can be used.
  1188. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1189. * <p>
  1190. * The expression must return a <code>Color</code>.
  1191. * </p>
  1192. * <p>
  1193. * This expression is only applicable to point features in a Vector tile.
  1194. * </p>
  1195. *
  1196. * @memberof Cesium3DTileStyle.prototype
  1197. *
  1198. * @type {StyleExpression}
  1199. *
  1200. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1201. *
  1202. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1203. *
  1204. * @example
  1205. * var style = new Cesium.Cesium3DTileStyle();
  1206. * // Override anchorLineColor expression with a string
  1207. * style.anchorLineColor = 'color("blue")';
  1208. *
  1209. * @example
  1210. * var style = new Cesium.Cesium3DTileStyle();
  1211. * // Override anchorLineColor expression with a condition
  1212. * style.anchorLineColor = {
  1213. * conditions : [
  1214. * ['${height} > 2', 'color("cyan")'],
  1215. * ['true', 'color("blue")']
  1216. * ]
  1217. * };
  1218. */
  1219. anchorLineColor: {
  1220. get: function () {
  1221. //>>includeStart('debug', pragmas.debug);
  1222. if (!this._ready) {
  1223. throw new DeveloperError(
  1224. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1225. );
  1226. }
  1227. //>>includeEnd('debug');
  1228. return this._anchorLineColor;
  1229. },
  1230. set: function (value) {
  1231. this._anchorLineColor = getExpression(this, value);
  1232. this._style.anchorLineColor = getJsonFromExpression(
  1233. this._anchorLineColor
  1234. );
  1235. },
  1236. },
  1237. /**
  1238. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>image</code> property. Alternatively a string or object defining a string style can be used.
  1239. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1240. * <p>
  1241. * The expression must return a <code>String</code>.
  1242. * </p>
  1243. * <p>
  1244. * This expression is only applicable to point features in a Vector tile.
  1245. * </p>
  1246. *
  1247. * @memberof Cesium3DTileStyle.prototype
  1248. *
  1249. * @type {StyleExpression}
  1250. *
  1251. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1252. *
  1253. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1254. *
  1255. * @example
  1256. * var style = new Cesium3DTileStyle({
  1257. * image : '(${Temperature} > 90) ? "/url/to/image1" : "/url/to/image2"'
  1258. * });
  1259. * style.image.evaluate(feature); // returns a String
  1260. *
  1261. * @example
  1262. * var style = new Cesium.Cesium3DTileStyle();
  1263. * // Override image expression with a custom function
  1264. * style.image = {
  1265. * evaluate : function(feature) {
  1266. * return '/url/to/image';
  1267. * }
  1268. * };
  1269. */
  1270. image: {
  1271. get: function () {
  1272. //>>includeStart('debug', pragmas.debug);
  1273. if (!this._ready) {
  1274. throw new DeveloperError(
  1275. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1276. );
  1277. }
  1278. //>>includeEnd('debug');
  1279. return this._image;
  1280. },
  1281. set: function (value) {
  1282. this._image = getExpression(this, value);
  1283. this._style.image = getJsonFromExpression(this._image);
  1284. },
  1285. },
  1286. /**
  1287. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>disableDepthTestDistance</code> property. Alternatively a string or object defining a number style can be used.
  1288. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1289. * <p>
  1290. * The expression must return a <code>Number</code>.
  1291. * </p>
  1292. * <p>
  1293. * This expression is only applicable to point features in a Vector tile.
  1294. * </p>
  1295. *
  1296. * @memberof Cesium3DTileStyle.prototype
  1297. *
  1298. * @type {StyleExpression}
  1299. *
  1300. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1301. *
  1302. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1303. *
  1304. * @example
  1305. * var style = new Cesium.Cesium3DTileStyle();
  1306. * // Override disableDepthTestDistance expression with a string
  1307. * style.disableDepthTestDistance = '1000.0';
  1308. * style.disableDepthTestDistance.evaluate(feature); // returns a Number
  1309. */
  1310. disableDepthTestDistance: {
  1311. get: function () {
  1312. //>>includeStart('debug', pragmas.debug);
  1313. if (!this._ready) {
  1314. throw new DeveloperError(
  1315. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1316. );
  1317. }
  1318. //>>includeEnd('debug');
  1319. return this._disableDepthTestDistance;
  1320. },
  1321. set: function (value) {
  1322. this._disableDepthTestDistance = getExpression(this, value);
  1323. this._style.disableDepthTestDistance = getJsonFromExpression(
  1324. this._disableDepthTestDistance
  1325. );
  1326. },
  1327. },
  1328. /**
  1329. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>horizontalOrigin</code> property. Alternatively a string or object defining a number style can be used.
  1330. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1331. * <p>
  1332. * The expression must return a <code>HorizontalOrigin</code>.
  1333. * </p>
  1334. * <p>
  1335. * This expression is only applicable to point features in a Vector tile.
  1336. * </p>
  1337. *
  1338. * @memberof Cesium3DTileStyle.prototype
  1339. *
  1340. * @type {StyleExpression}
  1341. *
  1342. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1343. *
  1344. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1345. *
  1346. * @example
  1347. * var style = new Cesium3DTileStyle({
  1348. * horizontalOrigin : HorizontalOrigin.LEFT
  1349. * });
  1350. * style.horizontalOrigin.evaluate(feature); // returns a HorizontalOrigin
  1351. *
  1352. * @example
  1353. * var style = new Cesium.Cesium3DTileStyle();
  1354. * // Override horizontalOrigin expression with a custom function
  1355. * style.horizontalOrigin = {
  1356. * evaluate : function(feature) {
  1357. * return HorizontalOrigin.CENTER;
  1358. * }
  1359. * };
  1360. */
  1361. horizontalOrigin: {
  1362. get: function () {
  1363. //>>includeStart('debug', pragmas.debug);
  1364. if (!this._ready) {
  1365. throw new DeveloperError(
  1366. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1367. );
  1368. }
  1369. //>>includeEnd('debug');
  1370. return this._horizontalOrigin;
  1371. },
  1372. set: function (value) {
  1373. this._horizontalOrigin = getExpression(this, value);
  1374. this._style.horizontalOrigin = getJsonFromExpression(
  1375. this._horizontalOrigin
  1376. );
  1377. },
  1378. },
  1379. /**
  1380. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>verticalOrigin</code> property. Alternatively a string or object defining a number style can be used.
  1381. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1382. * <p>
  1383. * The expression must return a <code>VerticalOrigin</code>.
  1384. * </p>
  1385. * <p>
  1386. * This expression is only applicable to point features in a Vector tile.
  1387. * </p>
  1388. *
  1389. * @memberof Cesium3DTileStyle.prototype
  1390. *
  1391. * @type {StyleExpression}
  1392. *
  1393. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1394. *
  1395. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1396. *
  1397. * @example
  1398. * var style = new Cesium3DTileStyle({
  1399. * verticalOrigin : VerticalOrigin.TOP
  1400. * });
  1401. * style.verticalOrigin.evaluate(feature); // returns a VerticalOrigin
  1402. *
  1403. * @example
  1404. * var style = new Cesium.Cesium3DTileStyle();
  1405. * // Override verticalOrigin expression with a custom function
  1406. * style.verticalOrigin = {
  1407. * evaluate : function(feature) {
  1408. * return VerticalOrigin.CENTER;
  1409. * }
  1410. * };
  1411. */
  1412. verticalOrigin: {
  1413. get: function () {
  1414. //>>includeStart('debug', pragmas.debug);
  1415. if (!this._ready) {
  1416. throw new DeveloperError(
  1417. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1418. );
  1419. }
  1420. //>>includeEnd('debug');
  1421. return this._verticalOrigin;
  1422. },
  1423. set: function (value) {
  1424. this._verticalOrigin = getExpression(this, value);
  1425. this._style.verticalOrigin = getJsonFromExpression(this._verticalOrigin);
  1426. },
  1427. },
  1428. /**
  1429. Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>labelHorizontalOrigin</code> property. Alternatively a string or object defining a number style can be used.
  1430. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1431. * <p>
  1432. * The expression must return a <code>HorizontalOrigin</code>.
  1433. * </p>
  1434. * <p>
  1435. * This expression is only applicable to point features in a Vector tile.
  1436. * </p>
  1437. *
  1438. * @memberof Cesium3DTileStyle.prototype
  1439. *
  1440. * @type {StyleExpression}
  1441. *
  1442. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1443. *
  1444. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1445. *
  1446. * @example
  1447. * var style = new Cesium3DTileStyle({
  1448. * labelHorizontalOrigin : HorizontalOrigin.LEFT
  1449. * });
  1450. * style.labelHorizontalOrigin.evaluate(feature); // returns a HorizontalOrigin
  1451. *
  1452. * @example
  1453. * var style = new Cesium.Cesium3DTileStyle();
  1454. * // Override labelHorizontalOrigin expression with a custom function
  1455. * style.labelHorizontalOrigin = {
  1456. * evaluate : function(feature) {
  1457. * return HorizontalOrigin.CENTER;
  1458. * }
  1459. * };
  1460. */
  1461. labelHorizontalOrigin: {
  1462. get: function () {
  1463. //>>includeStart('debug', pragmas.debug);
  1464. if (!this._ready) {
  1465. throw new DeveloperError(
  1466. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1467. );
  1468. }
  1469. //>>includeEnd('debug');
  1470. return this._labelHorizontalOrigin;
  1471. },
  1472. set: function (value) {
  1473. this._labelHorizontalOrigin = getExpression(this, value);
  1474. this._style.labelHorizontalOrigin = getJsonFromExpression(
  1475. this._labelHorizontalOrigin
  1476. );
  1477. },
  1478. },
  1479. /**
  1480. * Gets or sets the {@link StyleExpression} object used to evaluate the style's <code>labelVerticalOrigin</code> property. Alternatively a string or object defining a number style can be used.
  1481. * The getter will return the internal {@link Expression} or {@link ConditionsExpression}, which may differ from the value provided to the setter.
  1482. * <p>
  1483. * The expression must return a <code>VerticalOrigin</code>.
  1484. * </p>
  1485. * <p>
  1486. * This expression is only applicable to point features in a Vector tile.
  1487. * </p>
  1488. *
  1489. * @memberof Cesium3DTileStyle.prototype
  1490. *
  1491. * @type {StyleExpression}
  1492. *
  1493. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1494. *
  1495. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  1496. *
  1497. * @example
  1498. * var style = new Cesium3DTileStyle({
  1499. * labelVerticalOrigin : VerticalOrigin.TOP
  1500. * });
  1501. * style.labelVerticalOrigin.evaluate(feature); // returns a VerticalOrigin
  1502. *
  1503. * @example
  1504. * var style = new Cesium.Cesium3DTileStyle();
  1505. * // Override labelVerticalOrigin expression with a custom function
  1506. * style.labelVerticalOrigin = {
  1507. * evaluate : function(feature) {
  1508. * return VerticalOrigin.CENTER;
  1509. * }
  1510. * };
  1511. */
  1512. labelVerticalOrigin: {
  1513. get: function () {
  1514. //>>includeStart('debug', pragmas.debug);
  1515. if (!this._ready) {
  1516. throw new DeveloperError(
  1517. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1518. );
  1519. }
  1520. //>>includeEnd('debug');
  1521. return this._labelVerticalOrigin;
  1522. },
  1523. set: function (value) {
  1524. this._labelVerticalOrigin = getExpression(this, value);
  1525. this._style.labelVerticalOrigin = getJsonFromExpression(
  1526. this._labelVerticalOrigin
  1527. );
  1528. },
  1529. },
  1530. /**
  1531. * Gets or sets the object containing application-specific expression that can be explicitly
  1532. * evaluated, e.g., for display in a UI.
  1533. *
  1534. * @memberof Cesium3DTileStyle.prototype
  1535. *
  1536. * @type {StyleExpression}
  1537. *
  1538. * @exception {DeveloperError} The style is not loaded. Use {@link Cesium3DTileStyle#readyPromise} or wait for {@link Cesium3DTileStyle#ready} to be true.
  1539. *
  1540. * @example
  1541. * var style = new Cesium3DTileStyle({
  1542. * meta : {
  1543. * description : '"Building id ${id} has height ${Height}."'
  1544. * }
  1545. * });
  1546. * style.meta.description.evaluate(feature); // returns a String with the substituted variables
  1547. */
  1548. meta: {
  1549. get: function () {
  1550. //>>includeStart('debug', pragmas.debug);
  1551. if (!this._ready) {
  1552. throw new DeveloperError(
  1553. "The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true."
  1554. );
  1555. }
  1556. //>>includeEnd('debug');
  1557. return this._meta;
  1558. },
  1559. set: function (value) {
  1560. this._meta = value;
  1561. },
  1562. },
  1563. });
  1564. /**
  1565. * Gets the color shader function for this style.
  1566. *
  1567. * @param {String} functionName Name to give to the generated function.
  1568. * @param {String} propertyNameMap Maps property variable names to shader attribute names.
  1569. * @param {Object} shaderState Stores information about the generated shader function, including whether it is translucent.
  1570. *
  1571. * @returns {String} The shader function.
  1572. *
  1573. * @private
  1574. */
  1575. Cesium3DTileStyle.prototype.getColorShaderFunction = function (
  1576. functionName,
  1577. propertyNameMap,
  1578. shaderState
  1579. ) {
  1580. if (this._colorShaderFunctionReady) {
  1581. shaderState.translucent = this._colorShaderTranslucent;
  1582. // Return the cached result, may be undefined
  1583. return this._colorShaderFunction;
  1584. }
  1585. this._colorShaderFunctionReady = true;
  1586. this._colorShaderFunction = defined(this.color)
  1587. ? this.color.getShaderFunction(
  1588. functionName,
  1589. propertyNameMap,
  1590. shaderState,
  1591. "vec4"
  1592. )
  1593. : undefined;
  1594. this._colorShaderTranslucent = shaderState.translucent;
  1595. return this._colorShaderFunction;
  1596. };
  1597. /**
  1598. * Gets the show shader function for this style.
  1599. *
  1600. * @param {String} functionName Name to give to the generated function.
  1601. * @param {String} propertyNameMap Maps property variable names to shader attribute names.
  1602. * @param {Object} shaderState Stores information about the generated shader function, including whether it is translucent.
  1603. *
  1604. * @returns {String} The shader function.
  1605. *
  1606. * @private
  1607. */
  1608. Cesium3DTileStyle.prototype.getShowShaderFunction = function (
  1609. functionName,
  1610. propertyNameMap,
  1611. shaderState
  1612. ) {
  1613. if (this._showShaderFunctionReady) {
  1614. // Return the cached result, may be undefined
  1615. return this._showShaderFunction;
  1616. }
  1617. this._showShaderFunctionReady = true;
  1618. this._showShaderFunction = defined(this.show)
  1619. ? this.show.getShaderFunction(
  1620. functionName,
  1621. propertyNameMap,
  1622. shaderState,
  1623. "bool"
  1624. )
  1625. : undefined;
  1626. return this._showShaderFunction;
  1627. };
  1628. /**
  1629. * Gets the pointSize shader function for this style.
  1630. *
  1631. * @param {String} functionName Name to give to the generated function.
  1632. * @param {String} propertyNameMap Maps property variable names to shader attribute names.
  1633. * @param {Object} shaderState Stores information about the generated shader function, including whether it is translucent.
  1634. *
  1635. * @returns {String} The shader function.
  1636. *
  1637. * @private
  1638. */
  1639. Cesium3DTileStyle.prototype.getPointSizeShaderFunction = function (
  1640. functionName,
  1641. propertyNameMap,
  1642. shaderState
  1643. ) {
  1644. if (this._pointSizeShaderFunctionReady) {
  1645. // Return the cached result, may be undefined
  1646. return this._pointSizeShaderFunction;
  1647. }
  1648. this._pointSizeShaderFunctionReady = true;
  1649. this._pointSizeShaderFunction = defined(this.pointSize)
  1650. ? this.pointSize.getShaderFunction(
  1651. functionName,
  1652. propertyNameMap,
  1653. shaderState,
  1654. "float"
  1655. )
  1656. : undefined;
  1657. return this._pointSizeShaderFunction;
  1658. };
  1659. export default Cesium3DTileStyle;