@openglobus/og 0.10.3 → 0.10.6

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.
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+
3
+ import * as math from "../math.js";
4
+ import { Control } from "./Control.js";
5
+ import { input } from "../input/input.js";
6
+ import { Key } from "../Lock.js";
7
+ import { LonLat } from "../LonLat.js";
8
+ import { Mat4 } from "../math/Mat4.js";
9
+ import { Quat } from "../math/Quat.js";
10
+ import { Ray } from "../math/Ray.js";
11
+ import { Sphere } from "../bv/Sphere.js";
12
+ import { Vec3 } from "../math/Vec3.js";
13
+
14
+ class EarthNavigation extends Control {
15
+ constructor(options) {
16
+ super(options);
17
+
18
+ this.grabbedPoint = new Vec3();
19
+ this.inertia = 0.007;
20
+ this.grabbedSpheroid = new Sphere();
21
+ this.planet = null;
22
+ this._vRot = new Quat();
23
+ this._hRot = new Quat();
24
+ this._a = 0.0;
25
+ this.scaleRot = 0;
26
+ this.currState = 0;
27
+
28
+ this.positionState = [
29
+ { h: 17119745.303455353, max: 0.99, min: -0.99 },
30
+ { h: 6866011, max: 0.99, min: -0.99 },
31
+ { h: 3000000, max: 0.99, min: -0.99 },
32
+ { h: 1000000, max: 0.99, min: -0.99 },
33
+ { h: 500000, max: 0.99, min: -0.99 }
34
+ ];
35
+
36
+ var Touch = function () {
37
+ this.x = 0;
38
+ this.y = 0;
39
+ this.prev_x = 0;
40
+ this.prev_y = 0;
41
+ this.grabbedPoint = new Vec3();
42
+ this.grabbedSpheroid = new Sphere();
43
+ this.dX = function () {
44
+ return this.x - this.prev_x;
45
+ };
46
+ this.dY = function () {
47
+ return this.y - this.prev_y;
48
+ };
49
+ };
50
+
51
+ this.touches = [new Touch(), new Touch()];
52
+ }
53
+
54
+ switchZoomState(wheelDelta) {
55
+ this.stopRotation();
56
+
57
+ if (wheelDelta > 0) {
58
+ this.currState++;
59
+ } else {
60
+ this.currState--;
61
+ }
62
+
63
+ if (this.currState <= 0) this.currState = 0;
64
+
65
+ if (this.currState >= this.positionState.length) {
66
+ this.currState = this.positionState.length - 1;
67
+ }
68
+
69
+ this.planet.stopFlying();
70
+
71
+ var ll = this.renderer.activeCamera._lonLat;
72
+
73
+ globus.planet.flyLonLat(new LonLat(ll.lon, ll.lat, this.positionState[this.currState].h));
74
+ }
75
+
76
+ onMouseWheel(event) {
77
+ this.switchZoomState(event.wheelDelta);
78
+ }
79
+
80
+ oninit() {
81
+ this.activate();
82
+ }
83
+
84
+ onactivate() {
85
+ this.planet = this.renderer.renderNodes.Earth;
86
+
87
+ this.renderer.events.on("mousewheel", this.onMouseWheel, this);
88
+ this.renderer.events.on("lhold", this.onMouseLeftButtonDown, this);
89
+ this.renderer.events.on("ldown", this.onMouseLeftButtonClick, this);
90
+ this.renderer.events.on("lup", this.onMouseLeftButtonUp, this);
91
+
92
+ this.renderer.events.on("touchstart", this.onTouchStart, this);
93
+ this.renderer.events.on("touchend", this.onTouchEnd, this);
94
+ this.renderer.events.on("touchmove", this.onTouchMove, this);
95
+
96
+ this.renderer.events.on("draw", this.onDraw, this);
97
+ }
98
+
99
+ onTouchStart(e) {
100
+ if (e.sys.touches.length == 1) {
101
+ var t = this.touches[0];
102
+
103
+ t.x = e.sys.touches.item(0).pageX - e.sys.offsetLeft;
104
+ t.y = e.sys.touches.item(0).pageY - e.sys.offsetTop;
105
+ t.prev_x = e.sys.touches.item(0).pageX - e.sys.offsetLeft;
106
+ t.prev_y = e.sys.touches.item(0).pageY - e.sys.offsetTop;
107
+
108
+ t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t, true);
109
+
110
+ if (t.grabbedPoint) {
111
+ t.grabbedSpheroid.radius = t.grabbedPoint.length();
112
+ this.stopRotation();
113
+ }
114
+ }
115
+ }
116
+
117
+ onTouchEnd(e) {
118
+ if (e.sys.touches.length == 0) {
119
+ this.scaleRot = 1;
120
+
121
+ if (
122
+ Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3 &&
123
+ Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3
124
+ )
125
+ this.stopRotation();
126
+ }
127
+ }
128
+
129
+ onTouchMove(e) {
130
+ if (e.sys.touches.length == 1) {
131
+ var cam = this.renderer.activeCamera;
132
+
133
+ var t = this.touches[0];
134
+
135
+ t.prev_x = t.x;
136
+ t.prev_y = t.y;
137
+ t.x = e.sys.touches.item(0).pageX - e.sys.offsetLeft;
138
+ t.y = e.sys.touches.item(0).pageY - e.sys.offsetTop;
139
+
140
+ if (!t.grabbedPoint) return;
141
+
142
+ var direction = cam.unproject(t.x, t.y);
143
+ var targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid);
144
+
145
+ if (targetPoint) {
146
+ this._a =
147
+ Math.acos(t.grabbedPoint.y / t.grabbedSpheroid.radius) -
148
+ Math.acos(targetPoint.y / t.grabbedSpheroid.radius);
149
+ this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
150
+ this._hRot = Quat.getRotationBetweenVectors(
151
+ new Vec3(targetPoint.x, 0.0, targetPoint.z).normal(),
152
+ new Vec3(t.grabbedPoint.x, 0.0, t.grabbedPoint.z).normal()
153
+ );
154
+ var rot = this._hRot.mul(this._vRot);
155
+
156
+ var state = this.positionState[this.currState];
157
+ var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.UP);
158
+ if (lim > state.max || lim < state.min) {
159
+ rot = Quat.yRotation(rot.getYaw());
160
+ }
161
+
162
+ cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.UP);
163
+ cam.update();
164
+ }
165
+ }
166
+ }
167
+
168
+ onMouseLeftButtonClick() {
169
+ this.renderer.handler.gl.canvas.classList.add("ogGrabbingPoiner");
170
+ this.grabbedPoint = this.planet.getCartesianFromMouseTerrain(true);
171
+ if (this.grabbedPoint) {
172
+ this.grabbedSpheroid.radius = this.grabbedPoint.length();
173
+ this.stopRotation();
174
+ }
175
+ }
176
+
177
+ stopRotation() {
178
+ this.scaleRot = 0.0;
179
+ this._a = 0.0;
180
+ this._vRot.clear();
181
+ this._hRot.clear();
182
+ }
183
+
184
+ onMouseLeftButtonUp(e) {
185
+ this.scaleRot = 1;
186
+ this.renderer.handler.gl.canvas.classList.remove("ogGrabbingPoiner");
187
+
188
+ if (Math.abs(e.x - e.prev_x) < 3 && Math.abs(e.y - e.prev_y) < 3) this.stopRotation();
189
+ }
190
+
191
+ onMouseLeftButtonDown(e) {
192
+ var cam = this.renderer.activeCamera;
193
+
194
+ if (!this.grabbedPoint || cam.isFlying()) return;
195
+
196
+ if (this.renderer.events.mouseState.moving) {
197
+ var targetPoint = new Ray(cam.eye, e.direction).hitSphere(this.grabbedSpheroid);
198
+
199
+ if (targetPoint) {
200
+ this._a =
201
+ Math.acos(this.grabbedPoint.y / this.grabbedSpheroid.radius) -
202
+ Math.acos(targetPoint.y / this.grabbedSpheroid.radius);
203
+
204
+ this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
205
+ this._hRot = Quat.getRotationBetweenVectors(
206
+ new Vec3(targetPoint.x, 0.0, targetPoint.z).normal(),
207
+ new Vec3(this.grabbedPoint.x, 0.0, this.grabbedPoint.z).normal()
208
+ );
209
+ var rot = this._hRot.mul(this._vRot);
210
+
211
+ var state = this.positionState[this.currState];
212
+ var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.UP);
213
+ if (lim > state.max || lim < state.min) {
214
+ rot = Quat.yRotation(rot.getYaw());
215
+ }
216
+ cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.UP);
217
+ cam.update();
218
+ }
219
+ } else {
220
+ this.scaleRot = 0;
221
+ }
222
+ }
223
+
224
+ onDraw(e) {
225
+ var r = this.renderer;
226
+ var cam = r.activeCamera;
227
+
228
+ if (r.events.mouseState.leftButtonDown || !this.scaleRot || cam.isFlying()) return;
229
+
230
+ this.scaleRot -= this.inertia;
231
+ if (this.scaleRot <= 0) {
232
+ this.scaleRot = 0;
233
+ } else {
234
+ this._vRot = Quat.axisAngleToQuat(cam._u, this._a);
235
+ var rot = this._vRot.mul(this._hRot);
236
+
237
+ var lim = rot.mulVec3(cam.eye).normal().dot(Vec3.UP);
238
+
239
+ var state = this.positionState[this.currState];
240
+
241
+ if (lim > state.max || lim < state.min) {
242
+ rot = Quat.yRotation(rot.getYaw());
243
+ }
244
+
245
+ r.controlsBag.scaleRot = this.scaleRot;
246
+ rot = rot
247
+ .slerp(Quat.IDENTITY, 1 - this.scaleRot * this.scaleRot * this.scaleRot)
248
+ .normalize();
249
+ if (!(rot.x || rot.y || rot.z)) {
250
+ this.scaleRot = 0;
251
+ }
252
+
253
+ cam.set(rot.mulVec3(cam.eye), Vec3.ZERO, Vec3.UP);
254
+ cam.update();
255
+ }
256
+ }
257
+ }
258
+
259
+ export { EarthNavigation };
@@ -2,18 +2,18 @@
2
2
  * @module og/control/MouseNavigation
