ol 10.5.1-dev.1746262133835 → 10.5.1-dev.1746527002956

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.
package/layer/Heatmap.js CHANGED
@@ -261,12 +261,12 @@ class Heatmap extends BaseVector {
261
261
  if (typeof this.getBlur() === 'number') {
262
262
  blurCompiled = 'a_blur';
263
263
  blurRadiusUniforms['a_blur'] = () => this.getBlur();
264
- builder.addUniform('float a_blur');
264
+ builder.addUniform('a_blur', 'float');
265
265
  }
266
266
  if (typeof this.getRadius() === 'number') {
267
267
  radiusCompiled = 'a_radius';
268
268
  blurRadiusUniforms['a_radius'] = () => this.getRadius();
269
- builder.addUniform('float a_radius');
269
+ builder.addUniform('a_radius', 'float');
270
270
  }
271
271
 
272
272
  /** @type {import('../render/webgl/VectorStyleRenderer.js').AttributeDefinitions} */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "10.5.1-dev.1746262133835",
3
+ "version": "10.5.1-dev.1746527002956",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
@@ -1,11 +1,16 @@
1
1
  export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n";
2
2
  /**
3
3
  * @typedef {Object} AttributeDescription
4
- * @property {string} name Attribute name, as will be declared in the headers (including a_)
5
- * @property {string} type Attribute type, either `float`, `vec2`, `vec4`...
6
- * @property {string} varyingName Varying name, as will be declared in the fragment shader (including v_)
4
+ * @property {string} name Attribute name, as will be declared in the header of the vertex shader (including a_)
5
+ * @property {string} type Attribute GLSL type, either `float`, `vec2`, `vec4`...
6
+ * @property {string} varyingName Varying name, as will be declared in the header of both shaders (including v_)
7
7
  * @property {string} varyingType Varying type, either `float`, `vec2`, `vec4`...
8
- * @property {string} varyingExpression GLSL expression to assign to the varying in the vertex shader
8
+ * @property {string} varyingExpression GLSL expression to assign to the varying in the vertex shader (e.g. `unpackColor(a_myAttr)`)
9
+ */
10
+ /**
11
+ * @typedef {Object} UniformDescription
12
+ * @property {string} name Uniform name, as will be declared in the header of the vertex shader (including u_)
13
+ * @property {string} type Uniform GLSL type, either `float`, `vec2`, `vec4`...
9
14
  */
10
15
  /**
11
16
  * @classdesc
@@ -14,8 +19,8 @@ export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp
14
19
  *
15
20
  * ```js
16
21
  * const shader = new ShaderBuilder()
17
- * .addVarying('v_width', 'float', 'a_width')
18
- * .addUniform('u_time')
22
+ * .addAttribute('a_width', 'float')
23
+ * .addUniform('u_time', 'float)
19
24
  * .setColorExpression('...')
20
25
  * .setSymbolSizeExpression('...')
21
26
  * .getSymbolFragmentShader();
@@ -28,7 +33,7 @@ export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp
28
33
  export class ShaderBuilder {
29
34
  /**
30
35
  * Uniforms; these will be declared in the header (should include the type).
31
- * @type {Array<string>}
36
+ * @type {Array<UniformDescription>}
32
37
  * @private
33
38
  */
34
39
  private uniforms_;
@@ -136,23 +141,24 @@ export class ShaderBuilder {
136
141
  /**
137
142
  * Adds a uniform accessible in both fragment and vertex shaders.
138
143
  * The given name should include a type, such as `sampler2D u_texture`.
139
- * @param {string} name Uniform name
144
+ * @param {string} name Uniform name, including the `u_` prefix
145
+ * @param {'float'|'vec2'|'vec3'|'vec4'|'sampler2D'} type GLSL type
140
146
  * @return {ShaderBuilder} the builder object
141
147
  */
142
- addUniform(name: string): ShaderBuilder;
148
+ addUniform(name: string, type: "float" | "vec2" | "vec3" | "vec4" | "sampler2D"): ShaderBuilder;
143
149
  /**
144
150
  * Adds an attribute accessible in the vertex shader, read from the geometry buffer.
145
151
  * The given name should include a type, such as `vec2 a_position`.
146
152
  * Attributes will also be made available under the same name in fragment shaders.
147
- * @param {string} name Attribute name
148
- * @param {'float'|'vec2'|'vec3'|'vec4'} type Type
149
- * @param {string} [transform] Expression which will be assigned to the varying in the vertex shader, and
153
+ * @param {string} name Attribute name, including the `a_` prefix
154
+ * @param {'float'|'vec2'|'vec3'|'vec4'} type GLSL type
155
+ * @param {string} [varyingExpression] Expression which will be assigned to the varying in the vertex shader, and
150
156
  * passed on to the fragment shader.
151
- * @param {'float'|'vec2'|'vec3'|'vec4'} [transformedType] Type of the attribute after transformation;
157
+ * @param {'float'|'vec2'|'vec3'|'vec4'} [varyingType] Type of the attribute after transformation;
152
158
  * e.g. `vec4` after unpacking color components
153
159
  * @return {ShaderBuilder} the builder object
154
160
  */
155
- addAttribute(name: string, type: "float" | "vec2" | "vec3" | "vec4", transform?: string, transformedType?: "float" | "vec2" | "vec3" | "vec4"): ShaderBuilder;
161
+ addAttribute(name: string, type: "float" | "vec2" | "vec3" | "vec4", varyingExpression?: string, varyingType?: "float" | "vec2" | "vec3" | "vec4"): ShaderBuilder;
156
162
  /**
157
163
  * Sets an expression to compute the size of the shape.
158
164
  * This expression can use all the uniforms and attributes available
@@ -312,15 +318,15 @@ export class ShaderBuilder {
312
318
  }
313
319
  export type AttributeDescription = {
314
320
  /**
315
- * Attribute name, as will be declared in the headers (including a_)
321
+ * Attribute name, as will be declared in the header of the vertex shader (including a_)
316
322
  */
317
323
  name: string;
318
324
  /**
319
- * Attribute type, either `float`, `vec2`, `vec4`...
325
+ * Attribute GLSL type, either `float`, `vec2`, `vec4`...
320
326
  */
321
327
  type: string;
322
328
  /**
323
- * Varying name, as will be declared in the fragment shader (including v_)
329
+ * Varying name, as will be declared in the header of both shaders (including v_)
324
330
  */
325
331
  varyingName: string;
326
332
  /**
@@ -328,8 +334,18 @@ export type AttributeDescription = {
328
334
  */
329
335
  varyingType: string;
330
336
  /**
331
- * GLSL expression to assign to the varying in the vertex shader
337
+ * GLSL expression to assign to the varying in the vertex shader (e.g. `unpackColor(a_myAttr)`)
332
338
  */
333
339
  varyingExpression: string;
334
340
  };
341
+ export type UniformDescription = {
342
+ /**
343
+ * Uniform name, as will be declared in the header of the vertex shader (including u_)
344
+ */
345
+ name: string;
346
+ /**
347
+ * Uniform GLSL type, either `float`, `vec2`, `vec4`...
348
+ */
349
+ type: string;
350
+ };
335
351
  //# sourceMappingURL=ShaderBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"AAQA,oqBAsBE;AAIF;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IAEI;;;;OAIG;IACH,kBAAmB;IAEnB;;;;OAIG;IACH,oBAAqB;IAErB;;;OAGG;IACH,mBAAuB;IAEvB;;;OAGG;IACH,8BAEkE;IAElE;;;OAGG;IACH,kCAAsC;IAEtC;;;OAGG;IACH,gCAA0C;IAE1C;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,4BAAqD;IAErD;;;OAGG;IACH,2BAAiC;IAEjC;;;OAGG;IACH,8BAAkC;IAElC;;;OAGG;IACH,mBAAuB;IAEvB;;;OAGG;IACH,+BAAyE;IAEzE;;;OAGG;IACH,+BAEC;IAED;;OAEG;IACH,gCAAmC;IAEnC;;OAEG;IACH,6BAAiD;IAEjD;;OAEG;IACH,8BAAkD;IAElD;;OAEG;IACH,oCAAwC;IAExC;;OAEG;IACH,uCAA8C;IAE9C;;;OAGG;IACH,iBAAqB;IAErB;;;OAGG;IACH,6BAEC;IAED;;;OAGG;IACH,+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IAED;;OAEG;IACH,0BAFY,MAAM,CAIjB;IAED,yCAMC;IACD,2CAMC;IAED;;;OAGG;IACH,yBAFY,MAAM,GAAC,IAAI,CAyEtB;IAED;;;OAGG;IACH,2BAFY,MAAM,GAAC,IAAI,CAwCtB;IAED;;;OAGG;IACH,yBAFY,MAAM,GAAC,IAAI,CAmHtB;IAED;;;;OAIG;IACH,2BAFY,MAAM,GAAC,IAAI,CA+KtB;IAED;;;;OAIG;IACH,uBAFY,MAAM,GAAC,IAAI,CA+BtB;IAED;;;OAGG;IACH,yBAFY,MAAM,GAAC,IAAI,CAyDtB;CACF;;;;;UAj7Ba,MAAM;;;;UACN,MAAM;;;;iBACN,MAAM;;;;iBACN,MAAM;;;;uBACN,MAAM;;;;;;UAKN,MAAM;;;;UACN,MAAM"}
@@ -34,11 +34,17 @@ const DEFAULT_STYLE = createDefaultStyle();
34
34
 
35
35
  /**
36
36
  * @typedef {Object} AttributeDescription
37
- * @property {string} name Attribute name, as will be declared in the headers (including a_)
38
- * @property {string} type Attribute type, either `float`, `vec2`, `vec4`...
39
- * @property {string} varyingName Varying name, as will be declared in the fragment shader (including v_)
37
+ * @property {string} name Attribute name, as will be declared in the header of the vertex shader (including a_)
38
+ * @property {string} type Attribute GLSL type, either `float`, `vec2`, `vec4`...
39
+ * @property {string} varyingName Varying name, as will be declared in the header of both shaders (including v_)
40
40
  * @property {string} varyingType Varying type, either `float`, `vec2`, `vec4`...
41
- * @property {string} varyingExpression GLSL expression to assign to the varying in the vertex shader
41
+ * @property {string} varyingExpression GLSL expression to assign to the varying in the vertex shader (e.g. `unpackColor(a_myAttr)`)
42
+ */
43
+
44
+ /**
45
+ * @typedef {Object} UniformDescription
46
+ * @property {string} name Uniform name, as will be declared in the header of the vertex shader (including u_)
47
+ * @property {string} type Uniform GLSL type, either `float`, `vec2`, `vec4`...
42
48
  */
43
49
 
44
50
  /**
@@ -48,8 +54,8 @@ const DEFAULT_STYLE = createDefaultStyle();
48
54
  *
49
55
  * ```js
50
56
  * const shader = new ShaderBuilder()
51
- * .addVarying('v_width', 'float', 'a_width')
52
- * .addUniform('u_time')
57
+ * .addAttribute('a_width', 'float')
58
+ * .addUniform('u_time', 'float)
53
59
  * .setColorExpression('...')
54
60
  * .setSymbolSizeExpression('...')
55
61
  * .getSymbolFragmentShader();
@@ -63,7 +69,7 @@ export class ShaderBuilder {
63
69
  constructor() {
64
70
  /**
65
71
  * Uniforms; these will be declared in the header (should include the type).
66
- * @type {Array<string>}
72
+ * @type {Array<UniformDescription>}
67
73
  * @private
68
74
  */
69
75
  this.uniforms_ = [];
@@ -202,11 +208,15 @@ export class ShaderBuilder {
202
208
  /**
203
209
  * Adds a uniform accessible in both fragment and vertex shaders.
204
210
  * The given name should include a type, such as `sampler2D u_texture`.
205
- * @param {string} name Uniform name
211
+ * @param {string} name Uniform name, including the `u_` prefix
212
+ * @param {'float'|'vec2'|'vec3'|'vec4'|'sampler2D'} type GLSL type
206
213
  * @return {ShaderBuilder} the builder object
207
214
  */
208
- addUniform(name) {
209
- this.uniforms_.push(name);
215
+ addUniform(name, type) {
216
+ this.uniforms_.push({
217
+ name,
218
+ type,
219
+ });
210
220
  return this;
211
221
  }
212
222
 
@@ -214,21 +224,21 @@ export class ShaderBuilder {
214
224
  * Adds an attribute accessible in the vertex shader, read from the geometry buffer.
215
225
  * The given name should include a type, such as `vec2 a_position`.
216
226
  * Attributes will also be made available under the same name in fragment shaders.
217
- * @param {string} name Attribute name
218
- * @param {'float'|'vec2'|'vec3'|'vec4'} type Type
219
- * @param {string} [transform] Expression which will be assigned to the varying in the vertex shader, and
227
+ * @param {string} name Attribute name, including the `a_` prefix
228
+ * @param {'float'|'vec2'|'vec3'|'vec4'} type GLSL type
229
+ * @param {string} [varyingExpression] Expression which will be assigned to the varying in the vertex shader, and
220
230
  * passed on to the fragment shader.
221
- * @param {'float'|'vec2'|'vec3'|'vec4'} [transformedType] Type of the attribute after transformation;
231
+ * @param {'float'|'vec2'|'vec3'|'vec4'} [varyingType] Type of the attribute after transformation;
222
232
  * e.g. `vec4` after unpacking color components
223
233
  * @return {ShaderBuilder} the builder object
224
234
  */
225
- addAttribute(name, type, transform, transformedType) {
235
+ addAttribute(name, type, varyingExpression, varyingType) {
226
236
  this.attributes_.push({
227
237
  name,
228
238
  type,
229
239
  varyingName: name.replace(/^a_/, 'v_'),
230
- varyingType: transformedType ?? type,
231
- varyingExpression: transform ?? name,
240
+ varyingType: varyingType ?? type,
241
+ varyingExpression: varyingExpression ?? name,
232
242
  });
233
243
  return this;
234
244
  }
@@ -463,7 +473,7 @@ export class ShaderBuilder {
463
473
  }
464
474
 
465
475
  return `${COMMON_HEADER}
466
- ${this.uniforms_.map((uniform) => `uniform ${uniform};`).join('\n')}
476
+ ${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
467
477
  attribute vec2 a_position;
468
478
  attribute float a_index;
469
479
  attribute vec4 a_hitColor;
@@ -540,7 +550,7 @@ ${this.attributes_
540
550
  }
541
551
 
542
552
  return `${COMMON_HEADER}
543
- ${this.uniforms_.map((uniform) => `uniform ${uniform};`).join('\n')}
553
+ ${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
544
554
  varying vec2 v_texCoord;
545
555
  varying vec4 v_hitColor;
546
556
  varying vec2 v_centerPx;
@@ -584,7 +594,7 @@ ${this.attributes_
584
594
  }
585
595
 
586
596
  return `${COMMON_HEADER}
587
- ${this.uniforms_.map((uniform) => `uniform ${uniform};`).join('\n')}
597
+ ${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
588
598
  attribute vec2 a_segmentStart;
589
599
  attribute vec2 a_segmentEnd;
590
600
  attribute float a_measureStart;
@@ -704,7 +714,7 @@ ${this.attributes_
704
714
  }
705
715
 
706
716
  return `${COMMON_HEADER}
707
- ${this.uniforms_.map((uniform) => `uniform ${uniform};`).join('\n')}
717
+ ${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
708
718
  varying vec2 v_segmentStart;
709
719
  varying vec2 v_segmentEnd;
710
720
  varying float v_angleStart;
@@ -884,7 +894,7 @@ ${this.attributes_
884
894
  }
885
895
 
886
896
  return `${COMMON_HEADER}
887
- ${this.uniforms_.map((uniform) => `uniform ${uniform};`).join('\n')}
897
+ ${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
888
898
  attribute vec2 a_position;
889
899
  attribute vec4 a_hitColor;
890
900
 
@@ -919,7 +929,7 @@ ${this.attributes_
919
929
  }
920
930
 
921
931
  return `${COMMON_HEADER}
922
- ${this.uniforms_.map((uniform) => `uniform ${uniform};`).join('\n')}
932
+ ${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
923
933
  varying vec4 v_hitColor;
924
934
  ${this.attributes_
925
935
  .map(
@@ -1 +1 @@
1
- {"version":3,"file":"compileUtil.d.ts","sourceRoot":"","sources":["compileUtil.js"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,qDALW,OAAO,mBAAmB,EAAE,kBAAkB,SAC9C,OAAO,0BAA0B,EAAE,iBAAiB,iBACpD,MAAM,GACL,MAAM,CAUjB;AAED;;;;GAIG;AACH,iCAHW,OAAO,gBAAgB,EAAE,KAAK,GAAC,MAAM,GACpC,KAAK,CAAC,MAAM,CAAC,CASxB;AAWD;;;GAGG;AACH,0CAHW,MAAM,GACL,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,CAUlB;AAED;;;GAGG;AACH,0CAHW,MAAM,GACL,OAAO,GAAC,MAAM,GAAC,MAAM,GAAC,MAAM,CAQvC;AAED;;;;;GAKG;AACH,+CAHW,OAAO,oBAAoB,EAAE,aAAa,WAC1C,OAAO,mBAAmB,EAAE,kBAAkB,QAuCxD;AAED;;;;;;GAMG;AACH,qDAJW,OAAO,mBAAmB,EAAE,kBAAkB,cAC9C,OAAO,qBAAqB,EAAE,cAAc;;EA+BtD;AAED;;;;;GAKG;AACH,uDAHW,OAAO,mBAAmB,EAAE,kBAAkB,GAC7C,OAAO,0BAA0B,EAAE,oBAAoB,CA+BlE;AAxJD,2QAOG"}
1
+ {"version":3,"file":"compileUtil.d.ts","sourceRoot":"","sources":["compileUtil.js"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,qDALW,OAAO,mBAAmB,EAAE,kBAAkB,SAC9C,OAAO,0BAA0B,EAAE,iBAAiB,iBACpD,MAAM,GACL,MAAM,CAUjB;AAED;;;;GAIG;AACH,iCAHW,OAAO,gBAAgB,EAAE,KAAK,GAAC,MAAM,GACpC,KAAK,CAAC,MAAM,CAAC,CASxB;AAWD;;;GAGG;AACH,0CAHW,MAAM,GACL,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,CAUlB;AAED;;;GAGG;AACH,0CAHW,MAAM,GACL,OAAO,GAAC,MAAM,GAAC,MAAM,GAAC,MAAM,CAQvC;AAED;;;;;GAKG;AACH,+CAHW,OAAO,oBAAoB,EAAE,aAAa,WAC1C,OAAO,mBAAmB,EAAE,kBAAkB,QAuCxD;AAED;;;;;;GAMG;AACH,qDAJW,OAAO,mBAAmB,EAAE,kBAAkB,cAC9C,OAAO,qBAAqB,EAAE,cAAc;;EAoCtD;AAED;;;;;GAKG;AACH,uDAHW,OAAO,mBAAmB,EAAE,kBAAkB,GAC7C,OAAO,0BAA0B,EAAE,oBAAoB,CA+BlE;AA7JD,2QAOG"}
@@ -99,7 +99,7 @@ export function applyContextToBuilder(builder, context) {
99
99
  // we're not packing colors when they're passed as uniforms
100
100
  glslType = 'vec4';
101
101
  }
102
- builder.addUniform(`${glslType} ${uniformName}`);
102
+ builder.addUniform(uniformName, glslType);
103
103
  }
104
104
 
105
105
  // for each feature attribute used in the fragment shader, define a varying that will be used to pass data
@@ -153,7 +153,12 @@ export function generateUniformsFromContext(context, variables) {
153
153
  return value ? 1 : 0;
154
154
  }
155
155
  if (variable.type === ColorType) {
156
- return asArray(value || '#eee');
156
+ const color = [...asArray(value || '#eee')];
157
+ color[0] /= 255;
158
+ color[1] /= 255;
159
+ color[2] /= 255;
160
+ color[3] ??= 1;
161
+ return color;
157
162
  }
158
163
  if (typeof value === 'string') {
159
164
  return getStringNumberEquivalent(value);
@@ -157,11 +157,11 @@ function parseImageProperties(style, builder, uniforms, prefix, textureId) {
157
157
  uniforms[`u_texture${textureId}_size`] = () => {
158
158
  return image.complete ? [image.width, image.height] : [0, 0];
159
159
  };
160
- builder.addUniform(`vec2 u_texture${textureId}_size`);
160
+ builder.addUniform(`u_texture${textureId}_size`, 'vec2');
161
161
  const size = `u_texture${textureId}_size`;
162
162
 
163
163
  uniforms[`u_texture${textureId}`] = image;
164
- builder.addUniform(`sampler2D u_texture${textureId}`);
164
+ builder.addUniform(`u_texture${textureId}`, 'sampler2D');
165
165
  return size;
166
166
  }
167
167
 
@@ -184,7 +184,7 @@ function parseImageOffsetProperties(
184
184
  let offsetExpression = expressionToGlsl(
185
185
  context,
186
186
  style[`${prefix}offset`],
187
- NumberArrayType,
187
+ SizeType,
188
188
  );
189
189
  if (`${prefix}offset-origin` in style) {
190
190
  switch (style[`${prefix}offset-origin`]) {
@@ -191,8 +191,8 @@ class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer {
191
191
  ? `(${exisitingDiscard}) || (${discardFromMask})`
192
192
  : discardFromMask,
193
193
  );
194
- builder.addUniform(`sampler2D ${Uniforms.TILE_MASK_TEXTURE}`);
195
- builder.addUniform(`float ${Uniforms.TILE_ZOOM_LEVEL}`);
194
+ builder.addUniform(Uniforms.TILE_MASK_TEXTURE, 'sampler2D');
195
+ builder.addUniform(Uniforms.TILE_ZOOM_LEVEL, 'float');
196
196
  }
197
197
 
198
198
  this.styleRenderers_ = this.styles_.map((style) => {
@@ -234,7 +234,7 @@ class WebGLVectorTileLayerRenderer extends WebGLBaseTileLayerRenderer {
234
234
  .setFillColorExpression(
235
235
  `vec4(${Uniforms.TILE_ZOOM_LEVEL} / 50., 0., 0., 1.)`,
236
236
  )
237
- .addUniform(`float ${Uniforms.TILE_ZOOM_LEVEL}`);
237
+ .addUniform(Uniforms.TILE_ZOOM_LEVEL, 'float');
238
238
  this.tileMaskProgram_ = this.helper.getProgram(
239
239
  builder.getFillFragmentShader(),
240
240
  builder.getFillVertexShader(),
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.5.1-dev.1746262133835';
36
+ export const VERSION = '10.5.1-dev.1746527002956';