@pirireis/webglobeplugins 0.15.2-3.alpha → 0.15.2-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 (45) hide show
  1. package/Math/arc-generate-points copy.js +366 -0
  2. package/Math/arc.js +2 -1
  3. package/Math/circle-cdf-points.js +170 -1
  4. package/Math/circle.js +25 -0
  5. package/Math/globe-util/horizon-plane.js +112 -0
  6. package/Math/methods.js +2 -2
  7. package/Math/vec3.js +2 -6
  8. package/altitude-locator/draw-subset-obj.js +16 -0
  9. package/altitude-locator/plugin.js +1 -1
  10. package/bearing-line/plugin.js +2 -3
  11. package/package.json +1 -1
  12. package/point-tracks/plugin.js +22 -82
  13. package/programs/line-on-globe/lines-color-instanced-flat.js +1 -0
  14. package/programs/line-on-globe/linestrip/linestrip.js +28 -2
  15. package/programs/line-on-globe/paddings/paddings.js +1 -0
  16. package/programs/point-on-globe/element-globe-surface-glow.js +1 -0
  17. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  18. package/programs/totems/camerauniformblock.js +0 -7
  19. package/programs/totems/canvas-webglobe-info.js +9 -9
  20. package/range-tools-on-terrain/bearing-line/adapters.js +5 -8
  21. package/range-tools-on-terrain/bearing-line/plugin.js +20 -95
  22. package/range-tools-on-terrain/circle-line-chain/adapters.js +8 -15
  23. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +15 -32
  24. package/range-tools-on-terrain/circle-line-chain/plugin.js +15 -75
  25. package/range-tools-on-terrain/range-ring/adapters.js +6 -74
  26. package/range-tools-on-terrain/range-ring/plugin.js +7 -222
  27. package/range-tools-on-terrain/range-ring/types.js +1 -9
  28. package/semiplugins/lightweight/line-plugin.js +47 -65
  29. package/semiplugins/lightweight/piece-of-pie-plugin.js +18 -44
  30. package/semiplugins/shape-on-terrain/arc-plugin.js +100 -197
  31. package/semiplugins/shape-on-terrain/circle-plugin.js +90 -209
  32. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +101 -0
  33. package/semiplugins/shape-on-terrain/one-degree-padding.js +85 -0
  34. package/util/account/single-attribute-buffer-management/buffer-manager.js +0 -10
  35. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +8 -145
  36. package/util/account/single-attribute-buffer-management/object-store.js +0 -7
  37. package/util/build-strategy/static-dynamic.js +1 -11
  38. package/util/check/typecheck.js +0 -12
  39. package/util/geometry/index.js +1 -2
  40. package/programs/totems/globe-changes.js +0 -59
  41. package/semiplugins/interface.js +0 -1
  42. package/semiplugins/shape-on-terrain/padding-1-degree.js +0 -538
  43. package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +0 -159
  44. package/util/frame-counter-trigger.js +0 -84
  45. package/write-text/context-text4.js +0 -140
