@pirireis/webglobeplugins 0.11.0-alpha → 0.12.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.
@@ -1,289 +1,205 @@
1
- "use strict";
2
- // import { LineStripProgramCache } from "../../../programs/line-on-globe/linestrip"
3
- // import "../../../programs/interface";
4
- // import { createBufferAndReadInfo } from '../../../util/gl-util/buffer/attribute-loader';
1
+ import { LineStripProgramCache } from "../../../programs/line-on-globe/linestrip";
2
+ import { createBufferAndReadInfo } from '../../../util/gl-util/buffer/attribute-loader';
5
3
  // import { populateFloat32Array } from "../../../util/jshelpers/data-filler";
6
- // import { BufferManagementMap, BufferManager, BufferOrchestrator } from "../../../util/account/single-attribute-buffer-management/index";
7
- // import { globe3Dcoordinates, globe2Dcoordinates, RADIANS } from "../../../Math/methods";
8
- // import { generateArcPoints } from "../../../Math/arc-generate-points";
9
- // import { Vec3, Plane, Arc } from "../../../Math/types";
10
- // import * as vec3 from "../../../Math/vec3";
11
- // import * as plane from "../../../Math/plane";
12
- // import * as arc from "../../../Math/arc";
13
- // // import { arcFrustumPlanesIntersection } from "../../../Math/intersections/arc-frustum-planes";
14
- // import CameraUniformBlockTotem, { CameraUniformBlockTotemCache } from "../../../programs/totems/camerauniformblock";
15
- // import { FrustumPlanes } from "../../../Math/frustum/types";
16
- // const VERTEX_COUNT = 360;
17
- // const INITAL_CAPACITY = 10;
18
- // const _0vector = [0, 0, 0] as Vec3;
19
- // const _attractionPoint = [0, 0, 0] as Vec3;
20
- // const _start = [0, 0, 0] as Vec3;
21
- // const _end = [0, 0, 0] as Vec3;
22
- // const _0arc = arc.create([1, 0, 0] as Vec3, [0, 1, 0] as Vec3); // zero arc for intersection tests
23
- // // window add properties
24
- // declare global {
25
- // interface Window {
26
- // startPoint: Vec3;
27
- // endPoint: Vec3;
28
- // }
29
- // }
30
- // let interval = 1;
31
- // export class NaiveLineOnTerrainPlugin {
32
- // public id: string;
33
- // private program: ProgramInterface | null = null;
34
- // private _bufferManagersCompMap: BufferManagementMap | null = null;
35
- // private _bufferManagersCompMapTest: BufferManagementMap | null = null;
36
- // private _bufferOrchestrator: BufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
37
- // private _testOrchestrator: BufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
38
- // private _opacity: number = 1;
39
- // private _arcUBOHandler: UBOHandler | null = null;
40
- // private _vao: WebGLVertexArrayObject | null = null;
41
- // private _vaoAllTest: WebGLVertexArrayObject | null = null;
42
- // private _ubohandlerAllTest: UBOHandler | null = null;
43
- // private globe: any | null = null;
44
- // private gl: WebGL2RenderingContext | null = null;
45
- // private _arcMap: Map<string, Arc>;
46
- // private _arcMapTest: Map<string, Arc>;
47
- // private _screenPlane: Plane = { normal: [0, 0, 1] as Vec3, distance: 0 } as Plane;
48
- // private _doBuild: boolean = false
49
- // private _cameraUniformBlock: CameraUniformBlockTotem | null = null;
50
- // private _attractionStrength: number = 50;
51
- // public fieldOfView = 50 * RADIANS; // 50 degrees in radians
52
- // constructor(id: string) {
53
- // this.id = id;
54
- // this._arcMap = new Map();
55
- // this._arcMapTest = new Map();
56
- // }
57
- // insertArcFromLongLat(key: string, startPoint: { long: number, lat: number }, endPoint: { long: number, lat: number }) {
58
- // if (this._arcMap.has(key)) {
59
- // this._arcMap.delete(key);
60
- // }
61
- // vec3.fromUnitVectorLongLat(_start, [startPoint.long * RADIANS, startPoint.lat * RADIANS]);
62
- // vec3.fromUnitVectorLongLat(_end, [endPoint.long * RADIANS, endPoint.lat * RADIANS]);
63
- // window.startPoint = _start;
64
- // window.endPoint = _end;
65
- // const _arc = arc.create(_start, _end);
66
- // this._arcMap.set(key, _arc);
67
- // this._arcMapTest.set(key, arc.clone(_arc));
68
- // // const longLatArr = new Float32Array(2 * VERTEX_COUNT);
69
- // // //
70
- // // const _3Dpoints = generateArcPoints(_start, _end, VERTEX_COUNT);
71
- // // const longLat = {
72
- // // long: 1,
73
- // // lat: 1
74
- // // };
75
- // // for (let i = 0; i < _3Dpoints.length / 3; i++) {
76
- // // _0vector.set(_3Dpoints[i * 3], _3Dpoints[i * 3 + 1], _3Dpoints[i * 3 + 2]).toLongLat(longLat);
77
- // // longLatArr.set([longLat.long / RADIANS, longLat.lat / RADIANS], i * 2);
78
- // // }
79
- // // const result = [{
80
- // // key: key,
81
- // // longLatArr: longLatArr,
82
- // // }
83
- // // ]
84
- // // this._testOrchestrator.insertBulk(result, this._bufferManagersCompMapTest);
85
- // this._doBuild = true;
86
- // this.globe.DrawRender();
87
- // }
88
- // init(globe: any, gl: WebGL2RenderingContext) {
89
- // this.globe = globe;
90
- // this.gl = gl;
91
- // this.program = LineStripProgramCache.get(globe);
92
- // const g3D = globe3Dcoordinates(globe, 30);
93
- // const g2D = globe2Dcoordinates(globe);
94
- // this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
95
- // this._bufferManagersCompMap = new Map(
96
- // [
97
- // ["position3d", {
98
- // bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
99
- // adaptor: (item: any) => {
100
- // const { longLatArr } = item;
101
- // const result = g3D(longLatArr, { paddingCount: 1 });
102
- // // console.log("result", result);
103
- // return result;
104
- // }
105
- // }],
106
- // ["position2d", {
107
- // bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
108
- // adaptor: (item: any) => {
109
- // const { longLatArr } = item;
110
- // return g2D(longLatArr, { paddingCount: 1 });
111
- // }
112
- // }
113
- // ],
114
- // ]
115
- // );
116
- // this._bufferManagersCompMapTest = new Map([
117
- // ["positionTest3d", {
118
- // bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
119
- // adaptor: (item: any) => {
120
- // const { longLatArr } = item;
121
- // const result = g3D(longLatArr, { paddingCount: 1 });
122
- // return result;
123
- // }
124
- // }],
125
- // ["positionTest2d", {
126
- // bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
127
- // adaptor: (item: any) => {
128
- // const { longLatArr } = item;
129
- // return g2D(longLatArr, { paddingCount: 1 });
130
- // }
131
- // }
132
- // ]
133
- // ]
134
- // );
135
- // this._bufferOrchestrator = new BufferOrchestrator();
136
- // this._arcUBOHandler = this.program.createUBO();
137
- // this._arcUBOHandler.update(new Map([
138
- // ["u_color", new Float32Array([1, 0, 0, 1])],
139
- // ]));
140
- // this._ubohandlerAllTest = this.program.createUBO();
141
- // this._ubohandlerAllTest.update(new Map([
142
- // ["u_color", new Float32Array([0, 0, 1, 1])],
143
- // ]));
144
- // this._vao = this.program.createVAO(
145
- // createBufferAndReadInfo(this._bufferManagersCompMap.get("position3d")?.bufferManager.buffer as WebGLBuffer),
146
- // createBufferAndReadInfo(this._bufferManagersCompMap.get("position2d")?.bufferManager.buffer as WebGLBuffer),
147
- // null,
148
- // null,
149
- // null,
150
- // );
151
- // this._vaoAllTest = this.program.createVAO(
152
- // createBufferAndReadInfo(this._bufferManagersCompMapTest.get("positionTest3d")?.bufferManager.buffer as WebGLBuffer),
153
- // createBufferAndReadInfo(this._bufferManagersCompMapTest.get("positionTest2d")?.bufferManager.buffer as WebGLBuffer),
154
- // null,
155
- // null,
156
- // null,
157
- // );
158
- // }
159
- // setFieldOfView(fieldOfView: number) {
160
- // this.fieldOfView = fieldOfView * RADIANS; // convert degrees to radians
161
- // this.globe.DrawRender();
162
- // }
163
- // _buildArcs() {
164
- // const { globe, _arcMap, _cameraUniformBlock } = this;
165
- // const cameraPositionNormalized = _cameraUniformBlock.getCameraPositionNormalized() as Vec3;
166
- // const result = [];
167
- // const longLat = [0, 0] as [number, number];
168
- // for (const [key, arcInstance] of _arcMap) {
169
- // arc.copy(_0arc, arcInstance);
170
- // const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPositionNormalized);
171
- // if (!isOnArc) {
172
- // vec3.distanceSquared(cameraPositionNormalized, _0arc.p0) < vec3.distanceSquared(cameraPositionNormalized, _0arc.p1) ?
173
- // vec3.copy(_attractionPoint, _0arc.p0) : vec3.copy(_attractionPoint, _0arc.p1);
174
- // }
175
- // const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, this._attractionStrength);
176
- // const longLatArr = new Float32Array(2 * VERTEX_COUNT);
177
- // for (let i = 0; i < generatedPoints.length; i++) {
178
- // const point = generatedPoints[i];
179
- // vec3.toUnitVectorLongLat(longLat, point);
180
- // longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
181
- // }
182
- // result.push({
183
- // key: key,
184
- // longLatArr: longLatArr,
185
- // })
186
- // }
187
- // this._bufferOrchestrator.resetWithCapacity(this._bufferManagersCompMap, result.length);
188
- // this._bufferOrchestrator.insertBulk(result, this._bufferManagersCompMap);
189
- // this._doBuild = false; // reset build flag
190
- // this._checkIfCorrupted(); // check if any arc is corrupted
191
- // }
192
- // setAttractionStrength(strength: number) {
193
- // this._attractionStrength = strength;
194
- // this._doBuild = true; // trigger rebuild
195
- // this.globe.DrawRender();
196
- // }
197
- // // _buildArcs() {
198
- // // // updatePlane
199
- // // const { globe, _arcMap } = this;
200
- // // const planes = this._cameraUniformBlock.getFrustumPlanes() as FrustumPlanes;
201
- // // //
202
- // // const cameraPostition = new Vector3D();
203
- // // cameraPostition.copy(globe.Fp as Vector3D).normalize();
204
- // // // calculateHorizonPlane(globe, _screenPlane, this.fieldOfView);
205
- // // const result = [];
206
- // // const longLat = {
207
- // // long: 1,
208
- // // lat: 1
209
- // // }
210
- // // let counter = 0;
211
- // // for (const [key, arc] of _arcMap) {
212
- // // // const isArc = arc.intersectionMedium(_screenPlane, _0arc) as Arc;
213
- // // _0arc.copy(arc);
214
- // // const isArc = arcFrustumPlanesIntersection(_0arc, planes, _0arc);
215
- // // if (!isArc) {
216
- // // continue;
217
- // // }
218
- // // counter++;
219
- // // const longLatArr = new Float32Array(2 * VERTEX_COUNT);
220
- // // // const _3Dpoints = _0arc.populatePoints3DInRespectToCamera(cameraPostition, VERTEX_COUNT);
221
- // // const _3Dpoints = _0arc.populatePoints3D(VERTEX_COUNT);
222
- // // for (let i = 0; i < _3Dpoints.length / 3; i++) {
223
- // // _0vector.set(_3Dpoints[i * 3], _3Dpoints[i * 3 + 1], _3Dpoints[i * 3 + 2]).toLongLat(longLat);
224
- // // longLatArr.set([longLat.long / RADIANS, longLat.lat / RADIANS], i * 2);
225
- // // }
226
- // // result.push({
227
- // // key: key,
228
- // // longLatArr: longLatArr,
229
- // // });
230
- // // // if (!arc.imaginaryPlane.equals(_0arc.imaginaryPlane) || !arc.imaginaryPlane.equalsReverseOriantation(_0arc.imaginaryPlane)) {
231
- // // // // console.log("Arc with key", key, "has imaginary plane equal to the original arc's imaginary plane.");
232
- // // // throw new Error("The arc segment is not on the parent arc")
233
- // // // }
234
- // // }
235
- // // interval += 1;
236
- // // if (interval === 100) {
237
- // // interval = 1;
238
- // // console.log("Arc count on screen:", counter);
239
- // // }
240
- // // // update buffer
241
- // // this._bufferOrchestrator.resetWithCapacity(this._bufferManagersCompMap, result.length);
242
- // // this._bufferOrchestrator.insertBulk(result, this._bufferManagersCompMap);
243
- // // this._doBuild = false;
244
- // // this._checkIfCorrupted(); // check if any arc is corrupted
245
- // // }
246
- // draw3D() {
247
- // // Drawing logic here
248
- // this._buildArcs() // can be async
249
- // const { gl, program, _bufferOrchestrator } = this;
250
- // gl.disable(gl.DEPTH_TEST);
251
- // const drawOptionTest = {
252
- // drawRange: {
253
- // first: 0,
254
- // count: this._testOrchestrator.length * (VERTEX_COUNT + 1)
255
- // },
256
- // indexes: null
257
- // }
258
- // program.draw(
259
- // this._vaoAllTest,
260
- // drawOptionTest,
261
- // this._opacity,
262
- // this._ubohandlerAllTest
263
- // );
264
- // const drawOptions = {
265
- // drawRange: {
266
- // first: 0,
267
- // count: _bufferOrchestrator.length * (VERTEX_COUNT + 1)
268
- // },
269
- // indexes: null
270
- // }
271
- // program.draw(
272
- // this._vao,
273
- // drawOptions,
274
- // this._opacity,
275
- // this._arcUBOHandler
276
- // );
277
- // gl.enable(gl.DEPTH_TEST);
278
- // }
279
- // _checkIfCorrupted() {
280
- // for (const [key, arc] of this._arcMap) {
281
- // if (!arc.p0.equals(arc.p1)) {
282
- // continue; // valid arc
283
- // }
284
- // console.warn(`Arc with key ${key} is corrupted: p0 and p1 are the same point.`);
285
- // // this._arcMap.delete(key);
286
- // // this._arcMapTest.delete(key);
287
- // }
288
- // }
289
- // }
4
+ import { BufferManager, BufferOrchestrator } from "../../../util/account/single-attribute-buffer-management/index";
5
+ import { globe3Dcoordinates, globe2Dcoordinates, RADIANS } from "../../../Math/methods";
6
+ import { generateArcPoints } from "../../../Math/arc-cdf-points";
7
+ import * as vec3 from "../../../Math/vec3";
8
+ import * as arc from "../../../Math/arc";
9
+ import { CameraUniformBlockTotemCache } from "../../../programs/totems/camerauniformblock";
10
+ import { WORLD_RADIUS_3D } from "../../../Math/constants";
11
+ const VERTEX_COUNT = 70;
12
+ const INITAL_CAPACITY = 10;
13
+ const _0vector = [0, 0, 0];
14
+ const _attractionPoint = [0, 0, 0];
15
+ const _start = [0, 0, 0];
16
+ const _end = [0, 0, 0];
17
+ const _0arc = arc.create([1, 0, 0], [0, 1, 0]); // zero arc for intersection tests
18
+ let interval = 1;
19
+ export class NaiveLineOnTerrainPlugin {
20
+ id;
21
+ program = null;
22
+ _bufferManagersCompMap = null;
23
+ _bufferManagersCompMapTest = null;
24
+ _bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
25
+ _testOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
26
+ _opacity = 1;
27
+ _arcUBOHandler = null;
28
+ _vao = null;
29
+ _vaoAllTest = null;
30
+ _ubohandlerAllTest = null;
31
+ globe = null;
32
+ gl = null;
33
+ _arcMap;
34
+ _arcMapTest;
35
+ _doBuild = false;
36
+ _cameraUniformBlock = null;
37
+ _attractionStrength = 8;
38
+ constructor(id) {
39
+ this.id = id;
40
+ this._arcMap = new Map();
41
+ this._arcMapTest = new Map();
42
+ }
43
+ insertArcFromLongLat(key, startPoint, endPoint) {
44
+ if (this._arcMap.has(key)) {
45
+ this._arcMap.delete(key);
46
+ }
47
+ vec3.fromLongLatToUnitVector(_start, [startPoint.long * RADIANS, startPoint.lat * RADIANS]);
48
+ vec3.fromLongLatToUnitVector(_end, [endPoint.long * RADIANS, endPoint.lat * RADIANS]);
49
+ const _arc = arc.create(_start, _end);
50
+ this._arcMap.set(key, _arc);
51
+ this._arcMapTest.set(key, arc.clone(_arc));
52
+ this._doBuild = true;
53
+ this.globe.DrawRender();
54
+ }
55
+ deleteArcs(keys) {
56
+ for (const key of keys) {
57
+ if (this._arcMap.has(key)) {
58
+ this._arcMap.delete(key);
59
+ }
60
+ }
61
+ this._doBuild = true;
62
+ this.globe.DrawRender();
63
+ }
64
+ init(globe, gl) {
65
+ this.globe = globe;
66
+ this.gl = gl;
67
+ this.program = LineStripProgramCache.get(globe);
68
+ const g3D = globe3Dcoordinates(globe, 30);
69
+ const g2D = globe2Dcoordinates(globe);
70
+ this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
71
+ this._bufferManagersCompMap = new Map([
72
+ ["position3d", {
73
+ bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
74
+ adaptor: (item) => {
75
+ const { longLatArr } = item;
76
+ const result = g3D(longLatArr, { paddingCount: 1 });
77
+ // console.log("result", result);
78
+ return result;
79
+ }
80
+ }],
81
+ ["position2d", {
82
+ bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
83
+ adaptor: (item) => {
84
+ const { longLatArr } = item;
85
+ return g2D(longLatArr, { paddingCount: 1 });
86
+ }
87
+ }
88
+ ],
89
+ ]);
90
+ this._bufferManagersCompMapTest = new Map([
91
+ ["positionTest3d", {
92
+ bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
93
+ adaptor: (item) => {
94
+ const { longLatArr } = item;
95
+ const result = g3D(longLatArr, { paddingCount: 1 });
96
+ return result;
97
+ }
98
+ }],
99
+ ["positionTest2d", {
100
+ bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
101
+ adaptor: (item) => {
102
+ const { longLatArr } = item;
103
+ return g2D(longLatArr, { paddingCount: 1 });
104
+ }
105
+ }
106
+ ]
107
+ ]);
108
+ this._bufferOrchestrator = new BufferOrchestrator();
109
+ this._arcUBOHandler = this.program.createUBO();
110
+ this._arcUBOHandler.update(new Map([
111
+ ["u_color", new Float32Array([1, 0, 0, 1])],
112
+ ]));
113
+ this._ubohandlerAllTest = this.program.createUBO();
114
+ this._ubohandlerAllTest.update(new Map([
115
+ ["u_color", new Float32Array([0, 0, 1, 1])],
116
+ ]));
117
+ this._vao = this.program.createVAO(createBufferAndReadInfo(this._bufferManagersCompMap.get("position3d")?.bufferManager.buffer), createBufferAndReadInfo(this._bufferManagersCompMap.get("position2d")?.bufferManager.buffer), null, null, null);
118
+ this._vaoAllTest = this.program.createVAO(createBufferAndReadInfo(this._bufferManagersCompMapTest.get("positionTest3d")?.bufferManager.buffer), createBufferAndReadInfo(this._bufferManagersCompMapTest.get("positionTest2d")?.bufferManager.buffer), null, null, null);
119
+ }
120
+ draw3D() {
121
+ // Drawing logic here
122
+ this._buildArcs(); // can be async
123
+ const { gl, program, _bufferOrchestrator, _vao, _arcUBOHandler, _vaoAllTest, _ubohandlerAllTest, _testOrchestrator } = this;
124
+ if (!gl || !program || !_bufferOrchestrator || !_vao || !_arcUBOHandler
125
+ || !_vaoAllTest || !_ubohandlerAllTest || !_testOrchestrator) {
126
+ console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
127
+ return;
128
+ }
129
+ gl.disable(gl.DEPTH_TEST);
130
+ const drawOptions = {
131
+ drawRange: {
132
+ first: 0,
133
+ count: _bufferOrchestrator.length * (VERTEX_COUNT + 1)
134
+ },
135
+ indexes: null
136
+ };
137
+ program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
138
+ gl.enable(gl.DEPTH_TEST);
139
+ }
140
+ _buildArcs() {
141
+ if (!this._doBuild)
142
+ return; // if not needed to build, return early
143
+ const { globe, _arcMap, _cameraUniformBlock, _bufferManagersCompMap } = this;
144
+ if (!globe || !_cameraUniformBlock || !_bufferManagersCompMap) {
145
+ console.warn("Globe or camera uniform block is not initialized.");
146
+ return;
147
+ }
148
+ const lookAtPosition = _cameraUniformBlock.getLookAtVector();
149
+ const cameraPosition = _cameraUniformBlock.getCameraVector();
150
+ vec3.divideScalar(cameraPosition, cameraPosition, WORLD_RADIUS_3D);
151
+ vec3.add(cameraPosition, cameraPosition, lookAtPosition);
152
+ // vec3.normalize(cameraPosition, cameraPosition);
153
+ vec3.divideScalar(cameraPosition, cameraPosition, 2);
154
+ // vec3.multiplyScalar(cameraPosition, cameraPosition, 1.3);
155
+ const _attractionStrength = (() => {
156
+ const lod = globe.api_GetCurrentLODWithDecimal();
157
+ if (lod < 11) {
158
+ return 1;
159
+ }
160
+ return lod * (lod - 8.5);
161
+ })();
162
+ console.log("Attraction strength: ", _attractionStrength);
163
+ const result = [];
164
+ const longLat = [0, 0];
165
+ for (const [key, arcInstance] of _arcMap) {
166
+ arc.copy(_0arc, arcInstance);
167
+ const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
168
+ if (!isOnArc) {
169
+ if (vec3.distanceSquared(cameraPosition, _0arc.p0) < vec3.distanceSquared(cameraPosition, _0arc.p1)) {
170
+ vec3.copy(_attractionPoint, _0arc.p0);
171
+ }
172
+ else {
173
+ vec3.copy(_attractionPoint, _0arc.p1);
174
+ }
175
+ }
176
+ const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
177
+ const longLatArr = new Float32Array(2 * VERTEX_COUNT);
178
+ for (let i = 0; i < generatedPoints.length; i++) {
179
+ const point = generatedPoints[i];
180
+ vec3.fromUnitVectorToLongLat(longLat, point);
181
+ longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
182
+ }
183
+ result.push({
184
+ key: key,
185
+ longLatArr: longLatArr,
186
+ });
187
+ }
188
+ this._bufferOrchestrator.resetWithCapacity(_bufferManagersCompMap, result.length);
189
+ this._bufferOrchestrator.insertBulk(result, _bufferManagersCompMap);
190
+ this._doBuild = false; // reset build flag
191
+ this._checkIfCorrupted(); // check if any arc is corrupted
192
+ }
193
+ _checkIfCorrupted() {
194
+ for (const [key, arcInstance] of this._arcMap) {
195
+ const copyarc = this._arcMapTest.get(key);
196
+ if (!copyarc) {
197
+ console.warn(`Arc with key ${key} is missing in the test map.`);
198
+ continue;
199
+ }
200
+ if (!arc.equals(arcInstance, copyarc)) {
201
+ console.warn(`Arc with key ${key} is corrupted: p0 and p1 are the same point.`);
202
+ }
203
+ }
204
+ }
205
+ }