@pirireis/webglobeplugins 0.15.0-alpha → 0.15.1-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.0-alpha",
3
+ "version": "0.15.1-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -252,6 +252,24 @@ export class CircleLineChainPlugin {
252
252
  this._updateTexts(chainKeys, textWriterIDs);
253
253
  this.globe?.DrawRender();
254
254
  }
255
+ setDefaultSemiPluginColor(semiPluginName, color) {
256
+ switch (semiPluginName) {
257
+ case "circleOnTerrain":
258
+ this._semiPluginOptions.circleOnTerrainOptions.defaultColor = color;
259
+ this.circlePlugin?.setDefaultColor(color);
260
+ break;
261
+ case "arcOnTerrain":
262
+ this._semiPluginOptions.arcOnTerrainOptions.defaultColor = color;
263
+ this.arcPlugin?.setDefaultColor(color);
264
+ break;
265
+ case "line":
266
+ this._semiPluginOptions.lineOptions.defaultColor = color;
267
+ this.linePlugin?.setDefaultColor(color);
268
+ break;
269
+ default:
270
+ throw new Error(`Unknown semi-plugin name: ${semiPluginName}`);
271
+ }
272
+ }
255
273
  // IMPLICIT METHODS
256
274
  _checktextWritersMap(textWritersMap) {
257
275
  if (!(textWritersMap instanceof Map))
@@ -81,6 +81,15 @@ export class LinePlugin {
81
81
  this._options.defaultColor[3] = opacity; // Update the default color's alpha channel
82
82
  this.globe?.DrawRender();
83
83
  }
84
+ setDefaultColor(color) {
85
+ if (!this.globe || !this.gl) {
86
+ console.warn("Globe or WebGL context is not initialized.");
87
+ return;
88
+ }
89
+ this._options.defaultColor = color;
90
+ this._uboHandler?.updateSingle("u_color", new Float32Array(color));
91
+ this.globe?.DrawRender();
92
+ }
84
93
  // GLOBE INTERACTION METHODS
85
94
  draw3D() {
86
95
  if (this._freed) {
@@ -112,6 +112,15 @@ export class ArcOnTerrainPlugin {
112
112
  this._opacity = opacity;
113
113
  this.globe.DrawRender();
114
114
  }
115
+ setDefaultColor(color) {
116
+ if (!this.globe || !this.gl) {
117
+ console.warn("Globe or WebGL context is not initialized.");
118
+ return;
119
+ }
120
+ this._options.defaultColor = color;
121
+ this._arcUBOHandler?.updateSingle("u_color", new Float32Array(color));
122
+ this.globe.DrawRender();
123
+ }
115
124
  setCameraAttraction(isOn) {
116
125
  if (!this.globe || !this.gl) {
117
126
  console.warn("Globe or WebGL context is not initialized.");
@@ -177,6 +177,14 @@ export class CircleOnTerrainPlugin {
177
177
  this._opacity = opacity;
178
178
  this.globe.DrawRender();
179
179
  }
180
+ setDefaultColor(color) {
181
+ if (!this.globe || !this.gl) {
182
+ console.warn("Globe or WebGL context is not initialized.");
183
+ return;
184
+ }
185
+ this._circleUBOHandler?.updateSingle("u_color", new Float32Array(color));
186
+ this.globe.DrawRender();
187
+ }
180
188
  // IMPLICIT METHODS
181
189
  _buildCircles() {
182
190
  // @ts-ignore
@@ -211,8 +211,8 @@ export function decodeBase64(data) {
211
211
  * @returns An HTMLImageElement with the image data loaded.
212
212
  */
213
213
  export function createImageFromBase64(encodedData) {
214
- const bytes = decodeBase64(encodedData);
215
- const blob = new Blob([bytes], { type: "image/png" });
214
+ const source = decodeBase64(encodedData).buffer;
215
+ const blob = new Blob([source], { type: "image/png" });
216
216
  const urlCreator = window.URL || window.webkitURL;
217
217
  const imageUrl = urlCreator.createObjectURL(blob);
218
218
  const image = new Image();