@pirireis/webglobeplugins 0.13.0-alpha → 0.14.0-alpha

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 (54) hide show
  1. package/Math/arc-cdf-points.js +20 -0
  2. package/Math/arc-generate-points copy.js +1 -0
  3. package/Math/arc.js +21 -8
  4. package/Math/circle.js +35 -16
  5. package/Math/templete-shapes/grid-visually-equal.js +66 -0
  6. package/altitude-locator/plugin.js +3 -2
  7. package/bearing-line/plugin.js +1 -2
  8. package/circle-line-chain/plugin.js +4 -7
  9. package/compass-rose/compass-rose-padding-flat.js +12 -0
  10. package/package.json +1 -1
  11. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  12. package/programs/line-on-globe/linestrip/linestrip.js +5 -3
  13. package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
  14. package/programs/picking/pickable-renderer.js +1 -2
  15. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  16. package/programs/rings/partial-ring/piece-of-pie.js +26 -13
  17. package/programs/totems/camerauniformblock.js +1 -1
  18. package/programs/totems/index.js +1 -1
  19. package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
  20. package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
  21. package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
  22. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
  23. package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
  24. package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  25. package/range-tools-on-terrain/range-ring/adapters.js +25 -0
  26. package/range-tools-on-terrain/range-ring/plugin.js +31 -0
  27. package/range-tools-on-terrain/range-ring/types.js +1 -0
  28. package/rangerings/plugin.js +7 -11
  29. package/semiplugins/lightweight/line-plugin.js +195 -0
  30. package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
  31. package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
  32. package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +67 -38
  33. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
  34. package/semiplugins/type.js +1 -0
  35. package/types.js +0 -11
  36. package/util/account/create-buffermap-orchastration.js +39 -0
  37. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
  38. package/util/check/typecheck.js +15 -1
  39. package/util/geometry/index.js +3 -2
  40. package/util/gl-util/buffer/attribute-loader.js +2 -5
  41. package/util/gl-util/draw-options/methods.js +4 -5
  42. package/util/webglobjectbuilders.js +4 -9
  43. package/write-text/context-text3.js +17 -0
  44. package/write-text/context-text3old.js +152 -0
  45. package/programs/line-on-globe/circle-accurate.js +0 -176
  46. package/programs/line-on-globe/circle.js +0 -166
  47. package/programs/line-on-globe/to-the-surface.js +0 -111
  48. package/programs/totems/canvas-webglobe-info1.js +0 -106
  49. package/shape-on-terrain/arc/naive/plugin.js +0 -250
  50. package/util/check/get.js +0 -14
  51. package/util/gl-util/buffer/types.js +0 -1
  52. package/util/gl-util/draw-options/types.js +0 -15
  53. package/util/webglobjectbuilders1.js +0 -219
  54. /package/{shape-on-terrain/type.js → range-tools-on-terrain/bearing-line/types.js} +0 -0
