@openglobus/og 0.13.7 → 0.13.10
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/README.md +1 -1
- package/css/og.css +388 -129
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +20 -19
- package/src/og/Globe.js +15 -16
- package/src/og/Object3d.js +417 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/EarthCoordinates.js +1 -1
- package/src/og/control/GeoImageDragControl.js +102 -75
- package/src/og/control/LayerAnimation.js +383 -0
- package/src/og/control/LayerSwitcher.js +506 -159
- package/src/og/control/Lighting.js +27 -27
- package/src/og/control/MouseNavigation.js +460 -460
- package/src/og/control/RulerSwitcher.js +69 -0
- package/src/og/control/Sun.js +170 -170
- package/src/og/control/UIhelpers.js +146 -0
- package/src/og/control/ZoomControl.js +0 -2
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +43 -0
- package/src/og/control/ruler/RulerScene.js +374 -0
- package/src/og/control/visibleExtent/Segment.js +3 -5
- package/src/og/ellipsoid/Ellipsoid.js +19 -0
- package/src/og/ellipsoid/wgs84.js +1 -1
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +6 -2
- package/src/og/entity/LabelWorker.js +38 -53
- package/src/og/layer/BaseGeoImage.js +347 -312
- package/src/og/layer/CanvasTiles.js +312 -290
- package/src/og/layer/GeoImage.js +222 -214
- package/src/og/layer/GeoVideo.js +291 -291
- package/src/og/layer/Layer.js +94 -70
- package/src/og/layer/Material.js +109 -109
- package/src/og/layer/Vector.js +81 -14
- package/src/og/layer/XYZ.js +23 -11
- package/src/og/light/LightSource.js +364 -363
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +6 -6
- package/src/og/quadTree/Node.js +8 -6
- package/src/og/renderer/Renderer.js +2 -3
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +106 -44
- package/src/og/segment/Segment.js +34 -64
- package/src/og/segment/Slice.js +1 -1
- package/src/og/shaders/drawnode.js +1 -1
- package/src/og/shaders/label.js +30 -42
- package/src/og/terrain/GlobusTerrain.js +31 -20
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/BaseWorker.js +46 -0
- package/src/og/utils/FontAtlas.js +1 -2
- package/src/og/utils/GeoImageCreator.js +164 -161
- package/src/og/utils/Loader.js +187 -153
- package/src/og/utils/NormalMapCreator.js +403 -412
- package/src/og/utils/PlainSegmentWorker.js +29 -55
- package/src/og/utils/TerrainWorker.js +572 -589
- package/src/og/utils/VectorTileCreator.js +1 -1
- package/src/og/utils/functionComposition.js +13 -0
- package/src/og/webgl/Handler.js +42 -41
- package/src/og/webgl/ProgramController.js +143 -143
- package/types/Object3d.d.ts +22 -0
- package/types/arial.d.ts +1 -0
- package/types/camera/PlanetCamera.d.ts +4 -0
- package/types/control/GeoImageDragControl.d.ts +2 -0
- package/types/control/LayerAnimation.d.ts +73 -0
- package/types/control/LayerSwitcher.d.ts +55 -11
- package/types/control/MouseNavigation.d.ts +1 -0
- package/types/control/MouseWheelZoomControl.d.ts +1 -0
- package/types/control/Sun.d.ts +2 -1
- package/types/control/TouchNavigation.d.ts +1 -0
- package/types/control/UIhelpers.d.ts +13 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/Ruler.d.ts +13 -0
- package/types/control/ruler/RulerScene.d.ts +48 -0
- package/types/ellipsoid/Ellipsoid.d.ts +8 -0
- package/types/entity/LabelHandler.d.ts +2 -0
- package/types/entity/LabelWorker.d.ts +5 -7
- package/types/layer/BaseGeoImage.d.ts +9 -1
- package/types/layer/CanvasTiles.d.ts +5 -1
- package/types/layer/GeoImage.d.ts +1 -0
- package/types/layer/GeoTexture2d.d.ts +1 -0
- package/types/layer/Layer.d.ts +28 -32
- package/types/layer/Vector.d.ts +9 -0
- package/types/layer/WMS.d.ts +1 -0
- package/types/layer/XYZ.d.ts +8 -5
- package/types/math.d.ts +2 -2
- package/types/quadTree/EntityCollectionNode.d.ts +7 -0
- package/types/quadTree/Node.d.ts +1 -2
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +16 -0
- package/types/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +21 -6
- package/types/segment/SegmentLonLat.d.ts +2 -0
- package/types/terrain/BilTerrain.d.ts +6 -0
- package/types/terrain/GlobusTerrain.d.ts +7 -0
- package/types/terrain/MapboxTerrain.d.ts +8 -0
- package/types/utils/BaseWorker.d.ts +14 -0
- package/types/utils/Loader.d.ts +4 -1
- package/types/utils/PlainSegmentWorker.d.ts +4 -6
- package/types/utils/TerrainWorker.d.ts +4 -6
- package/types/utils/functionComposition.d.ts +5 -0
- package/types/webgl/Handler.d.ts +4 -1
|
@@ -237,7 +237,7 @@ export class VectorTileCreator {
|
|
|
237
237
|
height = _h;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
texture =
|
|
240
|
+
texture = material._updateTexture || h.createEmptyTexture_l(width, height);
|
|
241
241
|
|
|
242
242
|
f.setSize(width, height);
|
|
243
243
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Used to compose other functions,
|
|
4
|
+
// in a specific order to return to desired output.
|
|
5
|
+
|
|
6
|
+
const compose = x => ({
|
|
7
|
+
run: f => compose(f(x)), // runs the function
|
|
8
|
+
runForEach: f => compose(x.map(el => f(el))), // runs the function for an array
|
|
9
|
+
end: () => x, // result
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export {compose}
|
|
13
|
+
|
package/src/og/webgl/Handler.js
CHANGED
|
@@ -11,6 +11,7 @@ import { isEmpty } from "../utils/shared.js";
|
|
|
11
11
|
import { ProgramController } from "./ProgramController.js";
|
|
12
12
|
import { Stack } from "../Stack.js";
|
|
13
13
|
import { Vec2 } from "../math/Vec2.js";
|
|
14
|
+
import { Events } from "../Events.js";
|
|
14
15
|
|
|
15
16
|
const vendorPrefixes = ["", "WEBKIT_", "MOZ_"];
|
|
16
17
|
|
|
@@ -31,9 +32,9 @@ const MAX_LEVELS = 2;
|
|
|
31
32
|
* @param {Array.<string>} [params.extensions] - Additional WebGL extension list. Available by default: EXT_texture_filter_anisotropic.
|
|
32
33
|
*/
|
|
33
34
|
class Handler {
|
|
34
|
-
constructor(id, params) {
|
|
35
|
-
params = params || {};
|
|
35
|
+
constructor(id, params = {}) {
|
|
36
36
|
|
|
37
|
+
this.events = new Events(["visibilitychange", "resize"]);
|
|
37
38
|
/**
|
|
38
39
|
* Application default timer.
|
|
39
40
|
* @public
|
|
@@ -137,6 +138,8 @@ class Handler {
|
|
|
137
138
|
|
|
138
139
|
this.createTextureDefault = null;
|
|
139
140
|
|
|
141
|
+
this.ONCANVASRESIZE = null;
|
|
142
|
+
|
|
140
143
|
if (params.autoActivate || isEmpty(params.autoActivate)) {
|
|
141
144
|
this.initialize();
|
|
142
145
|
}
|
|
@@ -174,7 +177,6 @@ class Handler {
|
|
|
174
177
|
for (let i = 0; i < CONTEXT_TYPE.length; i++) {
|
|
175
178
|
ctx = canvas.getContext(CONTEXT_TYPE[i], contextAttributes);
|
|
176
179
|
if (ctx) {
|
|
177
|
-
console.log(CONTEXT_TYPE[i]);
|
|
178
180
|
ctx.type = CONTEXT_TYPE[i];
|
|
179
181
|
break;
|
|
180
182
|
}
|
|
@@ -223,25 +225,14 @@ class Handler {
|
|
|
223
225
|
let gl = this.gl;
|
|
224
226
|
let texture = gl.createTexture();
|
|
225
227
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
226
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
gl.TEXTURE_2D,
|
|
230
|
-
level,
|
|
231
|
-
gl[internalFormat.toUpperCase()],
|
|
232
|
-
width,
|
|
233
|
-
height,
|
|
234
|
-
0,
|
|
235
|
-
gl[format.toUpperCase()],
|
|
236
|
-
gl[type.toUpperCase()],
|
|
237
|
-
null
|
|
228
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
229
|
+
gl.texImage2D(gl.TEXTURE_2D, level, gl[internalFormat.toUpperCase()], width, height, 0,
|
|
230
|
+
gl[format.toUpperCase()], gl[type.toUpperCase()], null
|
|
238
231
|
);
|
|
239
|
-
|
|
240
232
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl[filter.toUpperCase()]);
|
|
241
233
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl[filter.toUpperCase()]);
|
|
242
234
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
243
235
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
244
|
-
|
|
245
236
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
246
237
|
return texture;
|
|
247
238
|
}
|
|
@@ -257,7 +248,7 @@ class Handler {
|
|
|
257
248
|
let gl = this.gl;
|
|
258
249
|
let texture = gl.createTexture();
|
|
259
250
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
260
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
251
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
261
252
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
262
253
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
263
254
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
@@ -278,7 +269,7 @@ class Handler {
|
|
|
278
269
|
let gl = this.gl;
|
|
279
270
|
let texture = gl.createTexture();
|
|
280
271
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
281
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
272
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
282
273
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
283
274
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
284
275
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
@@ -298,7 +289,7 @@ class Handler {
|
|
|
298
289
|
var gl = this.gl;
|
|
299
290
|
var texture = gl.createTexture();
|
|
300
291
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
301
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
292
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
302
293
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
303
294
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
304
295
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
@@ -339,10 +330,8 @@ class Handler {
|
|
|
339
330
|
let gl = this.gl;
|
|
340
331
|
let texture = gl.createTexture();
|
|
341
332
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
342
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
343
|
-
|
|
333
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
344
334
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
345
|
-
|
|
346
335
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
347
336
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
348
337
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -361,10 +350,8 @@ class Handler {
|
|
|
361
350
|
let gl = this.gl;
|
|
362
351
|
let texture = gl.createTexture();
|
|
363
352
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
364
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
365
|
-
|
|
353
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
366
354
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
367
|
-
|
|
368
355
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
369
356
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
370
357
|
gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
|
|
@@ -384,11 +371,10 @@ class Handler {
|
|
|
384
371
|
var gl = this.gl;
|
|
385
372
|
var texture = gl.createTexture();
|
|
386
373
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
387
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
388
|
-
|
|
374
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
375
|
+
//gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
389
376
|
gl.texStorage2D(gl.TEXTURE_2D, 1, internalFormat || gl.RGBA8, image.width, image.height);
|
|
390
377
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
391
|
-
|
|
392
378
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
393
379
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
394
380
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -407,10 +393,10 @@ class Handler {
|
|
|
407
393
|
let gl = this.gl;
|
|
408
394
|
let texture = gl.createTexture();
|
|
409
395
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
410
|
-
|
|
396
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
397
|
+
//gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
411
398
|
gl.texStorage2D(gl.TEXTURE_2D, 1, internalFormat || gl.RGBA8, image.width, image.height);
|
|
412
399
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
413
|
-
|
|
414
400
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
415
401
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
416
402
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -429,11 +415,10 @@ class Handler {
|
|
|
429
415
|
let gl = this.gl;
|
|
430
416
|
let texture = gl.createTexture();
|
|
431
417
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
432
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
433
|
-
|
|
418
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
419
|
+
//gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
434
420
|
gl.texStorage2D(gl.TEXTURE_2D, MAX_LEVELS, internalFormat || gl.RGBA8, image.width, image.height);
|
|
435
421
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
436
|
-
|
|
437
422
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
438
423
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
439
424
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -452,11 +437,10 @@ class Handler {
|
|
|
452
437
|
let gl = this.gl;
|
|
453
438
|
let texture = gl.createTexture();
|
|
454
439
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
455
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
456
|
-
|
|
440
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
441
|
+
//gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
457
442
|
gl.texStorage2D(gl.TEXTURE_2D, MAX_LEVELS, internalFormat || gl.RGBA8, image.width, image.height);
|
|
458
443
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
459
|
-
|
|
460
444
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
461
445
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
462
446
|
gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
|
|
@@ -503,7 +487,7 @@ class Handler {
|
|
|
503
487
|
for (let i = 0; i < faces.length; i++) {
|
|
504
488
|
let face = faces[i][1];
|
|
505
489
|
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
|
|
506
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
490
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
507
491
|
gl.texImage2D(face, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, emptyImage);
|
|
508
492
|
}
|
|
509
493
|
|
|
@@ -514,7 +498,7 @@ class Handler {
|
|
|
514
498
|
image.onload = (function (texture, face, image) {
|
|
515
499
|
return function () {
|
|
516
500
|
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
|
|
517
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
501
|
+
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
518
502
|
gl.texImage2D(face, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
519
503
|
};
|
|
520
504
|
})(texture, face, image);
|
|
@@ -677,6 +661,17 @@ class Handler {
|
|
|
677
661
|
/** Initilalize shaders and rendering parameters*/
|
|
678
662
|
this._initPrograms();
|
|
679
663
|
this._setDefaults();
|
|
664
|
+
|
|
665
|
+
document.addEventListener("visibilitychange", () => {
|
|
666
|
+
if (document.visibilityState === 'visible') {
|
|
667
|
+
this.start();
|
|
668
|
+
this.ONCANVASRESIZE && this.ONCANVASRESIZE();
|
|
669
|
+
this.events.dispatch(this.events.visibilitychange, true);
|
|
670
|
+
} else {
|
|
671
|
+
this.events.dispatch(this.events.visibilitychange, false);
|
|
672
|
+
this.stop();
|
|
673
|
+
}
|
|
674
|
+
});
|
|
680
675
|
}
|
|
681
676
|
|
|
682
677
|
/**
|
|
@@ -812,7 +807,8 @@ class Handler {
|
|
|
812
807
|
this._oneByHeight = 1.0 / this.canvas.height;
|
|
813
808
|
|
|
814
809
|
this.gl && this.gl.viewport(0, 0, w, h);
|
|
815
|
-
this.
|
|
810
|
+
this.ONCANVASRESIZE && this.ONCANVASRESIZE(this.canvas);
|
|
811
|
+
this.events.dispatch(this.events.resize, this);
|
|
816
812
|
}
|
|
817
813
|
|
|
818
814
|
get pixelRatio() {
|
|
@@ -882,7 +878,12 @@ class Handler {
|
|
|
882
878
|
let canvas = this.canvas;
|
|
883
879
|
|
|
884
880
|
if (Math.floor(canvas.clientWidth * this._params.pixelRatio) !== canvas.width || Math.floor(canvas.clientHeight * this._params.pixelRatio) !== canvas.height) {
|
|
885
|
-
|
|
881
|
+
if (canvas.clientWidth === 0 || canvas.clientHeight === 0) {
|
|
882
|
+
this.stop();
|
|
883
|
+
} else if (!document.hidden) {
|
|
884
|
+
this.start();
|
|
885
|
+
this.setSize(canvas.clientWidth, canvas.clientHeight);
|
|
886
|
+
}
|
|
886
887
|
}
|
|
887
888
|
|
|
888
889
|
/** Draw frame */
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import { Handler } from "./Handler.js";
|
|
2
|
-
import { Program } from "./Program.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This is shader program controller that used by hadler object to access the shader
|
|
8
|
-
* program capabilities, like switching program during the rendering.
|
|
9
|
-
* Get access to the program from ...handler.programs.<program name> etc.
|
|
10
|
-
* @class
|
|
11
|
-
*/
|
|
12
|
-
export class ProgramController {
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {Handler} handler - Handler.
|
|
16
|
-
* @param {Program} program - Shader program.
|
|
17
|
-
*/
|
|
18
|
-
constructor(handler, program) {
|
|
19
|
-
/**
|
|
20
|
-
* Shader program.
|
|
21
|
-
* @private
|
|
22
|
-
* @type {Program}
|
|
23
|
-
*/
|
|
24
|
-
this._program = program;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Handler.
|
|
28
|
-
* @private
|
|
29
|
-
* @type {Handler}
|
|
30
|
-
*/
|
|
31
|
-
this._handler = handler;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Program current frame activation flag.
|
|
35
|
-
* @private
|
|
36
|
-
* @type {boolean}
|
|
37
|
-
*/
|
|
38
|
-
this._activated = false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Lazy create program call.
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
initialize() {
|
|
46
|
-
this._program.createProgram(this._handler.gl);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Returns controller's shader program.
|
|
51
|
-
* @public
|
|
52
|
-
* @return {Program} -
|
|
53
|
-
*/
|
|
54
|
-
getProgram() {
|
|
55
|
-
return this._program;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Activates current shader program.
|
|
60
|
-
* @public
|
|
61
|
-
* @returns {ProgramController} -
|
|
62
|
-
*/
|
|
63
|
-
activate() {
|
|
64
|
-
if (!this._activated) {
|
|
65
|
-
this._handler.activeProgram.deactivate();
|
|
66
|
-
this._handler.activeProgram = this;
|
|
67
|
-
var p = this._program;
|
|
68
|
-
this._activated = true;
|
|
69
|
-
p.enableAttribArrays();
|
|
70
|
-
p.use();
|
|
71
|
-
}
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Remove program from handler
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
79
|
-
remove() {
|
|
80
|
-
var p = this._handler.programs;
|
|
81
|
-
if (p[this._program.name]) {
|
|
82
|
-
if (this._activated) {
|
|
83
|
-
this.deactivate();
|
|
84
|
-
}
|
|
85
|
-
this._program.delete();
|
|
86
|
-
p[this._program.name] = null;
|
|
87
|
-
delete p[this._program.name];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Deactivate shader program. This is not necessary while activae function used.
|
|
93
|
-
* @public
|
|
94
|
-
*/
|
|
95
|
-
deactivate() {
|
|
96
|
-
this._program.disableAttribArrays();
|
|
97
|
-
this._activated = false;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Returns program activity.
|
|
102
|
-
* @public
|
|
103
|
-
* @return {boolean} -
|
|
104
|
-
*/
|
|
105
|
-
isActive() {
|
|
106
|
-
return this._activated;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Sets program uniforms and attributes values and return controller instance.
|
|
111
|
-
* @public
|
|
112
|
-
* @param {Object} params - Object with variable name and value like { value: 12, someArray:[1,2,3], uSampler: texture,... }
|
|
113
|
-
* @return {ProgramController} -
|
|
114
|
-
*/
|
|
115
|
-
set(params) {
|
|
116
|
-
this.activate();
|
|
117
|
-
this._program.set(params);
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Draw index buffer with this program.
|
|
123
|
-
* @public
|
|
124
|
-
* @param {number} mode - Gl draw mode
|
|
125
|
-
* @param {WEBGLBuffer} buffer - Buffer to draw.
|
|
126
|
-
* @return {ProgramController} Returns current shader controller instance.
|
|
127
|
-
*/
|
|
128
|
-
drawIndexBuffer(mode, buffer) {
|
|
129
|
-
this._program.drawIndexBuffer(mode, buffer);
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Calls Gl drawArray function.
|
|
135
|
-
* @param {number} mode - Gl draw mode.
|
|
136
|
-
* @param {number} numItems - draw items count.
|
|
137
|
-
* @return {ProgramController} Returns current shader controller instance.
|
|
138
|
-
*/
|
|
139
|
-
drawArrays(mode, numItems) {
|
|
140
|
-
this._program.drawArrays(mode, numItems);
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
1
|
+
import { Handler } from "./Handler.js";
|
|
2
|
+
import { Program } from "./Program.js";
|
|
3
|
+
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is shader program controller that used by hadler object to access the shader
|
|
8
|
+
* program capabilities, like switching program during the rendering.
|
|
9
|
+
* Get access to the program from ...handler.programs.<program name> etc.
|
|
10
|
+
* @class
|
|
11
|
+
*/
|
|
12
|
+
export class ProgramController {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {Handler} handler - Handler.
|
|
16
|
+
* @param {Program} program - Shader program.
|
|
17
|
+
*/
|
|
18
|
+
constructor(handler, program) {
|
|
19
|
+
/**
|
|
20
|
+
* Shader program.
|
|
21
|
+
* @private
|
|
22
|
+
* @type {Program}
|
|
23
|
+
*/
|
|
24
|
+
this._program = program;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Handler.
|
|
28
|
+
* @private
|
|
29
|
+
* @type {Handler}
|
|
30
|
+
*/
|
|
31
|
+
this._handler = handler;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Program current frame activation flag.
|
|
35
|
+
* @private
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
this._activated = false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Lazy create program call.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
initialize() {
|
|
46
|
+
this._program.createProgram(this._handler.gl);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns controller's shader program.
|
|
51
|
+
* @public
|
|
52
|
+
* @return {Program} -
|
|
53
|
+
*/
|
|
54
|
+
getProgram() {
|
|
55
|
+
return this._program;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Activates current shader program.
|
|
60
|
+
* @public
|
|
61
|
+
* @returns {ProgramController} -
|
|
62
|
+
*/
|
|
63
|
+
activate() {
|
|
64
|
+
if (!this._activated) {
|
|
65
|
+
this._handler.activeProgram.deactivate();
|
|
66
|
+
this._handler.activeProgram = this;
|
|
67
|
+
var p = this._program;
|
|
68
|
+
this._activated = true;
|
|
69
|
+
p.enableAttribArrays();
|
|
70
|
+
p.use();
|
|
71
|
+
}
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Remove program from handler
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
remove() {
|
|
80
|
+
var p = this._handler.programs;
|
|
81
|
+
if (p[this._program.name]) {
|
|
82
|
+
if (this._activated) {
|
|
83
|
+
this.deactivate();
|
|
84
|
+
}
|
|
85
|
+
this._program.delete();
|
|
86
|
+
p[this._program.name] = null;
|
|
87
|
+
delete p[this._program.name];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Deactivate shader program. This is not necessary while activae function used.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
deactivate() {
|
|
96
|
+
this._program.disableAttribArrays();
|
|
97
|
+
this._activated = false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns program activity.
|
|
102
|
+
* @public
|
|
103
|
+
* @return {boolean} -
|
|
104
|
+
*/
|
|
105
|
+
isActive() {
|
|
106
|
+
return this._activated;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Sets program uniforms and attributes values and return controller instance.
|
|
111
|
+
* @public
|
|
112
|
+
* @param {Object} params - Object with variable name and value like { value: 12, someArray:[1,2,3], uSampler: texture,... }
|
|
113
|
+
* @return {ProgramController} -
|
|
114
|
+
*/
|
|
115
|
+
set(params) {
|
|
116
|
+
this.activate();
|
|
117
|
+
this._program.set(params);
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Draw index buffer with this program.
|
|
123
|
+
* @public
|
|
124
|
+
* @param {number} mode - Gl draw mode
|
|
125
|
+
* @param {WEBGLBuffer} buffer - Buffer to draw.
|
|
126
|
+
* @return {ProgramController} Returns current shader controller instance.
|
|
127
|
+
*/
|
|
128
|
+
drawIndexBuffer(mode, buffer) {
|
|
129
|
+
this._program.drawIndexBuffer(mode, buffer);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Calls Gl drawArray function.
|
|
135
|
+
* @param {number} mode - Gl draw mode.
|
|
136
|
+
* @param {number} numItems - draw items count.
|
|
137
|
+
* @return {ProgramController} Returns current shader controller instance.
|
|
138
|
+
*/
|
|
139
|
+
drawArrays(mode, numItems) {
|
|
140
|
+
this._program.drawArrays(mode, numItems);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class Object3d {
|
|
2
|
+
static scale(vertices: any, s: any): void;
|
|
3
|
+
static centroid(vertices: any): number[];
|
|
4
|
+
static translate(vertices: any, v: any): void;
|
|
5
|
+
static getNormals(vertices: any): any[];
|
|
6
|
+
static createSphere(lonBands?: number, latBands?: number, radius?: number, offsetX?: number, offsetY?: number, offsetZ?: number): Object3d;
|
|
7
|
+
static createDisc(radius: number, height: number, radialSegments: number, isTop: boolean, startIndex: number, offsetX: number, offsetY: any, offsetZ?: number): Object3d;
|
|
8
|
+
static createCylinder(radiusTop?: number, radiusBottom?: number, height?: number, radialSegments?: number, heightSegments?: number, isTop?: boolean, isBottom?: boolean, offsetX?: number, offsetY?: number, offsetZ?: number): Object3d;
|
|
9
|
+
static createCube(length?: number, height?: number, depth?: number, xOffset?: number, yOffset?: number, zOffset?: number): Object3d;
|
|
10
|
+
static createArrow(back?: number, height?: number, front?: number): Object3d;
|
|
11
|
+
constructor(data: any);
|
|
12
|
+
_name: any;
|
|
13
|
+
_vertices: any;
|
|
14
|
+
_texCoords: any[];
|
|
15
|
+
color: any[] | Float32Array;
|
|
16
|
+
_indexes: any;
|
|
17
|
+
_normals: any;
|
|
18
|
+
get name(): any;
|
|
19
|
+
get vertices(): any;
|
|
20
|
+
get normals(): any;
|
|
21
|
+
get indexes(): any;
|
|
22
|
+
}
|