@pirireis/webglobeplugins 0.12.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 (68) 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-cdf-points.js +0 -2
  5. package/Math/circle.js +35 -16
  6. package/Math/templete-shapes/grid-visually-equal.js +66 -0
  7. package/altitude-locator/plugin.js +3 -2
  8. package/bearing-line/plugin.js +1 -2
  9. package/circle-line-chain/plugin.js +4 -7
  10. package/compass-rose/compass-rose-padding-flat.js +12 -0
  11. package/package.json +1 -1
  12. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  13. package/programs/line-on-globe/linestrip/data.js +4 -0
  14. package/programs/line-on-globe/{linestrip.js → linestrip/linestrip.js} +37 -35
  15. package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
  16. package/programs/picking/pickable-renderer.js +1 -2
  17. package/programs/rings/distancering/circleflatprogram.js +116 -120
  18. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +1 -1
  19. package/programs/rings/distancering/circlepaddysharedbuffer.js +368 -354
  20. package/programs/rings/distancering/index.js +6 -5
  21. package/programs/rings/distancering/paddyflatprogram.js +127 -136
  22. package/programs/rings/distancering/paddyflatprogram2d.js +129 -138
  23. package/programs/rings/distancering/paddyflatprogram3d.js +128 -136
  24. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  25. package/programs/rings/partial-ring/piece-of-pie.js +26 -13
  26. package/programs/totems/camerauniformblock.js +1 -1
  27. package/programs/totems/index.js +1 -1
  28. package/programs/vectorfields/logics/pixelbased.js +5 -21
  29. package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
  30. package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
  31. package/range-tools-on-terrain/bearing-line/types.js +1 -0
  32. package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
  33. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
  34. package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
  35. package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  36. package/range-tools-on-terrain/range-ring/adapters.js +25 -0
  37. package/range-tools-on-terrain/range-ring/plugin.js +31 -0
  38. package/range-tools-on-terrain/range-ring/types.js +1 -0
  39. package/rangerings/plugin.js +7 -11
  40. package/semiplugins/lightweight/line-plugin.js +195 -0
  41. package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
  42. package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
  43. package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +129 -68
  44. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
  45. package/semiplugins/type.js +1 -0
  46. package/types.js +0 -11
  47. package/util/account/create-buffermap-orchastration.js +39 -0
  48. package/util/account/index.js +2 -2
  49. package/util/account/single-attribute-buffer-management/buffer-manager.js +2 -3
  50. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
  51. package/util/build-strategy/static-dynamic.js +1 -1
  52. package/util/check/typecheck.js +15 -1
  53. package/util/geometry/index.js +3 -2
  54. package/util/gl-util/buffer/attribute-loader.js +2 -5
  55. package/util/gl-util/draw-options/methods.js +4 -5
  56. package/util/webglobjectbuilders.js +4 -9
  57. package/write-text/context-text3.js +17 -0
  58. package/write-text/context-text3old.js +152 -0
  59. package/programs/line-on-globe/circle-accurate.js +0 -175
  60. package/programs/line-on-globe/circle.js +0 -164
  61. package/programs/line-on-globe/to-the-surface.js +0 -109
  62. package/programs/rings/distancering/shader.js +0 -1
  63. package/programs/totems/canvas-webglobe-info1.js +0 -106
  64. package/shape-on-terrain/arc/naive/plugin.js +0 -205
  65. package/util/check/get.js +0 -14
  66. package/util/gl-util/buffer/types.js +0 -1
  67. package/util/gl-util/draw-options/types.js +0 -15
  68. package/util/webglobjectbuilders1.js +0 -219
@@ -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
+ }
@@ -1,3 +1,3 @@
1
- import BufferOffsetManager from './bufferoffsetmanager';
2
- export { BufferOffsetManager };
1
+ // import BufferOffsetManager from './bufferoffsetmanager';
2
+ // export { BufferOffsetManager };
3
3
  export * from './single-attribute-buffer-management/index';
@@ -22,13 +22,12 @@ export class BufferManager {
22
22
  itemSize;
23
23
  bufferType;
24
24
  isFreed = false;
25
- constructor(gl, itemSize, { bufferType = "STATIC_DRAW", buffer = null, initialCapacity = null } = {}) {
25
+ constructor(gl, itemSize, { bufferType = "STATIC_DRAW", buffer = null, initialCapacity = 10 } = {}) {
26
26
  this.gl = gl;
27
27
  this.itemSize = itemSize;
28
28
  this.bufferType = bufferType;
29
29
  this.buffer = buffer === null ? gl.createBuffer() : buffer;
30
- if (initialCapacity !== null)
31
- this.resetWithCapacity(initialCapacity);
30
+ this.resetWithCapacity(initialCapacity);
32
31
  }
33
32
  resetWithCapacity(capacity) {
34
33
  const { gl, buffer, bufferType, itemSize } = this;
@@ -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.
@@ -17,7 +17,7 @@ export class StaticDynamicStrategy {
17
17
  updateState() {
18
18
  const currentLOD = this.globe.api_GetCurrentLODWithDecimal();
19
19
  const state = currentLOD < this._transitionLevel ? StaticDynamicState.STATIC : StaticDynamicState.DYNAMIC;
20
- if (this._lastStaticDynamicState === StaticDynamicState.STATIC && state === StaticDynamicState.DYNAMIC) {
20
+ if (this._lastStaticDynamicState === StaticDynamicState.DYNAMIC && state === StaticDynamicState.STATIC) {
21
21
  this._staticDynamicState = StaticDynamicState.TO_STATIC;
22
22
  }
23
23
  else {
@@ -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
+ // }