@pirireis/webglobeplugins 0.9.1 → 0.9.3

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 (67) hide show
  1. package/Math/arc.ts +74 -245
  2. package/Math/constants.ts +4 -1
  3. package/Math/frustum/camera.ts +32 -0
  4. package/Math/frustum/from-globeinfo.ts +63 -0
  5. package/Math/frustum/types.ts +11 -0
  6. package/Math/globe-util/horizon-plane.ts +137 -0
  7. package/Math/juction/arc-plane.ts +90 -0
  8. package/Math/juction/line-sphere.ts +30 -0
  9. package/Math/juction/plane-plane.ts +66 -0
  10. package/Math/line.ts +70 -0
  11. package/Math/methods.js +29 -1
  12. package/Math/plane.ts +57 -138
  13. package/Math/quaternion.ts +108 -144
  14. package/Math/types.ts +39 -30
  15. package/Math/vec3.ts +155 -0
  16. package/altitude-locator/plugin.js +1 -1
  17. package/bearing-line/plugin.js +1 -1
  18. package/circle-line-chain/plugin.js +1 -1
  19. package/globe-types.ts +13 -0
  20. package/heatwave/plugins/heatwaveglobeshell.js +5 -9
  21. package/index.js +3 -0
  22. package/package.json +1 -1
  23. package/programs/interface.ts +7 -0
  24. package/programs/line-on-globe/circle-accurate-3d.js +1 -1
  25. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  26. package/programs/line-on-globe/lines-color-instanced-flat.js +1 -1
  27. package/programs/line-on-globe/linestrip.ts +228 -0
  28. package/programs/line-on-globe/naive-accurate-flexible.js +1 -1
  29. package/programs/line-on-globe/to-the-surface.js +1 -1
  30. package/programs/picking/pickable-renderer.js +1 -1
  31. package/programs/point-on-globe/element-globe-surface-glow.js +1 -1
  32. package/programs/point-on-globe/element-point-glow.js +1 -1
  33. package/programs/totems/camerauniformblock.js +24 -1
  34. package/programs/vectorfields/logics/drawrectangleparticles.js +1 -1
  35. package/shape-on-terrain/arc/naive/plugin.ts +304 -0
  36. package/tests/Math/junction/arc-plane.test.ts +129 -0
  37. package/tests/Math/junction/plane-plane.test.ts +82 -0
  38. package/tests/Math/plane.test.ts +30 -32
  39. package/tests/Math/vec3.test.ts +14 -0
  40. package/timetracks/plugin-line-strip.js +3 -1
  41. package/{types.js → types.ts} +2 -1
  42. package/util/account/{index.js → index.ts} +1 -2
  43. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -31
  44. package/util/account/single-attribute-buffer-management/index.ts +13 -0
  45. package/util/gl-util/buffer/{integrate-buffer.js → attribute-loader.ts} +17 -6
  46. package/util/gl-util/buffer/index.ts +6 -0
  47. package/util/gl-util/buffer/types.ts +13 -0
  48. package/util/gl-util/draw-options/methods.js +4 -4
  49. package/util/gl-util/draw-options/{types.js → types.ts} +10 -0
  50. package/util/gl-util/uniform-block/{manager.js → manager.ts} +24 -13
  51. package/util/gl-util/uniform-block/types.ts +27 -0
  52. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +17 -17
  53. package/waveparticles/plugin.js +3 -0
  54. package/wind/plugin.js +6 -19
  55. package/Math/methodology/arc-part-on-screen.ts +0 -47
  56. package/Math/ray.ts +0 -101
  57. package/Math/vector3d.ts +0 -241
  58. package/shape-on-terrain/tree-search.js +0 -0
  59. package/surface-cover-shapes/arc/naive/data-manager.ts +0 -0
  60. package/surface-cover-shapes/arc/naive/plugin.ts +0 -0
  61. package/tests/Math/arc.test.ts +0 -112
  62. package/tests/Math/quaternion.test.ts +0 -98
  63. package/tests/Math/ray-plane.test.ts +0 -176
  64. package/tests/Math/vector3d.test.ts +0 -104
  65. package/util/account/single-attribute-buffer-management/index.js +0 -4
  66. package/util/gl-util/uniform-block/types.js +0 -7
  67. /package/{shape-on-terrain/intersection.js → Math/matrix4.ts} +0 -0
