@pirireis/webglobeplugins 0.10.4-alpha → 0.10.6-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.10.4-alpha",
3
+ "version": "0.10.6-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -28,20 +28,23 @@ export class TexturePointSampler {
28
28
  throw new Error("Texture count must be 1 or 2");
29
29
  }
30
30
  this._textureCount = textureCount;
31
- this._isReady = false; // Reset readiness when changing texture count
31
+ this._pushPointCallbackAll();
32
32
  }
33
33
  registerPoint(key, long, lat, callback) {
34
34
  if (key in this._pointObjects) {
35
35
  console.warn("key already registered, old one is unregistered");
36
36
  this.unregisterPoint(key);
37
37
  }
38
- if (!this._isInBBox(long, lat))
39
- return false;
40
- const index = this._metaCalculater.getFlooredIndex(long, lat);
41
- this._pointObjects.set(key, pointObject(long, lat, index, callback));
42
- if (this._isReady) {
38
+ if (!this._isInBBox(long, lat)) {
39
+ this._pointObjects.set(key, pointObject(long, lat, -1, callback));
43
40
  this._findAndSend(key);
41
+ return false;
42
+ }
43
+ else {
44
+ const index = this._metaCalculater.getFlooredIndex(long, lat);
45
+ this._pointObjects.set(key, pointObject(long, lat, index, callback));
44
46
  }
47
+ this._findAndSend(key);
45
48
  return true;
46
49
  }
47
50
  unregisterPoint(key) {
@@ -53,14 +56,15 @@ export class TexturePointSampler {
53
56
  console.warn("Point not registered, use registerPoint first");
54
57
  return false;
55
58
  }
59
+ pointObject.long = long;
60
+ pointObject.lat = lat;
56
61
  if (!this._isInBBox(long, lat)) {
57
62
  console.warn("Point is out of bbox, use registerPoint with valid coordinates");
63
+ pointObject.posIndex = -1; // Mark as invalid
58
64
  pointObject.callback(null, null, null);
59
65
  return false;
60
66
  }
61
67
  ;
62
- pointObject.long = long;
63
- pointObject.lat = lat;
64
68
  const index = this._metaCalculater.getFlooredIndex(long, lat);
65
69
  pointObject.posIndex = index;
66
70
  this._findAndSend(key);
@@ -92,9 +96,8 @@ export class TexturePointSampler {
92
96
  this.updateRatio(ratio);
93
97
  }
94
98
  updateRatio(ratio) {
95
- if (ratio < 0 || ratio > 1) {
96
- console.warn("Ratio must be between 0 and 1");
97
- ratio = Math.max(0, Math.min(1, ratio)); // Clamp the ratio
99
+ if (typeof ratio !== "number") {
100
+ throw new Error("Ratio must be a number");
98
101
  }
99
102
  this._ratio = ratio;
100
103
  this._pushPointCallbackAll();
@@ -118,6 +121,9 @@ export class TexturePointSampler {
118
121
  return;
119
122
  }
120
123
  const { posIndex, callback } = pointObject;
124
+ if (posIndex === -1) {
125
+ callback(null, null, null);
126
+ }
121
127
  const data0 = this._textures[0][posIndex];
122
128
  if (this._textureCount === 1) {
123
129
  callback(data0, data0, data0);
@@ -129,7 +135,7 @@ export class TexturePointSampler {
129
135
  }
130
136
  }
131
137
  _pushPointCallbackAll() {
132
- if (this._isReady) {
138
+ if (this._isReady && this._ratio >= 0 && this._ratio <= 1) {
133
139
  for (const key of this._pointObjects.keys()) {
134
140
  this._findAndSend(key);
135
141
  }