@pirireis/webglobeplugins 0.8.25 → 0.9.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/wind/plugin.js +30 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.8.25",
3
+ "version": "0.9.1",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
package/wind/plugin.js CHANGED
@@ -356,7 +356,11 @@ const windyLegendData = {
356
356
  export default class WindPlugin {
357
357
 
358
358
  /**
359
- * @param {String} id
359
+ * @param {String} id
360
+ * @param {Object} windDataMeta
361
+ * @param {number} windDataMeta.width - image width
362
+ * @param {number} windDataMeta.height - image height
363
+ * @param {Array} windDataMeta.bbox - bounding box [minLon, minLat, maxLon, maxLat]
360
364
  * @param {Object} options
361
365
  * @param {number} options.fadeOpacity - how fast the particle trails fade on each frame | between 0 - 1 | default 0.746
362
366
  * @param {number} options.speedFactor - how fast the particles move | between 0 - 1 | default 0.6
@@ -370,25 +374,28 @@ export default class WindPlugin {
370
374
  * @param {number} numParticles - number of particles | positive integer
371
375
  * @param {LegendData} options.legendData - legend data
372
376
  */
373
- constructor(id, {
374
- fadeOpacity = 0.746,
375
- speedFactor = 0.6,
376
- dropRate = 0.007,
377
- dropRateBump = 0.001,
378
- baseOpacity = 1.0,
379
- pointSize = 2.0,
380
- minSpeed = 0.0,
381
- maxSpeed = 1000.0,
382
- height = 0.0,
383
- numParticles = 40000,
384
- legendData = windyLegendData
385
- } = {}) {
377
+ constructor(id,
378
+ windDataMeta,
379
+ {
380
+ fadeOpacity = 0.746,
381
+ speedFactor = 0.6,
382
+ dropRate = 0.007,
383
+ dropRateBump = 0.001,
384
+ baseOpacity = 1.0,
385
+ pointSize = 2.0,
386
+ minSpeed = 0.0,
387
+ maxSpeed = 1000.0,
388
+ height = 0.0,
389
+ numParticles = 40000,
390
+ legendData = windyLegendData
391
+ } = {}) {
386
392
 
387
393
  this.id = id;
388
-
394
+ this._windDataMeta = windDataMeta;
389
395
  this.globe = null;
390
396
  this.gl = null;
391
397
 
398
+
392
399
  this._screenMoved = false;
393
400
  this.projMatrix = null;
394
401
  this.modelviewMatrix = null;
@@ -577,30 +584,29 @@ export default class WindPlugin {
577
584
  /**
578
585
  * @param {Object} windData
579
586
  * @param {HTMLImageElement} windData.image - image element
580
- * @param {number} windData.width - image width
581
- * @param {number} windData.height - image height
587
+
582
588
  * @param {number} windData.uMin - minimum u value
583
589
  * @param {number} windData.vMin - minimum v value
584
590
  * @param {number} windData.uMax - maximum u value
585
591
  * @param {number} windData.vMax - maximum v value
586
- * @param {Array} windData.bbox - bounding box [minLon, minLat, maxLon, maxLat]
587
592
  */
588
593
  setWind(windData) {
589
594
  if (windData == null) {
590
595
  return;
591
596
  }
597
+ const windDataMeta = this._windDataMeta;
592
598
  const gl = this.gl;
593
599
  this.windData = windData;
594
600
  this.windTexture = util.createTexture(gl, gl.LINEAR, windData.image);
595
601
  const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
596
602
  gl.useProgram(this.updateProgram.program);
597
- gl.uniform2f(this.updateProgram.u_wind_res, this.windData.width, this.windData.height);
603
+
604
+ gl.uniform2f(this.updateProgram.u_wind_res, windDataMeta.width, windDataMeta.height);
598
605
  gl.uniform2f(this.updateProgram.u_wind_min, this.windData.uMin, this.windData.vMin);
599
606
  gl.uniform2f(this.updateProgram.u_wind_max, this.windData.uMax, this.windData.vMax);
600
607
  this.setGeometry();
601
-
602
- const minXY = this._latLongToPixelXY(windData.bbox[1], windData.bbox[0]);
603
- const maxXY = this._latLongToPixelXY(windData.bbox[3], windData.bbox[2]);
608
+ const minXY = this._latLongToPixelXY(windDataMeta.bbox[1], windDataMeta.bbox[0]);
609
+ const maxXY = this._latLongToPixelXY(windDataMeta.bbox[3], windDataMeta.bbox[2]);
604
610
  this._loadBoundingBoxData(minXY.x, minXY.y, maxXY.x, maxXY.y);
605
611
 
606
612
  gl.useProgram(currentProgram);
@@ -637,7 +643,8 @@ export default class WindPlugin {
637
643
 
638
644
 
639
645
  _createPointCoordinatesDataCalculator() {
640
- this.coordinatesDataCalculator = new PointCoordinatesDataCalculator(this.windData.bbox, this.windData.width, this.windData.height);
646
+ const { bbox, width, height } = this._windDataMeta;
647
+ this.coordinatesDataCalculator = new PointCoordinatesDataCalculator(bbox, width, height);
641
648
  this._setCoorcinatesDataCalculatorData();
642
649
  }
643
650