@pirireis/webglobeplugins 0.15.14-alpha → 0.15.16-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.15.14-alpha",
3
+ "version": "0.15.16-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -29,24 +29,14 @@ uniform float u_opacity;
29
29
  in vec3 position3d;
30
30
  in vec2 position2d;
31
31
  in vec4 color;
32
- // in float dash_length;
33
- // in float dash_opacity;
34
-
35
- // out float v_dash_length;
36
- // out float v_dash_opacity;
37
32
  out vec4 v_color;
38
33
 
39
34
  flat out vec3 v_flat_position;
40
35
  out vec3 v_position;
41
36
 
42
37
  void main() {
43
-
44
38
  v_color = ( color.r == -1.0 ) ? u_color : color;
45
39
  v_color.a *= u_opacity;
46
-
47
- // v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
48
- // v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
49
-
50
40
  if ( is3D ) {
51
41
  gl_Position = cartesian3DToGLPosition( position3d );
52
42
  v_position = position3d;
@@ -73,18 +63,8 @@ in vec3 v_position;
73
63
  out vec4 outColor;
74
64
 
75
65
  void main() {
76
- outColor = v_color;
77
- return;
78
- // float dash_length = v_dash_length;
79
- // float dash_opacity = v_dash_opacity;
66
+ outColor = vec4( v_color.rgb, v_color.a );
80
67
 
81
- // if ( dash_length == 0.0 ) {
82
- outColor = vec4( v_color.rgb, v_color.a );
83
- // } else {
84
- // float dist = distance( v_flat_position, v_position );
85
- // // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
86
- // outColor = vec4( 1.0, 1.0, 1.0, v_color.a * opacity *alpha);
87
- // }
88
68
  }`;
89
69
  export class LineProgram {
90
70
  _vaosPublished = [];
@@ -110,8 +90,6 @@ export class LineProgram {
110
90
  this.gl.bindAttribLocation(this.program, 0, "position3d");
111
91
  this.gl.bindAttribLocation(this.program, 1, "position2d");
112
92
  this.gl.bindAttribLocation(this.program, 2, "color");
113
- // this.gl.bindAttribLocation(this.program, 3, "dash_length");
114
- // this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
115
93
  this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
116
94
  this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
117
95
  flexibleBlockManager.assignBindingPoint(this.gl, this.program);
@@ -123,16 +101,13 @@ export class LineProgram {
123
101
  this._ubosPublished.push(ubo);
124
102
  return ubo;
125
103
  }
126
- createVAO(position3D, position2D, color //, dashLength: BufferAndReadInfo, dashOpacity: BufferAndReadInfo,
127
- ) {
104
+ createVAO(position3D, position2D, color) {
128
105
  const { gl } = this;
129
106
  const vao = gl.createVertexArray();
130
107
  gl.bindVertexArray(vao);
131
108
  attributeLoader(gl, position3D, 0, 3);
132
109
  attributeLoader(gl, position2D, 1, 2);
133
110
  attributeLoader(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
134
- // attributeLoader(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
135
- // attributeLoader(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
136
111
  gl.bindVertexArray(null);
137
112
  return vao;
138
113
  }
@@ -110,7 +110,7 @@ export class BearingLinePlugin {
110
110
  this._textWritersMap = textWritersMap || new Map();
111
111
  this._textWritersMap.forEach((writer) => writer.setKeyAdaptor((item) => item.key));
112
112
  this._textDataPreAdaptor = textDataPreAdaptor || ((item) => item);
113
- this.circlePlugin = new CircleOnTerrainPlugin(id + "_circle");
113
+ this.circlePlugin = new CircleOnTerrainPlugin(id + "_circle", this._semiPluginsOptions.circleOnTerrainOptions);
114
114
  this.arcPlugin = new ArcOnTerrainPlugin(id + "_arc", {
115
115
  ...this._semiPluginsOptions.arcOnTerrainOptions,
116
116
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -73,10 +73,11 @@ export class CircleOnTerrainPlugin {
73
73
  defaultColor: [0.1, 0.1, 0.1, 1], // Default color in RGBA format
74
74
  defaultHeightFromGroundIn3D: 30.0
75
75
  };
76
- constructor(id, styleOptions = {}) {
76
+ constructor(id, styleOptions = null) {
77
77
  this.id = id;
78
- this._styleOptions = { ...this._styleOptions, ...styleOptions };
79
- this._styleOptions.defaultColor = new Float32Array(this._styleOptions.defaultColor);
78
+ if (styleOptions) {
79
+ this._styleOptions = { ...this._styleOptions, ...styleOptions };
80
+ }
80
81
  }
81
82
  init(globe, gl) {
82
83
  this.globe = globe;
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ // // One Degree Padding
3
+ // /**
4
+ // * 2d coordinates are loaded ones
5
+ // * 3d coordinates are calculated on the fly.
6
+ // *
7
+ // * 2d paddings are fixed size
8
+ // * 3d paddings gets shortened as lod increases
9
+ // *
10
+ // * color buffer is shared and does not change on unless insert or delete
11
+ // * changing color can be done by re inserting
12
+ // *
13
+ // *
14
+ // *
15
+ // */
16
+ // import { Globe, LongLat, Meter, Color, BUFFER_TYPE, UBOHandler } from '../../types';
17
+ // import { BufferManagersMap } from '../../util/account/single-attribute-buffer-management/types';
18
+ // import { BufferManager } from '../../util/account/single-attribute-buffer-management/buffer-manager';
19
+ // import { BufferOrchestrator } from '../../util/account/single-attribute-buffer-management/buffer-orchestrator';
20
+ // import { LineStripProgramCache, LineProgram } from '../../programs/line-on-globe/linestrip/linestrip';
21
+ // import { ProgramInterface } from '../../types';
22
+ // import { SemiPluginInterface } from '../interface';
23
+ // export type Padding1DegreeInput = {
24
+ // key: string;
25
+ // center: LongLat;
26
+ // outerRadius: Meter;
27
+ // heightFromGroundIn3D?: Meter; // optional, if not provided, defaultHeightFromGroundIn3D will be used
28
+ // color: Color;
29
+ // };
30
+ // export type Padding1DegreeOptions = {
31
+ // bufferType: BUFFER_TYPE;
32
+ // variativeColorsOn: boolean;
33
+ // defaultColor: Color;
34
+ // defaultHeightFromGroundIn3D: Meter;
35
+ // }
36
+ // const initialCapacity = 2; // initial capacity for the buffer managers
37
+ // // const _float32Array = new Float32Array(360 * 3 * 2).fill(NaN);
38
+ // export class Paddings1Degree implements ProgramInterface, SemiPluginInterface {
39
+ // id: string;
40
+ // private globe: Globe | null = null;
41
+ // private bufferOrchestrator: BufferOrchestrator;
42
+ // private bufferManagersMap: BufferManagersMap;
43
+ // private lineProgram: LineProgram | null = null;
44
+ // private _LODCoeffecientForPaddingScale: number = 1;
45
+ // private _PaddingSizeRatio = 0.1; // 0.1 means 10% of the padding size is used for 3d padding
46
+ // private _innerPaddingRatio = 0.9; //
47
+ // private _float32Array: Float32Array | null = null; // this is used to forward the data to the buffer manager
48
+ // private _uboHandler: UBOHandler | null = null; // this is used to forward the data to the shader program
49
+ // private _bufferNames: string[] = ["position2d", "position3d"];
50
+ // private _options: Padding1DegreeOptions = {
51
+ // bufferType: "STATIC_DRAW",
52
+ // variativeColorsOn: false,
53
+ // defaultColor: [1, 1, 1, 1], // white color
54
+ // defaultHeightFromGroundIn3D: 0.1, // 10 cm from ground
55
+ // };
56
+ // constructor(id: string, options: Padding1DegreeOptions | null = null) {
57
+ // this.id = id;
58
+ // this.bufferManagersMap = new Map();
59
+ // this.lineProgram = null;
60
+ // this._options = options ? { ...this._options, ...options } : this._options;
61
+ // this.bufferOrchestrator = new BufferOrchestrator()
62
+ // if (this._options.variativeColorsOn) {
63
+ // this._bufferNames.push("color");
64
+ // }
65
+ // }
66
+ // insertBulk(data: Padding1DegreeInput[]): void {
67
+ // if (this.globe === null) {
68
+ // throw new Error("Globe is not initialized");
69
+ // }
70
+ // // create floa32array
71
+ // this._float32Array = new Float32Array(360 * 4 * 4); // largest float32Array
72
+ // this.bufferOrchestrator.insertBulk(data, this.bufferManagersMap, this._bufferNames);
73
+ // this.globe?.DrawRender();
74
+ // }
75
+ // init(globe: Globe): void {
76
+ // this.globe = globe;
77
+ // this.lineProgram = LineStripProgramCache.get(globe);
78
+ // const bufferManagersMap = new Map(
79
+ // [
80
+ // ["position2d", {
81
+ // bufferManager: new BufferManager(globe.gl as WebGL2RenderingContext,
82
+ // 360 * 2 * 3, // plus 1 to cut
83
+ // { bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
84
+ // adaptor: (PaddingInput: Padding1DegreeInput) => {
85
+ // if (this._float32Array === null) {
86
+ // throw new Error("Float32Array is not initialized");
87
+ // } else {
88
+ // this._float32Array.fill(NaN); // reset the float32Array
89
+ // }
90
+ // for (let i = 0; i < 360; i++) {
91
+ // let { long, lat } = globe.Math.FindPointByPolar(
92
+ // PaddingInput.center[0], // center long
93
+ // PaddingInput.center[1], // center lat
94
+ // PaddingInput.outerRadius, // outer radius
95
+ // i, // angle
96
+ // );
97
+ // let coords = globe.api_GetMercator2DPoint(long, lat);
98
+ // // fill the second coordinate with 0
99
+ // this._float32Array[i * 3] = coords[0];
100
+ // this._float32Array[i * 3 + 1] = coords[1];
101
+ // ({ long, lat } = globe.Math.FindPointByPolar(
102
+ // PaddingInput.center[0], // center long
103
+ // PaddingInput.center[1], // center lat
104
+ // PaddingInput.outerRadius * this._innerPaddingRatio, // inner radius
105
+ // i, // angle
106
+ // ));
107
+ // let innerCoords = globe.api_GetMercator2DPoint(long, lat);
108
+ // // fill the second coordinate with 0
109
+ // this._float32Array[i * 3 + 2] = innerCoords[0];
110
+ // this._float32Array[i * 3 + 3] = innerCoords[1];
111
+ // }
112
+ // return this._float32Array.subarray(0, 360 * 2 * 3);
113
+ // }
114
+ // }
115
+ // ],
116
+ // [
117
+ // "position3d", {
118
+ // bufferManager: new BufferManager(globe.gl as WebGL2RenderingContext,
119
+ // 360 * 3 * 3, // plus 1 to cut
120
+ // { bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
121
+ // adaptor: (PaddingInput: Padding1DegreeInput) => {
122
+ // if (this._float32Array === null) {
123
+ // throw new Error("Float32Array is not initialized");
124
+ // } else {
125
+ // this._float32Array.fill(NaN); // reset the float32Array
126
+ // }
127
+ // const _float32Array = this._float32Array;
128
+ // for (let i = 0; i < 360; i++) {
129
+ // const height = PaddingInput.heightFromGroundIn3D ? PaddingInput.heightFromGroundIn3D : this._options.defaultHeightFromGroundIn3D;
130
+ // let { long, lat, } = globe.Math.FindPointByPolar(
131
+ // PaddingInput.center[0], // center long
132
+ // PaddingInput.center[1], // center lat
133
+ // PaddingInput.outerRadius, // outer radius
134
+ // i, // angle
135
+ // );
136
+ // let coords = globe.api_GetCartesian3DPoint(long, lat, height, 0);
137
+ // // fill the second coordinate with 0
138
+ // _float32Array[i * 4] = coords[0];
139
+ // _float32Array[i * 4 + 1] = coords[1];
140
+ // ({ long, lat } = globe.Math.FindPointByPolar(
141
+ // PaddingInput.center[0], // center long
142
+ // PaddingInput.center[1], // center lat
143
+ // PaddingInput.outerRadius * this._innerPaddingRatio, // inner radius
144
+ // i, // angle
145
+ // ));
146
+ // let innerCoords = globe.api_GetCartesian3DPoint(long, lat, height, 0);
147
+ // // fill the second coordinate with 0
148
+ // _float32Array[i * 4 + 2] = innerCoords[0];
149
+ // _float32Array[i * 4 + 3] = innerCoords[1];
150
+ // }
151
+ // return _float32Array.subarray(0, 360 * 3 * 3);
152
+ // }
153
+ // }
154
+ // ],
155
+ // ]
156
+ // );
157
+ // if (this._options.variativeColorsOn) {
158
+ // bufferManagersMap.set(
159
+ // "color", {
160
+ // bufferManager: new BufferManager(globe.gl as WebGL2RenderingContext,
161
+ // 360 * 4 * 3, // 4 for RGBA
162
+ // { bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
163
+ // adaptor: (PaddingInput: Padding1DegreeInput) => {
164
+ // const color = PaddingInput.color || this._options.defaultColor;
165
+ // const colorArray = new Float32Array(360 * 4 * 3);
166
+ // this._float32Array = colorArray; // store for forwarding
167
+ // for (let i = 0; i < 360; i++) {
168
+ // this._float32Array[i * 4] = color[0];
169
+ // this._float32Array[i * 4 + 1] = color[1];
170
+ // this._float32Array[i * 4 + 2] = color[2];
171
+ // this._float32Array[i * 4 + 3] = color[3];
172
+ // this._float32Array[i * 4 + 4] = color[0];
173
+ // this._float32Array[i * 4 + 5] = color[1];
174
+ // this._float32Array[i * 4 + 6] = color[2];
175
+ // this._float32Array[i * 4 + 7] = color[3];
176
+ // }
177
+ // return this._float32Array.subarray(0, 360 * 4 * 3);
178
+ // }
179
+ // }
180
+ // );
181
+ // }
182
+ // this.bufferOrchestrator.resetWithCapacity(bufferManagersMap, initialCapacity);
183
+ // this._uboHandler = this.lineProgram.createUBO("STATIC_DRAW");
184
+ // this._uboHandler.updateSingle("u_color", new Float32Array(this._options.defaultColor));
185
+ // }
186
+ // // This method is called when the plugin is destroyed
187
+ // __updateLODCoefficientForPaddingScale(): void {
188
+ // // TODO: call this ones when lod changes or each frame // maybe only on 3d geometry
189
+ // }
190
+ // }
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,286 +0,0 @@
1
- import { createProgram } from "../../../util/webglobjectbuilders";
2
- import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems/index";
3
- import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
4
- import { POLE, PI, longLatRadToMercator, mercatorXYToGLPosition, longLatRadToCartesian3D, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate,
5
- //circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
6
- cartesian3DToGLPosition } from "../../../util/shaderfunctions/geometrytransformations";
7
- /**
8
- * TODO:
9
- * 1. Triangle face looks at screen. if rotation angle is positive the last vertex must be the faintest.
10
- *
11
- */
12
- const drawModeMap = Object.freeze({
13
- LINE_STRIP: 0,
14
- TRIANGLE_FAN: 1,
15
- });
16
- //${ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate }
17
- const vertexShaderSource = `#version 300 es
18
-
19
- ${CameraUniformBlockString}
20
- ${PI}
21
- ${longLatRadToMercator}
22
- ${mercatorXYToGLPosition}
23
- ${longLatRadToCartesian3D}
24
- ${circleLimpFromLongLatRadCenterCartesian3D_accurate}
25
- ${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
26
- ${cartesian3DToGLPosition}
27
-
28
- uniform float edge_count;
29
- uniform int draw_mode; // %2 => 0: LINE_STRIP, 1: TRIANGLE_FAN
30
- uniform float plugin_alpha_multiplier;
31
- //, lat, startAngle, tailAngle, ...rgba, radius, rgbaMode
32
- // in vec2 center; // long, lat in radian
33
- in vec2 center2d;
34
- in vec3 center3d;
35
- in float start_angle2d;
36
- in float tail_angle2d;
37
-
38
- in float start_angle3d;
39
- in float tail_angle3d;
40
-
41
- in vec4 color;
42
- in float radius; // in meter
43
- in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
44
- // flat out int vid;
45
- // flat out float v_phase;
46
- out vec2 v_pos;
47
- out vec4 v_color;
48
- // flat out float v_angle;
49
-
50
- void main() {
51
- // vid = gl_VertexID;
52
- if (filling_mode == 2.0 || radius == 0.0) { return; }
53
- float start_angle, tail_angle;
54
- if (is3D) {
55
- start_angle = start_angle3d;
56
- tail_angle = tail_angle3d;
57
- } else {
58
- start_angle = start_angle2d;
59
- tail_angle = tail_angle2d;
60
- }
61
- float filling_mode_ = filling_mode;
62
- if ( draw_mode == 0 && filling_mode == 1.0) {filling_mode_ = 0.0;}
63
- float vertexID = float(gl_VertexID);
64
- float radius_ = radius;
65
- float alpha = plugin_alpha_multiplier;
66
- if (draw_mode == 1) { // TRIANGLE_FAN
67
- if (gl_VertexID == 0) {
68
- radius_ = 0.0;
69
- if ( filling_mode == 1.0 ) { alpha = 0.0; }
70
- }
71
- vertexID -= 1.0;
72
- }
73
- float phase = ( vertexID / (edge_count - 1.0) );
74
- // v_angle = tail_angle;
75
-
76
- if ( filling_mode_ == 1.0 ) {
77
- if ( tail_angle < 0.0 ) {
78
- v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
79
- } else {
80
- v_color = vec4( color.rgb , color.a * phase * alpha );
81
- }
82
- } else {
83
- v_color = vec4( color.rgb , color.a * alpha );
84
- }
85
- if ( filling_mode == 0.0 && draw_mode == 1 ) {
86
- v_color.a /= 2.0;
87
- }
88
- float angle;
89
- if ( tail_angle > 0.0 ) {
90
- angle = tail_angle * (-phase + 1.0) + start_angle;
91
- } else {
92
- angle = tail_angle * phase + start_angle;
93
- }
94
- if (is3D) {
95
- vec3 pos = circleLimpFromLongLatRadCenterCartesian3D_accurate(center3d, radius_, angle);
96
- v_pos = vec2(0.0, 0.0);
97
- gl_Position = cartesian3DToGLPosition(pos);
98
- }
99
- else {
100
- vec2 pos2 = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center2d, radius_, angle);
101
- v_pos = pos2;
102
- gl_Position = mercatorXYToGLPosition(pos2);
103
- }
104
-
105
- gl_PointSize = 10.0;
106
- }`;
107
- const fragmentShaderSource = `#version 300 es` + POLE + PI + `
108
- precision highp float;
109
- // flat in int vid;
110
- in vec4 v_color;
111
- in vec2 v_pos;
112
- // flat in float v_phase;
113
- // in float v_angle;
114
- out vec4 outColor;
115
- void main() {
116
- // if( vid % 2 == 0 ) { discard; }
117
- // if ( mod(v_angle, PI / 36.0 ) < (PI / 72.0)) { discard; }
118
- // if ( mod(v_angle * v_phase, PI / 90.0 ) < (PI / 180.0)) { discard; }
119
- if ( v_pos.x < -POLE || v_pos.x > POLE || v_pos.y < -POLE || v_pos.y > POLE ) { discard; }
120
- outColor = v_color;
121
- }`;
122
- export const ITEM_SIZE = 10;
123
- export class Logic {
124
- globe;
125
- gl;
126
- _lastMode;
127
- _lastEdgeCount;
128
- _lastAlphaMultiplier;
129
- program;
130
- _edgeCountLocation;
131
- _draw_modeLocation;
132
- _plugin_alpha_multiplierLocation;
133
- cameraBlockBindingPoint;
134
- cameraBlockTotem; // Type this based on your CameraUniformBlockTotem implementation
135
- constructor(globe) {
136
- this.globe = globe;
137
- this.gl = globe.gl;
138
- this._lastMode = 0;
139
- this._lastEdgeCount = 64;
140
- this._lastAlphaMultiplier = 1.0;
141
- this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
142
- const { gl, program } = this;
143
- { // set attributes locations
144
- gl.bindAttribLocation(program, 0, 'center2d');
145
- gl.bindAttribLocation(program, 1, 'center3d');
146
- gl.bindAttribLocation(program, 2, 'start_angle2d');
147
- gl.bindAttribLocation(program, 3, 'tail_angle2d');
148
- gl.bindAttribLocation(program, 4, 'start_angle3d');
149
- gl.bindAttribLocation(program, 5, 'tail_angle3d');
150
- gl.bindAttribLocation(program, 6, 'color');
151
- gl.bindAttribLocation(program, 7, 'radius');
152
- gl.bindAttribLocation(program, 8, 'filling_mode');
153
- // vao
154
- // instanced draw read 1
155
- }
156
- { // Uniforms
157
- this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
158
- this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
159
- this._plugin_alpha_multiplierLocation = gl.getUniformLocation(program, 'plugin_alpha_multiplier');
160
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
161
- gl.useProgram(program);
162
- gl.uniform1i(this._draw_modeLocation, this._lastMode);
163
- gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
164
- gl.uniform1f(this._plugin_alpha_multiplierLocation, 1.0);
165
- this.cameraBlockBindingPoint = 0;
166
- this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
167
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
168
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
169
- gl.useProgram(currentProgram);
170
- }
171
- }
172
- draw(length, vao, edgeCount, alphaMultiplier, drawMode) {
173
- const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
174
- // gl.disable(gl.DEPTH_TEST);
175
- gl.useProgram(program);
176
- if (drawModeMap[drawMode] !== this._lastMode) {
177
- gl.uniform1i(this._draw_modeLocation, drawModeMap[drawMode]);
178
- this._lastMode = drawModeMap[drawMode];
179
- }
180
- if (edgeCount !== this._lastEdgeCount) {
181
- gl.uniform1f(this._edgeCountLocation, edgeCount);
182
- this._lastEdgeCount = edgeCount;
183
- }
184
- if (alphaMultiplier !== this._lastAlphaMultiplier) {
185
- gl.uniform1f(this._plugin_alpha_multiplierLocation, alphaMultiplier);
186
- this._lastAlphaMultiplier = alphaMultiplier;
187
- }
188
- const overdraw = drawModeMap[drawMode];
189
- cameraBlockTotem.bind(cameraBlockBindingPoint);
190
- gl.bindVertexArray(vao);
191
- gl.drawArraysInstanced(gl[drawMode], 0, edgeCount + overdraw, length);
192
- cameraBlockTotem.unbind(cameraBlockBindingPoint);
193
- gl.bindVertexArray(null);
194
- // gl.enable(gl.DEPTH_TEST);
195
- }
196
- free() {
197
- noRegisterGlobeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
198
- this.gl.deleteProgram(this.program);
199
- this.program = null;
200
- }
201
- /**
202
- * in vec2 center; // long, lat in radian
203
- in float start_angle; // the start of partial circle from bearing point
204
- in float tail_angle; // the rotation of the partial circle
205
- in vec4 color;
206
- in float radius; // in meter
207
- in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
208
- */
209
- createVAO(center2dObj, center3dObj, startAngle2DObj, tailAngle2DObj, startAngle3DObj, tailAngle3DObj, colorObj, radiusObj, colorModeObj) {
210
- const { gl } = this;
211
- const vao = gl.createVertexArray();
212
- gl.bindVertexArray(vao);
213
- {
214
- const { buffer, stride, offset } = center2dObj;
215
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
216
- gl.enableVertexAttribArray(0);
217
- gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
218
- gl.vertexAttribDivisor(0, 1);
219
- }
220
- {
221
- const { buffer, stride, offset } = center3dObj;
222
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
223
- gl.enableVertexAttribArray(1);
224
- gl.vertexAttribPointer(1, 3, gl.FLOAT, false, stride, offset);
225
- gl.vertexAttribDivisor(1, 1);
226
- }
227
- {
228
- const { buffer, stride, offset } = startAngle2DObj;
229
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
230
- gl.enableVertexAttribArray(2);
231
- gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
232
- gl.vertexAttribDivisor(2, 1);
233
- }
234
- {
235
- const { buffer, stride, offset } = tailAngle2DObj;
236
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
237
- gl.enableVertexAttribArray(3);
238
- gl.vertexAttribPointer(3, 1, gl.FLOAT, false, stride, offset);
239
- gl.vertexAttribDivisor(3, 1);
240
- }
241
- {
242
- const { buffer, stride, offset } = startAngle3DObj;
243
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
244
- gl.enableVertexAttribArray(4);
245
- gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
246
- gl.vertexAttribDivisor(4, 1);
247
- }
248
- {
249
- const { buffer, stride, offset } = tailAngle3DObj;
250
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
251
- gl.enableVertexAttribArray(5);
252
- gl.vertexAttribPointer(5, 1, gl.FLOAT, false, stride, offset);
253
- gl.vertexAttribDivisor(5, 1);
254
- }
255
- {
256
- const { buffer, stride, offset } = colorObj;
257
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
258
- gl.enableVertexAttribArray(6);
259
- gl.vertexAttribPointer(6, 4, gl.FLOAT, false, stride, offset);
260
- gl.vertexAttribDivisor(6, 1);
261
- }
262
- {
263
- const { buffer, stride, offset } = radiusObj;
264
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
265
- gl.enableVertexAttribArray(7);
266
- gl.vertexAttribPointer(7, 1, gl.FLOAT, false, stride, offset);
267
- gl.vertexAttribDivisor(7, 1);
268
- }
269
- {
270
- const { buffer, stride, offset } = colorModeObj;
271
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
272
- gl.enableVertexAttribArray(8);
273
- gl.vertexAttribPointer(8, 1, gl.FLOAT, false, stride, offset);
274
- gl.vertexAttribDivisor(8, 1);
275
- }
276
- gl.bindVertexArray(null);
277
- gl.bindBuffer(gl.ARRAY_BUFFER, null);
278
- return vao;
279
- }
280
- createUBO() {
281
- }
282
- }
283
- export const PieceOfPieProgramCache = Object.freeze({
284
- get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
285
- release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
286
- });
@@ -1,85 +0,0 @@
1
- "use strict";
2
- // // One Degree Padding
3
- // /**
4
- // * 2d coordinates are loaded ones
5
- // * 3d coordinates are calculated on the fly.
6
- // *
7
- // * 2d paddings are fixed size
8
- // * 3d paddings gets shortened as lod increases
9
- // *
10
- // * color buffer is shared and does not change on unless insert or delete
11
- // * changing color can be done by re inserting
12
- // *
13
- // *
14
- // *
15
- // */
16
- // import { Globe, LongLat, Meter, Color } from '../../types';
17
- // import { BufferManagersMap } from '../../util/account/single-attribute-buffer-management/types';
18
- // import { BufferManager } from '../../util/account/single-attribute-buffer-management/buffer-manager';
19
- // import { BufferOrchestrator } from '../../util/acconut/single-attribute-buffer-management/buffer-orchestrator';
20
- // import { LineStripProgramCache, LineProgram } from '../../programs/line-on-globe/linestrip/linestrip';
21
- // import { ProgramInterface } from '../../types';
22
- // export type OneDegreePaddingInput = {
23
- // key: string;
24
- // center: LongLat;
25
- // outerRadius: Meter;
26
- // color: Color;
27
- // };
28
- // const _float32Array = new Float32Array(360 * 3 * 2).fill(NaN);
29
- // export class Paddings1Degree implements ProgramInterface {
30
- // id: string;
31
- // private globe: Globe | null = null;
32
- // private bufferOrchestrator: BufferOrchestrator;
33
- // private bufferManagersMap: BufferManagersMap;
34
- // private lineProgram: LineProgram | null = null;
35
- // private _LODCoeffecientForPaddingScale: number = 1;
36
- // private _PaddingSizeRatio = 0.1; // 0.1 means 10% of the padding size is used for 3d padding
37
- // private _finalPaddingSizeRatio = 0.1; // this._LODCoefficientForPaddingScale * this._PaddingSizeRatio; // final padding size ratio is the product of LOD coefficient and padding size ratio
38
- // constructor(id: string, { capacity = 1000 } = {}) {
39
- // this.id = id;
40
- // this.bufferOrchestrator = new BufferOrchestrator({ capacity });
41
- // this.bufferManagersMap = new Map();
42
- // this.lineProgram = null;
43
- // }
44
- // init(globe: Globe): void {
45
- // this.globe = globe;
46
- // this.lineProgram = LineStripProgramCache.get(globe);
47
- // }
48
- // __updateLODCoefficientForPaddingScale(): void {
49
- // // TODO: call this ones when lod changes or each frame // maybe only on 3d geometry
50
- // }
51
- // __fillBufferManagersMap() {
52
- // const globe = this.globe as Globe;
53
- // const gl = globe.gl as WebGL2RenderingContext;
54
- // this.bufferManagersMap.set("position2d", {
55
- // bufferManager: new BufferManager(gl,
56
- // 360 * (2 + 1), // plus 1 to cut
57
- // { bufferType: "STATIC_DRAW", initialCapacity: 10 }),
58
- // adaptor: (PaddingInput: OneDegreePaddingInput) => {
59
- // for (let i = 0; i < 360; i++) {
60
- // let { long, lat } = globe.Math.FindPointByPolar(
61
- // PaddingInput.center[0], // center long
62
- // PaddingInput.center[1], // center lat
63
- // PaddingInput.outerRadius, // outer radius
64
- // i, // angle
65
- // )
66
- // let corrds = globe.api_GetMercator2DPoint(long, lat);
67
- // // fill the second coordinate with 0
68
- // _float32Array[i * 3] = corrds[0];
69
- // _float32Array[i * 3 + 1] = corrds[1];
70
- // ({ long, lat } = globe.Math.FindPointByPolar(
71
- // PaddingInput.center[0], // center long
72
- // PaddingInput.center[1], // center lat
73
- // PaddingInput.outerRadius * this._finalPaddingSizeRatio, // inner radius
74
- // i, // angle
75
- // ));
76
- // let innerCorrds = globe.api_GetMercator2DPoint(long, lat);
77
- // // fill the second coordinate with 0
78
- // _float32Array[i * 3 + 2] = innerCorrds[0];
79
- // _float32Array[i * 3 + 3] = innerCorrds[1];
80
- // }
81
- // return _float32Array;
82
- // }
83
- // });
84
- // // Other methods like draw, insertBulk, deleteBulk, etc. would go here
85
- // }