@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,66 +0,0 @@
1
- import './types'
2
-
3
- /**
4
- * Represents the range of vertices or instances to draw.
5
- */
6
- interface DrawRange {
7
- first?: number;
8
- count: number;
9
- }
10
-
11
- /**
12
- * Parameters for drawing with optional element buffer and draw mode.
13
- */
14
- interface DrawRangeIndexParams {
15
- drawRange: DrawRange;
16
- elementBuffer?: WebGLBuffer | null;
17
- elementBufferIndexType?: GLenum;
18
- drawMode?: GLenum | null;
19
- }
20
-
21
- /**
22
- * Draws instanced geometry using WebGL2.
23
- */
24
- const drawInstanced = (
25
- gl: WebGL2RenderingContext,
26
- mode: GLenum,
27
- drawOptions: DrawRangeIndexParams,
28
- vertexCount: number
29
- ): void => {
30
- const { drawRange, elementBufferIndexType = gl.UNSIGNED_INT } = drawOptions;
31
- const { first = 0, count: instanceCount = 1 } = drawRange;
32
- if (first > 0 || drawOptions.elementBuffer) {
33
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, drawOptions.elementBuffer ?? null);
34
- gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, instanceCount);
35
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
36
- } else {
37
- gl.drawArraysInstanced(mode, first, vertexCount, instanceCount);
38
- }
39
- }
40
-
41
- /**
42
- * Draws geometry using WebGL2.
43
- */
44
- const drawArrays = (
45
- gl: WebGL2RenderingContext,
46
- defaultMode: GLenum,
47
- drawOptions: DrawRangeIndexParams
48
- ): void => {
49
- const {
50
- drawRange,
51
- elementBuffer,
52
- elementBufferIndexType = gl.UNSIGNED_INT,
53
- drawMode = null
54
- } = drawOptions;
55
- const { first = 0, count } = drawRange;
56
- const mode = drawMode ?? defaultMode;
57
- if (elementBuffer) {
58
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
59
- gl.drawElements(mode, count, elementBufferIndexType, first);
60
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
61
- } else {
62
- gl.drawArrays(mode, first, count);
63
- }
64
- }
65
-
66
- export { drawArrays, drawInstanced }
@@ -1,28 +0,0 @@
1
- /**
2
- * @typedef DrawRange
3
- * @type {Object}
4
- * @property {int} first
5
- * @property {int} count
6
- *
7
- * @typedef DrawRangeIndexParams
8
- * @type {Object}
9
- * @property {null|DrawRange} drawRange
10
- * @property {null|ElementBuffer} elementBuffer
11
- * @property {null|indexType} indexType
12
- * @property {null|int} drawMode
13
- *
14
- */
15
-
16
-
17
- type DrawRange = {
18
- first: number;
19
- count: number;
20
- };
21
-
22
- type DrawRangeIndexParams = {
23
- drawRange: DrawRange;
24
- elementBuffer?: WebGLBuffer;
25
- elementBufferIndexType?: number;
26
- drawMode?: number;
27
- };
28
-
@@ -1,187 +0,0 @@
1
- import "./types";
2
-
3
- const typeSizes = {
4
- 'float': 4,
5
- 'vec2': 8,
6
- 'vec3': 16, // vec3 takes up same space as vec4 due to alignment
7
- 'vec4': 16,
8
- 'mat2': 32, // 2 vec4s (16 * 2)
9
- 'mat3': 48, // 3 vec4s (16 * 3)
10
- 'mat4': 64, // 4 vec4s (16 * 4)
11
- 'int': 4,
12
- 'ivec2': 8,
13
- 'ivec3': 16,
14
- 'ivec4': 16,
15
- 'bool': 4
16
- };
17
-
18
- const typeAlignments = {
19
- 'float': 4,
20
- 'vec2': 8,
21
- 'vec3': 16,
22
- 'vec4': 16,
23
- 'mat2': 16, // aligns to vec4 boundary
24
- 'mat3': 16, // aligns to vec4 boundary
25
- 'mat4': 16, // aligns to vec4 boundary
26
- 'int': 4,
27
- 'ivec2': 8,
28
- 'ivec3': 16,
29
- 'ivec4': 16,
30
- 'bool': 4
31
- };
32
-
33
-
34
- const typeArrayConstructors = {
35
- 'float': Float32Array,
36
- 'vec2': Float32Array,
37
- 'vec3': Float32Array,
38
- 'vec4': Float32Array,
39
- 'mat2': Float32Array,
40
- 'mat3': Float32Array,
41
- 'mat4': Float32Array,
42
- 'int': Int32Array,
43
- 'ivec2': Int32Array,
44
- 'ivec3': Int32Array,
45
- 'ivec4': Int32Array,
46
- 'bool': Float32Array
47
- };
48
-
49
-
50
- class UniformBlockManager {
51
-
52
- /**
53
- *
54
- * @param {UniformBlockName} blockName
55
- * @param {Array<UniformBlockMember} blockMembers
56
- * @param {string} prefix usage name of block in the shader
57
- */
58
-
59
- blockName: string;
60
- blockMembers: Array<UniformBlockMember>;
61
- bindingPoint: number;
62
- prefix: string;
63
- offsetMap: Map<string, number>;
64
- size: number;
65
-
66
- constructor(blockName: string, blockMembers: Array<UniformBlockMember>, bindingPoint: number, prefix: string = "") {
67
- this.blockName = blockName;
68
- this.blockMembers = blockMembers;
69
- this.bindingPoint = bindingPoint;
70
- this.prefix = prefix;
71
- this.offsetMap = this.__create_LayoutSTD140_OffsetMap();
72
- this.size = this.__calculateSize();
73
- }
74
-
75
-
76
-
77
- glslCode() {
78
- let code = `layout(std140) uniform ${this.blockName} {`;
79
- for (const member of this.blockMembers) {
80
- const { name, type } = member;
81
- code += `${type} ${this.prefix}${name};`;
82
- }
83
- if (this.prefix) {
84
- code += `} ${this.prefix};`;
85
- } else {
86
- code += `};`;
87
- }
88
- return code;
89
- }
90
-
91
-
92
- createUBO(gl: WebGL2RenderingContext, bufferWriteType: string = "STATIC_DRAW"): UBOHandler {
93
- const ubo = gl.createBuffer();
94
- gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
95
- // @ts-ignore
96
- gl.bufferData(gl.UNIFORM_BUFFER, this.size, gl[bufferWriteType]);
97
- gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
98
-
99
- for (const member of this.blockMembers) {
100
- const { name, type, value = null } = member;;
101
- const offset = this.offsetMap.get(name) as number;
102
- const data = (value === null) ? new typeArrayConstructors[type](typeSizes[type] / 4).fill(NaN) : value;
103
- gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
104
- }
105
- gl.bindBuffer(gl.UNIFORM_BUFFER, null);
106
-
107
- return { // TODO typedef this, encapsulate this in a class or something, ask ai
108
- ubo,
109
- update: (nameValueMap: NameValueMap) => this.updateUBO(gl, ubo, nameValueMap),
110
- bind: () => this.bind(gl, ubo),
111
- unbind: () => this.unbind(gl),
112
- free: () => gl.deleteBuffer(ubo),
113
- };
114
- }
115
-
116
-
117
- updateUBO(gl: WebGL2RenderingContext, ubo: WebGLBuffer, nameValueMap: NameValueMap) {
118
- gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
119
- for (const [name, value] of nameValueMap.entries()) {
120
- const offset = this.offsetMap.get(name);
121
- if (offset === undefined) {
122
- throw new Error(`Uniform block member ${name} not found in offset map.`);
123
- }
124
- // @ts-ignore
125
- const type = this.blockMembers.find(member => member.name === name).type;
126
- let data: Float32Array | Int32Array | ArrayBuffer | DataView;
127
- if (Array.isArray(value)) {
128
- data = new typeArrayConstructors[type](value);
129
- } else if (typeof value === 'number') {
130
- data = new typeArrayConstructors[type]([value]);
131
- } else if (value instanceof ArrayBuffer) {
132
- data = new typeArrayConstructors[type](value);
133
- } else if (ArrayBuffer.isView(value) && !(value instanceof DataView))
134
- data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
135
- else {
136
- throw new Error(`Unsupported value type for ${name}: ${typeof value}`);
137
- }
138
- console.log("Data to be uploaded:", data);
139
- gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
140
- }
141
- gl.bindBuffer(gl.UNIFORM_BUFFER, null);
142
- }
143
-
144
- // call this after linking the program
145
- assignBindingPoint(gl: WebGL2RenderingContext, program: WebGLProgram) {
146
- const blockIndex = gl.getUniformBlockIndex(program, this.blockName);
147
- gl.uniformBlockBinding(program, blockIndex, this.bindingPoint);
148
- }
149
-
150
- // call this before drawing
151
- bind(gl: WebGL2RenderingContext, ubo: WebGLBuffer) {
152
- gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, ubo);
153
- }
154
-
155
- // call this right after drawing
156
- unbind(gl: WebGL2RenderingContext) {
157
- gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, null);
158
- }
159
-
160
-
161
- // implicit methods
162
- __create_LayoutSTD140_OffsetMap(): Map<string, number> {
163
- let offset = 0;
164
- const offsetMap = new Map();
165
- for (const member of this.blockMembers) {
166
- const { name, type } = member;
167
- const size = typeSizes[type];
168
- const alignment = typeAlignments[type];
169
- const padding = (alignment - (offset % alignment)) % alignment;
170
- offset += padding;
171
- offsetMap.set(name, offset);
172
- offset += size;
173
- }
174
- return offsetMap;
175
- }
176
-
177
- // __create_LayoutSTD140_OffsetMap() should be called before this
178
- __calculateSize() {
179
- const lastOffset = Array.from(this.offsetMap.values()).pop() as number || 0;
180
- const lastItemAlignment = typeAlignments[this.blockMembers[this.blockMembers.length - 1].type];
181
- return lastOffset + lastItemAlignment;
182
- }
183
-
184
- }
185
-
186
-
187
- export { UniformBlockManager };
@@ -1,70 +0,0 @@
1
- # UniformBlock Wrapper
2
-
3
- - Uniform shader string
4
- - bind/unbind
5
- - set/get uniform value generic
6
-
7
- ## INPUT
8
- - uniform block name
9
- - Array<{type, name}> UniformBlockMembers
10
-
11
-
12
- ## PROCESS
13
-
14
- - Calculate and save starting offset of each member
15
- - Create UBO
16
- - Bind UBO
17
- - Set uniform value
18
-
19
- ### Calculate and save starting offset of each member
20
-
21
- layout(std140) is a convention. The calculation should be done according to this convention.
22
-
23
-
24
- type | size
25
- --- | ---
26
- float | 4
27
- vec2 | 8
28
- vec3 | 12
29
- vec4 | 16
30
- mat2 | 16
31
- mat3 | 48
32
- mat4 | 64
33
-
34
- A line is 16 bytes aligned. Alignment can be shared if previous member is equal or bigger then the next member and the sum of the sizes are smaller then 16 bytes.
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
- ## setMethod
46
-
47
- update({
48
- color = null,
49
- bboxOffsetRad = null,
50
- bboxSizeRad = null,
51
- resolution = null,
52
- tailLengthRatio = null,
53
- wingLengthRatio = null,
54
- height = null,
55
- opacity = null,
56
- noDataValue = null,
57
- } = {}) {
58
- const { gl, ubo } = this;
59
- gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
60
- if (color !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(color));
61
- if (opacity !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 12, new Float32Array([opacity]));
62
- if (bboxOffsetRad !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 16, new Float32Array(bboxOffsetRad));
63
- if (bboxSizeRad !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 24, new Float32Array(bboxSizeRad));
64
- if (resolution !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 32, new Float32Array(resolution));
65
- if (tailLengthRatio !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 40, new Float32Array([tailLengthRatio]));
66
- if (wingLengthRatio !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 44, new Float32Array([wingLengthRatio]));
67
- if (height !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 48, new Float32Array([height]));
68
- if (noDataValue !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 52, new Float32Array([noDataValue]));
69
- gl.bindBuffer(gl.UNIFORM_BUFFER, null);
70
- }
File without changes
@@ -1,27 +0,0 @@
1
- /**
2
- * @typedef {string} UniformBlockName
3
- *
4
- * @typedef {string} GLSLType | mat4, mat3, vec4, vec3, vec2, float, int, bool
5
- * @typedef {{name: string, type: GLSLType, value: null|Float32Array}} UniformBlockMember
6
- *
7
- */
8
-
9
-
10
- type UniformBlockName = string;
11
- type GLSLType = "mat4" | "mat3" | "vec4" | "vec3" | "vec2" | "float" | "int" | "bool";
12
- type UniformBlockMember = {
13
- name: string;
14
- type: GLSLType;
15
- value: Float32Array | null;
16
- };
17
-
18
-
19
- type NameValueMap = Map<string, Array<number> | DataView | ArrayBuffer>;
20
-
21
- type UBOHandler = {
22
- ubo: WebGLBuffer;
23
- update: (nameValueMap: Map<string, any>) => void;
24
- bind: () => void;
25
- unbind: () => void;
26
- free: () => void;
27
- };
@@ -1,168 +0,0 @@
1
- /**
2
- * todo:
3
- * data must be processed before being set to the cache
4
- */
5
-
6
- export default class DataManager {
7
- /**
8
- *
9
- * @param {Array<number>} timeEpocs | array of time epocs
10
- * @param {Function} fetchMethod | fetchMethod(time) => Promise<data>
11
- * @param {boolean} autoDownload | auto download data or not
12
- */
13
- constructor(timeEpocs, fetchMethod, { autoDownload = true } = {}) {
14
-
15
- this._timeEpocs = timeEpocs.sort((a, b) => a - b);
16
- this._datas = []; this._datas.length = timeEpocs.length;
17
-
18
- // in construction
19
- this._dataPromises = []; this._dataPromises.length = timeEpocs.length;
20
-
21
- this._fetchMethod = fetchMethod;
22
- this._callbackmethods = [];
23
- this._callbackmethodOwners = [];
24
- this._lastTime = -1;
25
- this._lastIndex = -1;
26
- this.autoDownload(autoDownload);
27
- }
28
-
29
-
30
- autoDownload(bool, time) {
31
- if (!bool) {
32
- this._autoDownload = false;
33
- return;
34
- }
35
- let index = this._lastIndex === -1 ? 0 : this._lastIndex;
36
- if (time !== undefined) {
37
- if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
38
- this._autoDownload = bool;
39
- return;
40
- }
41
- index = this._findIndex(time);
42
- }
43
-
44
- if (this._downloadStartIndex === index && this._autoDownload === bool) return;
45
- this._downloadStartIndex = index;
46
- this._autoDownload = bool;
47
- const recursion = (startId, currentDownloadId) => {
48
- if (startId !== this._downloadStartIndex) return;
49
- if (currentDownloadId < this._timeEpocs.length && this._autoDownload) {
50
- this._getData(currentDownloadId).then(() => {
51
- recursion(startId, currentDownloadId + 1);
52
- });
53
- }
54
- }
55
- recursion(index, index);
56
- // save index as start index
57
- //start recursive download
58
-
59
- // use started id as a flag to stop the download
60
- }
61
-
62
-
63
-
64
- /**
65
- * @param {number} time
66
- * It looks like async function is not needed here. changes just overwrites the previous changes.
67
- */
68
- updateTime(time) {
69
- if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
70
- this._dontRender();
71
- return;
72
- }
73
- this._lastTime = time;
74
- const index = this._findIndex(time);
75
- const ratio = this._getRatio(time, index);
76
- Promise.all([this._getData(index - 1), this._getData(index)]).then((datas) => {
77
- if (this._lastTime === time) {
78
- this._lastIndex = index;
79
- this._ratio = ratio;
80
- this._pushCallback(ratio, datas);
81
- }
82
- });
83
- }
84
-
85
-
86
- register(key, callback) {
87
- if (this._callbackmethodOwners.indexOf(key) !== -1) {
88
- console.warn("key already registered, old one is unregistered");
89
- this.unregister(key);
90
- }
91
- this._callbackmethods.push(callback);
92
- this._callbackmethodOwners.push(key);
93
- if (this._lastIndex !== -1) callback(this._ratio, this._datas[this._lastIndex - 1], this._datas[this._lastIndex]);
94
- }
95
-
96
-
97
- /**
98
- * @param {*} key | id of the owner of the callback
99
- */
100
- unregister(key) {
101
- let index = this._callbackmethodOwners.indexOf(key);
102
- if (index !== -1) {
103
- this._callbackmethods.splice(index, 1);
104
- this._callbackmethodOwners.splice(index, 1);
105
- }
106
- if (this._callbackmethods.length === 0) {
107
- this.free();
108
- }
109
- }
110
-
111
-
112
- free() {
113
- this._callbackmethods = [];
114
- this._callbackmethodOwners = [];
115
- this._autoDownload = false;
116
- }
117
-
118
- _findIndex(time) {
119
- const { _timeEpocs } = this;
120
- let index = this._lastIndex === -1 ? 1 : this._lastIndex;
121
- if (this)
122
- if (time < _timeEpocs[index - 1]) {
123
- while (index > 1 && time < _timeEpocs[index - 1]) {
124
- index--;
125
- }
126
- } else if (time > _timeEpocs[index]) {
127
- while (index < _timeEpocs.length - 1 && time > _timeEpocs[index]) {
128
- index++;
129
- }
130
- }
131
- return index;
132
- }
133
-
134
-
135
- _getRatio(time, index) {
136
- return (time - this._timeEpocs[index - 1]) / (this._timeEpocs[index] - this._timeEpocs[index - 1]);
137
- }
138
-
139
-
140
- _pushCallback(ratio, datas) {
141
- for (let i = 0; i < this._callbackmethods.length; i++) {
142
- this._callbackmethods[i](ratio, ...datas);
143
- }
144
- }
145
-
146
-
147
- async _getData(index) {
148
- if (index < 0 || index >= this._timeEpocs.length) {
149
- throw new Error("Index out of range");
150
- }
151
- if (!this._datas[index]) {
152
- if (!this._dataPromises[index]) this._dataPromises[index] = this._fetchMethod(this._timeEpocs[index]).then((data) => {
153
- this._datas[index] = data;
154
- }, (error) => {
155
- console.error("error", error);
156
- }).finally(() => {
157
- this._dataPromises[index] = null;
158
- });
159
- }
160
- await this._dataPromises[index];
161
- return this._datas[index];
162
- }
163
-
164
- _dontRender() {
165
- this._pushCallback(0, [null, null]);
166
- }
167
-
168
- }
@@ -1,3 +0,0 @@
1
- import PointCoordinatesDataCalculator from "./pointcoordinatesdatacalculator";
2
- import HeatWaveDataManager from "./datamanager";
3
- export { HeatWaveDataManager, PointCoordinatesDataCalculator };
@@ -1,133 +0,0 @@
1
- import PointCoordsMeta from "./pointcoordsmeta";
2
-
3
-
4
- const pointObject = (long, lat, posIndex, callback) => {
5
- return { long, lat, posIndex, callback };
6
- }
7
-
8
- export default class PointCoordinatesDataCalculator {
9
- constructor(bbox, width, height) {
10
- this._pointObjects = {};
11
-
12
- this._ratio = 0.0;
13
-
14
- this._bbox = bbox;
15
- this._width = width;
16
- this._height = height;
17
- this._metaCalculater = new PointCoordsMeta(bbox, width, height);
18
-
19
- this._texture0 = null;
20
- this._texture1 = null;
21
- }
22
-
23
- /**
24
- *
25
- * @param {*} key
26
- * @param {*} lat
27
- * @param {*} long
28
- * @param {*} callback | callback(data0, data1, interpolated)
29
- */
30
- registerPoint(key, long, lat, callback) {
31
- if (key in this._pointObjects) {
32
- console.warn("key already registered, old one is unregistered");
33
- this.unregisterPoint(key);
34
- }
35
- if (!this._isInBBox(long, lat)) return false;
36
-
37
- const meta = this._metaCalculater.getFlooredMeta(long, lat)
38
-
39
- this._pointObjects[key] = pointObject(long, lat, meta.index, callback);
40
- if (this._texture0 && this._texture1) {
41
- const { data0, data1, interpolated } = this._findAPoint(meta.index);
42
- callback(data0, data1, interpolated);
43
- }
44
- return true;
45
- }
46
-
47
- _isInBBox(long, lat) {
48
- return lat >= this._bbox[1] && lat <= this._bbox[3] && long >= this._bbox[0] && long <= this._bbox[2];
49
- }
50
-
51
-
52
- unregisterPoint(key) {
53
- if (!(key in this._pointObjects)) return false;
54
- delete this._pointObjects[key];
55
- return true;
56
- }
57
-
58
- updatePoint(key, long, lat) {
59
-
60
- if (!(key in this._pointObjects)) return false;
61
- if (!this._isInBBox(long, lat)) return false;
62
- this._pointObjects[key].long = long;
63
- this._pointObjects[key].lat = lat;
64
- const meta = this._metaCalculater.getFlooredMeta(long, lat);
65
- this._pointObjects[key].posIndex = meta.index;
66
- const { data0, data1, interpolated } = this._findAPoint(meta.index);
67
- this._pointObjects[key].callback(data0, data1, interpolated);
68
- return true;
69
- }
70
-
71
- /**
72
- * @param {Number} ratio 0-1
73
- * @param {} textureData0
74
- * @param {*} textureData1
75
- */
76
- updateData(ratio, textureData0 = null, textureData1 = null) {
77
- if (!textureData0 && !textureData1) {
78
- this._pushPointCallBackEmpty();
79
- return;
80
- }
81
- if (textureData0 && textureData1) {
82
- this._texture0 = textureData0;
83
- this._texture1 = textureData1;
84
- }
85
- this._ratio = ratio;
86
- this._pushPointCallbackAll();
87
- }
88
-
89
-
90
- _findAPoint(posIndex) {
91
- const data0 = this._texture0[posIndex];
92
- const data1 = this._texture1[posIndex];
93
- const interpolated = data0 * (1 - this._ratio) + data1 * this._ratio;
94
- return { data0, data1, interpolated };
95
- }
96
-
97
- _pushPointCallbackAll() {
98
- for (const key in this._pointObjects) {
99
- const { posIndex, callback } = this._pointObjects[key];
100
- const { data0, data1, interpolated } = this._findAPoint(posIndex);
101
- callback(data0, data1, interpolated);
102
- }
103
- }
104
-
105
- _pushPointCallBackEmpty() {
106
- for (const key in this._pointObjects) {
107
- const { callback } = this._pointObjects[key];
108
- callback(null, null, null);
109
- }
110
- }
111
-
112
- flush() {
113
- this._pointObjects = {};
114
- }
115
- }
116
-
117
- // function test() {
118
- // const cp = window.plugin.getPointCoordinatesDataCalculator();
119
- // const bbox = [-15, 25, 70, 60];
120
- // cp.registerPoint("left up", -15, 60, (data0, data1, interpolated) => {
121
- // console.log("left up", data0, data1, interpolated);
122
- // });
123
- // cp.registerPoint("right up", 70, 60, (data0, data1, interpolated) => {
124
- // console.log("right up", data0, data1, interpolated);
125
- // });
126
- // cp.registerPoint("left down", -15, 25, (data0, data1, interpolated) => {
127
- // console.log("right down", data0, data1, interpolated);
128
- // });
129
- // cp.registerPoint("right down", 70, 25, (data0, data1, interpolated) => {
130
- // console.log("right down", data0, data1, interpolated);
131
- // });
132
- // return cp;
133
- // }