@@ -0,0 +1,96 @@
1
+ import { ArcOnTerrainPlugin } from "../arc-plugin";
2
+ const EDGE_COUNT = 5;
3
+ const paddingKeys = (padding) => {
4
+ const stepCount = padding.coverAngle / padding.stepAngle;
5
+ const keys = new Array(Math.ceil(stepCount));
6
+ for (let i = 0; i < stepCount; i++) {
7
+ keys[i] = padding.key + i;
8
+ }
9
+ if (keys.length > stepCount) {
10
+ keys[keys.length - 1] = padding.key + stepCount;
11
+ }
12
+ return keys;
13
+ };
14
+ const adapterPadding2Arc = (globe, padding) => {
15
+ const stepCount = padding.coverAngle / padding.stepAngle;
16
+ const result = new Array(Math.ceil(stepCount));
17
+ const fill = (i, angle) => {
18
+ const startPoint = globe.Math.FindPointByPolar(padding.center[0], padding.center[1], padding.outerRadius, angle);
19
+ const endPoint = globe.Math.FindPointByPolar(padding.center[0], padding.center[1], padding.innerRadius, angle);
20
+ result[i] = {
21
+ key: padding.key + i,
22
+ start: [startPoint.long, startPoint.lat],
23
+ end: [endPoint.long, endPoint.lat],
24
+ color: padding.color,
25
+ height: padding.height,
26
+ };
27
+ };
28
+ for (let i = 0; i < stepCount; i++) {
29
+ const angle = padding.startAngle + i * padding.stepAngle;
30
+ fill(i, angle);
31
+ }
32
+ if (result.length > stepCount) {
33
+ const i = result.length - 1;
34
+ const angle = padding.startAngle + padding.coverAngle;
35
+ fill(i, angle);
36
+ }
37
+ return result;
38
+ };
39
+ export const chargerAdaptor = (chargerInput, plugin, padding) => {
40
+ };
41
+ export class PaddingPlugin {
42
+ id;
43
+ arcPlugin;
44
+ _memory = new Map();
45
+ isFreed = false;
46
+ constructor(id) {
47
+ this.id = id;
48
+ this.arcPlugin = new ArcOnTerrainPlugin(id, {
49
+ cameraAttractionIsOn: false,
50
+ vertexCount: EDGE_COUNT,
51
+ });
52
+ }
53
+ insertBulk(items, globe) {
54
+ for (const padding of items) {
55
+ this.__delete(padding.key);
56
+ this._memory.set(padding.key, padding);
57
+ }
58
+ const arcInputs = items.flatMap(padding => adapterPadding2Arc(globe, padding));
59
+ this.arcPlugin.insertBulk(arcInputs);
60
+ }
61
+ deleteBulk(keys) {
62
+ const arcKeys = keys.flatMap(key => paddingKeys({ key, center: [0, 0], outerRadius: 0, innerRadius: 0, startAngle: 0, coverAngle: 0, stepAngle: 0, color: [0, 0, 0, 1] }));
63
+ this.arcPlugin.deleteBulk(arcKeys);
64
+ }
65
+ updateColor(key, color) {
66
+ // TODO: get all padding keys and update all of them
67
+ if (!this._memory.has(key)) {
68
+ console.warn(`Padding with key ${key} does not exist.`);
69
+ return;
70
+ }
71
+ const keys = paddingKeys(this._memory.get(key));
72
+ for (let i = 0; i < keys.length; i++) {
73
+ this.arcPlugin.updateColor(keys[i], color);
74
+ }
75
+ }
76
+ __delete(key) {
77
+ const padding = this._memory.get(key);
78
+ if (padding) {
79
+ const keys = paddingKeys(padding);
80
+ this.arcPlugin.deleteBulk(keys);
81
+ this._memory.delete(key);
82
+ }
83
+ }
84
+ init(globe, gl) {
85
+ this.arcPlugin.init(globe, gl);
86
+ }
87
+ draw3D() {
88
+ this.arcPlugin.draw3D();
89
+ }
90
+ free() {
91
+ if (this.isFreed)
92
+ return;
93
+ this.isFreed = true;
94
+ this.arcPlugin.free();
95
+ }
96
+ }
@@ -0,0 +1 @@
1
+ export {};
package/types.js CHANGED
@@ -1,12 +1 @@
1
- /**
2
- * @typedef DrawRange
3
- * @type {Object}
4
- * @property {int} first
5
- * @property {int} count
6
- *
7
- * @typedef DrawRangeIndexParamsClient
8
- * @type {Object}
9
- * @property {null|DrawRange} drawRange
10
- * @property {null|Int32List} indexes
11
- */
12
1
  export {};
