@openglobus/og 0.11.6 → 0.11.7
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 +11 -11
- package/src/og/Globe.js +8 -5
- package/src/og/Popup.js +3 -2
- package/src/og/camera/PlanetCamera.js +9 -4
- package/src/og/control/Lighting.js +33 -2
- package/src/og/ellipsoid/Ellipsoid.js +1 -1
- package/src/og/entity/BaseBillboard.js +67 -76
- package/src/og/entity/BillboardHandler.js +15 -8
- package/src/og/entity/Label.js +44 -47
- package/src/og/entity/LabelHandler.js +25 -25
- package/src/og/entity/LabelWorker.js +21 -16
- package/src/og/layer/Layer.js +28 -15
- package/src/og/layer/Material.js +1 -1
- package/src/og/quadTree/Node.js +16 -30
- package/src/og/renderer/Renderer.js +19 -29
- package/src/og/renderer/RendererEvents.js +41 -21
- package/src/og/scene/Planet.js +11 -28
- package/src/og/shaders/drawnode.js +135 -142
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +1 -1
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +2 -2
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +152 -118
- package/types/Clock.d.ts +0 -94
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -77
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -82
- package/types/ImageCanvas.d.ts +0 -123
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -42
- package/types/QueueArray.d.ts +0 -19
- package/types/Rectangle.d.ts +0 -80
- package/types/Stack.d.ts +0 -19
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -7
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -30
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -312
- package/types/camera/Frustum.d.ts +0 -133
- package/types/camera/PlanetCamera.d.ts +0 -218
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -17
- package/types/control/Control.d.ts +0 -104
- package/types/control/DebugInfo.d.ts +0 -15
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -21
- package/types/control/LayerSwitcher.d.ts +0 -21
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -47
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -11
- package/types/control/SimpleNavigation.d.ts +0 -25
- package/types/control/Sun.d.ts +0 -50
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -48
- package/types/control/ZoomControl.d.ts +0 -27
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -146
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -6
- package/types/entity/BaseBillboard.d.ts +0 -215
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -78
- package/types/entity/Entity.d.ts +0 -348
- package/types/entity/EntityCollection.d.ts +0 -317
- package/types/entity/GeoObject.d.ts +0 -111
- package/types/entity/GeoObjectHandler.d.ts +0 -77
- package/types/entity/Geometry.d.ts +0 -74
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -189
- package/types/entity/LabelHandler.d.ts +0 -31
- package/types/entity/LabelWorker.d.ts +0 -9
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -306
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -124
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -119
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -94
- package/types/layer/CanvasTiles.d.ts +0 -68
- package/types/layer/GeoImage.d.ts +0 -52
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -55
- package/types/layer/KML.d.ts +0 -63
- package/types/layer/Layer.d.ts +0 -326
- package/types/layer/Material.d.ts +0 -45
- package/types/layer/Vector.d.ts +0 -208
- package/types/layer/WMS.d.ts +0 -63
- package/types/layer/XYZ.d.ts +0 -120
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -178
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -65
- package/types/math/Mat4.d.ts +0 -176
- package/types/math/Plane.d.ts +0 -18
- package/types/math/Quat.d.ts +0 -379
- package/types/math/Ray.d.ts +0 -82
- package/types/math/Vec2.d.ts +0 -309
- package/types/math/Vec3.d.ts +0 -460
- package/types/math/Vec4.d.ts +0 -162
- package/types/math/coder.d.ts +0 -43
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -6
- package/types/proj/EPSG4326.d.ts +0 -6
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -300
- package/types/renderer/RendererEvents.d.ts +0 -233
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -577
- package/types/scene/RenderNode.d.ts +0 -142
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -279
- package/types/segment/SegmentLonLat.d.ts +0 -16
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/geoObject.d.ts +0 -3
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -250
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -7
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -116
- package/types/terrain/MapboxTerrain.d.ts +0 -7
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -231
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -397
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -161
- package/types/webgl/ProgramController.d.ts +0 -89
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
package/src/og/webgl/Handler.js
CHANGED
|
@@ -12,15 +12,11 @@ import { ProgramController } from "./ProgramController.js";
|
|
|
12
12
|
import { Stack } from "../Stack.js";
|
|
13
13
|
import { Vec2 } from "../math/Vec2.js";
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Maximum texture image size.
|
|
17
|
-
* @const
|
|
18
|
-
* @type {number}
|
|
19
|
-
*/
|
|
20
|
-
const MAX_SIZE = 4096;
|
|
21
|
-
|
|
22
15
|
const vendorPrefixes = ["", "WEBKIT_", "MOZ_"];
|
|
23
16
|
|
|
17
|
+
// Maximal mipmap levels
|
|
18
|
+
const MAX_LEVELS = 2;
|
|
19
|
+
|
|
24
20
|
/**
|
|
25
21
|
* A WebGL handler for accessing low-level WebGL capabilities.
|
|
26
22
|
* @class
|
|
@@ -92,21 +88,13 @@ class Handler {
|
|
|
92
88
|
* @type {Object}
|
|
93
89
|
*/
|
|
94
90
|
this._params = params || {};
|
|
95
|
-
this._params.anisotropy = this._params.anisotropy ||
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
this._params.width = w || 256;
|
|
101
|
-
|
|
102
|
-
let h = this._params.height;
|
|
103
|
-
if (h > MAX_SIZE) {
|
|
104
|
-
h = MAX_SIZE;
|
|
105
|
-
}
|
|
106
|
-
this._params.height = h || 256;
|
|
91
|
+
this._params.anisotropy = this._params.anisotropy || 4;
|
|
92
|
+
this._params.width = this._params.width || 256;
|
|
93
|
+
this._params.height = this._params.height || 256;
|
|
94
|
+
this._params.pixelRatio = this._params.pixelRatio || 1.0;
|
|
107
95
|
this._params.context = this._params.context || {};
|
|
108
96
|
this._params.extensions = this._params.extensions || [];
|
|
109
|
-
this._oneByHeight = 1 / this._params.height;
|
|
97
|
+
this._oneByHeight = 1.0 / (this._params.height * this._params.pixelRatio);
|
|
110
98
|
|
|
111
99
|
/**
|
|
112
100
|
* Current WebGL extensions. Becomes here after context initialization.
|
|
@@ -131,12 +119,21 @@ class Handler {
|
|
|
131
119
|
* @private
|
|
132
120
|
* @type {frameCallback}
|
|
133
121
|
*/
|
|
134
|
-
this._frameCallback = function () {};
|
|
122
|
+
this._frameCallback = function () { };
|
|
135
123
|
|
|
136
124
|
this.transparentTexture = null;
|
|
137
125
|
|
|
138
126
|
this.framebufferStack = new Stack();
|
|
139
127
|
|
|
128
|
+
this.createTexture = {
|
|
129
|
+
"NEAREST": null,
|
|
130
|
+
"LINEAR": null,
|
|
131
|
+
"MIPMAP": null,
|
|
132
|
+
"ANISOTROPIC": null
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
this.createTextureDefault = null;
|
|
136
|
+
|
|
140
137
|
if (params.autoActivate || isEmpty(params.autoActivate)) {
|
|
141
138
|
this.initialize();
|
|
142
139
|
}
|
|
@@ -245,48 +242,6 @@ class Handler {
|
|
|
245
242
|
return texture;
|
|
246
243
|
}
|
|
247
244
|
|
|
248
|
-
///**
|
|
249
|
-
// * Creates Empty half float texture.
|
|
250
|
-
// * @public
|
|
251
|
-
// * @param {number} width - Empty texture width.
|
|
252
|
-
// * @param {number} height - Empty texture height.
|
|
253
|
-
// * @returns {Object} - WebGL half float texture object.
|
|
254
|
-
// */
|
|
255
|
-
//createEmptyTexture_hf(width, height) {
|
|
256
|
-
// var gl = this.gl;
|
|
257
|
-
// var texture = gl.createTexture();
|
|
258
|
-
// gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
259
|
-
// gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
260
|
-
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.HALF_FLOAT_OES, null);
|
|
261
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
262
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
263
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
264
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
265
|
-
// gl.bindTexture(gl.TEXTURE_2D, null);
|
|
266
|
-
// return texture;
|
|
267
|
-
//}
|
|
268
|
-
|
|
269
|
-
///**
|
|
270
|
-
// * Creates Empty float texture.
|
|
271
|
-
// * @public
|
|
272
|
-
// * @param {number} width - Empty texture width.
|
|
273
|
-
// * @param {number} height - Empty texture height.
|
|
274
|
-
// * @returns {Object} - WebGL float texture object.
|
|
275
|
-
// */
|
|
276
|
-
//createEmptyTexture_f(width, height) {
|
|
277
|
-
// var gl = this.gl;
|
|
278
|
-
// var texture = gl.createTexture();
|
|
279
|
-
// gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
280
|
-
// gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
281
|
-
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.FLOAT, null);
|
|
282
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
283
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
284
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
285
|
-
// //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
286
|
-
// gl.bindTexture(gl.TEXTURE_2D, null);
|
|
287
|
-
// return texture;
|
|
288
|
-
//}
|
|
289
|
-
|
|
290
245
|
/**
|
|
291
246
|
* Creates Empty NEAREST filtered texture.
|
|
292
247
|
* @public
|
|
@@ -294,12 +249,12 @@ class Handler {
|
|
|
294
249
|
* @param {number} height - Empty texture height.
|
|
295
250
|
* @returns {Object} - WebGL texture object.
|
|
296
251
|
*/
|
|
297
|
-
createEmptyTexture_n(width, height) {
|
|
252
|
+
createEmptyTexture_n(width, height, internalFormat) {
|
|
298
253
|
let gl = this.gl;
|
|
299
254
|
let texture = gl.createTexture();
|
|
300
255
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
301
256
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
302
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
257
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
303
258
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
304
259
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
305
260
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -315,12 +270,12 @@ class Handler {
|
|
|
315
270
|
* @param {number} height - Empty texture height.
|
|
316
271
|
* @returns {Object} - WebGL texture object.
|
|
317
272
|
*/
|
|
318
|
-
createEmptyTexture_l(width, height) {
|
|
273
|
+
createEmptyTexture_l(width, height, internalFormat) {
|
|
319
274
|
let gl = this.gl;
|
|
320
275
|
let texture = gl.createTexture();
|
|
321
276
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
322
277
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
323
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
278
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
324
279
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
325
280
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
326
281
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -335,12 +290,12 @@ class Handler {
|
|
|
335
290
|
* @param {Object} image - Image or Canvas object.
|
|
336
291
|
* @returns {Object} - WebGL texture object.
|
|
337
292
|
*/
|
|
338
|
-
|
|
339
|
-
var gl =
|
|
293
|
+
createTexture_n_webgl1(image, internalFormat) {
|
|
294
|
+
var gl = this.gl;
|
|
340
295
|
var texture = gl.createTexture();
|
|
341
296
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
342
297
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
343
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
298
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
344
299
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
345
300
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
346
301
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -355,11 +310,13 @@ class Handler {
|
|
|
355
310
|
* @param {Object} image - Image or Canvas object.
|
|
356
311
|
* @returns {Object} - WebGL texture object.
|
|
357
312
|
*/
|
|
358
|
-
|
|
359
|
-
let gl =
|
|
313
|
+
createTexture_l_webgl1(image, internalFormat) {
|
|
314
|
+
let gl = this.gl;
|
|
360
315
|
let texture = gl.createTexture();
|
|
361
316
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
362
|
-
|
|
317
|
+
|
|
318
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
319
|
+
|
|
363
320
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
364
321
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
365
322
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -374,12 +331,14 @@ class Handler {
|
|
|
374
331
|
* @param {Object} image - Image or Canvas object.
|
|
375
332
|
* @returns {Object} - WebGL texture object.
|
|
376
333
|
*/
|
|
377
|
-
|
|
378
|
-
let gl =
|
|
334
|
+
createTexture_mm_webgl1(image, internalFormat) {
|
|
335
|
+
let gl = this.gl;
|
|
379
336
|
let texture = gl.createTexture();
|
|
380
337
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
381
338
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
382
|
-
|
|
339
|
+
|
|
340
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
341
|
+
|
|
383
342
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
384
343
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
385
344
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -394,19 +353,17 @@ class Handler {
|
|
|
394
353
|
* @param {Object} image - Image or Canvas object.
|
|
395
354
|
* @returns {Object} - WebGL texture object.
|
|
396
355
|
*/
|
|
397
|
-
|
|
398
|
-
let gl =
|
|
356
|
+
createTexture_a_webgl1(image, internalFormat) {
|
|
357
|
+
let gl = this.gl;
|
|
399
358
|
let texture = gl.createTexture();
|
|
400
359
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
401
360
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
402
|
-
|
|
361
|
+
|
|
362
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
363
|
+
|
|
403
364
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
404
365
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
405
|
-
gl.texParameterf(
|
|
406
|
-
gl.TEXTURE_2D,
|
|
407
|
-
handler.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,
|
|
408
|
-
handler._params.anisotropy
|
|
409
|
-
);
|
|
366
|
+
gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
|
|
410
367
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
411
368
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
412
369
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
@@ -414,29 +371,95 @@ class Handler {
|
|
|
414
371
|
}
|
|
415
372
|
|
|
416
373
|
/**
|
|
417
|
-
* Creates
|
|
374
|
+
* Creates NEAREST filter texture.
|
|
418
375
|
* @public
|
|
419
376
|
* @param {Object} image - Image or Canvas object.
|
|
420
377
|
* @returns {Object} - WebGL texture object.
|
|
421
378
|
*/
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
379
|
+
createTexture_n_webgl2(image, internalFormat) {
|
|
380
|
+
var gl = this.gl;
|
|
381
|
+
var texture = gl.createTexture();
|
|
382
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
383
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
384
|
+
|
|
385
|
+
gl.texStorage2D(gl.TEXTURE_2D, 1, internalFormat || gl.RGBA8, image.width, image.height);
|
|
386
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
425
387
|
|
|
426
|
-
|
|
427
|
-
|
|
388
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
389
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
390
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
391
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
392
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
393
|
+
return texture;
|
|
428
394
|
}
|
|
429
395
|
|
|
430
|
-
|
|
431
|
-
|
|
396
|
+
/**
|
|
397
|
+
* Creates LINEAR filter texture.
|
|
398
|
+
* @public
|
|
399
|
+
* @param {Object} image - Image or Canvas object.
|
|
400
|
+
* @returns {Object} - WebGL texture object.
|
|
401
|
+
*/
|
|
402
|
+
createTexture_l_webgl2(image, internalFormat) {
|
|
403
|
+
let gl = this.gl;
|
|
404
|
+
let texture = gl.createTexture();
|
|
405
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
406
|
+
|
|
407
|
+
gl.texStorage2D(gl.TEXTURE_2D, 1, internalFormat || gl.RGBA8, image.width, image.height);
|
|
408
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
409
|
+
|
|
410
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
411
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
412
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
413
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
414
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
415
|
+
return texture;
|
|
432
416
|
}
|
|
433
417
|
|
|
434
|
-
|
|
435
|
-
|
|
418
|
+
/**
|
|
419
|
+
* Creates MIPMAP filter texture.
|
|
420
|
+
* @public
|
|
421
|
+
* @param {Object} image - Image or Canvas object.
|
|
422
|
+
* @returns {Object} - WebGL texture object.
|
|
423
|
+
*/
|
|
424
|
+
createTexture_mm_webgl2(image, internalFormat) {
|
|
425
|
+
let gl = this.gl;
|
|
426
|
+
let texture = gl.createTexture();
|
|
427
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
428
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
429
|
+
|
|
430
|
+
gl.texStorage2D(gl.TEXTURE_2D, MAX_LEVELS, internalFormat || gl.RGBA8, image.width, image.height);
|
|
431
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
432
|
+
|
|
433
|
+
gl.generateMipmap(gl.TEXTURE_2D);
|
|
434
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
435
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
436
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
437
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
438
|
+
return texture;
|
|
436
439
|
}
|
|
437
440
|
|
|
438
|
-
|
|
439
|
-
|
|
441
|
+
/**
|
|
442
|
+
* Creates ANISOTROPY filter texture.
|
|
443
|
+
* @public
|
|
444
|
+
* @param {Object} image - Image or Canvas object.
|
|
445
|
+
* @returns {Object} - WebGL texture object.
|
|
446
|
+
*/
|
|
447
|
+
createTexture_a_webgl2(image, internalFormat) {
|
|
448
|
+
let gl = this.gl;
|
|
449
|
+
let texture = gl.createTexture();
|
|
450
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
451
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
452
|
+
|
|
453
|
+
gl.texStorage2D(gl.TEXTURE_2D, MAX_LEVELS, internalFormat || gl.RGBA8, image.width, image.height);
|
|
454
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
455
|
+
|
|
456
|
+
gl.generateMipmap(gl.TEXTURE_2D);
|
|
457
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
458
|
+
gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
|
|
459
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
460
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
461
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
462
|
+
return texture;
|
|
440
463
|
}
|
|
441
464
|
|
|
442
465
|
/**
|
|
@@ -623,8 +646,23 @@ class Handler {
|
|
|
623
646
|
this.initializeExtension(this._params.extensions[i], true);
|
|
624
647
|
}
|
|
625
648
|
|
|
649
|
+
//
|
|
650
|
+
//TODO: webgl1 case
|
|
651
|
+
//
|
|
652
|
+
this.createTexture_n = this.createTexture_n_webgl2.bind(this);
|
|
653
|
+
this.createTexture_l = this.createTexture_l_webgl2.bind(this);
|
|
654
|
+
this.createTexture_mm = this.createTexture_mm_webgl2.bind(this);
|
|
655
|
+
this.createTexture_a = this.createTexture_a_webgl2.bind(this);
|
|
656
|
+
|
|
657
|
+
this.createTexture["NEAREST"] = this.createTexture_n;
|
|
658
|
+
this.createTexture["LINEAR"] = this.createTexture_l;
|
|
659
|
+
this.createTexture["MIPMAP"] = this.createTexture_mm;
|
|
660
|
+
this.createTexture["ANISOTROPIC"] = this.createTexture_a;
|
|
661
|
+
|
|
626
662
|
if (!this.extensions.EXT_texture_filter_anisotropic) {
|
|
627
|
-
this.
|
|
663
|
+
this.createTextureDefault = this.createTexture_mm;
|
|
664
|
+
} else {
|
|
665
|
+
this.createTextureDefault = this.createTexture_a;
|
|
628
666
|
}
|
|
629
667
|
|
|
630
668
|
/** Initilalize shaders and rendering parameters*/
|
|
@@ -804,24 +842,26 @@ class Handler {
|
|
|
804
842
|
* @param {number} h - Canvas height.
|
|
805
843
|
*/
|
|
806
844
|
setSize(w, h) {
|
|
807
|
-
if (w > MAX_SIZE) {
|
|
808
|
-
w = MAX_SIZE;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
if (h > MAX_SIZE) {
|
|
812
|
-
h = MAX_SIZE;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
845
|
this._params.width = w;
|
|
816
846
|
this._params.height = h;
|
|
817
|
-
this.canvas.width = w;
|
|
818
|
-
this.canvas.height = h;
|
|
819
|
-
|
|
847
|
+
this.canvas.width = w * this._params.pixelRatio;
|
|
848
|
+
this.canvas.height = h * this._params.pixelRatio;
|
|
849
|
+
|
|
850
|
+
this._oneByHeight = 1.0 / this.canvas.height;
|
|
820
851
|
|
|
821
852
|
this.gl && this.gl.viewport(0, 0, w, h);
|
|
822
853
|
this.onCanvasResize && this.onCanvasResize(this.canvas);
|
|
823
854
|
}
|
|
824
855
|
|
|
856
|
+
get pixelRatio() {
|
|
857
|
+
return this._params.pixelRatio;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
set pixelRatio(pr) {
|
|
861
|
+
this._params.pixelRatio = pr;
|
|
862
|
+
this.setSize(this._params.width, this._params.height);
|
|
863
|
+
}
|
|
864
|
+
|
|
825
865
|
/**
|
|
826
866
|
* Returns context screen width.
|
|
827
867
|
* @public
|
|
@@ -878,7 +918,8 @@ class Handler {
|
|
|
878
918
|
|
|
879
919
|
/** Canvas resize checking */
|
|
880
920
|
let canvas = this.canvas;
|
|
881
|
-
|
|
921
|
+
|
|
922
|
+
if (canvas.clientWidth * this._params.pixelRatio !== canvas.width || canvas.clientHeight * this._params.pixelRatio !== canvas.height) {
|
|
882
923
|
this.setSize(canvas.clientWidth, canvas.clientHeight);
|
|
883
924
|
}
|
|
884
925
|
|
|
@@ -938,7 +979,7 @@ class Handler {
|
|
|
938
979
|
if (params && params.color) {
|
|
939
980
|
imgCnv = new ImageCanvas(2, 2);
|
|
940
981
|
imgCnv.fillColor(params.color);
|
|
941
|
-
texture =
|
|
982
|
+
texture = this.createTexture_n_webgl2(imgCnv._canvas, this.gl.RGBA8);
|
|
942
983
|
texture.default = true;
|
|
943
984
|
success(texture);
|
|
944
985
|
} else if (params && params.url) {
|
|
@@ -953,7 +994,7 @@ class Handler {
|
|
|
953
994
|
} else {
|
|
954
995
|
imgCnv = new ImageCanvas(2, 2);
|
|
955
996
|
imgCnv.fillColor("#C5C5C5");
|
|
956
|
-
texture =
|
|
997
|
+
texture = this.createTexture_n_webgl2(imgCnv._canvas, this.gl.RGBA8);
|
|
957
998
|
texture.default = true;
|
|
958
999
|
success(texture);
|
|
959
1000
|
}
|
|
@@ -1052,11 +1093,4 @@ class Handler {
|
|
|
1052
1093
|
}
|
|
1053
1094
|
}
|
|
1054
1095
|
|
|
1055
|
-
export const createTexture = {
|
|
1056
|
-
NEAREST: Handler.createTexture_n,
|
|
1057
|
-
LINEAR: Handler.createTexture_l,
|
|
1058
|
-
MIPMAP: Handler.createTexture_mm,
|
|
1059
|
-
ANISOTROPIC: Handler.createTexture_a
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
1096
|
export { Handler };
|
package/types/Clock.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class represents application timer that stores custom current julian datetime, and time speed multiplier.
|
|
3
|
-
* @class
|
|
4
|
-
* @param {Object} [params] - Clock parameters:
|
|
5
|
-
* @param {number} [params.startDate=0.0] - Julian start date.
|
|
6
|
-
* @param {number} [params.endDate=0.0] - Julian end date.
|
|
7
|
-
* @param {number} [params.currentDate] - Julian current date. Default: current date.
|
|
8
|
-
* @param {number} [params.multiplier=1.0] - Time speed multiolier.
|
|
9
|
-
*/
|
|
10
|
-
export class Clock {
|
|
11
|
-
static set _staticCounter(arg: any);
|
|
12
|
-
static get _staticCounter(): any;
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {Object} [params] - Clock parameters:
|
|
16
|
-
*/
|
|
17
|
-
constructor(params?: any);
|
|
18
|
-
_id: number;
|
|
19
|
-
/**
|
|
20
|
-
* Clock name.
|
|
21
|
-
* @public
|
|
22
|
-
* @type {string}
|
|
23
|
-
*/
|
|
24
|
-
public name: string;
|
|
25
|
-
/**
|
|
26
|
-
* Clock events.
|
|
27
|
-
* @public
|
|
28
|
-
* @type {Events}
|
|
29
|
-
*/
|
|
30
|
-
public events: Events;
|
|
31
|
-
/**
|
|
32
|
-
* Start julian date clock loop.
|
|
33
|
-
* @public
|
|
34
|
-
* @type {number}
|
|
35
|
-
*/
|
|
36
|
-
public startDate: number;
|
|
37
|
-
/**
|
|
38
|
-
* End julian date clock loop.
|
|
39
|
-
* @public
|
|
40
|
-
* @type {number}
|
|
41
|
-
*/
|
|
42
|
-
public endDate: number;
|
|
43
|
-
/**
|
|
44
|
-
* Current julian datetime.
|
|
45
|
-
* @public
|
|
46
|
-
* @type {number}
|
|
47
|
-
*/
|
|
48
|
-
public currentDate: number;
|
|
49
|
-
/**
|
|
50
|
-
* Timer speed multiplier.
|
|
51
|
-
* @public
|
|
52
|
-
* @type {number}
|
|
53
|
-
*/
|
|
54
|
-
public multiplier: number;
|
|
55
|
-
/**
|
|
56
|
-
* Animation frame delta time.
|
|
57
|
-
* @public
|
|
58
|
-
* @readonly
|
|
59
|
-
* @type {number}
|
|
60
|
-
*/
|
|
61
|
-
public readonly deltaTicks: number;
|
|
62
|
-
/**
|
|
63
|
-
* Timer activity.
|
|
64
|
-
* @public
|
|
65
|
-
* @type {boolean}
|
|
66
|
-
*/
|
|
67
|
-
public active: boolean;
|
|
68
|
-
_intervalDelay: number;
|
|
69
|
-
_intervalStart: number;
|
|
70
|
-
_intervalCallback: any;
|
|
71
|
-
clearInterval(): void;
|
|
72
|
-
setInterval(delay: any, callback: any): void;
|
|
73
|
-
/**
|
|
74
|
-
* Sets current clock datetime.
|
|
75
|
-
* @public
|
|
76
|
-
* @param {Object} date - JavaScript Date object.
|
|
77
|
-
*/
|
|
78
|
-
public setDate(date: any): void;
|
|
79
|
-
/**
|
|
80
|
-
* Returns current application date.
|
|
81
|
-
* @public
|
|
82
|
-
* @returns {Date} - Current date.
|
|
83
|
-
*/
|
|
84
|
-
public getDate(): Date;
|
|
85
|
-
reset(): void;
|
|
86
|
-
_tick(dt: any): void;
|
|
87
|
-
/**
|
|
88
|
-
* @public
|
|
89
|
-
* @param {Clock} clock - Clock instance to compare.
|
|
90
|
-
* @returns {boolean} - Returns true if a clock is the same instance.
|
|
91
|
-
*/
|
|
92
|
-
public equal(clock: Clock): boolean;
|
|
93
|
-
}
|
|
94
|
-
import { Events } from "./Events.js";
|
package/types/Deferred.d.ts
DELETED
package/types/Events.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base events class to handle custom events.
|
|
3
|
-
* @class
|
|
4
|
-
*/
|
|
5
|
-
export class Events {
|
|
6
|
-
static set _staticCounter(arg: any);
|
|
7
|
-
static get _staticCounter(): any;
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {Array.<string>} [eventNames] - Event names that could be dispatched.
|
|
11
|
-
* @param {*} [sender]
|
|
12
|
-
*/
|
|
13
|
-
constructor(eventNames?: Array<string>, sender?: any);
|
|
14
|
-
/**
|
|
15
|
-
* Registered event names.
|
|
16
|
-
* @protected
|
|
17
|
-
* @type {Array.<string>}
|
|
18
|
-
*/
|
|
19
|
-
protected _eventNames: Array<string>;
|
|
20
|
-
_sender: any;
|
|
21
|
-
/**
|
|
22
|
-
* Stop propagation flag
|
|
23
|
-
* @protected
|
|
24
|
-
* @type {boolean}
|
|
25
|
-
*/
|
|
26
|
-
protected _stopPropagation: boolean;
|
|
27
|
-
_stampCache: {};
|
|
28
|
-
__id: number;
|
|
29
|
-
bindSender(sender: any): void;
|
|
30
|
-
/**
|
|
31
|
-
* Function that creates event object properties that would be dispatched.
|
|
32
|
-
* @public
|
|
33
|
-
* @param {Array.<string>} eventNames - Specified event names list.
|
|
34
|
-
*/
|
|
35
|
-
public registerNames(eventNames: Array<string>): void;
|
|
36
|
-
_getStamp(name: any, id: any, ogid: any): string;
|
|
37
|
-
/**
|
|
38
|
-
* Returns true if event callback has stamped.
|
|
39
|
-
* @protected
|
|
40
|
-
* @param {Object} name - Event identifier.
|
|
41
|
-
* @param {Object} obj - Event callback.
|
|
42
|
-
* @return {boolean} -
|
|
43
|
-
*/
|
|
44
|
-
protected _stamp(name: any, obj: any): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Attach listener.
|
|
47
|
-
* @public
|
|
48
|
-
* @param {string} name - Event name to listen.
|
|
49
|
-
* @param {eventCallback} callback - Event callback function.
|
|
50
|
-
* @param {Object} sender - Event callback function owner.
|
|
51
|
-
*/
|
|
52
|
-
public on(name: string, callback: eventCallback, sender: any, priority?: number): void;
|
|
53
|
-
/**
|
|
54
|
-
* Stop listening event name with specified callback function.
|
|
55
|
-
* @public
|
|
56
|
-
* @param {string} name - Event name.
|
|
57
|
-
* @param {eventCallback} callback - Attached event callback.
|
|
58
|
-
*/
|
|
59
|
-
public off(name: string, callback: eventCallback): void;
|
|
60
|
-
/**
|
|
61
|
-
* Dispatch event.
|
|
62
|
-
* @public
|
|
63
|
-
* @param {Object} event - Event instance property that created by event name.
|
|
64
|
-
* @param {Object} [obj] - Event object.
|
|
65
|
-
*/
|
|
66
|
-
public dispatch(event: any, ...args: any[]): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Brakes events propagation.
|
|
69
|
-
* @public
|
|
70
|
-
*/
|
|
71
|
-
public stopPropagation(): void;
|
|
72
|
-
/**
|
|
73
|
-
* Removes all events.
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
public clear(): void;
|
|
77
|
-
}
|