ol 10.2.2-dev.1732295358287 → 10.2.2-dev.1732628402738

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/ol.d.ts +6 -0
  2. package/dist/ol.d.ts.map +1 -1
  3. package/dist/ol.js +1 -1
  4. package/dist/ol.js.map +1 -1
  5. package/expr/gpu.d.ts +10 -13
  6. package/expr/gpu.d.ts.map +1 -1
  7. package/expr/gpu.js +16 -19
  8. package/layer/Heatmap.js +3 -3
  9. package/layer/Layer.d.ts +4 -0
  10. package/layer/Layer.d.ts.map +1 -1
  11. package/layer/Layer.js +9 -3
  12. package/layer/WebGLPoints.d.ts +17 -4
  13. package/layer/WebGLPoints.d.ts.map +1 -1
  14. package/layer/WebGLPoints.js +8 -4
  15. package/layer/WebGLTile.d.ts.map +1 -1
  16. package/layer/WebGLTile.js +0 -1
  17. package/layer/WebGLVector.d.ts +173 -0
  18. package/layer/WebGLVector.d.ts.map +1 -0
  19. package/layer/WebGLVector.js +120 -0
  20. package/package.json +1 -1
  21. package/render/webgl/VectorStyleRenderer.d.ts +2 -1
  22. package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
  23. package/render/webgl/VectorStyleRenderer.js +4 -2
  24. package/renderer/webgl/PointsLayer.js +2 -2
  25. package/renderer/webgl/VectorLayer.d.ts +12 -0
  26. package/renderer/webgl/VectorLayer.d.ts.map +1 -1
  27. package/renderer/webgl/VectorLayer.js +19 -2
  28. package/renderer/webgl/VectorTileLayer.d.ts +16 -0
  29. package/renderer/webgl/VectorTileLayer.d.ts.map +1 -1
  30. package/renderer/webgl/VectorTileLayer.js +11 -0
  31. package/style/flat.d.ts +8 -0
  32. package/style/flat.d.ts.map +1 -1
  33. package/style/flat.js +7 -0
  34. package/style/webgl.d.ts +0 -7
  35. package/style/webgl.d.ts.map +1 -1
  36. package/style/webgl.js +0 -2
  37. package/util.js +1 -1
  38. package/webgl/ShaderBuilder.js +15 -15
  39. package/webgl/styleparser.d.ts +2 -1
  40. package/webgl/styleparser.d.ts.map +1 -1
  41. package/webgl/styleparser.js +57 -23
