@pirireis/webglobeplugins 0.9.6 → 0.9.7

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 (226) hide show
  1. package/package.json +5 -2
  2. package/Math/angle-calculation.js +0 -14
  3. package/Math/arc.ts +0 -76
  4. package/Math/bounds/line-bbox.js +0 -225
  5. package/Math/constants.ts +0 -11
  6. package/Math/frustum/camera.ts +0 -32
  7. package/Math/frustum/from-globeinfo.ts +0 -63
  8. package/Math/frustum/types.ts +0 -11
  9. package/Math/globe-util/horizon-plane.ts +0 -137
  10. package/Math/index.js +0 -0
  11. package/Math/juction/arc-plane.ts +0 -114
  12. package/Math/juction/line-sphere.ts +0 -30
  13. package/Math/juction/plane-plane.ts +0 -66
  14. package/Math/line.ts +0 -70
  15. package/Math/matrix4.ts +0 -0
  16. package/Math/methods.js +0 -237
  17. package/Math/plane.ts +0 -86
  18. package/Math/quaternion.ts +0 -120
  19. package/Math/roadmap.md +0 -10
  20. package/Math/types.ts +0 -45
  21. package/Math/utils.js +0 -3
  22. package/Math/vec3.ts +0 -155
  23. package/algorithms/search-binary.js +0 -14
  24. package/altitude-locator/adaptors.js +0 -0
  25. package/altitude-locator/draw-subset-obj.js +0 -27
  26. package/altitude-locator/keymethod.js +0 -0
  27. package/altitude-locator/plugin.js +0 -439
  28. package/altitude-locator/types.js +0 -26
  29. package/arrowfield/adaptor.js +0 -11
  30. package/arrowfield/index.js +0 -3
  31. package/arrowfield/plugin.js +0 -128
  32. package/bearing-line/index.js +0 -2
  33. package/bearing-line/plugin.js +0 -512
  34. package/circle-line-chain/chain-list-map.js +0 -221
  35. package/circle-line-chain/init.js +0 -0
  36. package/circle-line-chain/plugin.js +0 -469
  37. package/circle-line-chain/readme.md +0 -57
  38. package/circle-line-chain/util.js +0 -1
  39. package/compass-rose/compass-rose-padding-flat.js +0 -266
  40. package/compass-rose/compass-text-writer.js +0 -173
  41. package/compass-rose/index.js +0 -3
  42. package/compassrose/compassrose.js +0 -341
  43. package/compassrose/index.js +0 -2
  44. package/depth-locator/readme.md +0 -26
  45. package/globe-types.ts +0 -13
  46. package/heatwave/index.js +0 -4
  47. package/heatwave/isobar/objectarraylabels.js +0 -247
  48. package/heatwave/isobar/plugin.js +0 -340
  49. package/heatwave/isobar/quadtreecontours.js +0 -336
  50. package/heatwave/plugins/heatwaveglobeshell.js +0 -258
  51. package/jest.config.js +0 -6
  52. package/partialrings/buffer-manager.js +0 -89
  53. package/partialrings/goals.md +0 -17
  54. package/partialrings/index.js +0 -3
  55. package/partialrings/plugin.js +0 -160
  56. package/partialrings/program.js +0 -324
  57. package/pin/pin-object-array.js +0 -381
  58. package/pin/pin-point-totem.js +0 -77
  59. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -78
  60. package/point-heat-map/index.js +0 -0
  61. package/point-heat-map/plugin-webworker.js +0 -151
  62. package/point-heat-map/point-to-heat-map-flow.js +0 -150
  63. package/point-heat-map/readme.md +0 -15
  64. package/point-tracks/key-methods.js +0 -3
  65. package/point-tracks/plugin.js +0 -394
  66. package/programs/arrowfield/index.js +0 -2
  67. package/programs/arrowfield/logic.js +0 -286
  68. package/programs/arrowfield/object.js +0 -89
  69. package/programs/data2legend/density-to-legend.js +0 -115
  70. package/programs/data2legend/point-to-density-texture.js +0 -114
  71. package/programs/float2legendwithratio/index.js +0 -3
  72. package/programs/float2legendwithratio/logic.js +0 -194
  73. package/programs/float2legendwithratio/object.js +0 -141
  74. package/programs/globe-util/is-globe-moved.js +0 -27
  75. package/programs/globeshell/index.js +0 -2
  76. package/programs/globeshell/noise/noises.js +0 -0
  77. package/programs/globeshell/wiggle/index.js +0 -6
  78. package/programs/globeshell/wiggle/logic.js +0 -371
  79. package/programs/globeshell/wiggle/object.js +0 -93
  80. package/programs/helpers/blender/index.js +0 -0
  81. package/programs/helpers/blender/program.js +0 -91
  82. package/programs/helpers/fadeaway/index.js +0 -3
  83. package/programs/helpers/fadeaway/logic.js +0 -76
  84. package/programs/helpers/fadeaway/object.js +0 -20
  85. package/programs/helpers/index.js +0 -2
  86. package/programs/index.js +0 -21
  87. package/programs/interface.ts +0 -7
  88. package/programs/line-on-globe/angled-line.js +0 -206
  89. package/programs/line-on-globe/circle-accurate-3d.js +0 -167
  90. package/programs/line-on-globe/circle-accurate-flat.js +0 -262
  91. package/programs/line-on-globe/circle-accurate.js +0 -202
  92. package/programs/line-on-globe/circle.js +0 -191
  93. package/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -188
  94. package/programs/line-on-globe/index.js +0 -0
  95. package/programs/line-on-globe/lines-color-instanced-flat.js +0 -151
  96. package/programs/line-on-globe/linestrip.ts +0 -228
  97. package/programs/line-on-globe/naive-accurate-flexible.js +0 -239
  98. package/programs/line-on-globe/to-the-surface.js +0 -129
  99. package/programs/line-on-globe/util.js +0 -8
  100. package/programs/picking/pickable-renderer.js +0 -216
  101. package/programs/point-on-globe/element-globe-surface-glow.js +0 -168
  102. package/programs/point-on-globe/element-point-glow.js +0 -184
  103. package/programs/point-on-globe/square-pixel-point.js +0 -189
  104. package/programs/programcache.ts +0 -131
  105. package/programs/rings/distancering/circleflatprogram.js +0 -136
  106. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -378
  107. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -420
  108. package/programs/rings/distancering/index.js +0 -5
  109. package/programs/rings/distancering/paddyflatprogram.js +0 -146
  110. package/programs/rings/distancering/paddyflatprogram2d.js +0 -150
  111. package/programs/rings/distancering/paddyflatprogram3d.js +0 -146
  112. package/programs/rings/distancering/shader.js +0 -0
  113. package/programs/rings/index.js +0 -1
  114. package/programs/rings/partial-ring/piece-of-pie.js +0 -315
  115. package/programs/totems/camerauniformblock.d.ts +0 -48
  116. package/programs/totems/camerauniformblock.js +0 -197
  117. package/programs/totems/canvas-webglobe-info.js +0 -136
  118. package/programs/totems/gpu-selection-uniform-block.js +0 -132
  119. package/programs/totems/index.ts +0 -2
  120. package/programs/two-d/pixel-circle.js +0 -0
  121. package/programs/two-d/pixel-padding-for-compass.js +0 -174
  122. package/programs/util.js +0 -20
  123. package/programs/vectorfields/index.js +0 -3
  124. package/programs/vectorfields/logics/drawrectangleparticles.js +0 -125
  125. package/programs/vectorfields/logics/index.js +0 -5
  126. package/programs/vectorfields/logics/pixelbased.js +0 -161
  127. package/programs/vectorfields/logics/ubo.js +0 -64
  128. package/programs/vectorfields/pingpongbuffermanager.js +0 -80
  129. package/publish.bat +0 -60
  130. package/rangerings/enum.js +0 -3
  131. package/rangerings/index.js +0 -5
  132. package/rangerings/plugin.js +0 -649
  133. package/rangerings/rangeringangletext.js +0 -368
  134. package/rangerings/ring-account.js +0 -129
  135. package/shaders/fragment-toy/firework.js +0 -55
  136. package/shaders/fragment-toy/singularity.js +0 -59
  137. package/shape-on-terrain/arc/naive/plugin.ts +0 -304
  138. package/shape-on-terrain/goal.md +0 -12
  139. package/tests/Math/junction/arc-plane.test.ts +0 -133
  140. package/tests/Math/junction/plane-plane.test.ts +0 -82
  141. package/tests/Math/plane.test.ts +0 -43
  142. package/tests/Math/vec3.test.ts +0 -14
  143. package/timetracks/adaptors-line-strip.js +0 -80
  144. package/timetracks/adaptors.js +0 -133
  145. package/timetracks/index.js +0 -6
  146. package/timetracks/plugin-line-strip.js +0 -295
  147. package/timetracks/plugin.js +0 -304
  148. package/timetracks/program-line-strip.js +0 -688
  149. package/timetracks/program.js +0 -850
  150. package/timetracks/programpoint-line-strip.js +0 -175
  151. package/timetracks/programpoint.js +0 -168
  152. package/timetracks/readme.md +0 -1
  153. package/tsconfig.json +0 -22
  154. package/types.ts +0 -17
  155. package/util/account/bufferoffsetmanager.js +0 -209
  156. package/util/account/index.js +0 -6
  157. package/util/account/single-attribute-buffer-management/buffer-manager.ts +0 -119
  158. package/util/account/single-attribute-buffer-management/buffer-orchestrator.ts +0 -173
  159. package/util/account/single-attribute-buffer-management/index.ts +0 -13
  160. package/util/account/single-attribute-buffer-management/object-store.ts +0 -65
  161. package/util/account/single-attribute-buffer-management/types.ts +0 -39
  162. package/util/account/util.js +0 -22
  163. package/util/algorithms/index.js +0 -0
  164. package/util/algorithms/search-binary.js +0 -26
  165. package/util/check/get.js +0 -13
  166. package/util/check/index.js +0 -0
  167. package/util/check/typecheck.js +0 -39
  168. package/util/geometry/index.js +0 -53
  169. package/util/gl-util/buffer/attribute-loader.ts +0 -85
  170. package/util/gl-util/buffer/index.ts +0 -6
  171. package/util/gl-util/buffer/types.ts +0 -13
  172. package/util/gl-util/draw-options/methods.ts +0 -66
  173. package/util/gl-util/draw-options/types.ts +0 -28
  174. package/util/gl-util/uniform-block/manager.ts +0 -187
  175. package/util/gl-util/uniform-block/roadmap.md +0 -70
  176. package/util/gl-util/uniform-block/shader.js +0 -0
  177. package/util/gl-util/uniform-block/types.ts +0 -27
  178. package/util/heatwavedatamanager/datamanager.js +0 -168
  179. package/util/heatwavedatamanager/index.js +0 -3
  180. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -133
  181. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  182. package/util/index.js +0 -13
  183. package/util/interpolation/index.js +0 -0
  184. package/util/interpolation/timetrack/index.js +0 -9
  185. package/util/interpolation/timetrack/timetrack-interpolator.js +0 -88
  186. package/util/interpolation/timetrack/web-worker-str.js +0 -180
  187. package/util/interpolation/timetrack/web-worker.js +0 -51
  188. package/util/jshelpers/data-filler.js +0 -19
  189. package/util/jshelpers/equality.js +0 -17
  190. package/util/jshelpers/index.js +0 -1
  191. package/util/jshelpers/timefilters.js +0 -32
  192. package/util/picking/fence.js +0 -46
  193. package/util/picking/picker-displayer.js +0 -177
  194. package/util/programs/draw-texture-on-canvas.js +0 -102
  195. package/util/programs/index.js +0 -1
  196. package/util/programs/shapesonglobe.js +0 -246
  197. package/util/programs/supersampletotextures.js +0 -142
  198. package/util/programs/texturetoglobe.js +0 -203
  199. package/util/shaderfunctions/geometrytransformations.ts +0 -388
  200. package/util/shaderfunctions/index.js +0 -2
  201. package/util/shaderfunctions/nodata.js +0 -10
  202. package/util/shaderfunctions/noisefunctions.js +0 -44
  203. package/util/surface-line-data/arc-bboxes.ts +0 -42
  204. package/util/surface-line-data/arcs-to-cuts.js +0 -74
  205. package/util/surface-line-data/cut-arc.js +0 -0
  206. package/util/surface-line-data/flow.ts +0 -52
  207. package/util/surface-line-data/rbush-manager.js +0 -0
  208. package/util/surface-line-data/types.ts +0 -27
  209. package/util/surface-line-data/web-worker.js +0 -0
  210. package/util/webglobe/gldefaultstates.js +0 -5
  211. package/util/webglobe/index.js +0 -2
  212. package/util/webglobe/rasteroverlay.js +0 -96
  213. package/util/webglobjectbuilders.ts +0 -456
  214. package/util/webglobjectbuilders1.js +0 -271
  215. package/waveparticles/adaptor.js +0 -16
  216. package/waveparticles/index.js +0 -3
  217. package/waveparticles/plugin.js +0 -313
  218. package/wind/imagetovectorfieldandmagnitude.js +0 -39
  219. package/wind/index.js +0 -5
  220. package/wind/plugin.js +0 -1057
  221. package/wind/vectorfieldimage.js +0 -27
  222. package/write-text/attached-text-writer.js +0 -105
  223. package/write-text/context-text.js +0 -125
  224. package/write-text/context-text3.js +0 -178
  225. package/write-text/index.js +0 -1
  226. package/write-text/writer-plugin.js +0 -7
