@openglobus/og 0.11.2 → 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 +13 -13
- package/src/og/Clock.js +10 -10
- package/src/og/Events.js +8 -6
- package/src/og/Extent.js +82 -41
- package/src/og/Globe.js +25 -13
- package/src/og/ImageCanvas.js +22 -16
- package/src/og/LonLat.js +16 -13
- package/src/og/Popup.js +21 -14
- package/src/og/QueueArray.js +6 -2
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +5 -2
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +22 -16
- package/src/og/astro/jd.js +23 -18
- package/src/og/astro/orbit.js +13 -11
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +14 -11
- package/src/og/camera/Camera.js +51 -54
- package/src/og/camera/Frustum.js +29 -18
- package/src/og/camera/PlanetCamera.js +32 -23
- package/src/og/control/CompassButton.js +5 -1
- package/src/og/control/Control.js +12 -10
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +54 -33
- package/src/og/control/KeyboardNavigation.js +10 -10
- package/src/og/control/LayerSwitcher.js +22 -21
- package/src/og/control/Lighting.js +34 -3
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +6 -7
- package/src/og/control/ShowFps.js +13 -8
- package/src/og/control/SimpleNavigation.js +6 -8
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +4 -4
- package/src/og/control/TouchNavigation.js +44 -33
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/ellipsoid/Ellipsoid.js +162 -66
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +100 -56
- package/src/og/entity/Billboard.js +14 -10
- package/src/og/entity/BillboardHandler.js +317 -60
- package/src/og/entity/Entity.js +100 -68
- package/src/og/entity/EntityCollection.js +70 -47
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +27 -24
- package/src/og/entity/GeometryHandler.js +596 -124
- package/src/og/entity/Label.js +80 -49
- package/src/og/entity/LabelHandler.js +45 -244
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +80 -32
- package/src/og/entity/PointCloudHandler.js +8 -8
- package/src/og/entity/Polyline.js +16 -16
- package/src/og/entity/Ray.js +60 -27
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +26 -26
- package/src/og/entity/index.js +8 -16
- package/src/og/layer/BaseGeoImage.js +54 -23
- package/src/og/layer/CanvasTiles.js +24 -24
- package/src/og/layer/GeoImage.js +9 -9
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +63 -37
- package/src/og/layer/Layer.js +44 -21
- package/src/og/layer/Material.js +23 -20
- package/src/og/layer/Vector.js +114 -68
- package/src/og/layer/WMS.js +34 -17
- package/src/og/layer/XYZ.js +48 -46
- package/src/og/light/LightSource.js +46 -39
- package/src/og/math/Mat3.js +34 -22
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +182 -139
- package/src/og/math/Ray.js +38 -33
- package/src/og/math/Vec2.js +85 -75
- package/src/og/math/Vec3.js +142 -112
- package/src/og/math/Vec4.js +27 -31
- package/src/og/math/coder.js +10 -10
- package/src/og/math.js +12 -12
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +4 -6
- package/src/og/quadTree/Node.js +8 -8
- package/src/og/renderer/Renderer.js +59 -52
- package/src/og/renderer/RendererEvents.js +50 -27
- package/src/og/scene/BaseNode.js +7 -8
- package/src/og/scene/Planet.js +102 -103
- package/src/og/scene/RenderNode.js +28 -21
- package/src/og/segment/Segment.js +26 -21
- package/src/og/segment/SegmentLonLat.js +5 -5
- package/src/og/shaders/drawnode.js +135 -142
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +126 -54
- package/src/og/shapes/Icosphere.js +29 -14
- package/src/og/shapes/Sphere.js +12 -15
- package/src/og/terrain/BilTerrain.js +1 -0
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +9 -9
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +22 -24
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +16 -16
- package/src/og/webgl/Framebuffer.js +88 -40
- package/src/og/webgl/Handler.js +243 -169
- package/src/og/webgl/Multisample.js +47 -19
- package/src/og/webgl/Program.js +79 -34
- package/src/og/webgl/ProgramController.js +17 -13
- package/src/og/webgl/callbacks.js +8 -8
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/Clock.d.ts +0 -90
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -73
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -75
- package/types/ImageCanvas.d.ts +0 -121
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -38
- package/types/QueueArray.d.ts +0 -15
- package/types/Rectangle.d.ts +0 -74
- package/types/Stack.d.ts +0 -15
- 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 -6
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -25
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -303
- package/types/camera/Frustum.d.ts +0 -129
- package/types/camera/PlanetCamera.d.ts +0 -223
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -18
- package/types/control/Control.d.ts +0 -101
- package/types/control/DebugInfo.d.ts +0 -16
- 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 -22
- package/types/control/LayerSwitcher.d.ts +0 -23
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -51
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -12
- package/types/control/SimpleNavigation.d.ts +0 -28
- package/types/control/Sun.d.ts +0 -52
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -50
- package/types/control/ZoomControl.d.ts +0 -28
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -142
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -5
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -74
- package/types/entity/Entity.d.ts +0 -331
- package/types/entity/EntityCollection.d.ts +0 -303
- package/types/entity/Geometry.d.ts +0 -73
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -194
- package/types/entity/LabelHandler.d.ts +0 -24
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -304
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -123
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -118
- 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/inherits.d.ts +0 -4
- 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 -107
- package/types/layer/CanvasTiles.d.ts +0 -75
- package/types/layer/GeoImage.d.ts +0 -65
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -80
- package/types/layer/KML.d.ts +0 -58
- package/types/layer/Layer.d.ts +0 -321
- package/types/layer/Material.d.ts +0 -48
- package/types/layer/Vector.d.ts +0 -228
- package/types/layer/WMS.d.ts +0 -66
- package/types/layer/XYZ.d.ts +0 -130
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -177
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -63
- package/types/math/Mat4.d.ts +0 -173
- package/types/math/Plane.d.ts +0 -17
- package/types/math/Quat.d.ts +0 -376
- package/types/math/Ray.d.ts +0 -81
- package/types/math/Vec2.d.ts +0 -308
- package/types/math/Vec3.d.ts +0 -459
- package/types/math/Vec4.d.ts +0 -161
- package/types/math/coder.d.ts +0 -42
- 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 -5
- package/types/proj/EPSG4326.d.ts +0 -5
- 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 -296
- package/types/renderer/RendererEvents.d.ts +0 -230
- 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 -574
- package/types/scene/RenderNode.d.ts +0 -143
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -271
- package/types/segment/SegmentLonLat.d.ts +0 -62
- 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/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 -247
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -8
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -153
- package/types/terrain/MapboxTerrain.d.ts +0 -8
- 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 -230
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -372
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -84
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
import { ImageCanvas } from
|
|
4
|
-
import { Rectangle } from
|
|
5
|
-
import { ImagesCacheManager } from
|
|
3
|
+
import { ImageCanvas } from "../ImageCanvas.js";
|
|
4
|
+
import { Rectangle } from "../Rectangle.js";
|
|
5
|
+
import { ImagesCacheManager } from "./ImagesCacheManager.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Texture atlas stores images in one texture. Each image has its own
|
|
8
|
+
* Texture atlas stores images in one texture. Each image has its own
|
|
9
9
|
* atlas texture coordinates.
|
|
10
10
|
* @class
|
|
11
11
|
* @param {number} [width] - Texture atlas width, if it hasn't 1024 default.
|
|
@@ -13,11 +13,10 @@ import { ImagesCacheManager } from './ImagesCacheManager.js';
|
|
|
13
13
|
*/
|
|
14
14
|
class TextureAtlas {
|
|
15
15
|
constructor(width, height) {
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* Atlas nodes where input images store. It can be access by image.__nodeIndex.
|
|
19
18
|
* @public
|
|
20
|
-
* @type {Array.<
|
|
19
|
+
* @type {Array.<utils.TextureAtlasNode >}
|
|
21
20
|
*/
|
|
22
21
|
this.nodes = [];
|
|
23
22
|
|
|
@@ -71,7 +70,7 @@ class TextureAtlas {
|
|
|
71
70
|
/**
|
|
72
71
|
* Sets openglobus gl handler that creates gl texture.
|
|
73
72
|
* @public
|
|
74
|
-
* @param {
|
|
73
|
+
* @param {Handler} handler - WebGL handler.
|
|
75
74
|
*/
|
|
76
75
|
assignHandler(handler) {
|
|
77
76
|
this._handler = handler;
|
|
@@ -93,12 +92,11 @@ class TextureAtlas {
|
|
|
93
92
|
* Adds image to the atlas and returns creted node with texture coordinates of the stored image.
|
|
94
93
|
* @public
|
|
95
94
|
* @param {Object} image - Input javascript image object.
|
|
96
|
-
* @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
|
|
95
|
+
* @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
|
|
97
96
|
* and store image in the curent atlas sheme.
|
|
98
|
-
* @returns {
|
|
97
|
+
* @returns {utils.TextureAtlasNode} -
|
|
99
98
|
*/
|
|
100
99
|
addImage(image, fastInsert) {
|
|
101
|
-
|
|
102
100
|
if (!(image.width && image.height)) {
|
|
103
101
|
return;
|
|
104
102
|
}
|
|
@@ -145,11 +143,10 @@ class TextureAtlas {
|
|
|
145
143
|
/**
|
|
146
144
|
* Main atlas making function.
|
|
147
145
|
* @private
|
|
148
|
-
* @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
|
|
146
|
+
* @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
|
|
149
147
|
* and store image in the curent atlas sheme.
|
|
150
148
|
*/
|
|
151
149
|
_makeAtlas(fastInsert) {
|
|
152
|
-
|
|
153
150
|
if (fastInsert && this._btree) {
|
|
154
151
|
let im = this._images[this._images.length - 1];
|
|
155
152
|
this._completeNode(this.nodes, this._btree.insert(im));
|
|
@@ -157,10 +154,15 @@ class TextureAtlas {
|
|
|
157
154
|
let im = this._images.slice(0);
|
|
158
155
|
|
|
159
156
|
im.sort(function (b, a) {
|
|
160
|
-
return (
|
|
157
|
+
return (
|
|
158
|
+
(a.atlasWidth || a.width) - (b.atlasWidth || b.width) ||
|
|
159
|
+
(a.atlasHeight || a.height) - (b.atlasHeight || b.height)
|
|
160
|
+
);
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
-
this._btree = new TextureAtlasNode(
|
|
163
|
+
this._btree = new TextureAtlasNode(
|
|
164
|
+
new Rectangle(0, 0, this.canvas.getWidth(), this.canvas.getHeight())
|
|
165
|
+
);
|
|
164
166
|
this._btree.atlas = this;
|
|
165
167
|
|
|
166
168
|
this.clearCanvas();
|
|
@@ -178,19 +180,19 @@ class TextureAtlas {
|
|
|
178
180
|
* Creates atlas gl texture.
|
|
179
181
|
* @public
|
|
180
182
|
*/
|
|
181
|
-
createTexture(img) {
|
|
183
|
+
createTexture(img, internalFormat) {
|
|
182
184
|
if (this._handler) {
|
|
183
185
|
this._handler.gl.deleteTexture(this.texture);
|
|
184
186
|
if (img) {
|
|
185
187
|
this.canvas.resize(img.width, img.height);
|
|
186
188
|
this.canvas.drawImage(img, 0, 0, img.width, img.height);
|
|
187
189
|
}
|
|
188
|
-
this.texture = this._handler.createTexture_l(this.canvas._canvas);
|
|
190
|
+
this.texture = this._handler.createTexture_l(this.canvas._canvas, internalFormat);
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
/**
|
|
193
|
-
* Image handler callback.
|
|
195
|
+
* Image handler callback.
|
|
194
196
|
* @callback Object~successCallback
|
|
195
197
|
* @param {Image} img - Loaded image.
|
|
196
198
|
*/
|
|
@@ -215,7 +217,7 @@ class TextureAtlas {
|
|
|
215
217
|
/**
|
|
216
218
|
* Atlas binary tree node.
|
|
217
219
|
* @class
|
|
218
|
-
* @param {
|
|
220
|
+
* @param {Rectangle} rect - Node image rectangle.
|
|
219
221
|
*/
|
|
220
222
|
class TextureAtlasNode {
|
|
221
223
|
constructor(rect, texCoords) {
|
|
@@ -227,9 +229,7 @@ class TextureAtlasNode {
|
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
insert(img) {
|
|
230
|
-
|
|
231
232
|
if (this.childNodes) {
|
|
232
|
-
|
|
233
233
|
var newNode = this.childNodes[0].insert(img);
|
|
234
234
|
|
|
235
235
|
if (newNode != null) {
|
|
@@ -237,9 +237,7 @@ class TextureAtlasNode {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
return this.childNodes[1].insert(img);
|
|
240
|
-
|
|
241
240
|
} else {
|
|
242
|
-
|
|
243
241
|
if (this.image != null) {
|
|
244
242
|
return null;
|
|
245
243
|
}
|
|
@@ -279,4 +277,4 @@ class TextureAtlasNode {
|
|
|
279
277
|
}
|
|
280
278
|
}
|
|
281
279
|
|
|
282
|
-
export { TextureAtlas, TextureAtlasNode };
|
|
280
|
+
export { TextureAtlas, TextureAtlasNode };
|
|
@@ -217,8 +217,6 @@ export class VectorTileCreator {
|
|
|
217
217
|
|
|
218
218
|
// var prevLayerId = -1;
|
|
219
219
|
|
|
220
|
-
var extentParams = new Float32Array(4);
|
|
221
|
-
|
|
222
220
|
var extentParamsHigh = new Float32Array(4);
|
|
223
221
|
var extentParamsLow = new Float32Array(4);
|
|
224
222
|
|
|
@@ -245,7 +243,7 @@ export class VectorTileCreator {
|
|
|
245
243
|
|
|
246
244
|
f.bindOutputTexture(texture);
|
|
247
245
|
|
|
248
|
-
gl.clearColor(
|
|
246
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
249
247
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
250
248
|
|
|
251
249
|
var extent = material.segment.getExtentMerc();
|
package/src/og/utils/shared.js
CHANGED
|
@@ -56,7 +56,7 @@ export function readTextFile(fileUrl) {
|
|
|
56
56
|
* Convert html color string to the RGBA number vector.
|
|
57
57
|
* @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
|
|
58
58
|
* @param {number} [opacity] - Opacity for the output vector.
|
|
59
|
-
* @returns {
|
|
59
|
+
* @returns {math.Vec4} -
|
|
60
60
|
*/
|
|
61
61
|
export function htmlColorToRgba(htmlColor, opacity) {
|
|
62
62
|
var hColor = colorTable[htmlColor];
|
|
@@ -99,7 +99,7 @@ export function htmlColorToFloat32Array(htmlColor, opacity) {
|
|
|
99
99
|
* Convert html color string to the RGB number vector.
|
|
100
100
|
* @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
|
|
101
101
|
* @param {number} [opacity] - Opacity for the output vector.
|
|
102
|
-
* @returns {
|
|
102
|
+
* @returns {Vec3} -
|
|
103
103
|
*/
|
|
104
104
|
export function htmlColorToRgb(htmlColor) {
|
|
105
105
|
var hColor = colorTable[htmlColor];
|
|
@@ -283,7 +283,7 @@ export function binarySearchFast(arr, x) {
|
|
|
283
283
|
* Finds an item in a sorted array.
|
|
284
284
|
* @param {Array} ar The sorted array to search.
|
|
285
285
|
* @param {Object} el The item to find in the array.
|
|
286
|
-
* @param {
|
|
286
|
+
* @param {utils.binarySearch~compare_fn} compare_fn comparator The function to use to compare the item to
|
|
287
287
|
* elements in the array.
|
|
288
288
|
* @returns {Number} a negative number if a is less than b; 0 if a is equal to b;a positive number of a is greater than b.
|
|
289
289
|
*
|
|
@@ -316,7 +316,7 @@ export function binarySearch(ar, el, compare_fn) {
|
|
|
316
316
|
* Binary insertion that uses binarySearch algorithm.
|
|
317
317
|
* @param {Array} ar - The sorted array to insert.
|
|
318
318
|
* @param {Object} el - The item to insert.
|
|
319
|
-
* @param {
|
|
319
|
+
* @param {utils.binarySearch~compare_fn} compare_fn - comparator The function to use to compare the item to
|
|
320
320
|
* elements in the array.
|
|
321
321
|
* @returns {Number} Array index position in which item inserted in.
|
|
322
322
|
*/
|
|
@@ -332,12 +332,12 @@ export function binaryInsert(ar, el, compare_fn) {
|
|
|
332
332
|
/**
|
|
333
333
|
* Returns two segment lines intersection coordinate.
|
|
334
334
|
* @static
|
|
335
|
-
* @param {
|
|
336
|
-
* @param {
|
|
337
|
-
* @param {
|
|
338
|
-
* @param {
|
|
335
|
+
* @param {math.Vec2} start1 - First line first coordinate.
|
|
336
|
+
* @param {math.Vec2} end1 - First line second coordinate.
|
|
337
|
+
* @param {math.Vec2} start2 - Second line first coordinate.
|
|
338
|
+
* @param {math.Vec2} end2 - Second line second coordinate.
|
|
339
339
|
* @param {boolean} [isSegment] - Lines are segments.
|
|
340
|
-
* @return {
|
|
340
|
+
* @return {math.Vec2} - Intersection coordinate.
|
|
341
341
|
*/
|
|
342
342
|
export function getLinesIntersection2v(start1, end1, start2, end2, isSegment) {
|
|
343
343
|
var dir1 = end1.sub(start1);
|
|
@@ -372,12 +372,12 @@ export function getLinesIntersection2v(start1, end1, start2, end2, isSegment) {
|
|
|
372
372
|
/**
|
|
373
373
|
* Returns two segment lines intersection coordinate.
|
|
374
374
|
* @static
|
|
375
|
-
* @param {
|
|
376
|
-
* @param {
|
|
377
|
-
* @param {
|
|
378
|
-
* @param {
|
|
375
|
+
* @param {math.Vec2} start1 - First line first coordinate.
|
|
376
|
+
* @param {math.Vec2} end1 - First line second coordinate.
|
|
377
|
+
* @param {math.Vec2} start2 - Second line first coordinate.
|
|
378
|
+
* @param {math.Vec2} end2 - Second line second coordinate.
|
|
379
379
|
* @param {boolean} [isSegment] - Lines are segments.
|
|
380
|
-
* @return {
|
|
380
|
+
* @return {math.Vec2} - Intersection coordinate.
|
|
381
381
|
*/
|
|
382
382
|
export function getLinesIntersectionLonLat(start1, end1, start2, end2, isSegment) {
|
|
383
383
|
var dir1 = new LonLat(end1.lon - start1.lon, end1.lat - start1.lat);
|
|
@@ -752,7 +752,7 @@ export function concatTypedArrays(a, b) {
|
|
|
752
752
|
* @param {TypedArray | Array} a
|
|
753
753
|
* @param {TypedArray | Array} b
|
|
754
754
|
*/
|
|
755
|
-
export function concatArrays(a, b) {
|
|
755
|
+
export function concatArrays(a = [], b) {
|
|
756
756
|
if (ArrayBuffer.isView(a)) {
|
|
757
757
|
return concatTypedArrays(a, b);
|
|
758
758
|
} else {
|
|
@@ -940,4 +940,4 @@ export function cloneArray(items) {
|
|
|
940
940
|
*/
|
|
941
941
|
export function isUndef(obj) {
|
|
942
942
|
return obj === void 0;
|
|
943
|
-
}
|
|
943
|
+
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* @module og/webgl/Framebuffer
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { ImageCanvas } from
|
|
7
|
+
import { ImageCanvas } from "../ImageCanvas.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Class represents framebuffer.
|
|
11
11
|
* @class
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {Handler} handler - WebGL handler.
|
|
13
13
|
* @param {Object} [options] - Framebuffer options:
|
|
14
14
|
* @param {number} [options.width] - Framebuffer width. Default is handler canvas width.
|
|
15
15
|
* @param {number} [options.height] - Framebuffer height. Default is handler canvas height.
|
|
@@ -21,13 +21,11 @@ import { ImageCanvas } from '../ImageCanvas.js';
|
|
|
21
21
|
* @param {Boolean} [options.useDepth] - Using depth buffer during the rendering.
|
|
22
22
|
*/
|
|
23
23
|
export class Framebuffer {
|
|
24
|
-
|
|
25
24
|
constructor(handler, options = {}) {
|
|
26
|
-
|
|
27
25
|
/**
|
|
28
26
|
* WebGL handler.
|
|
29
27
|
* @public
|
|
30
|
-
* @type {
|
|
28
|
+
* @type {Handler}
|
|
31
29
|
*/
|
|
32
30
|
this.handler = handler;
|
|
33
31
|
|
|
@@ -49,20 +47,27 @@ export class Framebuffer {
|
|
|
49
47
|
|
|
50
48
|
this._filter = options.filter || "NEAREST";
|
|
51
49
|
|
|
52
|
-
this._internalFormatArr =
|
|
50
|
+
this._internalFormatArr =
|
|
51
|
+
options.internalFormat instanceof Array
|
|
52
|
+
? options.internalFormat
|
|
53
|
+
: [options.internalFormat || "RGBA"];
|
|
53
54
|
|
|
54
|
-
this._formatArr =
|
|
55
|
+
this._formatArr =
|
|
56
|
+
options.format instanceof Array ? options.format : [options.format || "RGBA"];
|
|
55
57
|
|
|
56
|
-
this._typeArr =
|
|
58
|
+
this._typeArr =
|
|
59
|
+
options.type instanceof Array ? options.type : [options.type || "UNSIGNED_BYTE"];
|
|
57
60
|
|
|
58
|
-
this._attachmentArr =
|
|
59
|
-
options.attachment
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
this._attachmentArr =
|
|
62
|
+
options.attachment instanceof Array
|
|
63
|
+
? options.attachment.map((a, i) => {
|
|
64
|
+
let res = a.toUpperCase();
|
|
65
|
+
if (res === "COLOR_ATTACHMENT") {
|
|
66
|
+
return `${res}${i.toString()}`;
|
|
67
|
+
}
|
|
68
|
+
return res;
|
|
69
|
+
})
|
|
70
|
+
: [options.attachment || "COLOR_ATTACHMENT0"];
|
|
66
71
|
|
|
67
72
|
/**
|
|
68
73
|
* Framebuffer width.
|
|
@@ -78,12 +83,13 @@ export class Framebuffer {
|
|
|
78
83
|
*/
|
|
79
84
|
this._height = options.height || handler.canvas.height;
|
|
80
85
|
|
|
81
|
-
this._depthComponent =
|
|
86
|
+
this._depthComponent =
|
|
87
|
+
options.depthComponent != undefined ? options.depthComponent : "DEPTH_COMPONENT16";
|
|
82
88
|
|
|
83
89
|
this._useDepth = options.useDepth != undefined ? options.useDepth : true;
|
|
84
90
|
|
|
85
91
|
/**
|
|
86
|
-
* Framebuffer activity.
|
|
92
|
+
* Framebuffer activity.
|
|
87
93
|
* @private
|
|
88
94
|
* @type {boolean}
|
|
89
95
|
*/
|
|
@@ -100,19 +106,25 @@ export class Framebuffer {
|
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
static blit(sourceFramebuffer, destFramebuffer, glAttachment, glMask, glFilter) {
|
|
103
|
-
|
|
104
109
|
let gl = sourceFramebuffer.handler.gl;
|
|
105
110
|
|
|
106
111
|
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, sourceFramebuffer._fbo);
|
|
107
|
-
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER,
|
|
112
|
+
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFramebuffer._fbo);
|
|
108
113
|
gl.readBuffer(glAttachment);
|
|
109
114
|
|
|
110
115
|
gl.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 1.0]);
|
|
111
116
|
|
|
112
117
|
gl.blitFramebuffer(
|
|
113
|
-
0,
|
|
114
|
-
0,
|
|
115
|
-
|
|
118
|
+
0,
|
|
119
|
+
0,
|
|
120
|
+
sourceFramebuffer._width,
|
|
121
|
+
sourceFramebuffer._height,
|
|
122
|
+
0,
|
|
123
|
+
0,
|
|
124
|
+
destFramebuffer._width,
|
|
125
|
+
destFramebuffer._height,
|
|
126
|
+
glMask,
|
|
127
|
+
glFilter
|
|
116
128
|
);
|
|
117
129
|
|
|
118
130
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
@@ -151,8 +163,8 @@ export class Framebuffer {
|
|
|
151
163
|
if (!this._isBare) {
|
|
152
164
|
let attachmentArr = [];
|
|
153
165
|
for (var i = 0; i < this.textures.length; i++) {
|
|
154
|
-
|
|
155
|
-
|
|
166
|
+
let ti =
|
|
167
|
+
this.textures[i] ||
|
|
156
168
|
this.handler.createEmptyTexture2DExt(
|
|
157
169
|
this._width,
|
|
158
170
|
this._height,
|
|
@@ -178,8 +190,18 @@ export class Framebuffer {
|
|
|
178
190
|
if (this._useDepth) {
|
|
179
191
|
this._depthRenderbuffer = gl.createRenderbuffer();
|
|
180
192
|
gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderbuffer);
|
|
181
|
-
gl.renderbufferStorage(
|
|
182
|
-
|
|
193
|
+
gl.renderbufferStorage(
|
|
194
|
+
gl.RENDERBUFFER,
|
|
195
|
+
gl[this._depthComponent],
|
|
196
|
+
this._width,
|
|
197
|
+
this._height
|
|
198
|
+
);
|
|
199
|
+
gl.framebufferRenderbuffer(
|
|
200
|
+
gl.FRAMEBUFFER,
|
|
201
|
+
gl.DEPTH_ATTACHMENT,
|
|
202
|
+
gl.RENDERBUFFER,
|
|
203
|
+
this._depthRenderbuffer
|
|
204
|
+
);
|
|
183
205
|
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
|
|
184
206
|
}
|
|
185
207
|
|
|
@@ -197,7 +219,13 @@ export class Framebuffer {
|
|
|
197
219
|
bindOutputTexture(texture, glAttachment) {
|
|
198
220
|
var gl = this.handler.gl;
|
|
199
221
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
200
|
-
gl.framebufferTexture2D(
|
|
222
|
+
gl.framebufferTexture2D(
|
|
223
|
+
gl.FRAMEBUFFER,
|
|
224
|
+
glAttachment || gl.COLOR_ATTACHMENT0,
|
|
225
|
+
gl.TEXTURE_2D,
|
|
226
|
+
texture,
|
|
227
|
+
0
|
|
228
|
+
);
|
|
201
229
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
202
230
|
}
|
|
203
231
|
|
|
@@ -248,7 +276,15 @@ export class Framebuffer {
|
|
|
248
276
|
var gl = this.handler.gl;
|
|
249
277
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
|
|
250
278
|
gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + index || 0);
|
|
251
|
-
gl.readPixels(
|
|
279
|
+
gl.readPixels(
|
|
280
|
+
nx * this._width,
|
|
281
|
+
ny * this._height,
|
|
282
|
+
w,
|
|
283
|
+
h,
|
|
284
|
+
gl.RGBA,
|
|
285
|
+
gl[this._typeArr[index]],
|
|
286
|
+
res
|
|
287
|
+
);
|
|
252
288
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
253
289
|
}
|
|
254
290
|
|
|
@@ -262,14 +298,22 @@ export class Framebuffer {
|
|
|
262
298
|
var gl = this.handler.gl;
|
|
263
299
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
|
|
264
300
|
gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + attachmentIndex);
|
|
265
|
-
gl.readPixels(
|
|
301
|
+
gl.readPixels(
|
|
302
|
+
0,
|
|
303
|
+
0,
|
|
304
|
+
this._width,
|
|
305
|
+
this._height,
|
|
306
|
+
gl.RGBA,
|
|
307
|
+
gl[this._typeArr[attachmentIndex]],
|
|
308
|
+
res
|
|
309
|
+
);
|
|
266
310
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
267
311
|
}
|
|
268
312
|
|
|
269
313
|
/**
|
|
270
314
|
* Activate framebuffer frame to draw.
|
|
271
315
|
* @public
|
|
272
|
-
* @returns {
|
|
316
|
+
* @returns {Framebuffer} Returns Current framebuffer.
|
|
273
317
|
*/
|
|
274
318
|
activate() {
|
|
275
319
|
var gl = this.handler.gl;
|
|
@@ -323,17 +367,21 @@ export class Framebuffer {
|
|
|
323
367
|
openImage() {
|
|
324
368
|
var img = this.getImage();
|
|
325
369
|
var dataUrl = img.src;
|
|
326
|
-
var windowContent =
|
|
327
|
-
windowContent +=
|
|
328
|
-
windowContent +=
|
|
329
|
-
windowContent +=
|
|
370
|
+
var windowContent = "<!DOCTYPE html>";
|
|
371
|
+
windowContent += "<html>";
|
|
372
|
+
windowContent += "<head><title>Print</title></head>";
|
|
373
|
+
windowContent += "<body>";
|
|
330
374
|
windowContent += '<img src="' + dataUrl + '">';
|
|
331
|
-
windowContent +=
|
|
332
|
-
windowContent +=
|
|
333
|
-
var printWin = window.open(
|
|
375
|
+
windowContent += "</body>";
|
|
376
|
+
windowContent += "</html>";
|
|
377
|
+
var printWin = window.open(
|
|
378
|
+
"",
|
|
379
|
+
"",
|
|
380
|
+
"width=" + img.width + "px ,height=" + img.height + "px"
|
|
381
|
+
);
|
|
334
382
|
printWin.document.open();
|
|
335
383
|
printWin.document.write(windowContent);
|
|
336
384
|
printWin.document.close();
|
|
337
385
|
printWin.focus();
|
|
338
386
|
}
|
|
339
|
-
}
|
|
387
|
+
}
|