@@ -1 +1 @@
1
- {"version":3,"file":"VectorStyleRenderer.d.ts","sourceRoot":"","sources":["VectorStyleRenderer.js"],"names":[],"mappings":";;;;yBA4BU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmBF,CAAS,IAAwD,EAAnD,OAAO,yBAAyB,EAAE,iBAAiB,EAAE,IAAmC,EAAnC,OAAO,eAAe,EAAE,WAAW,KAAE,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC;;mCAK7H;QAAO,MAAM,GAAE,mBAAmB;CAAC;iCACnC;QAAO,MAAM,GAAE,OAAO,oBAAoB,EAAE,YAAY;CAAC;;;;;oBAKxD,KAAK,CAAC,gBAAgB,CAAC;;;;uBACvB,KAAK,CAAC,gBAAgB,CAAC;;;;kBACvB,KAAK,CAAC,gBAAgB,CAAC;;;;6BACvB,OAAO,oBAAoB,EAAE,SAAS;;;;;;yBAKtC,YAAY,GAAC,IAAI;;;;4BACjB,YAAY,GAAC,IAAI;;;;uBACjB,YAAY,GAAC,IAAI;;;;;;;;;YAKjB,MAAM;;;;cACN,MAAM;;;;;;aAKN,OAAO,8BAA8B,EAAE,aAAa;;;;;;;;;;;;;;;0BAOrD,OAAO,sBAAsB,EAAE,UAAU,GAAC,YAAY;AA5CnE;;;;;;;GAOG;AAEH;;;GAGG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;GAaG;AACH;IACE;;;;OAIG;IACH,4BAJW,WAAW,UACX,OAAO,uBAAuB,EAAE,OAAO,sBACvC,OAAO,EAsMjB;IAnMC;;;OAGG;IACH,gBAAY;IAEZ;;OAEG;IACH,6BAA8C;IAgB9C;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,uBAAmB;IAEnB;;;OAGG;IACH,uBA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;;;OAKG;IACH,oCA+BC;IAED;;;;;;OAMG;IACH,gCAuEC;IAED;;;;;OAKG;IACH,gBAJW,YAAY,cACZ,OAAO,cAAc,EAAE,UAAU,qBACjC,MAAY,IAAI,QA8B1B;IAED;;;;;;;;OAQG;IACH,wBAkBC;IAED;;;OAGG;IACH,kBAHW,OAAO,uBAAuB,EAAE,OAAO,YACvC,YAAY,QAuCtB;CACF;6BA9jB4B,uBAAuB"}
@@ -104,10 +104,11 @@ export const Attributes = {
104
104
  class VectorStyleRenderer {
105
105
  /**
106
106
  * @param {VectorStyle} styleOrShaders Literal style or custom shaders
107
+ * @param {import('../../style/flat.js').StyleVariables} variables Style variables
107
108
  * @param {import('../../webgl/Helper.js').default} helper Helper
108
109
  * @param {boolean} enableHitDetection Whether to enable the hit detection (needs compatible shader)
109
110
  */
110
- constructor(styleOrShaders, helper, enableHitDetection) {
111
+ constructor(styleOrShaders, variables, helper, enableHitDetection) {
111
112
  /**
112
113
  * @private
113
114
  * @type {import('../../webgl/Helper.js').default}
@@ -125,6 +126,7 @@ class VectorStyleRenderer {
125
126
  /** @type {import('../../style/webgl.js').WebGLStyle} */ (
126
127
  styleOrShaders
127
128
  ),
129
+ variables,
128
130
  );
129
131
  shaders = {
130
132
  builder: parseResult.builder,
@@ -225,7 +227,7 @@ class VectorStyleRenderer {
225
227
 
226
228
  const customAttributesDesc = Object.entries(this.customAttributes_).map(
227
229
  ([name, value]) => ({
228
- name: `a_prop_${name}`,
230
+ name: `a_${name}`,
229
231
  size: value.size || 1,
230
232
  type: AttributeType.FLOAT,
231
233
  }),
@@ -178,7 +178,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
178
178
  const customAttributes = options.attributes
179
179
  ? options.attributes.map(function (attribute) {
180
180
  return {
181
- name: 'a_prop_' + attribute.name,
181
+ name: 'a_' + attribute.name,
182
182
  size: 1,
183
183
  type: AttributeType.FLOAT,
184
184
  };
@@ -205,7 +205,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
205
205
 
206
206
  if (this.hitDetectionEnabled_) {
207
207
  this.attributes.push({
208
- name: 'a_prop_hitColor',
208
+ name: 'a_hitColor',
209
209
  size: 4,
210
210
  type: AttributeType.FLOAT,
211
211
  });
@@ -23,6 +23,12 @@ export type Options = {
23
23
  * Vector style as literal style or shaders; can also accept an array of styles
24
24
  */
25
25
  style: VectorStyle | Array<VectorStyle>;
26
+ /**
27
+ * Style variables
28
+ */
29
+ variables: {
30
+ [x: string]: number | Array<number> | string | boolean;
31
+ };
26
32
  /**
27
33
  * Setting this to true will provide a slight performance boost, but will
28
34
  * prevent all hit detection on the layer.
@@ -40,6 +46,7 @@ export type Options = {
40
46
  * @typedef {Object} Options
41
47
  * @property {string} [className='ol-layer'] A CSS class name to set to the canvas element.
42
48
  * @property {VectorStyle|Array<VectorStyle>} style Vector style as literal style or shaders; can also accept an array of styles
49
+ * @property {Object<string, number|Array<number>|string|boolean>} variables Style variables
43
50
  * @property {boolean} [disableHitDetection=false] Setting this to true will provide a slight performance boost, but will
44
51
  * prevent all hit detection on the layer.
45
52
  * @property {Array<import("./Layer").PostProcessesOptions>} [postProcesses] Post-processes definitions
@@ -111,6 +118,11 @@ declare class WebGLVectorLayerRenderer extends WebGLLayerRenderer<any> {
111
118
  * @private
112
119
  */
113
120
  private currentFrameStateTransform_;
121
+ /**
122
+ * @type {import('../../style/flat.js').StyleVariables}
123
+ * @private
124
+ */
125
+ private styleVariables_;
114
126
  /**
115
127
  * @type {Array<VectorStyle>}
116
128
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"VectorLayer.d.ts","sourceRoot":"","sources":["VectorLayer.js"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;EAKE;;0BAGW,OAAO,2CAA2C,EAAE,WAAW;;;;;;;;;WAM9D,WAAW,GAAC,KAAK,CAAC,WAAW,CAAC;;;;;;;;;;;AAP5C;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE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MAAM,CAAC,GAAC,MAAM,GAAC,OAAO;KAAC;;;;;;;;;;;AARjE;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;OAGG;IACH,mBAHW,OAAO,sBAAsB,EAAE,OAAO,WACtC,OAAO,EA0GjB;IA5FC;;;OAGG;IACH,6BAAwD;IAExD;;;OAGG;IACH,yBAAqB;IAErB;;OAEG;IACH,wBAAyB;IAEzB;;OAEG;IACH,wBAAoC;IAEpC;;;;;;OAMG;IACH,0BAA0C;IAE1C;;OAEG;IACH,mBAAwB;IACxB;;OAEG;IACH,sBAAsC;IACtC;;OAEG;IACH,iBAA4B;IAE5B;;;OAGG;IACH,oCAAoD;IAEpD;;;OAGG;IACH,wBAAyB;IAEzB;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,wBAAyB;IAEzB;;;OAGG;IACH,iBAAkB;IAIlB;;OAEG;IACH,eAAsC;IAEtC;;;OAGG;IACH,8BAAkC;IAElC;;;OAGG;IACH,0BAA6B;IAG/B;;;OAGG;IACH,4BAoCC;IAED;;;OAGG;IACH,sBAKC;IAED;;OAEG;IACH,yBAWC;IAED;;OAEG;IACH,mCAMC;IAoBD;;;;OAIG;IACH,kCAGC;IAED;;;OAGG;IACH,oCAGC;IAED;;;OAGG;IACH,mCAGC;IAED;;OAEG;IACH,kCAEC;IAED;;;OAGG;IACH,uBAsBC;IAED;;;;;OAKG;IACH,iCAJW,OAAO,cAAc,EAAE,UAAU,GAChC,WAAW,CAoCtB;IAwED;;;;;;;OAOG;IACH,yBANW,OAAO,cAAc,EAAE,UAAU,mBACjC,OAAO,cACP,MAAM,YACN,MAAM,cACN,MAAM,QAuChB;IA0CD;;;OAGG;IACH,wBAFW,OAAO,2CAA2C,EAAE,YAAY,QAkB1E;CAkBF;+BA9jB8B,YAAY"}
@@ -48,6 +48,7 @@ export const Uniforms = {
48
48
  * @typedef {Object} Options
49
49
  * @property {string} [className='ol-layer'] A CSS class name to set to the canvas element.
50
50
  * @property {VectorStyle|Array<VectorStyle>} style Vector style as literal style or shaders; can also accept an array of styles
51
+ * @property {Object<string, number|Array<number>|string|boolean>} variables Style variables
51
52
  * @property {boolean} [disableHitDetection=false] Setting this to true will provide a slight performance boost, but will
52
53
  * prevent all hit detection on the layer.
53
54
  * @property {Array<import("./Layer").PostProcessesOptions>} [postProcesses] Post-processes definitions
@@ -138,6 +139,12 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
138
139
  */
139
140
  this.currentFrameStateTransform_ = createTransform();
140
141
 
142
+ /**
143
+ * @type {import('../../style/flat.js').StyleVariables}
144
+ * @private
145
+ */
146
+ this.styleVariables_ = {};
147
+
141
148
  /**
142
149
  * @type {Array<VectorStyle>}
143
150
  * @private
@@ -223,6 +230,7 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
223
230
  * @private
224
231
  */
225
232
  applyOptions_(options) {
233
+ this.styleVariables_ = options.variables;
226
234
  this.styles_ = Array.isArray(options.style)
227
235
  ? options.style
228
236
  : [options.style];
@@ -235,7 +243,12 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
235
243
  this.buffers_ = [];
236
244
  this.styleRenderers_ = this.styles_.map(
237
245
  (style) =>
238
- new VectorStyleRenderer(style, this.helper, this.hitDetectionEnabled_),
246
+ new VectorStyleRenderer(
247
+ style,
248
+ this.styleVariables_,
249
+ this.helper,
250
+ this.hitDetectionEnabled_,
251
+ ),
239
252
  );
240
253
  }
241
254
 
@@ -349,7 +362,11 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
349
362
  // draw the normal canvas
350
363
  this.helper.prepareDraw(frameState);
351
364
  this.renderWorlds(frameState, false, startWorld, endWorld, worldWidth);
352
- this.helper.finalizeDraw(frameState);
365
+ this.helper.finalizeDraw(
366
+ frameState,
367
+ this.dispatchPreComposeEvent,
368
+ this.dispatchPostComposeEvent,
369
+ );
353
370
 
354
371
  const canvas = this.helper.getCanvas();
355
372
  const layerState = frameState.layerStatesArray[frameState.layerIndex];
@@ -22,6 +22,14 @@ export type Options = {
22
22
  * Vector style as literal style or shaders; can also accept an array of styles
23
23
  */
24
24
  style: VectorStyle | Array<VectorStyle>;
25
+ /**
26
+ * Style variables. Each variable must hold a literal value (not
27
+ * an expression). These variables can be used as {@link import ("../../expr/expression.js").ExpressionValue expressions} in the styles properties
28
+ * using the `['var', 'varName']` operator.
29
+ */
30
+ variables?: {
31
+ [x: string]: string | number | boolean | number[];
32
+ } | undefined;
25
33
  /**
26
34
  * Setting this to true will provide a slight performance boost, but will
27
35
  * prevent all hit detection on the layer.
@@ -39,6 +47,9 @@ export type LayerType = import("../../layer/BaseTile.js").default<any, any>;
39
47
  /**
40
48
  * @typedef {Object} Options
41
49
  * @property {VectorStyle|Array<VectorStyle>} style Vector style as literal style or shaders; can also accept an array of styles
50
+ * @property {import('../../style/flat.js').StyleVariables} [variables] Style variables. Each variable must hold a literal value (not
51
+ * an expression). These variables can be used as {@link import("../../expr/expression.js").ExpressionValue expressions} in the styles properties
52
+ * using the `['var', 'varName']` operator.
42
53
  * @property {boolean} [disableHitDetection=false] Setting this to true will provide a slight performance boost, but will
43
54
  * prevent all hit detection on the layer.
44
55
  * @property {number} [cacheSize=512] The vector tile cache size.
@@ -67,6 +78,11 @@ declare class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer<im
67
78
  * @private
68
79
  */
69
80
  private styles_;
81
+ /**
82
+ * @type {import('../../style/flat.js').StyleVariables}
83
+ * @private
84
+ */
85
+ private styleVariables_;
70
86
  /**
71
87
  * @type {Array<VectorStyleRenderer>}
72
88
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"VectorTileLayer.d.ts","sourceRoot":"","sources":["VectorTileLayer.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;EAIE;;;;;0BAOW,OAAO,2CAA2C,EAAE,WAAW;;;;;WAK9D,WAAW,GAAC,KAAK,CAAC,WAAW,CAAC;;;;;;;;;;;wBAO/B,mDAAyC;AAbtD;;GAEG;AAEH;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,uBAHW,SAAS,WACT,OAAO,EAiFjB;IAtEC;;;OAGG;IACH,6BAAwD;IAExD;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,wBAAyB;IAEzB;;;;;;OAMG;IACH,oCAAoD;IAEpD;;OAEG;IACH,sBAAsC;IACtC;;OAEG;IACH,iBAA4B;IAE5B;;;OAGG;IACH,wBAA2B;IAE3B;;OAEG;IACH,yBAGC;IAGD;;;OAGG;IACH,4BAMC;IAED;;;OAGG;IACH,yBAAqB;IAKvB;;;OAGG;IACH,wBAHW,OAAO,QAWjB;IAED;;;OAGG;IACH,sBAIC;IAED;;OAEG;IACH,yBAwCC;IAED;;OAEG;IACH,sBAYC;IAUD;;OAEG;IACH,8DAWC;IAED;;OAEG;IACH,uEAMC;IAED;;OAEG;IACH,yDA0BC;IAED;;OAEG;IACH,4FAeC;IAED;;;;;;;OAOG;IACH,uBAoBC;IAED;;OAEG;IACH,sNA4BC;IAED;;;OAGG;IACH,4BAFW,OAAO,cAAc,EAAE,UAAU,QAEd;CAS/B;uCA/XM,oBAAoB;yBALF,6BAA6B"}
1
+ {"version":3,"file":"VectorTileLayer.d.ts","sourceRoot":"","sources":["VectorTileLayer.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;EAIE;;;;;0BAOW,OAAO,2CAA2C,EAAE,WAAW;;;;;WAK9D,WAAW,GAAC,KAAK,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;wBAU/B,mDAAyC;AAhBtD;;GAEG;AAEH;;;;;;;;;GASG;AAEH;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,uBAHW,SAAS,WACT,OAAO,EAuFjB;IA5EC;;;OAGG;IACH,6BAAwD;IAExD;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,wBAA8C;IAE9C;;;OAGG;IACH,wBAAyB;IAEzB;;;;;;OAMG;IACH,oCAAoD;IAEpD;;OAEG;IACH,sBAAsC;IACtC;;OAEG;IACH,iBAA4B;IAE5B;;;OAGG;IACH,wBAA2B;IAE3B;;OAEG;IACH,yBAGC;IAGD;;;OAGG;IACH,4BAMC;IAED;;;OAGG;IACH,yBAAqB;IAKvB;;;OAGG;IACH,wBAHW,OAAO,QAWjB;IAED;;;OAGG;IACH,sBAIC;IAED;;OAEG;IACH,yBA0CC;IAED;;OAEG;IACH,sBAYC;IAUD;;OAEG;IACH,8DAWC;IAED;;OAEG;IACH,uEAMC;IAED;;OAEG;IACH,yDA0BC;IAED;;OAEG;IACH,4FAeC;IAED;;;;;;;OAOG;IACH,uBAoBC;IAED;;OAEG;IACH,sNA4BC;IAED;;;OAGG;IACH,4BAFW,OAAO,cAAc,EAAE,UAAU,QAEd;CAS/B;uCA1YM,oBAAoB;yBALF,6BAA6B"}
@@ -42,6 +42,9 @@ export const Attributes = {
42
42
  /**
43
43
  * @typedef {Object} Options
44
44
  * @property {VectorStyle|Array<VectorStyle>} style Vector style as literal style or shaders; can also accept an array of styles
45
+ * @property {import('../../style/flat.js').StyleVariables} [variables] Style variables. Each variable must hold a literal value (not
46
+ * an expression). These variables can be used as {@link import("../../expr/expression.js").ExpressionValue expressions} in the styles properties
47
+ * using the `['var', 'varName']` operator.
45
48
  * @property {boolean} [disableHitDetection=false] Setting this to true will provide a slight performance boost, but will
46
49
  * prevent all hit detection on the layer.
47
50
  * @property {number} [cacheSize=512] The vector tile cache size.
@@ -82,6 +85,12 @@ class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer {
82
85
  */
83
86
  this.styles_ = [];
84
87
 
88
+ /**
89
+ * @type {import('../../style/flat.js').StyleVariables}
90
+ * @private
91
+ */
92
+ this.styleVariables_ = options.variables || {};
93
+
85
94
  /**
86
95
  * @type {Array<VectorStyleRenderer>}
87
96
  * @private
@@ -188,6 +197,7 @@ class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer {
188
197
  if (!isShaders) {
189
198
  const parseResult = parseLiteralStyle(
190
199
  /** @type {import('../../style/webgl.js').WebGLStyle} */ (style),
200
+ this.styleVariables_,
191
201
  );
192
202
  addBuilderParams(parseResult.builder);
193
203
  shaders = {
@@ -205,6 +215,7 @@ class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer {
205
215
  }
206
216
  return new VectorStyleRenderer(
207
217
  shaders,
218
+ this.styleVariables_,
208
219
  this.helper,
209
220
  this.hitDetectionEnabled_,
210
221
  );
package/style/flat.d.ts CHANGED
@@ -798,4 +798,12 @@ export type Rule = {
798
798
  */
799
799
  else?: boolean | undefined;
800
800
  };
801
+ /**
802
+ * Style variables are provided as an object. The variables can be read in a {@link import ("../expr/expression.js").ExpressionValue style expression}
803
+ * using the `['var', 'varName']` operator.
804
+ * Each variable must hold a literal value (not an expression).
805
+ */
806
+ export type StyleVariables = {
807
+ [x: string]: number | Array<number> | string | boolean;
808
+ };
801
809
  //# sourceMappingURL=flat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["flat.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,sCAFY,YAAY,CAYvB;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA4KrC,MAAM;;;;oBACN,MAAM;;;;oBACN,MAAM;;;;qBACN,MAAM;;;;yBACN,MAAM;;;;2BACN,MAAM;;;;2BACN,MAAM;;;;;;;;;;WAuBN,SAAS,GAAC,KAAK,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;6BAY3B;QAAO,MAAM,GAAE,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC,GAAC,MAAM,GAAC,OAAO;CAAC"}
package/style/flat.js CHANGED
@@ -300,3 +300,10 @@ export function createDefaultStyle() {
300
300
  * @property {boolean} [else] If true, the rule applies only if no other previous rule applies.
301
301
  * If the else rule also has a filter, the rule will not apply if the filter does not match.
302
302
  */
303
+
304
+ /**
305
+ * Style variables are provided as an object. The variables can be read in a {@link import("../expr/expression.js").ExpressionValue style expression}
306
+ * using the `['var', 'varName']` operator.
307
+ * Each variable must hold a literal value (not an expression).
308
+ * @typedef {Object<string, number|Array<number>|string|boolean>} StyleVariables
309
+ */
package/style/webgl.d.ts CHANGED
@@ -6,13 +6,6 @@ export type BaseProps = {
6
6
  * point will be displayed. If undefined, all points will show.
7
7
  */
8
8
  filter?: import("../expr/expression.js").ExpressionValue | undefined;
9
- /**
10
- * Style variables; each variable must hold a number.
11
- * Note: **this object is meant to be mutated**: changes to the values will immediately be visible on the rendered features
12
- */
13
- variables?: {
14
- [x: string]: string | number | boolean | number[];
15
- } | undefined;
16
9
  };
17
10
  export type FillProps = {
18
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"webgl.d.ts","sourceRoot":"","sources":["webgl.js"],"names":[],"mappings":"8BAMa,OAAO,uBAAuB,EAAE,eAAe;8BAG/C,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,GAAC,KAAK,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA0HzD,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU"}
1
+ {"version":3,"file":"webgl.d.ts","sourceRoot":"","sources":["webgl.js"],"names":[],"mappings":"8BAMa,OAAO,uBAAuB,EAAE,eAAe;8BAG/C,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,GAAC,KAAK,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAwHzD,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU"}
package/style/webgl.js CHANGED
@@ -14,8 +14,6 @@
14
14
  * @typedef {Object} BaseProps
15
15
  * @property {ExpressionValue} [filter] Filter expression. If it resolves to a number strictly greater than 0, the
16
16
  * point will be displayed. If undefined, all points will show.
17
- * @property {Object<string, number | Array<number> | string | boolean>} [variables] Style variables; each variable must hold a number.
18
- * Note: **this object is meant to be mutated**: changes to the values will immediately be visible on the rendered features
19
17
  */
20
18
 
21
19
  /**
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '10.2.2-dev.1732295358287';
36
+ export const VERSION = '10.2.2-dev.1732628402738';
@@ -479,7 +479,7 @@ ${this.uniforms_
479
479
  .join('\n')}
480
480
  attribute vec2 a_position;
481
481
  attribute float a_index;
482
- attribute vec4 a_prop_hitColor;
482
+ attribute vec4 a_hitColor;
483
483
  ${this.attributes_
484
484
  .map(function (attribute) {
485
485
  return 'attribute ' + attribute + ';';
@@ -487,7 +487,7 @@ ${this.attributes_
487
487
  .join('\n')}
488
488
  varying vec2 v_texCoord;
489
489
  varying vec2 v_quadCoord;
490
- varying vec4 v_prop_hitColor;
490
+ varying vec4 v_hitColor;
491
491
  varying vec2 v_centerPx;
492
492
  varying float v_angle;
493
493
  varying vec2 v_quadSizePx;
@@ -531,7 +531,7 @@ void main(void) {
531
531
  float u = a_index == 0.0 || a_index == 3.0 ? texCoord.s : texCoord.p;
532
532
  float v = a_index == 2.0 || a_index == 3.0 ? texCoord.t : texCoord.q;
533
533
  v_texCoord = vec2(u, v);
534
- v_prop_hitColor = a_prop_hitColor;
534
+ v_hitColor = a_hitColor;
535
535
  v_angle = angle;
536
536
  c = cos(-v_angle);
537
537
  s = sin(-v_angle);
@@ -561,7 +561,7 @@ ${this.uniforms_
561
561
  })
562
562
  .join('\n')}
563
563
  varying vec2 v_texCoord;
564
- varying vec4 v_prop_hitColor;
564
+ varying vec4 v_hitColor;
565
565
  varying vec2 v_centerPx;
566
566
  varying float v_angle;
567
567
  varying vec2 v_quadSizePx;
@@ -582,7 +582,7 @@ void main(void) {
582
582
  gl_FragColor.rgb *= gl_FragColor.a;
583
583
  if (u_hitDetection > 0) {
584
584
  if (gl_FragColor.a < 0.05) { discard; };
585
- gl_FragColor = v_prop_hitColor;
585
+ gl_FragColor = v_hitColor;
586
586
  }
587
587
  }`;
588
588
  }
@@ -609,7 +609,7 @@ attribute float a_measureEnd;
609
609
  attribute float a_parameters;
610
610
  attribute float a_distance;
611
611
  attribute vec2 a_joinAngles;
612
- attribute vec4 a_prop_hitColor;
612
+ attribute vec4 a_hitColor;
613
613
  ${this.attributes_
614
614
  .map(function (attribute) {
615
615
  return 'attribute ' + attribute + ';';
@@ -620,7 +620,7 @@ varying vec2 v_segmentEnd;
620
620
  varying float v_angleStart;
621
621
  varying float v_angleEnd;
622
622
  varying float v_width;
623
- varying vec4 v_prop_hitColor;
623
+ varying vec4 v_hitColor;
624
624
  varying float v_distanceOffsetPx;
625
625
  varying float v_measureStart;
626
626
  varying float v_measureEnd;
@@ -699,7 +699,7 @@ void main(void) {
699
699
  v_segmentStart = segmentStartPx;
700
700
  v_segmentEnd = segmentEndPx;
701
701
  v_width = lineWidth;
702
- v_prop_hitColor = a_prop_hitColor;
702
+ v_hitColor = a_hitColor;
703
703
  v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * angleTangentSum);
704
704
  v_measureStart = a_measureStart;
705
705
  v_measureEnd = a_measureEnd;
@@ -732,7 +732,7 @@ varying vec2 v_segmentEnd;
732
732
  varying float v_angleStart;
733
733
  varying float v_angleEnd;
734
734
  varying float v_width;
735
- varying vec4 v_prop_hitColor;
735
+ varying vec4 v_hitColor;
736
736
  varying float v_distanceOffsetPx;
737
737
  varying float v_measureStart;
738
738
  varying float v_measureEnd;
@@ -870,7 +870,7 @@ void main(void) {
870
870
  gl_FragColor.rgb *= gl_FragColor.a;
871
871
  if (u_hitDetection > 0) {
872
872
  if (gl_FragColor.a < 0.1) { discard; };
873
- gl_FragColor = v_prop_hitColor;
873
+ gl_FragColor = v_hitColor;
874
874
  }
875
875
  }`;
876
876
  }
@@ -892,13 +892,13 @@ ${this.uniforms_
892
892
  })
893
893
  .join('\n')}
894
894
  attribute vec2 a_position;
895
- attribute vec4 a_prop_hitColor;
895
+ attribute vec4 a_hitColor;
896
896
  ${this.attributes_
897
897
  .map(function (attribute) {
898
898
  return 'attribute ' + attribute + ';';
899
899
  })
900
900
  .join('\n')}
901
- varying vec4 v_prop_hitColor;
901
+ varying vec4 v_hitColor;
902
902
  ${this.varyings_
903
903
  .map(function (varying) {
904
904
  return 'varying ' + varying.type + ' ' + varying.name + ';';
@@ -907,7 +907,7 @@ ${this.varyings_
907
907
  ${this.vertexShaderFunctions_.join('\n')}
908
908
  void main(void) {
909
909
  gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
910
- v_prop_hitColor = a_prop_hitColor;
910
+ v_hitColor = a_hitColor;
911
911
  ${this.varyings_
912
912
  .map(function (varying) {
913
913
  return ' ' + varying.name + ' = ' + varying.expression + ';';
@@ -931,7 +931,7 @@ ${this.uniforms_
931
931
  return 'uniform ' + uniform + ';';
932
932
  })
933
933
  .join('\n')}
934
- varying vec4 v_prop_hitColor;
934
+ varying vec4 v_hitColor;
935
935
  ${this.varyings_
936
936
  .map(function (varying) {
937
937
  return 'varying ' + varying.type + ' ' + varying.name + ';';
@@ -970,7 +970,7 @@ void main(void) {
970
970
  gl_FragColor.rgb *= gl_FragColor.a;
971
971
  if (u_hitDetection > 0) {
972
972
  if (gl_FragColor.a < 0.1) { discard; };
973
- gl_FragColor = v_prop_hitColor;
973
+ gl_FragColor = v_hitColor;
974
974
  }
975
975
  }`;
976
976
  }
@@ -34,9 +34,10 @@ export function computeHash(input: any | string): string;
34
34
  * {@link module:ol/renderer/webgl/PointsLayer~WebGLPointsLayerRenderer}.
35
35
  *
36
36
  * @param {import("../style/webgl.js").WebGLStyle} style Literal style.
37
+ * @param {import('../style/flat.js').StyleVariables} variables Style variables.
37
38
  * @return {StyleParseResult} Result containing shader params, attributes and uniforms.
38
39
  */
39
- export function parseLiteralStyle(style: import("../style/webgl.js").WebGLStyle): StyleParseResult;
40
+ export function parseLiteralStyle(style: import("../style/webgl.js").WebGLStyle, variables: import("../style/flat.js").StyleVariables): StyleParseResult;
40
41
  export type StyleParseResult = {
41
42
  /**
42
43
  * Shader builder pre-configured according to a given style
@@ -1 +1 @@
1
- {"version":3,"file":"styleparser.d.ts","sourceRoot":"","sources":["styleparser.js"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,qDALW,OAAO,gBAAgB,EAAE,kBAAkB,SAC3C,OAAO,uBAAuB,EAAE,iBAAiB,sCAEhD,MAAM,CAUjB;AAED;;;;GAIG;AACH,iCAHW,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,GACjC,KAAK,CAAC,MAAM,CAAC,CASxB;AAqCD;;;;GAIG;AACH,mCAHW,MAAO,MAAM,GACZ,MAAM,CAOjB;AA4uBD;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AACH,yCAHW,OAAO,mBAAmB,EAAE,UAAU,GACrC,gBAAgB,CAuI3B;;;;;aArJa,aAAa;;;;cACb,OAAO,wCAAwC,EAAE,kBAAkB;;;;gBACnE,OAAO,wCAAwC,EAAE,oBAAoB;;8BAt0BvD,oBAAoB"}
1
+ {"version":3,"file":"styleparser.d.ts","sourceRoot":"","sources":["styleparser.js"],"names":[],"mappings":"AA0BA;;;;;;;GAOG;AACH,qDALW,OAAO,gBAAgB,EAAE,kBAAkB,SAC3C,OAAO,uBAAuB,EAAE,iBAAiB,sCAEhD,MAAM,CAUjB;AAED;;;;GAIG;AACH,iCAHW,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,GACjC,KAAK,CAAC,MAAM,CAAC,CASxB;AAqCD;;;;GAIG;AACH,mCAHW,MAAO,MAAM,GACZ,MAAM,CAOjB;AA4uBD;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AACH,yCAJW,OAAO,mBAAmB,EAAE,UAAU,aACtC,OAAO,kBAAkB,EAAE,cAAc,GACxC,gBAAgB,CAoK3B;;;;;aAnLa,aAAa;;;;cACb,OAAO,wCAAwC,EAAE,kBAAkB;;;;gBACnE,OAAO,wCAAwC,EAAE,oBAAoB;;8BAh0BvD,oBAAoB"}
@@ -9,16 +9,20 @@ import {
9
9
  NumberType,
10
10
  SizeType,
11
11
  StringType,
12
+ computeGeometryType,
12
13
  newParsingContext,
13
14
  } from '../expr/expression.js';
14
- import {ShaderBuilder} from './ShaderBuilder.js';
15
- import {asArray} from '../color.js';
16
15
  import {
16
+ FEATURE_ID_PROPERTY_NAME,
17
+ GEOMETRY_TYPE_PROPERTY_NAME,
17
18
  buildExpression,
18
19
  getStringNumberEquivalent,
20
+ newCompilationContext,
19
21
  stringToGlsl,
20
22
  uniformNameForVariable,
21
23
  } from '../expr/gpu.js';
24
+ import {ShaderBuilder} from './ShaderBuilder.js';
25
+ import {asArray} from '../color.js';
22
26
 
23
27
  /**
24
28
  * Recursively parses a style expression and outputs a GLSL-compatible string. Takes in a compilation context that
@@ -861,29 +865,19 @@ function parseFillProperties(
861
865
  * {@link module:ol/renderer/webgl/PointsLayer~WebGLPointsLayerRenderer}.
862
866
  *
863
867
  * @param {import("../style/webgl.js").WebGLStyle} style Literal style.
868
+ * @param {import('../style/flat.js').StyleVariables} variables Style variables.
864
869
  * @return {StyleParseResult} Result containing shader params, attributes and uniforms.
865
870
  */
866
- export function parseLiteralStyle(style) {
867
- /**
868
- * @type {import("../expr/gpu.js").CompilationContext}
869
- */
870
- const vertContext = {
871
- inFragmentShader: false,
872
- properties: {},
873
- variables: {},
874
- functions: {},
875
- style,
876
- };
871
+ export function parseLiteralStyle(style, variables) {
872
+ const vertContext = newCompilationContext();
877
873
 
878
874
  /**
879
875
  * @type {import("../expr/gpu.js").CompilationContext}
880
876
  */
881
877
  const fragContext = {
878
+ ...newCompilationContext(),
882
879
  inFragmentShader: true,
883
880
  variables: vertContext.variables,
884
- properties: {},
885
- functions: {},
886
- style,
887
881
  };
888
882
 
889
883
  const builder = new ShaderBuilder();
@@ -914,10 +908,15 @@ export function parseLiteralStyle(style) {
914
908
  for (const varName in fragContext.variables) {
915
909
  const variable = fragContext.variables[varName];
916
910
  const uniformName = uniformNameForVariable(variable.name);
917
- builder.addUniform(`${getGlslTypeFromType(variable.type)} ${uniformName}`);
911
+ let glslType = getGlslTypeFromType(variable.type);
912
+ if (variable.type === ColorType) {
913
+ // we're not packing colors when they're passed as uniforms
914
+ glslType = 'vec4';
915
+ }
916
+ builder.addUniform(`${glslType} ${uniformName}`);
918
917
 
919
918
  uniforms[uniformName] = () => {
920
- const value = style.variables[variable.name];
919
+ const value = variables[variable.name];
921
920
  if (typeof value === 'number') {
922
921
  return value;
923
922
  }
@@ -925,7 +924,7 @@ export function parseLiteralStyle(style) {
925
924
  return value ? 1 : 0;
926
925
  }
927
926
  if (variable.type === ColorType) {
928
- return packColor([...asArray(value || '#eee')]);
927
+ return asArray(value || '#eee');
929
928
  }
930
929
  if (typeof value === 'string') {
931
930
  return getStringNumberEquivalent(value);
@@ -971,12 +970,12 @@ export function parseLiteralStyle(style) {
971
970
  * @type {import('../render/webgl/VectorStyleRenderer.js').AttributeDefinitions}
972
971
  */
973
972
  const attributes = {};
973
+
974
+ // Define attributes with their callback for each property used in the vertex shader
974
975
  for (const propName in vertContext.properties) {
975
976
  const property = vertContext.properties[propName];
976
977
  const callback = (feature) => {
977
- const value = property.evaluator
978
- ? property.evaluator(feature)
979
- : feature.get(property.name);
978
+ const value = feature.get(property.name);
980
979
  if (property.type === ColorType) {
981
980
  return packColor([...asArray(value || '#eee')]);
982
981
  }
@@ -989,11 +988,46 @@ export function parseLiteralStyle(style) {
989
988
  return value;
990
989
  };
991
990
 
992
- attributes[property.name] = {
991
+ attributes[`prop_${property.name}`] = {
993
992
  size: getGlslSizeFromType(property.type),
994
993
  callback,
995
994
  };
996
995
  }
997
996
 
997
+ // Define attributes for special inputs
998
+ function defineSpecialInput(contextPropName, glslPropName, type, callback) {
999
+ const inVertContext = vertContext[contextPropName];
1000
+ const inFragContext = fragContext[contextPropName];
1001
+ if (!inVertContext && !inFragContext) {
1002
+ return;
1003
+ }
1004
+ const glslType = getGlslTypeFromType(type);
1005
+ const attrSize = getGlslSizeFromType(type);
1006
+ builder.addAttribute(`${glslType} a_${glslPropName}`);
1007
+ if (inFragContext) {
1008
+ builder.addVarying(`v_${glslPropName}`, glslType, `a_${glslPropName}`);
1009
+ }
1010
+ attributes[glslPropName] = {
1011
+ size: attrSize,
1012
+ callback,
1013
+ };
1014
+ }
1015
+ defineSpecialInput(
1016
+ 'geometryType',
1017
+ GEOMETRY_TYPE_PROPERTY_NAME,
1018
+ StringType,
1019
+ (feature) =>
1020
+ getStringNumberEquivalent(computeGeometryType(feature.getGeometry())),
1021
+ );
1022
+ defineSpecialInput(
1023
+ 'featureId',
1024
+ FEATURE_ID_PROPERTY_NAME,
1025
+ StringType | NumberType,
1026
+ (feature) => {
1027
+ const id = feature.getId() ?? null;
1028
+ return typeof id === 'string' ? getStringNumberEquivalent(id) : id;
1029
+ },
1030
+ );
1031
+
998
1032
  return {builder, attributes, uniforms};
999
1033
  }