Cesium3DTileStyle.js 70 KB

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