@@ -1,151 +0,0 @@
1
- import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
2
- import { mercatorXYToGLPosition, POLE } from "../../util/shaderfunctions/geometrytransformations";
3
- import { noRegisterGlobeProgramCache } from "../programcache";
4
- import { createProgram } from "../../util";
5
- import { Z_ALPHA_MODE } from "./util";
6
- import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
7
-
8
- /**
9
- * This program draws line between points provided from the first and second buffer.
10
- * draw method gl.drawArraysInstanced( gl.POINTS, 0,2, lineCount);
11
- * */
12
-
13
-
14
- // TODO: find better way to eleminate edge case distance(posA, posB) > 37000000.0
15
- const vertexShaderSource = `#version 300 es
16
- precision highp float;
17
- ${CameraUniformBlockString}
18
- ${mercatorXYToGLPosition}
19
- uniform float opacity;
20
- uniform int z_alpha_on;
21
-
22
- in vec2 posA;
23
- in vec2 posB;
24
- in vec4 color;
25
-
26
- out vec2 v_frame;
27
- out vec4 v_color;
28
- void main() {
29
-
30
- if ( is3D ) {
31
- return;
32
- }
33
- float gap = max( distance(posA.x, posB.x), distance(posA.y,posB.y)); //
34
- if ( gap > 37000000.0) { return; }
35
- float z_alpha;
36
- if ( z_alpha_on == 1 ){
37
- z_alpha = pow(2.0,z_level+1.0) / ( 10000000.0 / gap);
38
- z_alpha = smoothstep(0.1,0.9, z_alpha);
39
- if( z_alpha < 0.01) {return;}
40
- } else {
41
- z_alpha = 1.0;
42
- }
43
- vec2 pos;
44
- if ( gl_VertexID == 0 ) {
45
- pos = posA;
46
- } else {
47
- pos = posB;
48
- }
49
- v_frame = pos;
50
- gl_Position = mercatorXYToGLPosition( pos );
51
- v_color = color;
52
- v_color.a *= z_alpha * opacity;
53
- gl_PointSize = 4.0;
54
- }`;
55
-
56
-
57
- const fragmentShaderSource = `#version 300 es
58
- ${POLE}
59
- precision highp float;
60
- in vec4 v_color;
61
- in vec2 v_frame;
62
- out vec4 outColor;
63
- void main() {
64
- if ( v_frame.x < -POLE || v_frame.x > POLE || v_frame.y < -POLE || v_frame.y > POLE ){ discard; }
65
- outColor = v_color;
66
- }`;
67
-
68
-
69
- class Logic {
70
- constructor(globe) {
71
- this.globe = globe;
72
- this.gl = globe.gl;
73
- this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
74
- this._lastOpicity = 1.0;
75
- this._lastZAlphaOn = Z_ALPHA_MODE.OFF;
76
-
77
- const { gl, program } = this;
78
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
79
- gl.useProgram(program);
80
- { // assign attribute locations
81
- gl.bindAttribLocation(program, 0, 'posA');
82
- gl.bindAttribLocation(program, 1, 'posB');
83
- gl.bindAttribLocation(program, 2, 'color');
84
- }
85
-
86
- { // uniform locations
87
- this._opacityLocation = gl.getUniformLocation(program, 'opacity');
88
- this._zAlphaOnLocation = gl.getUniformLocation(program, 'z_alpha_on');
89
- gl.uniform1i(this._zAlphaOnLocation, this._lastZAlphaOn);
90
- gl.uniform1f(this._opacityLocation, this._lastOpicity);
91
- }
92
- { // uniform block
93
- this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
94
- this._cameraBindingPoint = 0;
95
- const cameraBlockBindingIndex = gl.getUniformBlockIndex(program, 'CameraUniformBlock');
96
- gl.uniformBlockBinding(program, cameraBlockBindingIndex, this._cameraBindingPoint);
97
- }
98
- gl.useProgram(currentProgram);
99
- }
100
-
101
-
102
- createVAO(posAObj, posBObj, colorObj) {
103
- const { gl } = this;
104
- const vao = gl.createVertexArray();
105
- const divisor = 1;
106
- gl.bindVertexArray(vao);
107
- attributeLoader(gl, posAObj, 0, 2, { divisor });
108
- attributeLoader(gl, posBObj, 1, 2, { divisor });
109
- attributeLoader(gl, colorObj, 2, 4, { divisor });
110
- gl.bindVertexArray(null);
111
- return vao;
112
- }
113
-
114
-
115
- draw(vao, lineCount, opacity = 1.0, zAlphaOn = Z_ALPHA_MODE.ON) {
116
- const { gl, program, _cameraBindingPoint, _cameraUniformBlock } = this;
117
- gl.useProgram(program);
118
- _cameraUniformBlock.bind(_cameraBindingPoint);
119
- gl.bindVertexArray(vao);
120
- if (this._lastOpicity !== opacity) {
121
- this._lastOpicity = opacity;
122
- gl.uniform1f(this._opacityLocation, opacity);
123
- }
124
- if (this._lastZAlphaOn !== zAlphaOn) {
125
- this._lastZAlphaOn = zAlphaOn;
126
- gl.uniform1i(this._zAlphaOnLocation, zAlphaOn);
127
- }
128
- gl.drawArraysInstanced(gl.LINES, 0, 2, lineCount);
129
- _cameraUniformBlock.unbind(_cameraBindingPoint);
130
- gl.bindVertexArray(null);
131
- }
132
-
133
-
134
- free() {
135
- if (this.isFreed) return;
136
- const { gl, program, globe } = this;
137
- CameraUniformBlockTotemCache.release(globe);
138
- gl.deleteProgram(program);
139
- this.isFreed = true;
140
- }
141
- }
142
-
143
-
144
- const LinesColorInstancedFlatCache = Object.freeze({
145
- get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
146
- release: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
147
- });
148
-
149
- export { LinesColorInstancedFlatCache, Z_ALPHA_MODE };
150
-
151
-
@@ -1,228 +0,0 @@
1
- import { createProgram } from "../../util/webglobjectbuilders";
2
- import "../interface";
3
- import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems"
4
-
5
- import {
6
- cartesian3DToGLPosition,
7
- mercatorXYToGLPosition,
8
- } from "../../util/shaderfunctions/geometrytransformations.js";
9
-
10
- import { noRegisterGlobeProgramCache } from "../programcache";
11
- import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
12
- import "../../util/gl-util/buffer/attribute-loader";
13
-
14
- import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
15
- import "../../util/gl-util/uniform-block/types";
16
-
17
- import { drawArrays } from "../../util/gl-util/draw-options/methods";
18
- import "../../util/gl-util/draw-options/types";
19
-
20
-
21
-
22
- const ESCAPE_VALUE = -1;
23
-
24
- const uniformBindingPoints = {
25
- camera: 0,
26
- flexible: 1,
27
- }
28
-
29
- const one = new Float32Array([1]);
30
- const flexibleBlockManager = new UniformBlockManager(
31
- 'FlexibleAttributes',
32
- [
33
- { name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
34
- { name: "u_dash_opacity", type: "float", value: one },
35
- { name: "u_dash_length", type: "float", value: one },
36
- ],
37
- uniformBindingPoints.flexible,
38
- );
39
-
40
-
41
-
42
-
43
- const vertexShaderSource = `#version 300 es
44
- precision highp float;
45
-
46
- ${CameraUniformBlockString}
47
- ${cartesian3DToGLPosition}
48
- ${mercatorXYToGLPosition}
49
-
50
- ${flexibleBlockManager.glslCode()}
51
-
52
- in vec3 position3d;
53
- in vec2 position2d;
54
- in vec4 color;
55
- in float dash_length;
56
- in float dash_opacity;
57
-
58
- out float v_dash_length;
59
- out float v_dash_opacity;
60
- out vec4 v_color;
61
-
62
- flat out vec3 v_flat_position;
63
- out vec3 v_position;
64
-
65
- void main() {
66
-
67
- v_color = ( color.r == -1.0 ) ? u_color : color;
68
- v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
69
- v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
70
-
71
- if ( is3D ) {
72
- gl_Position = cartesian3DToGLPosition( position3d );
73
- v_position = position3d;
74
- v_flat_position = position3d;
75
- } else {
76
- gl_Position = mercatorXYToGLPosition( position2d );
77
- v_position = vec3( position2d, 0.0 );
78
- v_flat_position = vec3( position2d, 0.0 );
79
- }
80
- gl_PointSize = 4.0;
81
- }`;
82
-
83
-
84
- const fragmentShaderSource = `#version 300 es
85
- precision highp float;
86
-
87
- uniform float opacity;
88
-
89
- in vec4 v_color;
90
- in float v_dash_length;
91
- in float v_dash_opacity;
92
-
93
- flat in vec3 v_flat_position;
94
- in vec3 v_position;
95
-
96
-
97
- out vec4 outColor;
98
-
99
- void main() {
100
- outColor = v_color;
101
- return;
102
- float dash_length = v_dash_length;
103
- float dash_opacity = v_dash_opacity;
104
-
105
- if ( dash_length == 0.0 ) {
106
- outColor = vec4( v_color.rgb, v_color.a * v_dash_opacity );
107
- } else {
108
- float dist = distance( v_flat_position, v_position );
109
- // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
110
- outColor = vec4( v_color.rgb, v_color.a * opacity );
111
- }
112
- }`;
113
-
114
- console.log("LineStripProgram");
115
- console.log(vertexShaderSource);
116
- console.log(fragmentShaderSource);
117
-
118
-
119
- class Logic implements ProgramInterface {
120
-
121
- _vaosPublished: object[] = [];
122
- _ubosPublished: UBOHandler[] = [];
123
- program: WebGLProgram;
124
- gl: WebGL2RenderingContext;
125
- globe: any;
126
- cameraBlockTotem: any;
127
- _defaultFlexibleUBO: UBOHandler;
128
- _opacity: {
129
- value: number,
130
- location: WebGLUniformLocation | null
131
- } = {
132
- value: 1,
133
- location: null
134
- };
135
-
136
- constructor(globe: any) {
137
- console.log("LineStripProgram globe", globe);
138
- this.gl = globe.gl;
139
-
140
- this.globe = globe;
141
- this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource) as WebGLProgram;
142
- const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
143
- this.gl.useProgram(this.program);
144
- this._opacity.location = this.gl.getUniformLocation(this.program, "opacity");
145
- this.gl.uniform1f(this._opacity.location, this._opacity.value);
146
-
147
-
148
- // bind attribute locations
149
- this.gl.bindAttribLocation(this.program, 0, "position3d");
150
- this.gl.bindAttribLocation(this.program, 1, "position2d");
151
- this.gl.bindAttribLocation(this.program, 2, "color");
152
- this.gl.bindAttribLocation(this.program, 3, "dash_length");
153
- this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
154
-
155
-
156
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
157
- this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
158
-
159
- flexibleBlockManager.assignBindingPoint(this.gl, this.program);
160
- this._defaultFlexibleUBO = flexibleBlockManager.createUBO(this.gl);
161
-
162
- this.gl.useProgram(currentProgram);
163
- }
164
-
165
-
166
-
167
- createUBO(bufferReadType: "STATIC_DRAW" | "DYNAMIC_DRAW" | "STREAM_DRAW" = "STATIC_DRAW"): UBOHandler {
168
- const ubo = flexibleBlockManager.createUBO(this.gl, bufferReadType);
169
- this._ubosPublished.push(ubo);
170
- return ubo;
171
- }
172
-
173
-
174
-
175
- createVAO(
176
- position3D: BufferAndReadInfo, position2D: BufferAndReadInfo, color: BufferAndReadInfo, dashLength: BufferAndReadInfo, dashOpacity: BufferAndReadInfo,
177
- ): WebGLVertexArrayObject {
178
- const { gl } = this;
179
- const vao = gl.createVertexArray();
180
- gl.bindVertexArray(vao);
181
- attributeLoader(gl, position3D, 0, 3);
182
- attributeLoader(gl, position2D, 1, 2);
183
- attributeLoader(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
184
- attributeLoader(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
185
- attributeLoader(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
186
- gl.bindVertexArray(null);
187
- return vao;
188
- }
189
-
190
-
191
-
192
- draw(vao: WebGLVertexArrayObject, drawOptions: DrawRangeIndexParams, opacity: number = 1, flexibleUBO: UBOHandler | null = null) {
193
-
194
- const { gl, program, cameraBlockTotem } = this;
195
-
196
- gl.useProgram(program);
197
- if (opacity !== this._opacity.value) {
198
- this._opacity.value = opacity;
199
- this.gl.uniform1f(this._opacity.location, this._opacity.value);
200
- }
201
- const ubo = flexibleUBO || this._defaultFlexibleUBO;
202
- cameraBlockTotem.bind(uniformBindingPoints.camera);
203
- ubo.bind();
204
- gl.bindVertexArray(vao);
205
- drawArrays(gl, gl.POINTS, drawOptions);
206
- drawArrays(gl, gl.LINE_STRIP, drawOptions);
207
- gl.bindVertexArray(null);
208
- ubo.unbind();
209
- cameraBlockTotem.unbind(uniformBindingPoints.camera);
210
- }
211
-
212
-
213
-
214
- free() {
215
- this._vaosPublished.forEach((vao: WebGLVertexArrayObject) => this.gl.deleteVertexArray(vao));
216
- this._ubosPublished.forEach((ubo: UBOHandler) => ubo.free());
217
- this.gl.deleteProgram(this.program);
218
- this._defaultFlexibleUBO.free();
219
- CameraUniformBlockTotemCache.release(this.globe);
220
- this.gl.deleteProgram(this.program);
221
-
222
- }
223
- }
224
-
225
- export const LineStripProgramCache = Object.freeze({
226
- get: (globe: any): ProgramInterface => noRegisterGlobeProgramCache.getProgram(globe, Logic),
227
- release: (globe: any) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic),
228
- });
@@ -1,239 +0,0 @@
1
- import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems";
2
- import { slerp, POLE, R_3D, mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
3
- import { createProgram } from "../../util";
4
- import { noRegisterGlobeProgramCache } from "../programcache";
5
- import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
- import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
7
-
8
- import "../../util/gl-util/draw-options/types";
9
- import { drawInstanced } from "../../util/gl-util/draw-options/methods";
10
-
11
- const GLOBE_MIDPOINT_COUNT = 30;
12
-
13
- const escapeValue = -1.0;
14
-
15
-
16
- const uniformBindingPoints = {
17
- camera: 0,
18
- flexible: 1
19
- }
20
-
21
-
22
- const uniformBlockManager = new UniformBlockManager(
23
- 'FlexibleAttibutes',
24
- [
25
- { name: 'u_color', type: 'vec4' },
26
- { name: 'u_dash_ratio', type: 'float' },
27
- { name: 'u_dash_opacity', type: 'float' }
28
- ],
29
- uniformBindingPoints.flexible
30
- )
31
-
32
- const vertexShader = `#version 300 es
33
- precision highp float;
34
-
35
- ${R_3D}
36
- ${CameraUniformBlockString}
37
- ${slerp}
38
- ${mercatorXYToGLPosition}
39
- ${cartesian3DToGLPosition}
40
-
41
- ${uniformBlockManager.glslCode()}
42
-
43
- in vec2 start_position;
44
- in vec3 start_position3d;
45
- in vec2 end_position;
46
- in vec3 end_position3d;
47
-
48
- in float dash_ratio;
49
- in float dash_opacity;
50
- in vec4 color;
51
-
52
- out float v_dash_ratio;
53
- out float v_dash_opacity;
54
- out vec4 v_color;
55
-
56
- out vec2 v_limp;
57
- out float interpolation;
58
-
59
- void main() {
60
- vec2 longLat;
61
-
62
- v_color = (color.r == -1.0) ? u_color: color;
63
- v_dash_ratio = (dash_ratio == -1.0) ? u_dash_ratio : dash_ratio;
64
- v_dash_opacity = (dash_opacity == -1.0) ? u_dash_opacity : dash_opacity;
65
-
66
- if (is3D) {
67
- interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT - 1}.0;
68
- vec3 cartesian = slerp(start_position3d, end_position3d, interpolation);
69
- gl_Position = cartesian3DToGLPosition(cartesian);
70
- v_limp = vec2(0.0, 0.0);
71
- } else {
72
- if ( distance( start_position, end_position) > 30000000.0) { return; }
73
- interpolation = float(gl_VertexID);
74
- if (gl_VertexID % 2 == 0) {
75
- longLat = start_position;
76
- } else {
77
- longLat = end_position;
78
- }
79
- v_limp = longLat;
80
- gl_Position = mercatorXYToGLPosition(longLat);
81
- }
82
- }
83
- `;
84
-
85
- const fragmentShader = `#version 300 es
86
- ${POLE}
87
- precision highp float;
88
-
89
- uniform float opacity;
90
-
91
- in float interpolation;
92
- in vec2 v_limp;
93
- in vec4 v_color;
94
- in float v_dash_ratio;
95
- in float v_dash_opacity;
96
-
97
- out vec4 color;
98
-
99
- void main() {
100
- if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }
101
- color = v_color;
102
- color.a *= opacity;
103
- if ( v_dash_ratio >= 1.0 ) { return; }
104
- if (interpolation > 0.95) { return; }
105
- if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }
106
-
107
- }
108
- `;
109
-
110
-
111
- class Logic {
112
- vaosPublished = [];
113
- isFreed = false;
114
- constructor(globe) {
115
- this.globe = globe;
116
- this.gl = globe.gl;
117
- this.program = createProgram(this.gl, vertexShader, fragmentShader);
118
- this._lastOpacity = 1.0;
119
- const { gl, program } = this;
120
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
121
- gl.useProgram(program);
122
-
123
- // assign attribute locations
124
- gl.bindAttribLocation(program, 0, "start_position");
125
- gl.bindAttribLocation(program, 1, "start_position3d");
126
- gl.bindAttribLocation(program, 2, "end_position");
127
- gl.bindAttribLocation(program, 3, "end_position3d");
128
- gl.bindAttribLocation(program, 4, "dash_ratio");
129
- gl.bindAttribLocation(program, 5, "dash_opacity");
130
- gl.bindAttribLocation(program, 6, "color");
131
- this._opacityLocation = gl.getUniformLocation(program, "opacity");
132
-
133
- gl.uniform1f(this._opacityLocation, this._lastOpacity);
134
-
135
- gl.useProgram(currentProgram);
136
-
137
-
138
-
139
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
140
- this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
141
-
142
-
143
- this._ubosPublished = [];
144
- uniformBlockManager.assignBindingPoint(this.gl, this.program);
145
- this._defaultFlexibleUBO = this.createUBO();
146
- }
147
-
148
-
149
- /**
150
- *
151
- * @param {*} vao
152
- * @param {DrawRangeIndexParams} drawOptions
153
- * @param {number} opacity
154
- * @param {Object} flexibleOptions
155
- * @param {Array<number, number, number, number>} flexibleOptions.color // 0-1
156
- * @param {number} flexibleOptions.dash_opacity
157
- * @param {number} flexibleOptions.dash_ratio
158
- */
159
- draw(vao, drawOptions, opacity, flexibleUBO = null) {
160
- const { gl, program, globe, cameraBlockTotem, _defaultFlexibleUBO } = this;
161
- gl.useProgram(program);
162
- cameraBlockTotem.bind(uniformBindingPoints.camera);
163
- gl.bindVertexArray(vao);
164
- if (opacity !== this._lastOpacity) {
165
- gl.uniform1f(this._opacityLocation, opacity);
166
- this._lastOpacity = opacity;
167
- }
168
- // this._setFlexibleUniforms(flexibleOptions);
169
- const vertexCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
170
- const ubo = flexibleUBO || _defaultFlexibleUBO;
171
- ubo.bind();
172
- drawInstanced(gl, gl.LINE_STRIP, drawOptions, vertexCount);
173
- ubo.unbind();
174
- gl.bindVertexArray(null);
175
- cameraBlockTotem.unbind(uniformBindingPoints.camera);
176
- }
177
-
178
-
179
- createUBO(bufferReadType = "STATIC_DRAW") {
180
- const ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
181
- this._ubosPublished.push(ubo);
182
- ubo.update(
183
- new Map([
184
- ["u_color", [1, 1, 1, 1]],
185
- ["u_dash_ratio", [1]],
186
- ["u_dash_opacity", [1]]
187
- ])
188
- );
189
- return ubo;
190
- }
191
-
192
-
193
-
194
-
195
- createVAO(
196
- startPotision2DBufferObj, startPotision3DBufferObj,
197
- endPosition2DBufferObj, endPosition3DBufferObj,
198
- dashRatioBufferObj,
199
- dashOpacityBufferObj,
200
- colorBufferObj) {
201
-
202
- const { gl } = this;
203
- const vao = gl.createVertexArray();
204
- gl.bindVertexArray(vao);
205
-
206
- const divisor = 1;
207
-
208
- attributeLoader(gl, startPotision2DBufferObj, 0, 2, { divisor });
209
- attributeLoader(gl, startPotision3DBufferObj, 1, 3, { divisor });
210
- attributeLoader(gl, endPosition2DBufferObj, 2, 2, { divisor });
211
- attributeLoader(gl, endPosition3DBufferObj, 3, 3, { divisor });
212
- attributeLoader(gl, dashRatioBufferObj, 4, 1, { divisor, escapeValues: [escapeValue] });
213
- attributeLoader(gl, dashOpacityBufferObj, 5, 1, { divisor, escapeValues: [escapeValue] });
214
- attributeLoader(gl, colorBufferObj, 6, 4, { divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] });
215
-
216
- gl.bindVertexArray(null);
217
- gl.bindBuffer(gl.ARRAY_BUFFER, null);
218
- this.vaosPublished.push(vao);
219
- return vao;
220
- }
221
-
222
-
223
- free() {
224
- if (this.isFreed) return;
225
- CameraUniformBlockTotemCache.release(this.globe);
226
- this.gl.deleteProgram(this.program);
227
- this.vaosPublished.forEach(vao => this.gl.deleteVertexArray(vao));
228
- this._ubosPublished.forEach(ubo => ubo.free());
229
- this.isFreed = true;
230
- }
231
- }
232
-
233
-
234
-
235
- export const LineOnGlobeCache = Object.freeze({
236
- get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
237
- release: (globe) => { return noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
238
- });
239
-