@pirireis/webglobeplugins 0.14.0-alpha → 0.15.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.14.0-alpha",
3
+ "version": "0.15.0-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -149,7 +149,7 @@ export class LineProgram {
149
149
  cameraBlockTotem.bind(uniformBindingPoints.camera);
150
150
  ubo.bind();
151
151
  gl.bindVertexArray(vao);
152
- drawArrays(gl, gl.POINTS, drawOptions);
152
+ // drawArrays(gl, gl.POINTS, drawOptions);
153
153
  drawArrays(gl, gl.LINE_STRIP, drawOptions);
154
154
  gl.bindVertexArray(null);
155
155
  ubo.unbind();
@@ -0,0 +1 @@
1
+ "use strict";
@@ -124,7 +124,6 @@ export class CircleLineChainPlugin {
124
124
  // Reconstruct chains
125
125
  this._reconstructChains(chainKeys);
126
126
  // Update texts
127
- console.log("insertBulk", chainKeys, textWriterIDs);
128
127
  this._updateTexts(chainKeys, textWriterIDs);
129
128
  this.globe?.DrawRender();
130
129
  }
@@ -335,16 +334,16 @@ export class CircleLineChainPlugin {
335
334
  switch (currentGeometry) {
336
335
  case 0: {
337
336
  // globe view
338
- const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
339
- if (arcOpacity !== 0) {
340
- this.arcPlugin?.setPluginOpacity(arcOpacity);
341
- this.arcPlugin?.draw3D();
342
- }
343
337
  const lineOpacity = getOpacity(this._opacities, "globeArc");
344
338
  if (lineOpacity !== 0) {
345
339
  this.linePlugin?.setPluginOpacity(lineOpacity);
346
340
  this.linePlugin?.draw3D();
347
341
  }
342
+ const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
343
+ if (arcOpacity !== 0) {
344
+ this.arcPlugin?.setPluginOpacity(arcOpacity);
345
+ this.arcPlugin?.draw3D();
346
+ }
348
347
  break;
349
348
  }
350
349
  case 1: {
@@ -6,7 +6,7 @@
6
6
  // color: rangeRing.rgba as Color,
7
7
  // altitude: rangeRing.altitude,
8
8
  // };
9
- // }
9
+ // }
10
10
  export const rangeRingToCircleInputAdapter = (rangeRing) => {
11
11
  return rangeRing.rings.map(ring => ({
12
12
  key: ring.rindID,
@@ -49,7 +49,7 @@ export class ArcOnTerrainPlugin {
49
49
  defaultColor: defaultColor ? defaultColor : [0.1, 0.1, 1, 1],
50
50
  defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
51
51
  vertexCount: vertexCount ? vertexCount : 70,
52
- cameraAttractionIsOn: cameraAttractionIsOn ? cameraAttractionIsOn : true
52
+ cameraAttractionIsOn: cameraAttractionIsOn ? true : false
53
53
  };
54
54
  }
55
55
  insertBulk(arcs) {
@@ -41,21 +41,25 @@ export const chargerAdaptor = (chargerInput, plugin, padding) => {
41
41
  export class PaddingPlugin {
42
42
  id;
43
43
  arcPlugin;
44
+ globe = null;
44
45
  _memory = new Map();
45
46
  isFreed = false;
46
- constructor(id) {
47
+ constructor(id, { variativeColorsOn = true, defaultColor = [1, 1, 1, 1], defaultHeightFromGroundIn3D = 30.0, vertexCount = EDGE_COUNT } = {}) {
47
48
  this.id = id;
48
49
  this.arcPlugin = new ArcOnTerrainPlugin(id, {
49
50
  cameraAttractionIsOn: false,
50
- vertexCount: EDGE_COUNT,
51
+ vertexCount: vertexCount,
52
+ variativeColorsOn: variativeColorsOn,
53
+ defaultColor: defaultColor,
54
+ defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D,
51
55
  });
52
56
  }
53
- insertBulk(items, globe) {
57
+ insertBulk(items) {
54
58
  for (const padding of items) {
55
59
  this.__delete(padding.key);
56
60
  this._memory.set(padding.key, padding);
57
61
  }
58
- const arcInputs = items.flatMap(padding => adapterPadding2Arc(globe, padding));
62
+ const arcInputs = items.flatMap(padding => adapterPadding2Arc(this.globe, padding));
59
63
  this.arcPlugin.insertBulk(arcInputs);
60
64
  }
61
65
  deleteBulk(keys) {
@@ -82,6 +86,7 @@ export class PaddingPlugin {
82
86
  }
83
87
  }
84
88
  init(globe, gl) {
89
+ this.globe = globe;
85
90
  this.arcPlugin.init(globe, gl);
86
91
  }
87
92
  draw3D() {
@@ -0,0 +1,85 @@
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
+ // }
@@ -212,7 +212,7 @@ export function decodeBase64(data) {
212
212
  */
213
213
  export function createImageFromBase64(encodedData) {
214
214
  const bytes = decodeBase64(encodedData);
215
- const blob = new Blob([bytes.buffer], { type: "image/png" });
215
+ const blob = new Blob([bytes], { type: "image/png" });
216
216
  const urlCreator = window.URL || window.webkitURL;
217
217
  const imageUrl = urlCreator.createObjectURL(blob);
218
218
  const image = new Image();