@@ -1,159 +0,0 @@
1
- "use strict";
2
- // import { BufferOrchestrator as BufferOrchestratorI, BufferManagersMap, BufferManager } from "./types";
3
- // const EXTRA_SIZE = 10;
4
- // export class BufferOrchestrator implements BufferOrchestratorI {
5
- // _capacity: number;
6
- // offsetMap: Map<string, number>;
7
- // tombstoneOffsets: number[];
8
- // _length: number;
9
- // constructor({ capacity = 10 } = {}) {
10
- // this._capacity = capacity;
11
- // this.offsetMap = new Map();
12
- // this.tombstoneOffsets = [];
13
- // this._length = 0;
14
- // }
15
- // resetWithCapacity(bufferManagersMap: BufferManagersMap, capacity: number | null = null) {
16
- // this._capacity = capacity !== null ? capacity : this._capacity;
17
- // for (const [key, { bufferManager }] of bufferManagersMap) {
18
- // bufferManager.resetWithCapacity(this._capacity);
19
- // }
20
- // this.offsetMap.clear();
21
- // this.tombstoneOffsets = [];
22
- // this._length = 0;
23
- // }
24
- // insertBulk(items: any[], bufferManagersMap: BufferManagersMap, bufferKeys: string[] | null = null) {
25
- // this.ensureSpace(items.length, bufferManagersMap);
26
- // const { offsetMap } = this;
27
- // const offsets = [];
28
- // for (const item of items) {
29
- // let o = offsetMap.get(item.key);
30
- // const offset = o !== undefined ? o : this.nextOffset() as number;
31
- // if (offset === undefined) {
32
- // throw new Error("The Size Should Be Increased!!")
33
- // }
34
- // offsetMap.set(item.key, offset);
35
- // offsets.push(offset);
36
- // }
37
- // if (bufferKeys) {
38
- // for (const key of bufferKeys) {
39
- // const bufferManagerComp = bufferManagersMap.get(key);
40
- // if (bufferManagerComp === undefined) throw new Error("insertBulk bufferKey does not exist");
41
- // const { bufferManager, adaptor } = bufferManagerComp;
42
- // bufferManager.insertBulk(items.map(adaptor), offsets);
43
- // }
44
- // } else {
45
- // for (const [key, { bufferManager, adaptor }] of bufferManagersMap) {
46
- // bufferManager.insertBulk(items.map(adaptor), offsets);
47
- // }
48
- // }
49
- // }
50
- // // does not assign offset to the new items.
51
- // updateBulk(items: any[], bufferManagersMap: BufferManagersMap, bufferKeys: string[] | null = null) {
52
- // const { offsetMap } = this;
53
- // const offsets = [];
54
- // for (const item of items) {
55
- // const offset = offsetMap.get(item.key);
56
- // if (offset !== undefined) {
57
- // offsets.push(offset);
58
- // } else {
59
- // throw new Error("updateBulk item Key does not exist");
60
- // }
61
- // }
62
- // if (bufferKeys) {
63
- // for (const key of bufferKeys) {
64
- // const bufferManagerComp = bufferManagersMap.get(key);
65
- // if (bufferManagerComp === undefined) throw new Error("updateBulk bufferKey does not exist");
66
- // const { bufferManager, adaptor } = bufferManagerComp;
67
- // bufferManager.insertBulk(items.map(adaptor), offsets);
68
- // }
69
- // } else {
70
- // for (const [key, { bufferManager, adaptor }] of bufferManagersMap) {
71
- // bufferManager.insertBulk(items.map(adaptor), offsets);
72
- // }
73
- // }
74
- // }
75
- // deleteBulk(keys: string[], bufferManagersMap: BufferManagersMap) {
76
- // const offsets = [];
77
- // for (const key of keys) {
78
- // const offset = this.getOffset(key);
79
- // if (offset !== undefined) {
80
- // offsets.push(offset);
81
- // this.offsetMap.delete(key);
82
- // this.tombstoneOffsets.push(offset);
83
- // }
84
- // }
85
- // for (const [key, { bufferManager }] of bufferManagersMap) {
86
- // bufferManager.deleteBulk(offsets);
87
- // }
88
- // }
89
- // getOffset(key: string) {
90
- // return this.offsetMap.get(key);
91
- // }
92
- // nextOffset(): number | undefined {
93
- // if (this.tombstoneOffsets.length > 0) {
94
- // const offset = this.tombstoneOffsets.pop() as number;
95
- // return offset;
96
- // }
97
- // if (this._length < this._capacity) {
98
- // return this._length++;
99
- // }
100
- // return undefined;
101
- // }
102
- // ensureSpace(itemsLength: number, bufferManagersMap: BufferManagersMap) {
103
- // if (itemsLength <= this.emptySpace) return;
104
- // const newCapacity = this.length + itemsLength;
105
- // for (const [key, { bufferManager }] of bufferManagersMap) {
106
- // bufferManager.extendBuffer(this.length, newCapacity);
107
- // }
108
- // this._capacity = newCapacity;
109
- // }
110
- // defrag(bufferManagers: BufferManagersMap, bufferKeys: string[]) { // TODO defrag and leave some empty space
111
- // const offsetMap = this.offsetMap;
112
- // const newCapacity = offsetMap.size + EXTRA_SIZE;
113
- // if (bufferKeys) {
114
- // for (const key of bufferKeys) {
115
- // const offset = offsetMap.get(key);
116
- // if (offset !== undefined) {
117
- // for (const [key, { bufferManager }] of bufferManagers) {
118
- // bufferManager.defrag([offset], this.length, newCapacity);
119
- // }
120
- // }
121
- // }
122
- // } else {
123
- // for (const [key, { bufferManager }] of bufferManagers) {
124
- // bufferManager.defrag(offsetMap.values(), this.length, newCapacity);
125
- // }
126
- // }
127
- // this._defrag();
128
- // this._length = offsetMap.size;
129
- // this._capacity = newCapacity;
130
- // this.tombstoneOffsets = [];
131
- // }
132
- // /**
133
- // * Flushes metadata and sets length to 0 without actualize change on buffers
134
- // * This method created for cases in which data is loaded on each frame
135
- // */
136
- // flush({ capacity = 10 } = {}) {
137
- // this._length = 0;
138
- // this._capacity = capacity;
139
- // this.tombstoneOffsets = []
140
- // this.offsetMap.clear();
141
- // }
142
- // _defrag() {
143
- // const newOffsetMap = new Map();
144
- // let newOffset = 0;
145
- // for (const [key, offset] of this.offsetMap) {
146
- // newOffsetMap.set(key, newOffset++);
147
- // }
148
- // this.offsetMap = newOffsetMap
149
- // }
150
- // get length() {
151
- // return this._length;
152
- // }
153
- // get emptySpace() {
154
- // return this._capacity - this.offsetMap.size;
155
- // }
156
- // get capacity() {
157
- // return this._capacity;
158
- // }
159
- // }
@@ -1,84 +0,0 @@
1
- import { CameraUniformBlockTotemCache } from "../programs/totems/camerauniformblock";
2
- export class FrameCounterTrigger {
3
- globe;
4
- count = 0;
5
- threshold;
6
- timeoutMs;
7
- timeoutId = null;
8
- accumulatedChanges = {
9
- geometry: false,
10
- look: false,
11
- lod: false,
12
- lod2DWheel: false,
13
- elevationScale: false,
14
- screenMoved: false
15
- };
16
- cameraBlockTotem;
17
- updateCallback;
18
- constructor(globe, threshold, timeoutMs, updateCallback) {
19
- this.threshold = threshold;
20
- this.timeoutMs = timeoutMs;
21
- this.updateCallback = updateCallback;
22
- this.globe = globe;
23
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
24
- }
25
- trigger(level = null) {
26
- const globeChanges = this.cameraBlockTotem.getGlobeChanges();
27
- if (!globeChanges.screenMoved)
28
- return;
29
- this.setChanges(globeChanges);
30
- if (globeChanges.geometry || globeChanges.elevationScale || globeChanges.lod2DWheel) {
31
- this.triggerUpdate();
32
- return;
33
- }
34
- this.count++;
35
- if (this.count === 1) {
36
- this.startTimeout();
37
- }
38
- if (this.count >= this.threshold) {
39
- this.triggerUpdate();
40
- }
41
- }
42
- startTimeout() {
43
- this.clearTimeout();
44
- this.timeoutId = setTimeout(() => {
45
- this.triggerUpdate();
46
- }, this.timeoutMs);
47
- }
48
- triggerUpdate() {
49
- this.clearTimeout();
50
- this.updateCallback(this.accumulatedChanges);
51
- this.reset();
52
- }
53
- clearTimeout() {
54
- if (this.timeoutId) {
55
- clearTimeout(this.timeoutId);
56
- this.timeoutId = null;
57
- }
58
- }
59
- setChanges(changes) {
60
- // accumulate true states until reset
61
- this.accumulatedChanges.geometry = this.accumulatedChanges.geometry || changes.geometry;
62
- this.accumulatedChanges.look = this.accumulatedChanges.look || changes.look;
63
- this.accumulatedChanges.lod = this.accumulatedChanges.lod || changes.lod;
64
- this.accumulatedChanges.elevationScale = this.accumulatedChanges.elevationScale || changes.elevationScale;
65
- this.accumulatedChanges.screenMoved = this.accumulatedChanges.screenMoved || changes.screenMoved;
66
- this.accumulatedChanges.lod2DWheel = this.accumulatedChanges.lod2DWheel || changes.lod2DWheel;
67
- }
68
- getLevel() {
69
- return this.accumulatedChanges;
70
- }
71
- reset() {
72
- this.count = 0;
73
- this.accumulatedChanges.geometry = false;
74
- this.accumulatedChanges.look = false;
75
- this.accumulatedChanges.lod = false;
76
- this.accumulatedChanges.lod2DWheel = false;
77
- this.accumulatedChanges.elevationScale = false;
78
- this.accumulatedChanges.screenMoved = false;
79
- this.clearTimeout();
80
- }
81
- free() {
82
- CameraUniformBlockTotemCache.release(this.globe);
83
- }
84
- }
@@ -1,140 +0,0 @@
1
- // @ts-ignore
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
- const defaultStyle = {
13
- textFont: {
14
- name: 'Arial',
15
- textColor: '#FFFFFF', // beyaz
16
- hollowColor: '#000000', // siyah
17
- size: 12, // piksel
18
- hollow: true,
19
- bold: true,
20
- italic: false,
21
- },
22
- opacity: 1.0,
23
- zMode: CSZMode.Z_GROUND_PERVERTEX,
24
- };
25
- // xOffset = 0,
26
- // yOffset = 0,
27
- // doDraw = true,
28
- // textAdaptor = null,
29
- // coordinatesAdaptor = null,
30
- // keyAdaptor = null,
31
- // opacityAdaptor = null,
32
- // angleAdaptor = null,
33
- // angleOnSphere = false,
34
- // positionAdaptor = (item: any, i: number, container: any[], properties?: any): string => "left",
35
- export class ContextTextWriter4 {
36
- globe;
37
- itemMap;
38
- style;
39
- doDraw;
40
- textAdaptor;
41
- deleteAdaptor;
42
- zoomLevelAdaptor;
43
- xOffset;
44
- yOffset;
45
- angleOptions;
46
- constructor(globe, textAdaptor, deleteAdaptor, zoomLevelAdaptor = (zoomLevel) => (item) => {
47
- return {
48
- opacityMultiplier: 1,
49
- sizeMultiplier: 1
50
- };
51
- }, style = defaultStyle, angleOptions = {
52
- angleOnSphere: false,
53
- angleIsOn: false
54
- }, doDraw = true, offset = { x: 0, y: 0 }) {
55
- this.globe = globe;
56
- this.itemMap = new Map();
57
- this.setStyle(style);
58
- this.angleOptions = angleOptions;
59
- this.doDraw = doDraw;
60
- this.style = style;
61
- this.angleOptions = angleOptions;
62
- this.textAdaptor = textAdaptor;
63
- this.deleteAdaptor = deleteAdaptor;
64
- this.zoomLevelAdaptor = zoomLevelAdaptor;
65
- this.xOffset = offset.x;
66
- this.yOffset = offset.y;
67
- }
68
- setDoDraw(bool) {
69
- this.doDraw = bool;
70
- this.globe.DrawRender();
71
- }
72
- setStyle(style) {
73
- isTextFont(style.textFont);
74
- opacityCheck(style.opacity); //TODO: use shallow copy
75
- this.style = style;
76
- this.globe.DrawRender();
77
- }
78
- setOpacity(opacity) {
79
- this.style.opacity = opacity;
80
- this.globe.DrawRender();
81
- }
82
- draw() {
83
- if (!this.doDraw)
84
- return;
85
- const { globe, style, itemMap, xOffset, yOffset } = this;
86
- const { textFont, opacity: opacity_ } = style;
87
- const textSize = textFont.size;
88
- const is3D = globe.api_GetCurrentGeometry() === 0;
89
- const angleIsOn = is3D ? (this.angleOptions.angleIsOn && this.angleOptions.angleOnSphere) : (this.angleOptions.angleIsOn);
90
- const zoomLevel = globe.api_GetCurrentLODWithDecimal();
91
- const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
92
- for (const item of itemMap.values()) {
93
- const { lat, long, text, opacity = null, angle = null, zPayload, position } = item;
94
- const { x, y } = globe.api_GetScreenPointFromGeo({
95
- long: long,
96
- lat: lat,
97
- z: 0,
98
- }, style.zMode === CSZMode.Z_MSL);
99
- const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(zPayload);
100
- const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
101
- textFont.size = sizeMultiplier * textSize;
102
- textFont.position = position;
103
- if (x !== null && y !== null)
104
- globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
105
- }
106
- textFont.size = textSize;
107
- }
108
- insertText(data) {
109
- const textDatas = this.textAdaptor(data);
110
- for (const textData of textDatas) {
111
- this.itemMap.set(textData.key, textData);
112
- }
113
- }
114
- insertTextBulk(datas) {
115
- for (const data of datas) {
116
- this.insertText(data);
117
- }
118
- }
119
- deleteText(data) {
120
- const key = this.deleteAdaptor ? this.deleteAdaptor(data) : data;
121
- if (this.itemMap.has(key)) {
122
- this.itemMap.delete(key);
123
- }
124
- }
125
- deleteTextBulk(datas) {
126
- for (const data of datas) {
127
- this.deleteText(data);
128
- }
129
- }
130
- setOffsets(x, y) {
131
- this.xOffset = x;
132
- this.yOffset = y;
133
- }
134
- clear() {
135
- this.itemMap.clear();
136
- }
137
- free() {
138
- this.itemMap = null;
139
- }
140
- }