Skip to content

Commit b927915

Browse files
committed
Website updates
1 parent 029cb7e commit b927915

21 files changed

+366
-283
lines changed

dist/en/main/examples/common.js

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/dist/ol.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/dist/ol.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/render/webgl/ShaderBuilder.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/render/webgl/ShaderBuilder.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export class ShaderBuilder {
475475
return `${COMMON_HEADER}
476476
${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
477477
attribute vec2 a_position;
478-
attribute float a_index;
478+
attribute vec2 a_localPosition;
479479
attribute vec4 a_hitColor;
480480
481481
varying vec2 v_texCoord;
@@ -505,25 +505,16 @@ void main(void) {
505505
v_quadSizePx = ${this.symbolSizeExpression_};
506506
vec2 halfSizePx = v_quadSizePx * 0.5;
507507
vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
508-
vec2 offsetPx = centerOffsetPx;
509-
if (a_index == 0.0) {
510-
offsetPx -= halfSizePx;
511-
} else if (a_index == 1.0) {
512-
offsetPx += halfSizePx * vec2(1., -1.);
513-
} else if (a_index == 2.0) {
514-
offsetPx += halfSizePx;
515-
} else {
516-
offsetPx += halfSizePx * vec2(-1., 1.);
517-
}
508+
vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
518509
float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_ ? ' + u_rotation' : ''};
519510
float c = cos(-angle);
520511
float s = sin(-angle);
521512
offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
522513
vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
523514
gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
524515
vec4 texCoord = ${this.texCoordExpression_};
525-
float u = a_index == 0.0 || a_index == 3.0 ? texCoord.s : texCoord.p;
526-
float v = a_index == 2.0 || a_index == 3.0 ? texCoord.t : texCoord.q;
516+
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
517+
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
527518
v_texCoord = vec2(u, v);
528519
v_hitColor = a_hitColor;
529520
v_angle = angle;
@@ -597,9 +588,10 @@ ${this.attributes_
597588
${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
598589
attribute vec2 a_segmentStart;
599590
attribute vec2 a_segmentEnd;
591+
attribute vec2 a_localPosition;
600592
attribute float a_measureStart;
601593
attribute float a_measureEnd;
602-
attribute float a_parameters;
594+
attribute float a_angleTangentSum;
603595
attribute float a_distance;
604596
attribute vec2 a_joinAngles;
605597
attribute vec4 a_hitColor;
@@ -656,10 +648,9 @@ vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
656648
void main(void) {
657649
v_angleStart = a_joinAngles.x;
658650
v_angleEnd = a_joinAngles.y;
659-
float vertexNumber = floor(abs(a_parameters) / 10000. + 0.5);
660-
currentLineMetric = vertexNumber < 1.5 ? a_measureStart : a_measureEnd;
651+
float startEndRatio = a_localPosition.x * 0.5 + 0.5;
652+
currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
661653
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
662-
float angleTangentSum = fract(abs(a_parameters) / 10000.) * 10000. * sign(a_parameters);
663654
664655
float lineWidth = ${this.strokeWidthExpression_};
665656
float lineOffsetPx = ${this.strokeOffsetExpression_};
@@ -673,11 +664,11 @@ void main(void) {
673664
segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
674665
675666
// compute current vertex position
676-
float normalDir = vertexNumber < 0.5 || (vertexNumber > 1.5 && vertexNumber < 2.5) ? 1.0 : -1.0;
677-
float tangentDir = vertexNumber < 1.5 ? 1.0 : -1.0;
678-
float angle = vertexNumber < 1.5 ? v_angleStart : v_angleEnd;
667+
float normalDir = -1. * a_localPosition.y;
668+
float tangentDir = -1. * a_localPosition.x;
669+
float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
679670
vec2 joinDirection;
680-
vec2 positionPx = vertexNumber < 1.5 ? segmentStartPx : segmentEndPx;
671+
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
681672
// if angle is too high, do not make a proper join
682673
if (cos(angle) > ${LINESTRING_ANGLE_COSINE_CUTOFF} || isCap(angle)) {
683674
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
@@ -691,7 +682,7 @@ void main(void) {
691682
v_segmentEnd = segmentEndPx;
692683
v_width = lineWidth;
693684
v_hitColor = a_hitColor;
694-
v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * angleTangentSum);
685+
v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * a_angleTangentSum);
695686
v_measureStart = a_measureStart;
696687
v_measureEnd = a_measureEnd;
697688
${this.attributes_

dist/en/main/ol/render/webgl/VectorStyleRenderer.d.ts

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export function convertStyleToShaders(style: FlatStyleLike | StyleShaders | Arra
1212
export type Attributes = string;
1313
export namespace Attributes {
1414
let POSITION: string;
15-
let INDEX: string;
15+
let LOCAL_POSITION: string;
1616
let SEGMENT_START: string;
1717
let SEGMENT_END: string;
1818
let MEASURE_START: string;
1919
let MEASURE_END: string;
20-
let PARAMETERS: string;
20+
let ANGLE_TANGENT_SUM: string;
2121
let JOIN_ANGLES: string;
2222
let DISTANCE: string;
2323
}
@@ -44,19 +44,23 @@ export type AttributeDefinitions = {
4444
export type UniformDefinitions = {
4545
[x: string]: import("../../webgl/Helper.js").UniformValue;
4646
};
47+
/**
48+
* Buffers organized like so: [indicesBuffer, vertexAttributesBuffer, instanceAttributesBuffer]
49+
*/
50+
export type WebGLArrayBufferSet = Array<WebGLArrayBuffer>;
4751
export type WebGLBuffers = {
4852
/**
4953
* Array containing indices and vertices buffers for polygons
5054
*/
51-
polygonBuffers: Array<WebGLArrayBuffer>;
55+
polygonBuffers: WebGLArrayBufferSet;
5256
/**
5357
* Array containing indices and vertices buffers for line strings
5458
*/
55-
lineStringBuffers: Array<WebGLArrayBuffer>;
59+
lineStringBuffers: WebGLArrayBufferSet;
5660
/**
5761
* Array containing indices and vertices buffers for points
5862
*/
59-
pointBuffers: Array<WebGLArrayBuffer>;
63+
pointBuffers: WebGLArrayBufferSet;
6064
/**
6165
* Inverse of the transform applied when generating buffers
6266
*/
@@ -103,9 +107,17 @@ export type SubRenderPass = {
103107
*/
104108
fragmentShader: string;
105109
/**
106-
* Attributes description
110+
* Attributes description, defined for each primitive vertex
107111
*/
108112
attributesDesc: Array<import("../../webgl/Helper.js").AttributeDescription>;
113+
/**
114+
* Attributes description, defined once per primitive
115+
*/
116+
instancedAttributesDesc: Array<import("../../webgl/Helper.js").AttributeDescription>;
117+
/**
118+
* Number of vertices per instance primitive in this render pass
119+
*/
120+
instancePrimitiveVertexCount: number;
109121
/**
110122
* Program; this has to be recreated if the helper is lost/changed
111123
*/
@@ -137,11 +149,14 @@ export type RenderPass = {
137149
* @typedef {Object<string, AttributeDefinition>} AttributeDefinitions
138150
* @typedef {Object<string, import("../../webgl/Helper").UniformValue>} UniformDefinitions
139151
*/
152+
/**
153+
* @typedef {Array<WebGLArrayBuffer>} WebGLArrayBufferSet Buffers organized like so: [indicesBuffer, vertexAttributesBuffer, instanceAttributesBuffer]
154+
*/
140155
/**
141156
* @typedef {Object} WebGLBuffers
142-
* @property {Array<WebGLArrayBuffer>} polygonBuffers Array containing indices and vertices buffers for polygons
143-
* @property {Array<WebGLArrayBuffer>} lineStringBuffers Array containing indices and vertices buffers for line strings
144-
* @property {Array<WebGLArrayBuffer>} pointBuffers Array containing indices and vertices buffers for points
157+
* @property {WebGLArrayBufferSet} polygonBuffers Array containing indices and vertices buffers for polygons
158+
* @property {WebGLArrayBufferSet} lineStringBuffers Array containing indices and vertices buffers for line strings
159+
* @property {WebGLArrayBufferSet} pointBuffers Array containing indices and vertices buffers for points
145160
* @property {import("../../transform.js").Transform} invertVerticesTransform Inverse of the transform applied when generating buffers
146161
*/
147162
/**
@@ -171,7 +186,9 @@ export type RenderPass = {
171186
* @typedef {Object} SubRenderPass
172187
* @property {string} vertexShader Vertex shader
173188
* @property {string} fragmentShader Fragment shader
174-
* @property {Array<import('../../webgl/Helper.js').AttributeDescription>} attributesDesc Attributes description
189+
* @property {Array<import('../../webgl/Helper.js').AttributeDescription>} attributesDesc Attributes description, defined for each primitive vertex
190+
* @property {Array<import('../../webgl/Helper.js').AttributeDescription>} instancedAttributesDesc Attributes description, defined once per primitive
191+
* @property {number} instancePrimitiveVertexCount Number of vertices per instance primitive in this render pass
175192
* @property {WebGLProgram} [program] Program; this has to be recreated if the helper is lost/changed
176193
*/
177194
/**
@@ -248,7 +265,7 @@ declare class VectorStyleRenderer {
248265
* @param {Float32Array|null} renderInstructions Render instructions
249266
* @param {import("../../geom/Geometry.js").Type} geometryType Geometry type
250267
* @param {import("../../transform.js").Transform} transform Transform to apply to coordinates
251-
* @return {Promise<Array<WebGLArrayBuffer>>|null} Indices buffer and vertices buffer; null if nothing to render
268+
* @return {Promise<WebGLArrayBufferSet>|null} Indices buffer and vertices buffer; null if nothing to render
252269
* @private
253270
*/
254271
private generateBuffersForType_;
@@ -261,9 +278,9 @@ declare class VectorStyleRenderer {
261278
render(buffers: WebGLBuffers, frameState: import("../../Map.js").FrameState, preRenderCallback: () => void): void;
262279
/**
263280
* @param {WebGLArrayBuffer} indicesBuffer Indices buffer
264-
* @param {WebGLArrayBuffer} verticesBuffer Vertices buffer
265-
* @param {WebGLProgram} program Program
266-
* @param {Array<import('../../webgl/Helper.js').AttributeDescription>} attributes Attribute descriptions
281+
* @param {WebGLArrayBuffer} vertexAttributesBuffer Vertex attributes buffer
282+
* @param {WebGLArrayBuffer} instanceAttributesBuffer Instance attributes buffer
283+
* @param {SubRenderPass} subRenderPass Render pass (program, attributes, etc.) specific to one geometry type
267284
* @param {import("../../Map.js").FrameState} frameState Frame state.
268285
* @param {function(): void} preRenderCallback This callback will be called right before drawing, and can be used to set uniforms
269286
* @private

dist/en/main/ol/render/webgl/VectorStyleRenderer.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)