@pirireis/webglobeplugins 0.16.7 → 0.17.1

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 (159) hide show
  1. package/Math/angle-calculation.js +1 -0
  2. package/Math/contour/quadtreecontours.js +300 -0
  3. package/Math/finite-line-2d.js +58 -0
  4. package/Math/methods.js +6 -0
  5. package/Math/tessellation/hybrid-triangle-tessellation-meta.js +123 -0
  6. package/Math/tessellation/tile-merger.js +298 -0
  7. package/Math/tessellation/triangle-tessellation-meta.js +195 -42
  8. package/Math/tessellation/triangle-tessellation.js +5 -1
  9. package/compass-rose/compass-text-writer.js +39 -33
  10. package/constants.js +3 -0
  11. package/{util/heatwavedatamanager → heatwave}/datamanager.js +1 -1
  12. package/heatwave/{plugins/heatwaveglobeshell.js → heatwave.js} +8 -6
  13. package/heatwave/index.js +5 -3
  14. package/heatwave/{isobar/plugin.js → isobar.js} +6 -5
  15. package/{util/heatwavedatamanager → heatwave}/texture-point-sampler.js +24 -3
  16. package/investigation-tools/draw/tiles/adapters.js +67 -0
  17. package/investigation-tools/draw/tiles/tiles.js +128 -0
  18. package/package.json +4 -2
  19. package/programs/arrowfield/{object.js → arrow-field.js} +1 -1
  20. package/programs/arrowfield/logic.js +1 -1
  21. package/programs/data2legend/density-to-legend.js +24 -29
  22. package/programs/data2legend/point-to-density-texture.js +14 -17
  23. package/programs/float2legendwithratio/logic.js +2 -2
  24. package/programs/float2legendwithratio/object.js +1 -1
  25. package/programs/helpers/{blender/program.js → blender.js} +1 -1
  26. package/programs/helpers/{fadeaway/logic.js → fadeaway.js} +11 -2
  27. package/programs/index.js +20 -9
  28. package/programs/line-on-globe/circle-accurate-3d.js +12 -14
  29. package/programs/line-on-globe/circle-accurate-flat.js +0 -1
  30. package/programs/line-on-globe/degree-padding-around-circle-3d.js +13 -15
  31. package/programs/line-on-globe/lines-color-instanced-flat.js +15 -18
  32. package/programs/line-on-globe/naive-accurate-flexible.js +0 -1
  33. package/programs/picking/pickable-polygon-renderer.js +1 -1
  34. package/programs/picking/pickable-renderer.js +2 -2
  35. package/programs/point-on-globe/element-globe-surface-glow.js +2 -2
  36. package/programs/point-on-globe/element-point-glow.js +1 -1
  37. package/programs/point-on-globe/square-pixel-point.js +1 -1
  38. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +180 -30
  39. package/programs/polygon-on-globe/texture-dem-triangles.js +93 -34
  40. package/programs/rings/partial-ring/piece-of-pie.js +26 -29
  41. package/programs/totems/camerauniformblock.js +31 -42
  42. package/programs/two-d/pixel-padding-for-compass.js +14 -24
  43. package/programs/vectorfields/logics/drawrectangleparticles.js +9 -8
  44. package/programs/vectorfields/logics/drawrectangleparticles1.js +112 -0
  45. package/programs/vectorfields/logics/pixelbased.js +1 -2
  46. package/programs/vectorfields/pingpongbuffermanager.js +1 -1
  47. package/range-tools-on-terrain/bearing-line/adapters.js +1 -1
  48. package/range-tools-on-terrain/circle-line-chain/adapters.js +0 -5
  49. package/range-tools-on-terrain/circle-line-chain/plugin.js +1 -1
  50. package/range-tools-on-terrain/range-ring/plugin.js +4 -6
  51. package/semiplugins/lightweight/line-plugin.js +0 -1
  52. package/semiplugins/shape-on-terrain/arc-plugin.js +9 -2
  53. package/semiplugins/shape-on-terrain/circle-plugin.js +2 -2
  54. package/semiplugins/shape-on-terrain/padding-1-degree.js +1 -1
  55. package/semiplugins/shell/bbox-renderer/index.js +2 -0
  56. package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/logic.js +101 -102
  57. package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/object.js +6 -7
  58. package/semiplugins/utility/container-plugin.js +94 -0
  59. package/semiplugins/utility/object-pass-container-plugin.js +80 -0
  60. package/{point-heat-map → tracks/point-heat-map}/adaptors/timetracksplugin-format-to-this.js +1 -1
  61. package/{point-heat-map → tracks/point-heat-map}/plugin-webworker.js +3 -3
  62. package/{point-heat-map → tracks/point-heat-map}/point-to-heat-map-flow.js +11 -14
  63. package/{point-tracks → tracks/point-tracks}/plugin.js +6 -5
  64. package/{timetracks → tracks/timetracks}/adaptors-line-strip.js +1 -1
  65. package/{timetracks → tracks/timetracks}/program-line-strip.js +49 -49
  66. package/{timetracks → tracks/timetracks}/programpoint-line-strip.js +16 -13
  67. package/types.js +6 -0
  68. package/util/account/bufferoffsetmanager.js +1 -1
  69. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +9 -95
  70. package/util/gl-util/uniform-block/manager.js +0 -1
  71. package/util/gl-util/uniform-block/types.js +0 -7
  72. package/util/index.js +10 -13
  73. package/util/picking/fence.js +16 -18
  74. package/util/picking/picker-displayer.js +6 -8
  75. package/util/programs/{shapesonglobe.js → draw-from-pixel-coords.js} +4 -7
  76. package/util/programs/draw-texture-on-canvas.js +1 -1
  77. package/util/programs/texturetoglobe.js +3 -3
  78. package/util/shaderfunctions/geometrytransformations.js +1 -1
  79. package/vectorfield/arrowfield/index.js +3 -0
  80. package/{arrowfield → vectorfield/arrowfield}/plugin.js +2 -2
  81. package/{waveparticles → vectorfield/waveparticles}/plugin.js +12 -12
  82. package/{wind → vectorfield/wind}/index.js +1 -1
  83. package/{wind → vectorfield/wind}/plugin.js +65 -51
  84. package/write-text/context-text3.js +0 -1
  85. package/write-text/context-text4.js +2 -1
  86. package/write-text/objectarraylabels/index.js +2 -0
  87. package/Math/tessellation/tessellation-algorithm.js +0 -67
  88. package/arrowfield/index.js +0 -3
  89. package/bearing-line/index.js +0 -2
  90. package/bearing-line/plugin.js +0 -444
  91. package/circle-line-chain/chain-list-map.js +0 -201
  92. package/circle-line-chain/init.js +0 -1
  93. package/circle-line-chain/plugin.js +0 -411
  94. package/circle-line-chain/util.js +0 -1
  95. package/compassrose/compassrose.js +0 -293
  96. package/compassrose/index.js +0 -2
  97. package/index.js +0 -12
  98. package/partialrings/buffer-manager.js +0 -75
  99. package/partialrings/index.js +0 -2
  100. package/partialrings/plugin.js +0 -128
  101. package/partialrings/program.js +0 -279
  102. package/programs/arrowfield/index.js +0 -2
  103. package/programs/globe-util/is-globe-moved.js +0 -19
  104. package/programs/globeshell/index.js +0 -2
  105. package/programs/globeshell/wiggle/index.js +0 -2
  106. package/programs/helpers/blender/index.js +0 -1
  107. package/programs/helpers/fadeaway/index.js +0 -2
  108. package/programs/helpers/fadeaway/object.js +0 -14
  109. package/programs/helpers/index.js +0 -2
  110. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +0 -118
  111. package/programs/rings/distancering/circleflatprogram.js +0 -116
  112. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -326
  113. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -368
  114. package/programs/rings/distancering/index.js +0 -6
  115. package/programs/rings/distancering/paddyflatprogram.js +0 -127
  116. package/programs/rings/distancering/paddyflatprogram2d.js +0 -129
  117. package/programs/rings/distancering/paddyflatprogram3d.js +0 -128
  118. package/programs/two-d/pixel-circle.js +0 -1
  119. package/programs/vectorfields/index.js +0 -3
  120. package/rangerings/enum.js +0 -2
  121. package/rangerings/index.js +0 -5
  122. package/rangerings/plugin.js +0 -543
  123. package/rangerings/rangeringangletext.js +0 -326
  124. package/rangerings/ring-account.js +0 -112
  125. package/timetracks/index.js +0 -1
  126. package/util/build-strategy/general-strategy.js +0 -62
  127. package/util/gl-util/uniform-block/shader.js +0 -1
  128. package/util/heatwavedatamanager/index.js +0 -2
  129. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  130. package/util/jshelpers/data-filler.js +0 -17
  131. package/util/jshelpers/equality.js +0 -18
  132. package/util/jshelpers/index.js +0 -2
  133. package/util/jshelpers/timefilters.js +0 -30
  134. package/util/programs/index.js +0 -1
  135. package/util/surface-line-data/arc-bboxes.js +0 -25
  136. package/util/surface-line-data/arcs-to-cuts.js +0 -50
  137. package/util/surface-line-data/cut-arc.js +0 -1
  138. package/util/surface-line-data/flow.js +0 -28
  139. package/util/surface-line-data/rbush-manager.js +0 -1
  140. package/util/surface-line-data/types.js +0 -1
  141. package/util/surface-line-data/web-worker.js +0 -1
  142. package/util/webglobe/rasteroverlay.js +0 -75
  143. package/write-text/attached-text-writer.js +0 -87
  144. package/write-text/context-text3old.js +0 -152
  145. package/write-text/index.js +0 -1
  146. package/write-text/writer-plugin.js +0 -8
  147. /package/{heatwave/isobar/quadtreecontours.js → Math/contour/quadtreecontours1.js} +0 -0
  148. /package/pin/{pin-object-array.js → pin-object-array1.js} +0 -0
  149. /package/pin/{pin-point-totem.js → pin-point-totem1.js} +0 -0
  150. /package/{point-heat-map → tracks/point-heat-map}/index.js +0 -0
  151. /package/{point-tracks → tracks/point-tracks}/key-methods.js +0 -0
  152. /package/{timetracks → tracks/timetracks}/plugin-line-strip.js +0 -0
  153. /package/{arrowfield → vectorfield/arrowfield}/adaptor.js +0 -0
  154. /package/{waveparticles → vectorfield/waveparticles}/adaptor.js +0 -0
  155. /package/{waveparticles → vectorfield/waveparticles}/index.js +0 -0
  156. /package/{wind → vectorfield/wind}/imagetovectorfieldandmagnitude.js +0 -0
  157. /package/{wind → vectorfield/wind}/vectorfieldimage.js +0 -0
  158. /package/write-text/{context-text.js → context-textDELETE.js} +0 -0
  159. /package/{heatwave/isobar → write-text/objectarraylabels}/objectarraylabels.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { createProgram } from "../../util/webglobjectbuilders";