@@ -0,0 +1,39 @@
1
+ // IN construction
2
+ import { BufferManager } from "./single-attribute-buffer-management/buffer-manager";
3
+ import { BufferOrchestrator } from "./single-attribute-buffer-management/buffer-orchestrator";
4
+ export class BufferMapOrchestrator {
5
+ gl;
6
+ bufferManagersMap;
7
+ bufferOrchestrator;
8
+ constructor(gl, bufferDetailsMap, initialCapacity = 10) {
9
+ this.gl = gl;
10
+ this.bufferManagersMap = new Map();
11
+ this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
12
+ for (const [key, details] of bufferDetailsMap) {
13
+ const { itemSize, bufferType, adaptor } = details;
14
+ const bufferManager = new BufferManager(gl, itemSize, { bufferType, initialCapacity });
15
+ this.bufferManagersMap.set(key, { bufferManager, adaptor });
16
+ }
17
+ }
18
+ insertBulk(items) {
19
+ // @ts-ignore
20
+ this.bufferOrchestrator.insertBulk(items, this.bufferManagersMap);
21
+ }
22
+ updateBulk(items, bufferKeys = []) {
23
+ // @ts-ignore
24
+ this.bufferOrchestrator.updateBulk(items, this.bufferManagersMap, bufferKeys);
25
+ }
26
+ deleteBulk(keys) {
27
+ // @ts-ignore
28
+ this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
29
+ }
30
+ resetWithCapacity(capacity) {
31
+ this.bufferOrchestrator.resetWithCapacity(this.bufferManagersMap, capacity);
32
+ }
33
+ free() {
34
+ for (const [key, { bufferManager }] of this.bufferManagersMap) {
35
+ bufferManager.free();
36
+ }
37
+ this.bufferManagersMap.clear();
38
+ }
39
+ }
@@ -19,7 +19,7 @@ export class BufferOrchestrator {
19
19
  this.tombstoneOffsets = [];
20
20
  this._length = 0;
21
21
  }