@@ -0,0 +1,228 @@
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
+ import "../interface";
3
+ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems"
4
+
5
+ import {
6
+ cartesian3DToGLPosition,
7
+ mercatorXYToGLPosition,
8
+ } from "../../util/shaderfunctions/geometrytransformations.js";
9
+
10
+ import { noRegisterGlobeProgramCache } from "../programcache";
11
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
12
+ import "../../util/gl-util/buffer/attribute-loader";
13
+
14
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
15
+ import "../../util/gl-util/uniform-block/types";
16
+
17
+ import { drawArrays } from "../../util/gl-util/draw-options/methods.js";
18
+ import "../../util/gl-util/draw-options/types";
19
+
20
+
21
+
22
+ const ESCAPE_VALUE = -1;
23
+
24
+ const uniformBindingPoints = {
25
+ camera: 0,
26
+ flexible: 1,
27
+ }
28
+
29
+ const one = new Float32Array([1]);
30
+ const flexibleBlockManager = new UniformBlockManager(
31
+ 'FlexibleAttributes',
32
+ [
33
+ { name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
34
+ { name: "u_dash_opacity", type: "float", value: one },
35
+ { name: "u_dash_length", type: "float", value: one },
36
+ ],
37
+ uniformBindingPoints.flexible,
38
+ );
39
+
40
+
41
+
42
+
43
+ const vertexShaderSource = `#version 300 es
44
+ precision highp float;
45
+
46
+ ${CameraUniformBlockString}
47
+ ${cartesian3DToGLPosition}
48
+ ${mercatorXYToGLPosition}
49
+
50
+ ${flexibleBlockManager.glslCode()}
51
+
52
+ in vec3 position3d;
53
+ in vec2 position2d;
54
+ in vec4 color;
55
+ in float dash_length;
56
+ in float dash_opacity;
57
+
58
+ out float v_dash_length;
59
+ out float v_dash_opacity;
60
+ out vec4 v_color;
61
+
62
+ flat out vec3 v_flat_position;
63
+ out vec3 v_position;
64
+
65
+ void main() {
66
+
67
+ v_color = ( color.r == -1.0 ) ? u_color : color;
68
+ v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
69
+ v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
70
+
71
+ if ( is3D ) {
72
+ gl_Position = cartesian3DToGLPosition( position3d );
73
+ v_position = position3d;
74
+ v_flat_position = position3d;
75
+ } else {
76
+ gl_Position = mercatorXYToGLPosition( position2d );
77
+ v_position = vec3( position2d, 0.0 );
78
+ v_flat_position = vec3( position2d, 0.0 );
79
+ }
80
+ gl_PointSize = 4.0;
81
+ }`;
82
+
83
+
84
+ const fragmentShaderSource = `#version 300 es
85
+ precision highp float;
86
+
87
+ uniform float opacity;
88
+
89
+ in vec4 v_color;
90
+ in float v_dash_length;
91
+ in float v_dash_opacity;
92
+
93
+ flat in vec3 v_flat_position;
94
+ in vec3 v_position;
95
+
96
+
97
+ out vec4 outColor;
98
+
99
+ void main() {
100
+ outColor = v_color;
101
+ return;
102
+ float dash_length = v_dash_length;
103
+ float dash_opacity = v_dash_opacity;
104
+
105
+ if ( dash_length == 0.0 ) {
106
+ outColor = vec4( v_color.rgb, v_color.a * v_dash_opacity );
107
+ } else {
108
+ float dist = distance( v_flat_position, v_position );
109
+ // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
110
+ outColor = vec4( v_color.rgb, v_color.a * opacity );
111
+ }
112
+ }`;
113
+
114
+ console.log("LineStripProgram");
115
+ console.log(vertexShaderSource);
116
+ console.log(fragmentShaderSource);
117
+
118
+
119
+ class Logic implements ProgramInterface {
120
+
121
+ _vaosPublished: object[] = [];
122
+ _ubosPublished: UBOHandler[] = [];
123
+ program: WebGLProgram;
124
+ gl: WebGL2RenderingContext;
125
+ globe: any;
126
+ cameraBlockTotem: any;
127
+ _defaultFlexibleUBO: UBOHandler;
128
+ _opacity: {
129
+ value: number,
130
+ location: WebGLUniformLocation | null
131
+ } = {
132
+ value: 1,
133
+ location: null
134
+ };
135
+
136
+ constructor(globe: any) {
137
+ console.log("LineStripProgram globe", globe);
138
+ this.gl = globe.gl;
139
+
140
+ this.globe = globe;
141
+ this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
142
+ const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
143
+ this.gl.useProgram(this.program);
144
+ this._opacity.location = this.gl.getUniformLocation(this.program, "opacity");
145
+ this.gl.uniform1f(this._opacity.location, this._opacity.value);
146
+
147
+
148
+ // bind attribute locations
149
+ this.gl.bindAttribLocation(this.program, 0, "position3d");
150
+ this.gl.bindAttribLocation(this.program, 1, "position2d");
151
+ this.gl.bindAttribLocation(this.program, 2, "color");
152
+ this.gl.bindAttribLocation(this.program, 3, "dash_length");
153
+ this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
154
+
155
+
156
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
157
+ this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
158
+
159
+ flexibleBlockManager.assignBindingPoint(this.gl, this.program);
160
+ this._defaultFlexibleUBO = flexibleBlockManager.createUBO(this.gl);
161
+
162
+ this.gl.useProgram(currentProgram);
163
+ }
164
+
165
+
166
+
167
+ createUBO(bufferReadType: "STATIC_DRAW" | "DYNAMIC_DRAW" | "STREAM_DRAW" = "STATIC_DRAW"): UBOHandler {
168
+ const ubo = flexibleBlockManager.createUBO(this.gl, bufferReadType);
169
+ this._ubosPublished.push(ubo);
170
+ return ubo;
171
+ }
172
+
173
+
174
+
175
+ createVAO(
176
+ position3D: BufferAndReadInfo, position2D: BufferAndReadInfo, color: BufferAndReadInfo, dashLength: BufferAndReadInfo, dashOpacity: BufferAndReadInfo,
177
+ ): WebGLVertexArrayObject {
178
+ const { gl } = this;
179
+ const vao = gl.createVertexArray();
180
+ gl.bindVertexArray(vao);
181
+ attributeLoader(gl, position3D, 0, 3);
182
+ attributeLoader(gl, position2D, 1, 2);
183
+ attributeLoader(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
184
+ attributeLoader(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
185
+ attributeLoader(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
186
+ gl.bindVertexArray(null);
187
+ return vao;
188
+ }
189
+
190
+
191
+
192
+ draw(vao: WebGLVertexArrayObject, drawOptions: DrawRangeIndexParams, opacity: number = 1, flexibleUBO: UBOHandler | null = null) {
193
+
194
+ const { gl, program, cameraBlockTotem } = this;
195
+
196
+ gl.useProgram(program);
197
+ if (opacity !== this._opacity.value) {
198
+ this._opacity.value = opacity;
199
+ this.gl.uniform1f(this._opacity.location, this._opacity.value);
200
+ }
201
+ const ubo = flexibleUBO || this._defaultFlexibleUBO;
202
+ cameraBlockTotem.bind(uniformBindingPoints.camera);
203
+ ubo.bind();
204
+ gl.bindVertexArray(vao);
205
+ drawArrays(gl, gl.POINTS, drawOptions);
206
+ drawArrays(gl, gl.LINE_STRIP, drawOptions);
207
+ gl.bindVertexArray(null);
208
+ ubo.unbind();
209
+ cameraBlockTotem.unbind(uniformBindingPoints.camera);
210
+ }
211
+
212
+
213
+
214
+ free() {
215
+ this._vaosPublished.forEach((vao: WebGLVertexArrayObject) => this.gl.deleteVertexArray(vao));
216
+ this._ubosPublished.forEach((ubo: UBOHandler) => ubo.free());
217
+ this.gl.deleteProgram(this.program);
218
+ this._defaultFlexibleUBO.free();
219
+ CameraUniformBlockTotemCache.release(this.globe);
220
+ this.gl.deleteProgram(this.program);
221
+
222
+ }
223
+ }
224
+
225
+ export const LineStripProgramCache = Object.freeze({
226
+ get: (globe: any): ProgramInterface => noRegisterGlobeProgramCache.getProgram(globe, Logic),
227
+ release: (globe: any) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic),
228
+ });
@@ -2,7 +2,7 @@ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totem
2
2
  import { slerp, POLE, R_3D, mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
3
3
  import { createProgram } from "../../util";
4
4
  import { noRegisterGlobeProgramCache } from "../programcache";
5
- import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
5
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
6
  import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
7
7
 
8
8
  import "../../util/gl-util/draw-options/types";
@@ -3,7 +3,7 @@ import { createProgram } from './util'
3
3
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from '../totems';
4
4
  import { cartesian3DToGLPosition, R_3D } from '../../util/shaderfunctions/geometrytransformations';
5
5
  import { noRegisterGlobeProgramCache } from '../programcache';
6
- import { attributeLoader } from '../../util/gl-util/buffer/integrate-buffer';
6
+ import { attributeLoader } from '../../util/gl-util/buffer/attribute-loader';
7
7
  import '../draw-options/types';
8
8
  import { drawInstanced } from '../draw-options/methods';
9
9
 
@@ -4,7 +4,7 @@ import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../
4
4
  import { noRegisterGlobeProgramCache } from "../programcache";
5
5
  import "../../util/gl-util/draw-options/types";
6
6
  import { drawArrays } from "../../util/gl-util/draw-options/methods";
7
- import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
7
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
8
8
  import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
9
9
 
10
10
 
@@ -12,7 +12,7 @@ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totem
12
12
  import { PI, mercatorXYToGLPosition, cartesian3DToGLPosition, circleLimpFromLongLatRadCenterCartesian3D_accurate } from "../../util/shaderfunctions/geometrytransformations";
13
13
  import { createProgram } from "../../util";
14
14
  import { noRegisterGlobeProgramCache } from "../programcache";
15
- import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
15
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
16
16
  import { drawInstanced } from "../../util/gl-util/draw-options/methods";
17
17
  import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
18
18
 
@@ -2,7 +2,7 @@ import { createProgram } from "../../util";
2
2
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
3
  import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
4
4
  import { noRegisterGlobeProgramCache } from "../programcache";
5
- import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
5
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
6
  import { drawArrays } from "../../util/gl-util/draw-options/methods";
7
7
  import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
8
8
  import { singularity } from "../../shaders/fragment-toy/singularity";
@@ -1,5 +1,7 @@
1
1
  import { globeProgramCache } from "../programcache";
2
-
2
+ // import { getFrustumPlanes } from "../../Math/frustum/from-projection-matrix";
3
+ // import { getFrustum } from "../../Math/frustum/from-globeinfo"
4
+ // import { Plane } from "../../Math/";
3
5
 
4
6
  export const CameraUniformBlockString = `
5
7
  layout(std140) uniform CameraUniformBlock {
@@ -30,6 +32,14 @@ export default class
30
32
  this.gl = null;
31
33
  this.globe = null;
32
34
  this.ubo = null;
35
+ // this._frustumPlanes = {
36
+ // left: new Plane(),
37
+ // right: new Plane(),
38
+ // top: new Plane(),
39
+ // bottom: new Plane(),
40
+ // near: new Plane(),
41
+ // far: new Plane()
42
+ // }
33
43
  this._isMovedParams = {
34
44
  lastLod: null,
35
45
  isMoved: false,
@@ -107,6 +117,8 @@ export default class
107
117
  ]));
108
118
  }
109
119
 
120
+ // this._frustumPlanes = getFrustumPlanes(projection, translate);
121
+
110
122
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
111
123
 
112
124
  { // isMoved
@@ -114,6 +126,9 @@ export default class
114
126
  this._isMovedParams.isMoved = this._isMovedParams.lastLod !== currentLOD || globe.api_IsScreenMoving();
115
127
  this._isMovedParams.lastLod = currentLOD;
116
128
  }
129
+
130
+ // getFrustum(globe, 50, this._frustumPlanes);
131
+
117
132
  }
118
133
 
119
134
  assignBindingPoint(program, bindingPoint) {
@@ -127,6 +142,9 @@ export default class
127
142
  return this.ubo;
128
143
  }
129
144
 
145
+ getFrustumPlanes() {
146
+ return this._frustumPlanes;
147
+ }
130
148
 
131
149
  bind(bindingPoint) {
132
150
  const { gl, ubo } = this;
@@ -168,6 +186,11 @@ export default class
168
186
  }
169
187
 
170
188
 
189
+
190
+
191
+
192
+
193
+
171
194
  export const CameraUniformBlockTotemCache = Object.freeze({
172
195
  get: (globe) => { return globeProgramCache.getProgram(globe, CameraUniformBlockTotem) },
173
196
  release: (globe) => { return globeProgramCache.releaseProgram(globe, CameraUniformBlockTotem) }
@@ -118,7 +118,7 @@ export default class {
118
118
  }
119
119
 
120
120
  free() {
121
- glProgramCache.releaseProgram(this.logic);
121
+ glProgramCache.releaseProgram(this.gl, Logic);
122
122
  this.logic = null;
123
123
  this.gl = null;
124
124
  }
@@ -0,0 +1,304 @@
1
+ // import { LineStripProgramCache } from "../../../programs/line-on-globe/linestrip"
2
+ // import "../../../programs/interface";
3
+
4
+ // import { createBufferAndReadInfo } from '../../../util/gl-util/buffer/attribute-loader';
5
+ // import { populateFloat32Array } from "../../../util/jshelpers/data-filler";
6
+ // import { BufferManagement, BufferManager, BufferOrchestrator } from "../../../util/account/single-attribute-buffer-management/index";
7
+ // import { globe3Dcoordinates, globe2Dcoordinates, RADIANS } from "../../../Math/methods";
8
+ // import { Vector3D } from "../../../Math/vector3d";
9
+ // import { Arc } from "../../../Math/arc";
10
+ // import { Plane } from "../../../Math/plane";
11
+ // import { arcFrustumPlanesIntersection } from "../../../Math/intersections/arc-frustum-planes";
12
+
13
+ // import { CameraUniformBlockTotemCache, CameraUniformBlockTotem } from "../../../programs/totems/camerauniformblock";
14
+ // import { FrustumPlanes } from "../../../Math/frustum/types";
15
+ // const VERTEX_COUNT = 360;
16
+ // const INITAL_CAPACITY = 10;
17
+ // const _0vector = new Vector3D();
18
+ // const _0arc = new Arc();
19
+
20
+ // // window add properties
21
+ // declare global {
22
+ // interface Window {
23
+ // startPoint: Vector3D;
24
+ // endPoint: Vector3D;
25
+ // }
26
+ // }
27
+
28
+ // let interval = 1;
29
+
30
+ // const testVec = new Vector3D(0, 0, 1);
31
+ // testVec.setFromLongLat(30 * RADIANS, 30 * RADIANS);
32
+ // console.log("testVec", testVec.x, testVec.y, testVec.z);
33
+
34
+ // testVec.setFromLongLat(50 * RADIANS, 50 * RADIANS);
35
+ // console.log("testVec", testVec.x, testVec.y, testVec.z);
36
+
37
+
38
+ // export class NaiveLineOnTerrainPlugin {
39
+ // public id: string;
40
+ // private program: ProgramInterface;
41
+ // private _bufferManagersCompMap: BufferManagement;
42
+ // private _bufferManagersCompMapTest: BufferManagement;
43
+ // private _bufferOrchestrator: BufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
44
+ // private _testOrchestrator: BufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
45
+ // private _opacity: number = 1;
46
+ // private _arcUBOHandler: UBOHandler;
47
+ // private _vao: WebGLVertexArrayObject;
48
+ // private _vaoAllTest: WebGLVertexArrayObject;
49
+ // private _ubohandlerAllTest: UBOHandler;
50
+ // private globe: any;
51
+ // private gl: WebGL2RenderingContext;
52
+ // private _arcMap: Map<string, Arc>;
53
+ // private _arcMapTest: Map<string, Arc>;
54
+ // private _screenPlane: Plane = new Plane();
55
+ // private _doBuild: boolean = false
56
+ // private _cameraUniformBlock: CameraUniformBlockTotem;
57
+ // public fieldOfView = 50 * RADIANS; // 50 degrees in radians
58
+
59
+ // constructor(id: string) {
60
+ // this.id = id;
61
+ // this._arcMap = new Map();
62
+ // this._arcMapTest = new Map();
63
+ // }
64
+
65
+
66
+
67
+ // insertArcFromLongLat(key: string, startPoint: { long: number, lat: number }, endPoint: { long: number, lat: number }) {
68
+ // if (this._arcMap.has(key)) {
69
+ // this._arcMap.delete(key);
70
+ // }
71
+ // const start = _0vector.setFromLongLat(startPoint.long * RADIANS, startPoint.lat * RADIANS).clone();
72
+ // const end = _0vector.setFromLongLat(endPoint.long * RADIANS, endPoint.lat * RADIANS).clone();
73
+
74
+
75
+
76
+ // window.startPoint = start;
77
+ // window.endPoint = end;
78
+ // const arc = new Arc(start, end);
79
+ // this._arcMap.set(key, arc);
80
+ // this._arcMapTest.set(key, arc.clone());
81
+ // const longLatArr = new Float32Array(2 * VERTEX_COUNT);
82
+ // const _3Dpoints = arc.populatePoints3D(VERTEX_COUNT);
83
+ // const longLat = {
84
+ // long: 1,
85
+ // lat: 1
86
+ // };
87
+ // for (let i = 0; i < _3Dpoints.length / 3; i++) {
88
+ // _0vector.set(_3Dpoints[i * 3], _3Dpoints[i * 3 + 1], _3Dpoints[i * 3 + 2]).toLongLat(longLat);
89
+ // longLatArr.set([longLat.long / RADIANS, longLat.lat / RADIANS], i * 2);
90
+ // }
91
+ // const result = [{
92
+ // key: key,
93
+ // longLatArr: longLatArr,
94
+ // }
95
+ // ]
96
+ // this._testOrchestrator.insertBulk(result, this._bufferManagersCompMapTest);
97
+
98
+ // this._doBuild = true;
99
+ // }
100
+
101
+
102
+
103
+ // init(globe: any, gl: WebGL2RenderingContext) {
104
+ // this.globe = globe;
105
+ // this.gl = gl;
106
+ // this.program = LineStripProgramCache.get(globe);
107
+
108
+ // const g3D = globe3Dcoordinates(globe, 30);
109
+ // const g2D = globe2Dcoordinates(globe);
110
+ // this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
111
+ // this._bufferManagersCompMap = new Map(
112
+ // [
113
+ // ["position3d", {
114
+ // bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
115
+ // adaptor: (item: any) => {
116
+ // const { longLatArr } = item;
117
+ // const result = g3D(longLatArr, { paddingCount: 1 });
118
+ // // console.log("result", result);
119
+ // return result;
120
+ // }
121
+ // }],
122
+ // ["position2d", {
123
+ // bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
124
+ // adaptor: (item: any) => {
125
+ // const { longLatArr } = item;
126
+ // return g2D(longLatArr, { paddingCount: 1 });
127
+ // }
128
+ // }
129
+ // ],
130
+ // ]
131
+ // );
132
+
133
+ // this._bufferManagersCompMapTest = new Map([
134
+ // ["positionTest3d", {
135
+ // bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
136
+ // adaptor: (item: any) => {
137
+ // const { longLatArr } = item;
138
+ // const result = g3D(longLatArr, { paddingCount: 1 });
139
+ // return result;
140
+ // }
141
+ // }],
142
+ // ["positionTest2d", {
143
+ // bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
144
+ // adaptor: (item: any) => {
145
+ // const { longLatArr } = item;
146
+ // return g2D(longLatArr, { paddingCount: 1 });
147
+ // }
148
+ // }
149
+ // ]
150
+ // ]
151
+ // );
152
+
153
+ // this._bufferOrchestrator = new BufferOrchestrator(gl, this._bufferManagersCompMap);
154
+
155
+ // this._arcUBOHandler = this.program.createUBO();
156
+ // this._arcUBOHandler.update(new Map([
157
+ // ["u_color", new Float32Array([1, 0, 0, 1])],
158
+ // ]));
159
+ // this._ubohandlerAllTest = this.program.createUBO();
160
+ // this._ubohandlerAllTest.update(new Map([
161
+ // ["u_color", new Float32Array([0, 0, 1, 1])],
162
+ // ]));
163
+
164
+ // this._vao = this.program.createVAO(
165
+ // createBufferAndReadInfo(this._bufferManagersCompMap.get("position3d").bufferManager.buffer),
166
+ // createBufferAndReadInfo(this._bufferManagersCompMap.get("position2d").bufferManager.buffer),
167
+ // null,
168
+ // null,
169
+ // null,
170
+ // );
171
+ // this._vaoAllTest = this.program.createVAO(
172
+ // createBufferAndReadInfo(this._bufferManagersCompMapTest.get("positionTest3d").bufferManager.buffer),
173
+ // createBufferAndReadInfo(this._bufferManagersCompMapTest.get("positionTest2d").bufferManager.buffer),
174
+ // null,
175
+ // null,
176
+ // null,
177
+ // );
178
+ // }
179
+
180
+ // setFieldOfView(fieldOfView: number) {
181
+ // this.fieldOfView = fieldOfView * RADIANS; // convert degrees to radians
182
+ // this.globe.DrawRender();
183
+ // }
184
+
185
+
186
+
187
+ // _buildArcs() {
188
+ // // updatePlane
189
+ // const { globe, _arcMap } = this;
190
+
191
+ // const planes = this._cameraUniformBlock.getFrustumPlanes() as FrustumPlanes;
192
+ // //
193
+
194
+ // const cameraPostition = new Vector3D();
195
+ // cameraPostition.copy(globe.Fp as Vector3D).normalize();
196
+ // // calculateHorizonPlane(globe, _screenPlane, this.fieldOfView);
197
+
198
+ // const result = [];
199
+ // const longLat = {
200
+ // long: 1,
201
+ // lat: 1
202
+ // }
203
+
204
+ // let counter = 0;
205
+ // for (const [key, arc] of _arcMap) {
206
+ // // const isArc = arc.intersectionMedium(_screenPlane, _0arc) as Arc;
207
+ // _0arc.copy(arc);
208
+
209
+ // const isArc = arcFrustumPlanesIntersection(_0arc, planes, _0arc);
210
+
211
+ // if (!isArc) {
212
+ // continue;
213
+ // }
214
+ // counter++;
215
+ // const longLatArr = new Float32Array(2 * VERTEX_COUNT);
216
+ // // const _3Dpoints = _0arc.populatePoints3DInRespectToCamera(cameraPostition, VERTEX_COUNT);
217
+ // const _3Dpoints = _0arc.populatePoints3D(VERTEX_COUNT);
218
+
219
+ // for (let i = 0; i < _3Dpoints.length / 3; i++) {
220
+ // _0vector.set(_3Dpoints[i * 3], _3Dpoints[i * 3 + 1], _3Dpoints[i * 3 + 2]).toLongLat(longLat);
221
+ // longLatArr.set([longLat.long / RADIANS, longLat.lat / RADIANS], i * 2);
222
+ // }
223
+
224
+ // result.push({
225
+ // key: key,
226
+ // longLatArr: longLatArr,
227
+ // });
228
+
229
+ // // if (!arc.imaginaryPlane.equals(_0arc.imaginaryPlane) || !arc.imaginaryPlane.equalsReverseOriantation(_0arc.imaginaryPlane)) {
230
+ // // // console.log("Arc with key", key, "has imaginary plane equal to the original arc's imaginary plane.");
231
+ // // throw new Error("The arc segment is not on the parent arc")
232
+ // // }
233
+ // }
234
+ // interval += 1;
235
+ // if (interval === 100) {
236
+ // interval = 1;
237
+ // console.log("Arc count on screen:", counter);
238
+ // }
239
+ // // update buffer
240
+ // this._bufferOrchestrator.resetWithCapacity(this._bufferManagersCompMap, result.length);
241
+
242
+ // this._bufferOrchestrator.insertBulk(result, this._bufferManagersCompMap);
243
+
244
+ // this._doBuild = false;
245
+ // this._checkIfCorrupted(); // check if any arc is corrupted
246
+
247
+ // }
248
+
249
+
250
+ // draw3D() {
251
+ // // Drawing logic here
252
+ // this._buildArcs() // can be async
253
+ // const { gl, program, _bufferOrchestrator } = this;
254
+
255
+ // gl.disable(gl.DEPTH_TEST);
256
+
257
+
258
+
259
+ // const drawOptionTest = {
260
+ // drawRange: {
261
+ // first: 0,
262
+ // count: this._testOrchestrator.length * (VERTEX_COUNT + 1)
263
+ // },
264
+ // indexes: null
265
+ // }
266
+
267
+ // program.draw(
268
+ // this._vaoAllTest,
269
+ // drawOptionTest,
270
+ // this._opacity,
271
+ // this._ubohandlerAllTest
272
+ // );
273
+
274
+
275
+ // const drawOptions = {
276
+ // drawRange: {
277
+ // first: 0,
278
+ // count: _bufferOrchestrator.length * (VERTEX_COUNT + 1)
279
+ // },
280
+ // indexes: null
281
+ // }
282
+
283
+ // program.draw(
284
+ // this._vao,
285
+ // drawOptions,
286
+ // this._opacity,
287
+ // this._arcUBOHandler
288
+ // );
289
+
290
+
291
+ // gl.enable(gl.DEPTH_TEST);
292
+ // }
293
+
294
+ // _checkIfCorrupted() {
295
+ // for (const [key, arc] of this._arcMap) {
296
+ // if (!arc.p0.equals(arc.p1)) {
297
+ // continue; // valid arc
298
+ // }
299
+ // console.warn(`Arc with key ${key} is corrupted: p0 and p1 are the same point.`);
300
+ // // this._arcMap.delete(key);
301
+ // // this._arcMapTest.delete(key);
302
+ // }
303
+ // }
304
+ // }