2
2
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems/camerauniformblock";
3
- import { cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
3
+ import { cartesian3DToGLPosition, } from "../../util/shaderfunctions/geometrytransformations";
4
4
  import { isPointInBBox } from "../../util/shaderfunctions/geometrytransformations";
5
5
  import { drawArrays } from "../../util/gl-util/draw-options/methods";
6
6
  import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
@@ -25,19 +25,14 @@ ${CameraUniformBlockString}
25
25
 
26
26
  ${cartesian3DToGLPosition}
27
27
  in vec3 a_position;
28
- in vec2 a_longLat;
28
+ in vec2 a_xy;
29
29
  uniform sampler2DArray u_demTexture; // <-- changed from array to single
30
30
  uniform vec4 u_demTextureBBOX[6];
31
-
31
+ uniform vec2 u_textureDataCoverRatio[6];
32
+ uniform int u_breakLoopIndex;
32
33
 
33
34
  ${styleBlockManager.glslCode()}
34
-
35
-
36
- // TODO: light directioni
37
- // out vec3 v_position;
38
- // out vec3 v_normal;
39
- // out vec2 v_textureCoord;
40
-
35
+ // Todo: light direction.
41
36
  out vec4 v_color;
42
37
 
43
38
 
@@ -46,23 +41,35 @@ ${isPointInBBox}
46
41
  void main() {
47
42
 
48
43
  float elevation = ${WORLD_RADIUS_3D}; // default elevation at sea level
44
+ float altitude = 0.0;
49
45
  v_color = vec4(1.0, 1.0, 1.0, 1.0); // default color white
46
+
50
47
  for (int i = 0; i < 6; i++) {
51
- if (isPointInBBox(a_longLat, u_demTextureBBOX[i])) {
52
- vec2 uv = (a_longLat - u_demTextureBBOX[i].xy) / (u_demTextureBBOX[i].zw - u_demTextureBBOX[i].xy);
53
- float altitude = texture(u_demTexture, vec3(uv, float(i))).r;
54
- elevation += altitude;
55
- v_color = mix(vec4(0.0, 0.0, 1.0, 1.0), vec4(1.0, 0.0, 0.0, 1.0), altitude / 100.0); // color from blue to red based on altitude
56
- break;
57
- }
48
+ if (isPointInBBox(a_xy, u_demTextureBBOX[i])) {
49
+ vec2 uv = (a_xy - u_demTextureBBOX[i].xy) / (u_demTextureBBOX[i].zw - u_demTextureBBOX[i].xy);
50
+ // uv.y = 1.0 - uv.y; // flip y coordinate
51
+ // rescale and transform uv to fit in the texture data cover bbox
52
+ uv *= u_textureDataCoverRatio[i];
53
+ altitude = texture(u_demTexture, vec3(uv, float(i))).r;
54
+ if (altitude != 0.0) {
55
+ break;
56
+ }
57
+ }
58
58
  }
59
59
  if (u_color.a > 0.0) {
60
60
  v_color = u_color;
61
+ } else {
62
+ if ( altitude > 0.00001 ) {
63
+ v_color = mix(vec4(1.0, 1.0, 1.0, 1.0), vec4(1.0, 0.2, 0.2, 1.0), altitude / 2.0); // color from white to red based on altitude
64
+ } else {
65
+ // white
66
+ v_color = vec4(1.0, 1.0, 1.0, 0.5);
67
+ }
61
68
  }
62
69
  v_color.a *= u_opacity;
63
- vec3 position = a_position * elevation;
70
+ vec3 position = a_position * (elevation + altitude * 2.0);
64
71
  gl_Position = cartesian3DToGLPosition(position);
65
- gl_PointSize = u_pointSize;
72
+ gl_PointSize = 6.0; //u_pointSize;
66
73
  }
67
74
  `;
68
75
  const fragmentShaderSource = `#version 300 es
@@ -75,6 +82,10 @@ void main() {
75
82
  outColor = v_color;
76
83
  }
77
84
  `;
85
+ function resCalculation(sourceResolution, mergeCount) {
86
+ return sourceResolution + (mergeCount - 1) * (sourceResolution - 1);
87
+ }
88
+ const RESOLUTION = resCalculation(5, 12); // 5 is tile dimension length, 12 is merge count
78
89
  export class TextureDemTriangles {
79
90
  globe;
80
91
  gl;
@@ -88,12 +99,14 @@ export class TextureDemTriangles {
88
99
  locations = {
89
100
  attributes: {
90
101
  a_position: -1,
91
- a_longLat: -1,
102
+ a_xy: -1,
92
103
  },
93
104
  uniforms: {
94
105
  u_demTexture: -1,
95
106
  u_demTextureBBOX: -1,
107
+ u_textureDataCoverRatio: -1,
96
108
  u_style: -1,
109
+ u_breakLoopIndex: -1,
97
110
  }
98
111
  };
99
112
  constructor(globe) {
@@ -104,19 +117,23 @@ export class TextureDemTriangles {
104
117
  this.cameraUniformBlock.assignBindingPoint(this.program, uniformBindingPoints.camera);
105
118
  // get attribute locations
106
119
  this.locations.attributes.a_position = this.gl.getAttribLocation(this.program, 'a_position');
107
- this.locations.attributes.a_longLat = this.gl.getAttribLocation(this.program, 'a_longLat');
120
+ this.locations.attributes.a_xy = this.gl.getAttribLocation(this.program, 'a_xy');
108
121
  // get uniform locations
109
122
  this.locations.uniforms.u_demTexture = this.gl.getUniformLocation(this.program, 'u_demTexture');
110
123
  this.locations.uniforms.u_demTextureBBOX = this.gl.getUniformLocation(this.program, 'u_demTextureBBOX');
124
+ this.locations.uniforms.u_textureDataCoverRatio = this.gl.getUniformLocation(this.program, 'u_textureDataCoverRatio');
125
+ this.locations.uniforms.u_breakLoopIndex = this.gl.getUniformLocation(this.program, 'u_breakLoopIndex');
111
126
  this.locations.uniforms.u_style = this.gl.getUniformBlockIndex(this.program, 'Style');
112
127
  this.gl.uniformBlockBinding(this.program, this.locations.uniforms.u_style, uniformBindingPoints.style);
113
128
  // create 3d texture
114
129
  const texture = this.gl.createTexture();
115
130
  this.gl.bindTexture(this.gl.TEXTURE_2D_ARRAY, texture);
116
- // this.gl.texImage3D(this.gl.TEXTURE_2D_ARRAY, 0, this.gl.R32F, 25, 25, 6, 0, this.gl.RED, this.gl.FLOAT, null);
117
- this.gl.texStorage3D(this.gl.TEXTURE_2D_ARRAY, 1, this.gl.R32F, 5, 5, 6);
131
+ // Calculate correct size: tileDimensionLength + (mergeCount - 1) * (tileDimensionLength - 1)
132
+ // For tileDimensionLength=5, mergeCount=8: 5 + 7*4 = RESOLUTION
133
+ this.gl.texStorage3D(this.gl.TEXTURE_2D_ARRAY, 1, this.gl.R32F, RESOLUTION, RESOLUTION, 6);
118
134
  // set texture parameters
119
135
  const ext = this.gl.getExtension('OES_texture_float_linear');
136
+ console.log('OES_texture_float_linear extension:', ext);
120
137
  this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
121
138
  this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
122
139
  this.gl.texParameteri(this.gl.TEXTURE_2D_ARRAY, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
@@ -128,11 +145,17 @@ export class TextureDemTriangles {
128
145
  const vao = this.gl.createVertexArray();
129
146
  this.gl.bindVertexArray(vao);
130
147
  attributeLoader(this.gl, pos3dBufferInfo, this.locations.attributes.a_position, 3);
131
- attributeLoader(this.gl, longLatBufferInfo, this.locations.attributes.a_longLat, 2);
148
+ attributeLoader(this.gl, longLatBufferInfo, this.locations.attributes.a_xy, 2);
132
149
  this.gl.bindVertexArray(null);
133
150
  return vao;
134
151
  }
135
- setDemTextures(demTexturesData, demTextureBBOX) {
152
+ setDemTextures(demTexturesData, demTextureBBOX, coverRatio) {
153
+ // Add validation for maximum layers
154
+ const maxLayers = this.gl.getParameter(this.gl.MAX_ARRAY_TEXTURE_LAYERS);
155
+ if (demTexturesData.length > Math.min(maxLayers, 6)) {
156
+ console.error(`Too many DEM textures: ${demTexturesData.length}, max supported: ${Math.min(maxLayers, 6)}`);
157
+ return;
158
+ }
136
159
  // bind textures to texture units
137
160
  const gl = this.gl;
138
161
  gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.texture);
@@ -142,23 +165,33 @@ export class TextureDemTriangles {
142
165
  // bind and upload each texture to the 3D texture array
143
166
  for (let i = 0; i < demTexturesData.length; i++) {
144
167
  const data = demTexturesData[i];
145
- if (data.length === 5 * 5) { // <-- FIXED
146
- gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, i, 5, 5, 1, gl.RED, gl.FLOAT, new Float32Array(data));
168
+ if (data.length === RESOLUTION * RESOLUTION) { // <-- FIXED
169
+ gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, i, RESOLUTION, RESOLUTION, 1, gl.RED, gl.FLOAT, new Float32Array(data));
170
+ }
171
+ else {
172
+ console.warn(`DEM texture ${i} has incorrect size: ${data.length}, expected: ${RESOLUTION * RESOLUTION}`);
147
173
  }
148
174
  }
149
175
  // set uniform for texture units
150
176
  const bboxVec4Array = new Float32Array(6 * 4);
151
177
  for (let i = 0; i < demTextureBBOX.length; i++) {
152
178
  const bbox = demTextureBBOX[i];
153
- bboxVec4Array[i * 4 + 0] = bbox.northWest[0];
154
- bboxVec4Array[i * 4 + 1] = bbox.southEast[1];
155
- bboxVec4Array[i * 4 + 2] = bbox.southEast[0];
156
- bboxVec4Array[i * 4 + 3] = bbox.northWest[1];
179
+ bboxVec4Array[i * 4 + 0] = bbox.ll[0];
180
+ bboxVec4Array[i * 4 + 1] = bbox.ll[1];
181
+ bboxVec4Array[i * 4 + 2] = bbox.ur[0];
182
+ bboxVec4Array[i * 4 + 3] = bbox.ur[1];
157
183
  }
158
184
  const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
159
185
  gl.useProgram(this.program);
160
186
  gl.uniform4fv(this.locations.uniforms.u_demTextureBBOX, bboxVec4Array);
187
+ if (coverRatio) {
188
+ gl.uniform2fv(this.locations.uniforms.u_textureDataCoverRatio, new Float32Array(coverRatio.flatMap(ratio => [ratio.x, ratio.y])));
189
+ }
190
+ else {
191
+ gl.uniform2fv(this.locations.uniforms.u_textureDataCoverRatio, new Float32Array(12).fill(1.0));
192
+ }
161
193
  gl.bindTexture(gl.TEXTURE_2D_ARRAY, null);
194
+ gl.uniform1i(this.locations.uniforms.u_breakLoopIndex, demTexturesData.length);
162
195
  gl.useProgram(currentProgram);
163
196
  }
164
197
  createUBO(bufferReadType = "STATIC_DRAW") {
@@ -178,7 +211,11 @@ export class TextureDemTriangles {
178
211
  gl.useProgram(this.program);
179
212
  this.cameraUniformBlock.bind(uniformBindingPoints.camera);
180
213
  // TURN OFF flip y for texture
181
- gl.disable(gl.DEPTH_TEST);
214
+ // gl.disable(gl.DEPTH_TEST);
215
+ // gl.depthMask(false);
216
+ // gl.depthRange(0.0, 0.01); // Use near 1% of depth range
217
+ // Step 3: Optionally: Set depth func to ALWAYS (to ignore previous depth)
218
+ // This ensures your new geometry passes depth test regardless of prior depth values
182
219
  gl.activeTexture(gl.TEXTURE0);
183
220
  gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.texture);
184
221
  gl.uniform1i(this.locations.uniforms.u_demTexture, 0); // texture unit 0
@@ -186,9 +223,9 @@ export class TextureDemTriangles {
186
223
  gl.bindVertexArray(vao);
187
224
  // bind UBO for style
188
225
  ubo.bind();
226
+ drawOnTopBegin(gl);
189
227
  drawArrays(gl, gl.POINTS, drawOptions);
190
- gl.enable(gl.DEPTH_TEST);
191
- // unbind everything
228
+ drawOnTopEnd(gl);
192
229
  gl.bindVertexArray(null);
193
230
  gl.bindTexture(gl.TEXTURE_2D_ARRAY, null);
194
231
  gl.useProgram(null);
@@ -207,3 +244,25 @@ export class TextureDemTriangles {
207
244
  return result;
208
245
  }
209
246
  }
247
+ function drawOnTopBegin(gl) {
248
+ gl.disable(gl.DEPTH_TEST);
249
+ // gl.enable(gl.POLYGON_OFFSET_FILL);
250
+ // // Use an offset to "nudge" the depth value slightly closer or farther.
251
+ // // Common values are gl.polygonOffset(1.0, 1.0) or gl.polygonOffset(0.RESOLUTION, 0.RESOLUTION)
252
+ // gl.polygonOffset(1.0, 1.0);
253
+ // gl.depthRange(0.0, 0.0001); // Use near 0.01% of depth range
254
+ // gl.enable(gl.POLYGON_OFFSET_FILL);
255
+ // You will need to experiment with these values!
256
+ // A good starting point is -1.0, -1.0.
257
+ // Negative values "pull" the fragments closer to the camera.
258
+ // gl.polygonOffset(-1.0, -1.0);
259
+ // gl.enable(gl.POLYGON_OFFSET_FILL);
260
+ // gl.polygonOffset(-1.0, -2.0);
261
+ }
262
+ function drawOnTopEnd(gl) {
263
+ gl.enable(gl.DEPTH_TEST);
264
+ // gl.disable(gl.POLYGON_OFFSET_FILL);
265
+ // gl.disable(gl.POLYGON_OFFSET_FILL);
266
+ // gl.depthRange(0.0, 1.0); // Restore full depth range
267
+ // gl.disable(gl.POLYGON_OFFSET_FILL);
268
+ }
@@ -147,34 +147,32 @@ export class Logic {
147
147
  this._lastAlphaMultiplier = 1.0;
148
148
  this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
149
149
  const { gl, program } = this;
150
- { // set attributes locations
151
- gl.bindAttribLocation(program, 0, 'center2d');
152
- gl.bindAttribLocation(program, 1, 'center3d');
153
- gl.bindAttribLocation(program, 2, 'start_angle2d');
154
- gl.bindAttribLocation(program, 3, 'tail_angle2d');
155
- gl.bindAttribLocation(program, 4, 'start_angle3d');
156
- gl.bindAttribLocation(program, 5, 'tail_angle3d');
157
- gl.bindAttribLocation(program, 6, 'color');
158
- gl.bindAttribLocation(program, 7, 'radius');
159
- gl.bindAttribLocation(program, 8, 'filling_mode');
160
- // vao
161
- // instanced draw read 1
162
- }
163
- { // Uniforms
164
- this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
165
- this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
166
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
167
- gl.useProgram(program);
168
- gl.uniform1i(this._draw_modeLocation, this._lastMode);
169
- gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
170
- this.cameraBlockBindingPoint = 0;
171
- this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
172
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
173
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
174
- flexibleBlockManager.assignBindingPoint(gl, program);
175
- this._defaultFlexibleUBO = flexibleBlockManager.createUBO(gl);
176
- gl.useProgram(currentProgram);
177
- }
150
+ // set attributes locations
151
+ gl.bindAttribLocation(program, 0, 'center2d');
152
+ gl.bindAttribLocation(program, 1, 'center3d');
153
+ gl.bindAttribLocation(program, 2, 'start_angle2d');
154
+ gl.bindAttribLocation(program, 3, 'tail_angle2d');
155
+ gl.bindAttribLocation(program, 4, 'start_angle3d');
156
+ gl.bindAttribLocation(program, 5, 'tail_angle3d');
157
+ gl.bindAttribLocation(program, 6, 'color');
158
+ gl.bindAttribLocation(program, 7, 'radius');
159
+ gl.bindAttribLocation(program, 8, 'filling_mode');
160
+ // vao
161
+ // instanced draw read 1
162
+ // Uniforms
163
+ this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
164
+ this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
165
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
166
+ gl.useProgram(program);
167
+ gl.uniform1i(this._draw_modeLocation, this._lastMode);
168
+ gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
169
+ this.cameraBlockBindingPoint = 0;
170
+ this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
171
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
172
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
173
+ flexibleBlockManager.assignBindingPoint(gl, program);
174
+ this._defaultFlexibleUBO = flexibleBlockManager.createUBO(gl);
175
+ gl.useProgram(currentProgram);
178
176
  }
179
177
  draw(length, vao, edgeCount, drawMode, ubo = null) {
180
178
  const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
@@ -240,7 +238,6 @@ export class Logic {
240
238
  }
241
239
  createUBO() {
242
240
  const { gl } = this;
243
- const bufferReadType = gl.DYNAMIC_DRAW;
244
241
  const ubo = flexibleBlockManager.createUBO(gl, "STATIC_DRAW");
245
242
  this._ubosPublished.push(ubo);
246
243
  return ubo;
@@ -2,7 +2,6 @@ import { globeProgramCache } from "../programcache";
2
2
  import { fromLongLatToUnitVector } from "../../Math/vec3";
3
3
  import { RADIAN } from "../../Math/methods";
4
4
  import { GlobeChangeObserver } from "./globe-changes";
5
- // import { approximatedZoomLevel } from "../../util/geometry/index";
6
5
  export const CameraUniformBlockString = `
7
6
  layout(std140) uniform CameraUniformBlock {
8
7
  mat4 view; // 64 bytes 0
@@ -93,49 +92,39 @@ export class CameraUniformBlockTotem {
93
92
  const globe = this.globe;
94
93
  this._globeChangeObserver?.checkChanges();
95
94
  gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
96
- {
97
- // view, projection, translate
98
- gl.bufferSubData(gl.UNIFORM_BUFFER, 0, modelView);
99
- gl.bufferSubData(gl.UNIFORM_BUFFER, 64, projection);
100
- traslateFloat32.set([translate.x, translate.y, translate.z], 0);
101
- gl.bufferSubData(gl.UNIFORM_BUFFER, 128, traslateFloat32);
102
- }
103
- {
104
- // zoom level
105
- gl.bufferSubData(gl.UNIFORM_BUFFER, 160, new Float32Array([globe.api_GetCurrentLODWithDecimal()]));
106
- }
107
- {
108
- // mapWH
109
- if (globe.api_GetCurrentGeometry() === 1) {
110
- const { width, height } = globe.api_GetCurrentWorldWH();
111
- mapWHFloat32.set([width, height]);
112
- gl.bufferSubData(gl.UNIFORM_BUFFER, 144, mapWHFloat32);
113
- }
114
- }
115
- {
116
- // float world_distance; // 4 bytes 164
117
- // float world_tilt; // 4 bytes 168
118
- // float world_north_angle; // 4 bytes 172
119
- // vec2 world_center_radian; // 8 bytes 180
120
- const { CenterLong, CenterLat, Distance, Tilt, NorthAng } = globe.api_GetCurrentLookInfo();
121
- gl.bufferSubData(gl.UNIFORM_BUFFER, 164, new Float32Array([
122
- Distance,
123
- Radian * Tilt,
124
- Radian * NorthAng,
125
- Radian * CenterLong,
126
- Radian * CenterLat,
127
- ]));
95
+ // view, projection, translate
96
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 0, modelView);
97
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 64, projection);
98
+ traslateFloat32.set([translate.x, translate.y, translate.z], 0);
99
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 128, traslateFloat32);
100
+ // zoom level
101
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 160, new Float32Array([globe.api_GetCurrentLODWithDecimal()]));
102
+ // mapWH
103
+ if (globe.api_GetCurrentGeometry() === 1) {
104
+ const { width, height } = globe.api_GetCurrentWorldWH();
105
+ mapWHFloat32.set([width, height]);
106
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 144, mapWHFloat32);
128
107
  }