22
- insertBulk(items, bufferManagersMap) {
22
+ insertBulk(items, bufferManagersMap, bufferKeys = null) {
23
23
  this.ensureSpace(items.length, bufferManagersMap);
24
24
  const { offsetMap } = this;
25
25
  const offsets = [];
@@ -29,8 +29,19 @@ export class BufferOrchestrator {
29
29
  offsetMap.set(item.key, offset);
30
30
  offsets.push(offset);
31
31
  }
32
- for (const [key, { bufferManager, adaptor }] of bufferManagersMap) {
33
- bufferManager.insertBulk(items.map(adaptor), offsets);
32
+ if (bufferKeys) {
33
+ for (const key of bufferKeys) {
34
+ const bufferManagerComp = bufferManagersMap.get(key);
35
+ if (bufferManagerComp === undefined)
36
+ throw new Error("insertBulk bufferKey does not exist");
37
+ const { bufferManager, adaptor } = bufferManagerComp;
38
+ bufferManager.insertBulk(items.map(adaptor), offsets);
39
+ }
40
+ }
41
+ else {
42
+ for (const [key, { bufferManager, adaptor }] of bufferManagersMap) {
43
+ bufferManager.insertBulk(items.map(adaptor), offsets);
44
+ }
34
45
  }
35
46
  }
36
47
  // does not assign offset to the new items.
@@ -2,7 +2,7 @@
2
2
  const doesOwnProperties = (properties, errorMessage) => {
3
3
  return (object) => {
4
4
  properties.forEach(element => {
5
- if (!Object.hasOwn(object, element))
5
+ if (!object.hasOwnProperty(element))
6
6
  throw new TypeError(errorMessage + ':' + element);
7
7
  });
8
8
  };
@@ -38,3 +38,17 @@ export const isBoolean = (x) => {
38
38
  if (typeof x !== "boolean")
39
39
  throw new TypeError("type must be boolean");
40
40
  };
41
+ export const mapGetOrThrow = (errorNote) => {
42
+ return (mapInstance, ids) => {
43
+ if (!ids)
44
+ throw new Error("There is no map keys to get");
45
+ const result = [];
46
+ for (let i = 0; i < ids.length; i++) {
47
+ const e = mapInstance.get(ids[i]);
48
+ if (e === undefined)
49
+ throw new Error(errorNote + " " + ids[i]);
50
+ result.push(e);
51
+ }
52
+ return result;
53
+ };
54
+ };
@@ -24,8 +24,9 @@ function latLongBboxtoPixelXYBbox(minX, minY, maxX, maxY) {
24
24
  }
25
25
  /**
26
26
  *
27
- * @param {Float32List} array
28
- * @returns {Float32Array}
27
+ * @param array - The array to normalize
28
+ * @param newLength - The target length for the normalized array
29
+ * @returns Normalized Float32Array
29
30
  */
30
31
  function normalize(array, newLength = 1) {
31
32
  let total = 0;
@@ -1,4 +1,3 @@
1
- import './types';
2
1
  /**
3
2
  * @typedef BufferAndReadInfo Buffers can be intertwined or interleaved.
4
3
  * This object forces user to adapt generic convention of buffer and read information.
@@ -20,10 +19,8 @@ import './types';
20
19
  * @returns
21
20
  */
22
21
  const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, type = null, escapeValues = null, normalized = false } = {}) => {
23
- if (size < 1 || size > 4)
24
- throw new Error("Size must be between 1 and 4");
25
- if (bufferAndReadInfo == null) {
26
- if (escapeValues !== null)
22
+ if (bufferAndReadInfo == null || bufferAndReadInfo.buffer == null) {
23
+ if (escapeValues)
27
24
  constantFunction(gl, index, size, escapeValues);
28
25
  return;
29
26
  }
@@ -1,17 +1,16 @@
1
- import './types';
2
1
  /**
3
2
  * Draws instanced geometry using WebGL2.
4
3
  */
5
4
  const drawInstanced = (gl, mode, drawOptions, vertexCount) => {
6
5
  const { drawRange, elementBufferIndexType = gl.UNSIGNED_INT } = drawOptions;
7
- const { first = 0, count: instanceCount = 1 } = drawRange;
8
- if (first > 0 || drawOptions.elementBuffer) {
6
+ const { first = 0, count } = drawRange;
7
+ if (drawOptions.elementBuffer) {
9
8
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, drawOptions.elementBuffer ?? null);
10
- gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, instanceCount);
9
+ gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, count);
11
10
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
12
11
  }
13
12
  else {
14
- gl.drawArraysInstanced(mode, first, vertexCount, instanceCount);
13
+ gl.drawArraysInstanced(mode, first, vertexCount, count);
15
14
  }
16
15
  };
17
16
  /**
@@ -34,8 +34,7 @@ export function createShader(gl, type, source) {
34
34
  export function createProgram(gl, vertexSource, fragmentSource) {
35
35
  const program = gl.createProgram();
36
36
  if (!program) {
37
- console.error("Failed to create WebGLProgram.");
38
- return undefined;
37
+ throw new Error("Failed to create WebGLProgram.");
39
38
  }
40
39
  let vertexShader;
41
40
  let fragmentShader;
@@ -45,18 +44,14 @@ export function createProgram(gl, vertexSource, fragmentSource) {
45
44
  }
46
45
  catch (e) { // Catching errors from createShader
47
46
  console.error(e.message);
48
- gl.deleteProgram(program); // Clean up the program if shaders failed
49
- return undefined;
47
+ throw new Error(`Shader creation failed: ${e.message}`);
50
48
  }
51
49
  gl.attachShader(program, vertexShader);
52
50
  gl.attachShader(program, fragmentShader);
53
51
  gl.linkProgram(program);
54
52
  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
55
- console.error("Failed to link WebGL program:", gl.getProgramInfoLog(program));
56
- gl.deleteProgram(program);
57
- gl.deleteShader(vertexShader);
58
- gl.deleteShader(fragmentShader);
59
- return undefined;
53
+ // console.error("Failed to link WebGL program:", gl.getProgramInfoLog(program));
54
+ throw new Error(`Error linking program:\n${gl.getProgramInfoLog(program)}`);
60
55
  }
61
56
  // Detach and delete shaders after linking to free up resources
62
57
  gl.detachShader(program, vertexShader);
@@ -1,3 +1,4 @@
1
+ // @ts-ignore
1
2
  import { CSZMode } from "@pirireis/webglobe";
2
3
  import { isTextFont, opacityCheck } from "../util/check/typecheck";
3
4
  /**
@@ -9,6 +10,22 @@ import { isTextFont, opacityCheck } from "../util/check/typecheck";
9
10
  * TODO: key check and raise error if doesnt exist
10
11
  */
11
12
  export class ContextTextWriter3 {
13
+ globe;
14
+ itemMap;
15
+ // @ts-ignore
16
+ style;
17
+ doDraw;
18
+ textAdaptor;
19
+ coordinatesAdaptor;
20
+ keyAdaptor;
21
+ zoomLevelAdaptor;
22
+ positionAdaptor;
23
+ opacityAdaptor;
24
+ angleOnSphere;
25
+ angleAdaptor;
26
+ angleAdaptorIsOn;
27
+ xOffset;
28
+ yOffset;
12
29
  constructor(globe, { style = {
13
30
  textFont: {
14
31
  name: 'Arial',
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ // import { CSZMode } from "@pirireis/webglobe";
3
+ // import { isTextFont, opacityCheck } from "../util/check/typecheck";
4
+ // /**
5
+ // * TODOs:
6
+ // * 1) update all if initials change (propably need a context and a callback to iterate over zPayload)
7
+ // * 2) expose a mechanic to update text on zoom change
8
+ // * 3) extend the mechanic on 2 to other events
9
+ // *
10
+ // * TODO: key check and raise error if doesnt exist
11
+ // */
12
+ // export class ContextTextWriter3 {
13
+ // constructor(globe, {
14
+ // style = {
15
+ // textFont: {
16
+ // name: 'Arial',
17
+ // textColor: '#FFFFFF', // beyaz
18
+ // hollowColor: '#000000', // siyah
19
+ // size: 12, // piksel
20
+ // hollow: true,
21
+ // bold: true,
22
+ // italic: false,
23
+ // },
24
+ // opacity: 1.0,
25
+ // zMode: CSZMode.Z_GROUND_PERVERTEX,
26
+ // },
27
+ // xOffset = 0,
28
+ // yOffset = 0,
29
+ // doDraw = true,
30
+ // textAdaptor = null,
31
+ // coordinatesAdaptor = null,
32
+ // keyAdaptor = null,
33
+ // opacityAdaptor = null,
34
+ // angleAdaptor = null,
35
+ // angleOnSphere = false,
36
+ // positionAdaptor = (item, i, container, properties) => "left",
37
+ // zoomLevelAdaptor = (zoomLevel) => (item) => {
38
+ // return {
39
+ // opacityMultiplier: 1,
40
+ // sizeMultiplier: 1
41
+ // }
42
+ // }
43
+ // } = {}) {
44
+ // this.globe = globe;
45
+ // this.itemMap = new Map();
46
+ // this.setStyle(style);
47
+ // this.doDraw = doDraw;
48
+ // this._checkParameterTypes(textAdaptor, coordinatesAdaptor, keyAdaptor, opacityAdaptor, angleAdaptor, xOffset, yOffset);
49
+ // this.textAdaptor = textAdaptor;
50
+ // this.coordinatesAdaptor = coordinatesAdaptor;
51
+ // this.keyAdaptor = keyAdaptor;
52
+ // this.zoomLevelAdaptor = zoomLevelAdaptor;
53
+ // this.positionAdaptor = positionAdaptor;
54
+ // this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
55
+ // this.angleOnSphere = angleOnSphere;
56
+ // if (angleAdaptor) {
57
+ // this.angleAdaptor = angleAdaptor
58
+ // this.angleAdaptorIsOn = true;
59
+ // } else {
60
+ // this.angleAdaptor = () => null
61
+ // this.angleAdaptorIsOn = false
62
+ // }
63
+ // this.xOffset = xOffset;
64
+ // this.yOffset = yOffset;
65
+ // }
66
+ // _checkParameterTypes(textAdaptor, coordinatesAdaptor, keyAdaptor, opacityAdaptor, angleAdaptor, xOffset, yOffset) {
67
+ // if (textAdaptor !== null) if (!(textAdaptor instanceof Function)) throw new Error("textAdaptor is not an instance of a Function");
68
+ // if (coordinatesAdaptor !== null) if (!(coordinatesAdaptor instanceof Function)) throw new Error("coordinatesAdaptor is not an instance of a Function");
69
+ // if (keyAdaptor !== null) if (!(keyAdaptor instanceof Function)) throw new Error("keyAdaptor is not an instance of a Function");
70
+ // if (opacityAdaptor !== null) if (!(opacityAdaptor instanceof Function)) throw new Error("opacityAdaptor is not an instance of a Function");
71
+ // if (angleAdaptor !== null) if (!(angleAdaptor instanceof Function)) throw new Error("angleAdaptor is not an instance of a Function");
72
+ // if (typeof xOffset !== "number") throw new Error("xOffset type is not a number");
73
+ // if (typeof yOffset !== "number") throw new Error("yOffset type is not a number");
74
+ // }
75
+ // setKeyAdaptor(adaptor) {
76
+ // this.keyAdaptor = adaptor;
77
+ // }
78
+ // setDoDraw(bool) {
79
+ // this.doDraw = bool;
80
+ // this.globe.DrawRender();
81
+ // }
82
+ // setStyle(style) {
83
+ // isTextFont(style.textFont);
84
+ // opacityCheck(style.opacity); //TODO: use shallow copy
85
+ // this.style = style;
86
+ // this.globe.DrawRender();
87
+ // }
88
+ // setOpacity(opacity) {
89
+ // this.style.opacity = opacity;
90
+ // this.globe.DrawRender();
91
+ // }
92
+ // draw() {
93
+ // if (!this.doDraw) return;
94
+ // const { globe, style, itemMap, xOffset, yOffset } = this;
95
+ // const { textFont, opacity: opacity_ } = style;
96
+ // const textSize = textFont.size;
97
+ // const is3D = globe.api_GetCurrentGeometry() === 0;
98
+ // const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn)
99
+ // const zoomLevel = globe.api_GetCurrentLODWithDecimal();
100
+ // const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
101
+ // for (const item of itemMap.values()) {
102
+ // const { lat, long, text, opacity = null, angle = null, zPayload, position } = item;
103
+ // const { x, y } = globe.api_GetScreenPointFromGeo(
104
+ // {
105
+ // long: long,
106
+ // lat: lat,
107
+ // z: 0,
108
+ // },
109
+ // style.zMode === CSZMode.Z_MSL,
110
+ // );
111
+ // const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(zPayload);
112
+ // const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
113
+ // textFont.size = sizeMultiplier * textSize;
114
+ // textFont.position = position;
115
+ // if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
116
+ // }
117
+ // textFont.size = textSize;
118
+ // }
119
+ // insertTextBulk(container, properties) {
120
+ // container.forEach((v, i, c) => {
121
+ // this.insertText(v, i, c, properties);
122
+ // });
123
+ // }
124
+ // deleteTextBulk(keys) {
125
+ // for (const key of keys) {
126
+ // this.itemMap.delete(key);
127
+ // }
128
+ // }
129
+ // insertText(item, id, container, properties) {
130
+ // const key = this.keyAdaptor(item, id, container, properties)
131
+ // const coords = this.coordinatesAdaptor(item, id, container, properties)
132
+ // if (coords == null) {
133
+ // this.itemMap.delete(key);
134
+ // return;
135
+ // }
136
+ // const text = this.textAdaptor(item, id, container, properties)
137
+ // if (text == null) {
138
+ // this.itemMap.delete(key);
139
+ // return
140
+ // };
141
+ // const opacity = this.opacityAdaptor(item, id, container, properties);
142
+ // const angle = this.angleAdaptor(item, id, container, properties);
143
+ // const position = this.positionAdaptor(item, id, container, properties);
144
+ // this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, zPayload: item, position });
145
+ // }
146
+ // clear() {
147
+ // this.itemMap.clear();
148
+ // }
149
+ // free() {
150
+ // this.itemMap = null;
151
+ // }
152
+ // }
@@ -1,176 +0,0 @@
1
- "use strict";
2
- // TODO: Delete this file if it is not needed anymore.
3
- // import { createProgram } from "../../util/webglobjectbuilders";
4
- // import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
5
- // import { noRegisterGlobeProgramCache } from "../programcache";
6
- // import { vaoAttributeLoader } from "../../util/account/util";
7
- // import {
8
- // longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition, realDistanceOnSphereR1,
9
- // circleLimpFromLongLatRadCenterCartesian3D_accurate,
10
- // circleLimpFromLongLatRadCenterMercatorCompass_accurate,
11
- // circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
12
- // POLE
13
- // } from "../../util/shaderfunctions/geometrytransformations";
14
- // /**
15
- // * TODO:
16
- // * 1. integrate geometry functions for radius angle and center
17
- // * 2. integrate attributes
18
- // *
19
- // * TODO:
20
- // * center_position is too small or doenst loaded as expected.
21
- // */
22
- // const EDGE_COUNT_ON_SPHERE = 360;
23
- // const vertexShaderSource = `#version 300 es
24
- // precision highp float;
25
- // ${CameraUniformBlockString}
26
- // ${longLatRadToMercator}
27
- // ${longLatRadToCartesian3D}
28
- // ${cartesian3DToGLPosition}
29
- // ${mercatorXYToGLPosition}
30
- // ${realDistanceOnSphereR1}
31
- // ${circleLimpFromLongLatRadCenterCartesian3D_accurate}
32
- // ${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
33
- // ${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
34
- // uniform float edge_count;
35
- // in vec2 center_position;
36
- // in vec3 center_position3d;
37
- // in float radius;
38
- // in vec4 color;
39
- // in float dash_ratio;
40
- // in float dash_opacity;
41
- // out float interpolation;
42
- // out vec4 v_color;
43
- // out float v_dash_ratio;
44
- // out float v_dash_opacity;
45
- // out vec2 v_limp;
46
- // void main() {
47
- // interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
48
- // float angle = PI * 2.0 * interpolation;
49
- // if ( is3D ) {
50
- // vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, radius, angle);
51
- // gl_Position = cartesian3DToGLPosition(position);
52
- // v_limp = vec2(0.0, 0.0);
53
- // } else {
54
- // vec2 position;
55
- // if ( radius < 0.0) {
56
- // float cosine1 = cos(asin(tanh(center_position.y / 6378137.0)));
57
- // position = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center_position, radius / cosine1 , angle);
58
- // } else {
59
- // position = circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate( center_position, radius, angle);
60
- // }
61
- // v_limp = position;
62
- // gl_Position = mercatorXYToGLPosition( position);
63
- // }
64
- // v_dash_ratio = dash_ratio;
65
- // v_dash_opacity = dash_opacity;
66
- // v_color = color;
67
- // gl_PointSize = 3.0;
68
- // }`
69
- // const fragmentShaderSource = `#version 300 es
70
- // ${POLE}
71
- // precision highp float;
72
- // uniform float opacity;
73
- // in vec4 v_color;
74
- // in float v_dash_ratio;
75
- // in float v_dash_opacity;
76
- // in float interpolation;
77
- // in vec2 v_limp;
78
- // out vec4 color;
79
- // void main() {
80
- // if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ color = vec4(0.0,0.0,0.0,0.0); return; }
81
- // color = v_color;
82
- // color.a *= opacity;
83
- // if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
84
- // if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
85
- // color.a *= v_dash_opacity;
86
- // }
87
- // }
88
- // `;
89
- // class Logic {
90
- // constructor(globe) {
91
- // this.globe = globe;
92
- // this.gl = globe.gl;
93
- // this._lastOpacity = 1.0;
94
- // this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
95
- // const { gl, program } = this;
96
- // this.program.uniforms = {
97
- // opacity: gl.getUniformLocation(program, "opacity")
98
- // };
99
- // { // initial uniform values
100
- // const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
101
- // gl.useProgram(program);
102
- // gl.uniform1f(program.uniforms.opacity, 1.0);
103
- // gl.useProgram(currentProgram);
104
- // }
105
- // //
106
- // { // assign attribute locations
107
- // gl.bindAttribLocation(program, 0, "center_position");
108
- // gl.bindAttribLocation(program, 1, "center_position3d");
109
- // gl.bindAttribLocation(program, 2, "radius");
110
- // gl.bindAttribLocation(program, 3, "color");
111
- // gl.bindAttribLocation(program, 4, "dash_ratio");
112
- // gl.bindAttribLocation(program, 5, "dash_opacity");
113
- // }
114
- // this.cameraBindingPoint = 0;
115
- // this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
116
- // const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
117
- // gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
118
- // }
119
- // createVAO(centerObj, center3dObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
120
- // const { gl } = this;
121
- // const vao = gl.createVertexArray();
122
- // const divisor = 1;
123
- // gl.bindVertexArray(vao);
124
- // { // make this a function end import from account module.
125
- // const { buffer, stride = 0, offset = 0 } = centerObj;
126
- // vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, divisor);
127
- // }
128
- // { // make this a function end import from account module.
129
- // const { buffer, stride = 0, offset = 0 } = center3dObj;
130
- // vaoAttributeLoader(gl, buffer, 1, 3, stride, offset, divisor);
131
- // }
132
- // {
133
- // const { buffer, stride = 0, offset = 0 } = radiusObj;
134
- // vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, divisor);
135
- // }
136
- // {
137
- // const { buffer, stride = 0, offset = 0 } = colorObj;
138
- // vaoAttributeLoader(gl, buffer, 3, 4, stride, offset, divisor);
139
- // }
140
- // {
141
- // const { buffer, stride = 0, offset = 0 } = dashRatioObj;
142
- // vaoAttributeLoader(gl, buffer, 4, 1, stride, offset, divisor);
143
- // }
144
- // {
145
- // const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
146
- // vaoAttributeLoader(gl, buffer, 5, 1, stride, offset, divisor);
147
- // }
148
- // gl.bindVertexArray(null);
149
- // gl.bindVertexArray(null);
150
- // return vao;
151
- // }
152
- // draw(vao, length, opacity) {
153
- // const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
154
- // gl.useProgram(program);
155
- // if (this._lastOpacity !== opacity) {
156
- // gl.uniform1f(program.uniforms.opacity, opacity);
157
- // this._lastOpacity = opacity;
158
- // }
159
- // gl.bindVertexArray(vao);
160
- // cameraBlockTotem.bind(cameraBindingPoint);
161
- // gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
162
- // gl.drawArraysInstanced(gl.POINTS, 0, EDGE_COUNT_ON_SPHERE + 1, length);
163
- // cameraBlockTotem.unbind(cameraBindingPoint);
164
- // gl.bindVertexArray(null);
165
- // }
166
- // free() {
167
- // if (this.isFreed) return;
168
- // CameraUniformBlockTotemCache.release(this.globe);
169
- // this.gl.deleteProgram(this.program);
170
- // this.isFreed = true;
171
- // }
172
- // }
173
- // export const CircleCache = Object.freeze({
174
- // get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
175
- // release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
176
- // });