3
3
  */
4
4
 
5
- 'use strict';
6
-
7
- import * as math from '../math.js';
8
- import { Control } from './Control.js';
9
- import { input } from '../input/input.js';
10
- import { Key } from '../Lock.js';
11
- import { LonLat } from '../LonLat.js';
12
- import { Mat4 } from '../math/Mat4.js';
13
- import { Quat } from '../math/Quat.js';
14
- import { Ray } from '../math/Ray.js';
15
- import { Sphere } from '../bv/Sphere.js';
16
- import { Vec3 } from '../math/Vec3.js';
5
+ "use strict";
6
+
7
+ import * as math from "../math.js";
8
+ import { Control } from "./Control.js";
9
+ import { input } from "../input/input.js";
10
+ import { Key } from "../Lock.js";
11
+ import { LonLat } from "../LonLat.js";
12
+ import { Mat4 } from "../math/Mat4.js";
13
+ import { Quat } from "../math/Quat.js";
14
+ import { Ray } from "../math/Ray.js";
15
+ import { Sphere } from "../bv/Sphere.js";
16
+ import { Vec3 } from "../math/Vec3.js";
17
17
 
18
18
  /**
19
19
  * Mouse planet camera dragging control.
@@ -46,11 +46,12 @@ class MouseNavigation extends Control {
46
46
 
47
47
  this._lmbDoubleClickActive = true;
48
48
 
49
+ this.minSlope = options.minSlope || 0.1;
50
+
49
51
  this._keyLock = new Key();
50
52
  }
51
53
 
52
54
  static getMovePointsFromPixelTerrain(cam, planet, stepsCount, delta, point, forward, dir) {
53
-
54
55
  var steps = [];
55
56
 
56
57
  var eye = cam.eye.clone(),
@@ -65,12 +66,11 @@ class MouseNavigation extends Control {
65
66
  }
66
67
 
67
68
  if (a) {
68
-
69
69
  if (!dir) {
70
70
  dir = Vec3.sub(a, cam.eye).normalize();
71
71
  }
72
72
 
73
- var d = a ? delta * cam.eye.distance(a) / stepsCount : 1000;
73
+ var d = a ? (delta * cam.eye.distance(a)) / stepsCount : 1000;
74
74
 
75
75
  if (forward) {
76
76
  d = -d;
@@ -163,7 +163,7 @@ class MouseNavigation extends Control {
163
163
  this.renderer.events.off("ldblclick", this.onMouseLeftButtonDoubleClick);
164
164
  this.renderer.events.off("mouseleave", this.onMouseLeave);
165
165
  this.renderer.events.off("mouseenter", this.onMouseEnter);
166
- };
166
+ }
167
167
 
168
168
  activateDoubleClickZoom() {
169
169
  if (!this._lmbDoubleClickActive) {
@@ -180,8 +180,16 @@ class MouseNavigation extends Control {
180
180
  }
181
181
 
182
182
  onMouseEnter(e) {
183
- if (this.renderer.events.isKeyPressed(input.KEY_ALT)) {
184
- this.renderer.events.releaseKeys();
183
+ const renderEvents = this.renderer.events;
184
+ if (renderEvents.isKeyPressed(input.KEY_ALT)) {
185
+ renderEvents.releaseKeys();
186
+ }
187
+
188
+ renderEvents.updateButtonsStates(e.buttons);
189
+ if (renderEvents.mouseState.leftButtonDown) {
190
+ this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
191
+ } else {
192
+ this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
185
193
  }
186
194
  }
187
195
 
@@ -189,10 +197,10 @@ class MouseNavigation extends Control {
189
197
  if (this.renderer.events.mouseState.leftButtonDown) {
190
198
  this.scaleRot = 0;
191
199
  }
200
+ this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
192
201
  }
193
202
 
194
203
  onMouseWheel(event) {
195
-
196
204
  if (this.stepIndex) {
197
205
  return;
198
206
  }
@@ -208,8 +216,15 @@ class MouseNavigation extends Control {
208
216
  this.planet._normalMapCreator.lock(this._keyLock);
209
217
 
210
218
  var ms = this.renderer.events.mouseState;
211
- this.stepsForward = MouseNavigation.getMovePointsFromPixelTerrain(this.renderer.activeCamera,
212
- this.planet, this.stepsCount, this.distDiff, ms, event.wheelDelta > 0, ms.direction);
219
+ this.stepsForward = MouseNavigation.getMovePointsFromPixelTerrain(
220
+ this.renderer.activeCamera,
221
+ this.planet,
222
+ this.stepsCount,
223
+ this.distDiff,
224
+ ms,
225
+ event.wheelDelta > 0,
226
+ ms.direction
227
+ );
213
228
  if (this.stepsForward) {
214
229
  this.stepIndex = this.stepsCount;
215
230
  }
@@ -229,9 +244,13 @@ class MouseNavigation extends Control {
229
244
  if (p) {
230
245
  var g = this.planet.ellipsoid.cartesianToLonLat(p);
231
246
  if (this.renderer.events.isKeyPressed(input.KEY_ALT)) {
232
- this.planet.flyLonLat(new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 2.0));
247
+ this.planet.flyLonLat(
248
+ new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 2.0)
249
+ );
233
250
  } else {
234
- this.planet.flyLonLat(new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 0.57));
251
+ this.planet.flyLonLat(
252
+ new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 0.57)
253
+ );
235
254
  }
236
255
  }
237
256
  }
@@ -264,7 +283,6 @@ class MouseNavigation extends Control {
264
283
 
265
284
  onMouseLeftButtonDown(e) {
266
285
  if (this._active) {
267
-
268
286
  if (!this.grabbedPoint) {
269
287
  return;
270
288
  }
@@ -272,14 +290,16 @@ class MouseNavigation extends Control {
272
290
  this.planet.stopFlying();
273
291
 
274
292
  if (this.renderer.events.mouseState.moving) {
275
-
276
293
  var cam = this.renderer.activeCamera;
277
294
 
278
295
  if (cam.slope > 0.2) {
279
296
  var targetPoint = new Ray(cam.eye, e.direction).hitSphere(this.grabbedSpheroid);
280
297
  if (targetPoint) {
281
298
  this.scaleRot = 1.0;
282
- this.qRot = Quat.getRotationBetweenVectors(targetPoint.normal(), this.grabbedPoint.normal());
299
+ this.qRot = Quat.getRotationBetweenVectors(
300
+ targetPoint.normal(),
301
+ this.grabbedPoint.normal()
302
+ );
283
303
  var rot = this.qRot;
284
304
  cam.eye = rot.mulVec3(cam.eye);
285
305
  cam._v = rot.mulVec3(cam._v);
@@ -291,7 +311,6 @@ class MouseNavigation extends Control {
291
311
  cam.update();
292
312
  }
293
313
  } else {
294
-
295
314
  var p0 = this.grabbedPoint,
296
315
  p1 = Vec3.add(p0, cam._u),
297
316
  p2 = Vec3.add(p0, p0.normal());
@@ -312,23 +331,28 @@ class MouseNavigation extends Control {
312
331
  onMouseRightButtonClick(e) {
313
332
  this.stopRotation();
314
333
  this.planet.stopFlying();
315
- this.pointOnEarth = this.planet.getCartesianFromPixelTerrain({ x: e.x, y: e.y }, true);
334
+ this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
335
+ {
336
+ x: e.x,
337
+ y: e.y
338
+ },
339
+ true
340
+ );
316
341
  if (this.pointOnEarth) {
317
342
  this.earthUp = this.pointOnEarth.normal();
318
343
  }
319
- };
344
+ }
320
345
 
321
346
  onMouseRightButtonDown(e) {
322
347
  var cam = this.renderer.activeCamera;
323
348
 
324
349
  if (this.pointOnEarth && this.renderer.events.mouseState.moving) {
325
-
326
350
  this.renderer.controlsBag.scaleRot = 1.0;
327
- var l = 0.5 / cam.eye.distance(this.pointOnEarth) * cam._lonLat.height * math.RADIANS;
351
+ var l = (0.5 / cam.eye.distance(this.pointOnEarth)) * cam._lonLat.height * math.RADIANS;
328
352
  if (l > 0.007) l = 0.007;
329
353
  cam.rotateHorizontal(l * (e.x - e.prev_x), false, this.pointOnEarth, this.earthUp);
330
354
 
331
- cam.rotateVertical(l * (e.y - e.prev_y), this.pointOnEarth, true);
355
+ cam.rotateVertical(l * (e.y - e.prev_y), this.pointOnEarth, this.minSlope);
332
356
 
333
357
  cam.checkTerrainCollision();
334
358
 
@@ -341,9 +365,7 @@ class MouseNavigation extends Control {
341
365
  }
342
366
 
343
367
  onMouseMove(e) {
344
-
345
368
  if (this._active && this.renderer.events.isKeyPressed(input.KEY_ALT)) {
346
-
347
369
  if (!this._shiftBusy) {
348
370
  this._shiftBusy = true;
349
371
  this.onMouseRightButtonClick(e);
@@ -354,9 +376,7 @@ class MouseNavigation extends Control {
354
376
  }
355
377
 
356
378
  onDraw(e) {
357
-
358
379
  if (this._active) {
359
-
360
380
  var r = this.renderer;
361
381
  var cam = r.activeCamera;
362
382
  var prevEye = cam.eye.clone();
@@ -364,6 +384,13 @@ class MouseNavigation extends Control {
364
384
  if (this.stepIndex) {
365
385
  r.controlsBag.scaleRot = 1.0;
366
386
  var sf = this.stepsForward[this.stepsCount - this.stepIndex--];
387
+
388
+ let maxAlt = cam.maxAltitude + this.planet.ellipsoid._a;
389
+
390
+ if (sf.eye.length() > maxAlt) {
391
+ return;
392
+ }
393
+
367
394
  cam.eye = sf.eye;
368
395
  cam._v = sf.v;
369
396
  cam._u = sf.u;
@@ -390,9 +417,10 @@ class MouseNavigation extends Control {
390
417
  if (this.scaleRot <= 0.0) {
391
418
  this.scaleRot = 0.0;
392
419
  } else {
393
-
394
420
  r.controlsBag.scaleRot = this.scaleRot;
395
- var rot = this.qRot.slerp(Quat.IDENTITY, 1.0 - this.scaleRot * this.scaleRot * this.scaleRot).normalize();
421
+ var rot = this.qRot
422
+ .slerp(Quat.IDENTITY, 1.0 - this.scaleRot * this.scaleRot * this.scaleRot)
423
+ .normalize();
396
424
  if (!(rot.x || rot.y || rot.z)) {
397
425
  this.scaleRot = 0.0;
398
426
  }
@@ -417,6 +445,6 @@ class MouseNavigation extends Control {
417
445
  }
418
446
  }
419
447
  }
420
- };
448
+ }
421
449
 
422
- export { MouseNavigation };
450
+ export { MouseNavigation };
@@ -2,10 +2,10 @@
2
2
  * @module og/layer/CanvasTiles
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import * as quadTree from '../quadTree/quadTree.js';
8
- import { Layer } from './Layer.js';
7
+ import * as quadTree from "../quadTree/quadTree.js";
8
+ import { Layer } from "./Layer.js";
9
9
 
10
10
  /**
11
11
  * Maximum tiles per frame.
@@ -92,7 +92,7 @@ class CanvasTiles extends Layer {
92
92
  }
93
93
  this._pendingsQueue = [];
94
94
  // this._pendingsQueue.clear();
95
- };
95
+ }
96
96
 
97
97
  /**
98
98
  * Sets layer visibility.
@@ -119,11 +119,12 @@ class CanvasTiles extends Layer {
119
119
  * @param {og.planetSegment.Material} material -
120
120
  */