108
+ // float world_distance; // 4 bytes 164
109
+ // float world_tilt; // 4 bytes 168
110
+ // float world_north_angle; // 4 bytes 172
111
+ // vec2 world_center_radian; // 8 bytes 180
112
+ const { CenterLong, CenterLat, Distance, Tilt, NorthAng } = globe.api_GetCurrentLookInfo();
113
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 164, new Float32Array([
114
+ Distance,
115
+ Radian * Tilt,
116
+ Radian * NorthAng,
117
+ Radian * CenterLong,
118
+ Radian * CenterLat,
119
+ ]));
129
120
  // this._frustumPlanes = getFrustumPlanes(projection, translate);
130
121
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
131
- {
132
- // isMoved
133
- const currentLOD = globe.api_GetCurrentLODWithDecimal();
134
- this._isMovedParams.isMoved =
135
- this._isMovedParams.lastLod !== currentLOD ||
136
- globe.api_IsScreenMoving();
137
- this._isMovedParams.lastLod = currentLOD;
138
- }
122
+ // isMoved
123
+ const currentLOD = globe.api_GetCurrentLODWithDecimal();
124
+ this._isMovedParams.isMoved =
125
+ this._isMovedParams.lastLod !== currentLOD ||
126
+ globe.api_IsScreenMoving();
127
+ this._isMovedParams.lastLod = currentLOD;
139
128
  this.__setCameraVectors();
140
129
  // this._calculateAproximatedLOD();
141
130
  }
@@ -146,7 +135,7 @@ export class CameraUniformBlockTotem {
146
135
  const globe = this.globe;
147
136
  const currentGeom = globe.api_GetCurrentGeometry();
148
137
  if (currentGeom === 0) {
149
- const { Fp, FUPos } = globe;
138
+ const { Fp } = globe; // FUPos
150
139
  const cameraVector = [Fp.x, Fp.y, Fp.z];
151
140
  const length = Math.sqrt(cameraVector.reduce((sum, val) => sum + val * val, 0));
152
141
  this._normalizedCameraVector[0] = cameraVector[0] / length;
@@ -1,4 +1,4 @@
1
- import { createProgram } from "../../util";
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
2
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
3
  import { noRegisterGlobeProgramCache } from "../programcache";
4
4
  const vertexCount = 720;
@@ -73,29 +73,19 @@ class Logic {
73
73
  this._lastOpacity = 1;
74
74
  this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
75
75
  const { gl, program } = this;
76
- { // assign attribute locations
77
- // in vec2 screen_coordinate;
78
- // in float pixel_radius_small_ratio;
79
- // in float pixel_radius_big_ratio;
80
- // in vec4 rgba;
81
- gl.bindAttribLocation(program, 0, "screen_coordinate");
82
- gl.bindAttribLocation(program, 1, "pixel_radius_small_ratio");
83
- gl.bindAttribLocation(program, 2, "pixel_radius_big_ratio");
84
- gl.bindAttribLocation(program, 3, "rgba");
85
- }
86
- {
87
- this._opacityLocation = gl.getUniformLocation(program, "plugin_opacity");
88
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
89
- gl.useProgram(program);
90
- gl.uniform1f(this._opacityLocation, this._lastOpacity);
91
- gl.useProgram(currentProgram);
92
- }
93
- {
94
- this.cameraBlockBindingPoint = 0;
95
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
96
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
97
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
98
- }
76
+ gl.bindAttribLocation(program, 0, "screen_coordinate");
77
+ gl.bindAttribLocation(program, 1, "pixel_radius_small_ratio");
78
+ gl.bindAttribLocation(program, 2, "pixel_radius_big_ratio");
79
+ gl.bindAttribLocation(program, 3, "rgba");
80
+ this._opacityLocation = gl.getUniformLocation(program, "plugin_opacity");
81
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
82
+ gl.useProgram(program);
83
+ gl.uniform1f(this._opacityLocation, this._lastOpacity);
84
+ gl.useProgram(currentProgram);
85
+ this.cameraBlockBindingPoint = 0;
86
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
87
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
88
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
99
89
  }
100
90
  draw(vao, length, opacity) {
101
91
  const { globe, gl, program, cameraBlockTotem, cameraBlockBindingPoint, _opacityLocation } = this;
@@ -1,5 +1,4 @@
1
- import { createProgram } from "../../../util";
2
- import { UBO_BINDING_POINT, shaderUboSource } from "./ubo.js";
1
+ import { createProgram } from "../../../util/webglobjectbuilders";
3
2
  import { glProgramCache } from "../../programcache";
4
3
  import { SeaWaveUbo } from "./ubo-new";
5
4
  /**
@@ -64,10 +63,12 @@ void main(){
64
63
  outColor = vec4(base_color, 1.0);
65
64
  }`;
66
65
  class Logic {
66
+ gl;
67
+ program;
68
+ _vector_field_location;
67
69
  constructor(gl) {
68
70
  this.gl = gl;
69
- [this.program,
70
- this._vector_field_location] = this._createProgram();
71
+ [this.program, this._vector_field_location] = this._createProgram();
71
72
  // this.decoyBuffer = new DecoyBufferManager(gl);
72
73
  }
73
74
  _createProgram() {
@@ -76,13 +77,13 @@ class Logic {
76
77
  // ubo point
77
78
  // const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
78
79
  // gl.uniformBlockBinding(program, ubo_location, UBO_BINDING_POINT);
79
- SeaWaveUbo.assignBindingPoint(gl, program, 0);
80
+ SeaWaveUbo.assignBindingPoint(gl, program);
80
81
  return [program, gl.getUniformLocation(program, 'u_vector_field')];
81
82
  }
82
83
  /**
83
- * @param {*} bufferManager | PingPongBufferManager
84
- * @param {*} vectorTexture | RG32F texture R: x, G: y
85
- * @param {*} uboManager | WaveParticalUboManager under ubo.js
84
+ * @param bufferManager | PingPongBufferManager
85
+ * @param vectorTexture | RG32F texture R: x, G: y
86
+ * @param uboManager | WaveParticalUboManager under ubo.js
86
87
  */
87
88
  draw(bufferManager, vectorTexture, uboManager) {
88
89
  const { gl, program } = this;
@@ -0,0 +1,112 @@
1
+ import { createProgram } from "../../../util/webglobjectbuilders";
2
+ import { glProgramCache } from "../../programcache";
3
+ import { SeaWaveUbo } from "./ubo-new";
4
+ /**
5
+ * [+] ubo
6
+ */
7
+ const vertexShaderSource = `#version 300 es
8
+ precision highp float;
9
+ ` + SeaWaveUbo.glslCode() + `
10
+ uniform sampler2D u_vector_field;
11
+ in vec2 in_position;
12
+ out vec3 base_color;
13
+
14
+
15
+ vec2 read_value(const vec2 uv) {
16
+ vec2 value = texture(u_vector_field, uv).rg;
17
+ if ( value.x == escape_value || value.y == escape_value) {
18
+ return vec2(0.0);
19
+ }
20
+ return value;
21
+ }
22
+
23
+
24
+ vec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu ayni isi yapiyor
25
+ // return texture(u_vector_field, uv).rg; // lower-res hardware filtering
26
+ vec2 res = vec2(textureSize(u_vector_field, 0));
27
+ vec2 px = 1.0 / res;
28
+ vec2 vc = (floor(uv * res)) * px;
29
+ vec2 f = fract(uv * res);
30
+ vec2 tl = read_value(vc).rg;
31
+ vec2 tr = read_value(vc + vec2(px.x, 0)).rg;
32
+ vec2 bl = read_value(vc + vec2(0, px.y)).rg;
33
+ vec2 br = read_value(vc + px).rg;
34
+
35
+ return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
36
+ }
37
+
38
+
39
+ void main(){
40
+ vec2 direction_vector = lookup_wind(in_position);
41
+ if (direction_vector.r == 0.0 && direction_vector.g == 0.0) return;
42
+
43
+
44
+ vec2 limp;
45
+ if ( 0 == gl_VertexID) { limp = -tail_wing_base_limp; }
46
+ else if ( 1 == gl_VertexID) { limp = vec2( tail_wing_base_limp.x, -tail_wing_base_limp.y); }
47
+ else if ( 2 == gl_VertexID) { limp = tail_wing_base_limp; }
48
+ else { limp = vec2(-tail_wing_base_limp.x, tail_wing_base_limp.y); } // if ( 3 == gl_VertexID)
49
+
50
+ limp = (limp * mat2(
51
+ direction_vector.x, -direction_vector.y,
52
+ direction_vector.y, direction_vector.x)) / draw_texture_size;
53
+
54
+ vec2 pos = in_position * 2.0 - 1.0;
55
+ gl_Position = vec4(pos + limp, 0.0, 1.0);
56
+ base_color = color;
57
+ }`;
58
+ const fragmentShaderSource = `#version 300 es
59
+ precision highp float;
60
+ out vec4 outColor;
61
+ in vec3 base_color;
62
+ void main(){
63
+ outColor = vec4(base_color, 1.0);
64
+ }`;
65
+ class Logic {
66
+ constructor(gl) {
67
+ this.gl = gl;
68
+ [this.program,
69
+ this._vector_field_location] = this._createProgram();
70
+ // this.decoyBuffer = new DecoyBufferManager(gl);
71
+ }
72
+ _createProgram() {
73
+ const gl = this.gl;
74
+ const program = createProgram(gl, vertexShaderSource, fragmentShaderSource);
75
+ // ubo point
76
+ // const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
77
+ // gl.uniformBlockBinding(program, ubo_location, UBO_BINDING_POINT);
78
+ SeaWaveUbo.assignBindingPoint(gl, program, 0);
79
+ return [program, gl.getUniformLocation(program, 'u_vector_field')];
80
+ }
81
+ /**
82
+ * @param {*} bufferManager | PingPongBufferManager
83
+ * @param {*} vectorTexture | RG32F texture R: x, G: y
84
+ * @param {*} uboManager | WaveParticalUboManager under ubo.js
85
+ */
86
+ draw(bufferManager, vectorTexture, uboManager) {
87
+ const { gl, program } = this;
88
+ gl.useProgram(program);
89
+ gl.bindVertexArray(bufferManager.getSourceVao());
90
+ // gl.bindVertexArray(this.decoyBuffer.getSourceVao());
91
+ uboManager.bind();
92
+ gl.activeTexture(gl.TEXTURE0);
93
+ gl.uniform1i(this._vector_field_location, 0);
94
+ gl.bindTexture(gl.TEXTURE_2D, vectorTexture);
95
+ gl.drawArraysInstanced(gl.TRIANGLE_FAN, 0, 4, bufferManager.length);
96
+ gl.drawArraysInstanced(gl.POINTS, 0, 4, bufferManager.length);
97
+ gl.bindVertexArray(null);
98
+ uboManager.unbind();
99
+ }
100
+ free() {
101
+ this.gl.deleteProgram(this.program);
102
+ this.program = null;
103
+ }
104
+ }
105
+ export const drawRectangleParticlesProgramCache = Object.freeze({
106
+ getProgram: (gl) => {
107
+ return glProgramCache.getProgram(gl, Logic);
108
+ },
109
+ releaseProgram: (gl) => {
110
+ glProgramCache.releaseProgram(gl, Logic);
111
+ }
112
+ });
@@ -1,5 +1,4 @@
1
- import { createShader } from "../../../util";
2
- import { UBO_SIZE, UBO_BINDING_POINT, shaderUboSource } from "./ubo.js";
1
+ import { createShader } from "../../../util/webglobjectbuilders";
3
2
  import { glProgramCache } from "../../programcache";
4
3
  import { SeaWaveUbo } from "./ubo-new";
5
4
  // program output is buffer
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * update coords and draw particles programs will use this class.
7
7
  */
8
- export default class {
8
+ export class PingPongBufferManager {
9
9
  constructor(gl, particleCount, inPositionLocation = 0) {
10
10
  this.gl = gl;
11
11
  this._inPositionLocation = inPositionLocation;
@@ -18,7 +18,7 @@ export const flatLinesInputAdapter = (bearingLine) => {
18
18
  };
19
19
  };
20
20
  export const flatLinesBearingInputAdapter = (bearingLine) => {
21
- const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0, msl } = bearingLine;
21
+ const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0 } = bearingLine;
22
22
  return {
23
23
  key: key,
24
24
  start: [long, lat],
@@ -1,9 +1,4 @@
1
1
  export const keyMethod = (chainKey, nodeKey) => `${chainKey}_${nodeKey}`;
2
- const distance = (node1, node2) => {
3
- const dx = node1.long - node2.long;
4
- const dy = node1.lat - node2.lat;
5
- return Math.sqrt(dx * dx + dy * dy);
6
- };
7
2
  export const circleDataAdaptor = (globe, chain) => {
8
3
  const circleInputs = [];
9
4
  const { chainKey, chainProperties, nodes } = chain;
@@ -102,7 +102,7 @@ export class CircleLineChainPlugin {
102
102
  return;
103
103
  const chainKeys = [];
104
104
  const chainsToClean = [];
105
- for (const { chainKey, chainProperties, nodes } of chains) {
105
+ for (const { chainKey } of chains) {
106
106
  if (this._chainListMap.hasChain(chainKey)) {
107
107
  chainsToClean.push(chainKey);
108
108
  }