121
121
  loadMaterial(material) {
122
-
123
122
  var seg = material.segment;
124
123
 
125
124
  if (this._isBaseLayer) {
126
- material.texture = seg._isNorth ? seg.planet.solidTextureOne : seg.planet.solidTextureTwo;
125
+ material.texture = seg._isNorth
126
+ ? seg.planet.solidTextureOne
127
+ : seg.planet.solidTextureTwo;
127
128
  } else {
128
129
  material.texture = seg.planet.transparentTexture;
129
130
  }
@@ -149,33 +150,32 @@ class CanvasTiles extends Layer {
149
150
  this._counter++;
150
151
  var that = this;
151
152
  if (this.drawTile) {
152
-
153
153
  /**
154
154
  * Tile custom draw function.
155
155
  * @callback og.layer.CanvasTiles~drawTileCallback
156
156
  * @param {og.planetSegment.Material} material
157
157
  * @param {applyCanvasCallback} applyCanvasCallback
158
158
  */
159
- setTimeout(function () {
160
- var e = that.events.load;
161
- if (e.handlers.length) {
162
- that.events.dispatch(e, material);
159
+ var e = that.events.load;
160
+ if (e.handlers.length) {
161
+ that.events.dispatch(e, material);
162
+ }
163
+ that.drawTile(
164
+ material,
165
+ /**
166
+ * Apply canvas.
167
+ * @callback applyCanvasCallback
168
+ * @param {Object} canvas -
169
+ */
170
+ function (canvas) {
171
+ that._counter--;
172
+ CanvasTiles.__requestsCounter--;
173
+ if (material.isLoading) {
174
+ material.applyImage(canvas);
175
+ }
176
+ that._dequeueRequest();
163
177
  }
164
- that.drawTile(material,
165
- /**
166
- * Apply canvas.
167
- * @callback applyCanvasCallback
168
- * @param {Object} canvas -
169
- */
170
- function (canvas) {
171
- that._counter--;
172
- CanvasTiles.__requestsCounter--;
173
- if (material.isLoading) {
174
- material.applyImage(canvas);
175
- }
176
- that._dequeueRequest();
177
- });
178
- }, 50);
178
+ );
179
179
  } else {
180
180
  material.textureNotExists();
181
181
  }
@@ -214,7 +214,10 @@ class CanvasTiles extends Layer {
214
214
  while (this._pendingsQueue.length) {
215
215
  var pmat = this._pendingsQueue.pop();
216
216
  if (pmat.segment.node) {
217
- if (pmat.segment.initialized && pmat.segment.node.getState() === quadTree.RENDERING) {
217
+ if (
218
+ pmat.segment.initialized &&
219
+ pmat.segment.node.getState() === quadTree.RENDERING
220
+ ) {
218
221
  return pmat;
219
222
  }
220
223
  pmat.isLoading = false;
@@ -227,7 +230,6 @@ class CanvasTiles extends Layer {
227
230
  if (material.isReady) {
228
231
  return [0, 0, 1, 1];
229
232
  } else {
230
-
231
233
  !material.isLoading && this.loadMaterial(material);
232
234
 
233
235
  var segment = material.segment;
@@ -278,10 +280,10 @@ class CanvasTiles extends Layer {
278
280
  material.textureExists = false;
279
281
 
280
282
  if (material.image) {
281
- material.image.src = '';
283
+ material.image.src = "";
282
284
  material.image = null;
283
285
  }
284
286
  }
285
- };
287
+ }
286
288
 
287
289
  export { CanvasTiles };