@openglobus/og 0.11.4 → 0.11.8
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/css/og.css +3 -2
- package/package.json +12 -14
- package/src/og/Clock.js +6 -10
- package/src/og/Events.js +5 -7
- package/src/og/Extent.js +73 -32
- package/src/og/Globe.js +8 -5
- package/src/og/ImageCanvas.js +18 -15
- package/src/og/LonLat.js +13 -10
- package/src/og/Popup.js +19 -17
- package/src/og/QueueArray.js +3 -4
- package/src/og/Rectangle.js +4 -6
- package/src/og/Stack.js +2 -4
- package/src/og/ajax.js +20 -14
- package/src/og/astro/earth.js +21 -15
- package/src/og/bv/Box.js +2 -3
- package/src/og/bv/Sphere.js +10 -7
- package/src/og/camera/Frustum.js +19 -12
- package/src/og/camera/PlanetCamera.js +9 -5
- package/src/og/control/CompassButton.js +1 -2
- package/src/og/control/Control.js +7 -9
- package/src/og/control/DebugInfo.js +0 -1
- package/src/og/control/KeyboardNavigation.js +9 -9
- package/src/og/control/LayerSwitcher.js +21 -20
- package/src/og/control/Lighting.js +74 -64
- package/src/og/control/MouseNavigation.js +21 -18
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/SegmentBoundVisualization.js +5 -6
- package/src/og/control/ShowFps.js +12 -7
- package/src/og/control/SimpleNavigation.js +5 -7
- package/src/og/control/Sun.js +22 -12
- package/src/og/control/ToggleWireframe.js +3 -3
- package/src/og/control/TouchNavigation.js +43 -32
- package/src/og/control/ZoomControl.js +40 -24
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/ellipsoid/Ellipsoid.js +149 -57
- package/src/og/ellipsoid/wgs84.js +3 -3
- package/src/og/entity/BaseBillboard.js +72 -30
- package/src/og/entity/Billboard.js +9 -5
- package/src/og/entity/BillboardHandler.js +315 -62
- package/src/og/entity/Entity.js +39 -1
- package/src/og/entity/EntityCollection.js +47 -24
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/GeometryHandler.js +595 -123
- package/src/og/entity/Label.js +62 -30
- package/src/og/entity/LabelHandler.js +40 -242
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +76 -28
- package/src/og/entity/PointCloudHandler.js +5 -5
- package/src/og/entity/Ray.js +49 -16
- package/src/og/entity/Strip.js +72 -43
- package/src/og/entity/StripHandler.js +23 -23
- package/src/og/layer/BaseGeoImage.js +50 -19
- package/src/og/layer/CanvasTiles.js +16 -17
- package/src/og/layer/GeoImage.js +8 -16
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/KML.js +55 -33
- package/src/og/layer/Layer.js +24 -32
- package/src/og/layer/Material.js +1 -1
- package/src/og/layer/Vector.js +94 -48
- package/src/og/layer/WMS.js +33 -18
- package/src/og/layer/XYZ.js +4 -5
- package/src/og/light/LightSource.js +19 -12
- package/src/og/math/Mat3.js +24 -12
- package/src/og/math/Mat4.js +603 -603
- package/src/og/math/Plane.js +19 -18
- package/src/og/math/Ray.js +17 -12
- package/src/og/math/Vec2.js +24 -14
- package/src/og/math/Vec3.js +60 -30
- package/src/og/math/coder.js +7 -7
- package/src/og/proj/EPSG3857.js +3 -3
- package/src/og/proj/EPSG4326.js +3 -3
- package/src/og/proj/Proj.js +2 -4
- package/src/og/quadTree/Node.js +3 -3
- package/src/og/renderer/Renderer.js +106 -124
- package/src/og/renderer/RendererEvents.js +45 -23
- package/src/og/scene/BaseNode.js +2 -3
- package/src/og/scene/Planet.js +51 -90
- package/src/og/scene/RenderNode.js +15 -8
- package/src/og/segment/Segment.js +60 -156
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +245 -342
- 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 +108 -36
- package/src/og/shapes/Icosphere.js +25 -10
- package/src/og/shapes/Sphere.js +8 -11
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/utils/TextureAtlas.js +18 -20
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +2 -2
- package/src/og/webgl/Handler.js +215 -162
- package/src/og/webgl/Multisample.js +44 -16
- package/src/og/webgl/Program.js +78 -33
- package/src/og/webgl/callbacks.js +3 -3
- 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 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -78
- package/types/entity/Entity.d.ts +0 -333
- package/types/entity/EntityCollection.d.ts +0 -311
- 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 -29
- 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 -325
- 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 -298
- 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/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 -388
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- 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
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @module og/shape/BaseShape
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Vec3 } from
|
|
8
|
-
import { Quat } from
|
|
9
|
-
import { Mat4 } from
|
|
7
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
8
|
+
import { Quat } from "../math/Quat.js";
|
|
9
|
+
import { Mat4 } from "../math/Mat4.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Base geometry shape class.
|
|
@@ -20,9 +20,7 @@ import { Mat4 } from '../math/Mat4.js';
|
|
|
20
20
|
* @param {boolean} [options.visibility] - Shape visibility.
|
|
21
21
|
*/
|
|
22
22
|
class BaseShape {
|
|
23
|
-
|
|
24
23
|
constructor(options) {
|
|
25
|
-
|
|
26
24
|
options = options || {};
|
|
27
25
|
|
|
28
26
|
/**
|
|
@@ -59,14 +57,16 @@ class BaseShape {
|
|
|
59
57
|
* @public
|
|
60
58
|
* @type {Array.<number>} - (exactly 4 entries)
|
|
61
59
|
*/
|
|
62
|
-
this.color = options.color
|
|
60
|
+
this.color = options.color
|
|
61
|
+
? new Float32Array(options.color)
|
|
62
|
+
: new Float32Array([1.0, 1.0, 1.0, 1.0]);
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Shape visibility.
|
|
66
66
|
* @public
|
|
67
67
|
* @type {boolean}
|
|
68
68
|
*/
|
|
69
|
-
this.visibility =
|
|
69
|
+
this.visibility = options.visibility != undefined ? options.visibility : true;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Image url source.
|
|
@@ -206,7 +206,6 @@ class BaseShape {
|
|
|
206
206
|
* @public
|
|
207
207
|
*/
|
|
208
208
|
clear() {
|
|
209
|
-
|
|
210
209
|
this.position.set(0.0, 0.0, 0.0);
|
|
211
210
|
this.orientation.set(0.0, 0.0, 0.0, 1.0);
|
|
212
211
|
this.scale.set(1.0, 1.0, 1.0);
|
|
@@ -305,7 +304,7 @@ class BaseShape {
|
|
|
305
304
|
var img = new Image();
|
|
306
305
|
var that = this;
|
|
307
306
|
img.onload = function () {
|
|
308
|
-
that.texture = renderNode.renderer.handler.
|
|
307
|
+
that.texture = renderNode.renderer.handler.createTextureDefault(this);
|
|
309
308
|
};
|
|
310
309
|
img.src = this._src;
|
|
311
310
|
}
|
|
@@ -377,10 +376,26 @@ class BaseShape {
|
|
|
377
376
|
_createBuffers() {
|
|
378
377
|
this._deleteBuffers();
|
|
379
378
|
var r = this._renderNode.renderer;
|
|
380
|
-
this._positionBuffer = r.handler.createArrayBuffer(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
379
|
+
this._positionBuffer = r.handler.createArrayBuffer(
|
|
380
|
+
new Float32Array(this._positionData),
|
|
381
|
+
3,
|
|
382
|
+
this._positionData.length / 3
|
|
383
|
+
);
|
|
384
|
+
this._normalBuffer = r.handler.createArrayBuffer(
|
|
385
|
+
new Float32Array(this._normalData),
|
|
386
|
+
3,
|
|
387
|
+
this._normalData.length / 3
|
|
388
|
+
);
|
|
389
|
+
this._indexBuffer = r.handler.createElementArrayBuffer(
|
|
390
|
+
new Uint16Array(this._indexData),
|
|
391
|
+
1,
|
|
392
|
+
this._indexData.length
|
|
393
|
+
);
|
|
394
|
+
this._textureCoordBuffer = r.handler.createArrayBuffer(
|
|
395
|
+
new Float32Array(this._textureCoordData),
|
|
396
|
+
2,
|
|
397
|
+
this._textureCoordData.length / 2
|
|
398
|
+
);
|
|
384
399
|
}
|
|
385
400
|
|
|
386
401
|
/**
|
|
@@ -400,9 +415,11 @@ class BaseShape {
|
|
|
400
415
|
let rn = this._renderNode;
|
|
401
416
|
let r = rn.renderer;
|
|
402
417
|
|
|
403
|
-
let sh,
|
|
418
|
+
let sh,
|
|
419
|
+
p,
|
|
404
420
|
gl = r.handler.gl,
|
|
405
|
-
sha,
|
|
421
|
+
sha,
|
|
422
|
+
shu;
|
|
406
423
|
|
|
407
424
|
if (rn.lightEnabled) {
|
|
408
425
|
sh = r.handler.programs.shape_wl;
|
|
@@ -415,12 +432,23 @@ class BaseShape {
|
|
|
415
432
|
gl.uniform4fv(shu.lightsPositions, rn._lightsTransformedPositions);
|
|
416
433
|
gl.uniform3fv(shu.lightsParamsv, rn._lightsParamsv);
|
|
417
434
|
gl.uniform1fv(shu.lightsParamsf, rn._lightsParamsf);
|
|
418
|
-
gl.uniformMatrix4fv(
|
|
435
|
+
gl.uniformMatrix4fv(
|
|
436
|
+
shu.projectionMatrix,
|
|
437
|
+
false,
|
|
438
|
+
r.activeCamera.getProjectionMatrix()
|
|
439
|
+
);
|
|
419
440
|
gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera.getViewMatrix());
|
|
420
441
|
gl.uniformMatrix3fv(shu.normalMatrix, false, r.activeCamera.getNormalMatrix());
|
|
421
442
|
|
|
422
443
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._normalBuffer);
|
|
423
|
-
gl.vertexAttribPointer(
|
|
444
|
+
gl.vertexAttribPointer(
|
|
445
|
+
sha.aVertexNormal,
|
|
446
|
+
this._normalBuffer.itemSize,
|
|
447
|
+
gl.FLOAT,
|
|
448
|
+
false,
|
|
449
|
+
0,
|
|
450
|
+
0
|
|
451
|
+
);
|
|
424
452
|
} else {
|
|
425
453
|
sh = r.handler.programs.shape_nl;
|
|
426
454
|
p = sh._program;
|
|
@@ -429,13 +457,24 @@ class BaseShape {
|
|
|
429
457
|
|
|
430
458
|
sh.activate();
|
|
431
459
|
|
|
432
|
-
gl.uniformMatrix4fv(
|
|
460
|
+
gl.uniformMatrix4fv(
|
|
461
|
+
shu.projectionViewMatrix,
|
|
462
|
+
false,
|
|
463
|
+
r.activeCamera.getProjectionViewMatrix()
|
|
464
|
+
);
|
|
433
465
|
}
|
|
434
466
|
|
|
435
467
|
gl.uniform4fv(shu.uColor, this.color);
|
|
436
468
|
|
|
437
469
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._positionBuffer);
|
|
438
|
-
gl.vertexAttribPointer(
|
|
470
|
+
gl.vertexAttribPointer(
|
|
471
|
+
sha.aVertexPosition,
|
|
472
|
+
this._positionBuffer.itemSize,
|
|
473
|
+
gl.FLOAT,
|
|
474
|
+
false,
|
|
475
|
+
0,
|
|
476
|
+
0
|
|
477
|
+
);
|
|
439
478
|
gl.uniformMatrix4fv(shu.modelMatrix, false, this._mxModel._m);
|
|
440
479
|
|
|
441
480
|
gl.activeTexture(gl.TEXTURE0);
|
|
@@ -443,41 +482,74 @@ class BaseShape {
|
|
|
443
482
|
gl.uniform1i(shu.uSampler, 0);
|
|
444
483
|
|
|
445
484
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._textureCoordBuffer);
|
|
446
|
-
gl.vertexAttribPointer(
|
|
485
|
+
gl.vertexAttribPointer(
|
|
486
|
+
sha.aTextureCoord,
|
|
487
|
+
this._textureCoordBuffer.itemSize,
|
|
488
|
+
gl.FLOAT,
|
|
489
|
+
false,
|
|
490
|
+
0,
|
|
491
|
+
0
|
|
492
|
+
);
|
|
447
493
|
|
|
448
494
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
|
|
449
|
-
gl.drawElements(
|
|
495
|
+
gl.drawElements(
|
|
496
|
+
r.handler.gl.TRIANGLES,
|
|
497
|
+
this._indexBuffer.numItems,
|
|
498
|
+
gl.UNSIGNED_SHORT,
|
|
499
|
+
0
|
|
500
|
+
);
|
|
450
501
|
}
|
|
451
502
|
}
|
|
452
503
|
|
|
453
|
-
drawPicking() {
|
|
504
|
+
drawPicking() {
|
|
454
505
|
if (this.visibility) {
|
|
455
506
|
let rn = this._renderNode;
|
|
456
507
|
let r = rn.renderer;
|
|
457
508
|
|
|
458
|
-
let sh,
|
|
509
|
+
let sh,
|
|
510
|
+
p,
|
|
459
511
|
gl = r.handler.gl,
|
|
460
|
-
sha,
|
|
512
|
+
sha,
|
|
513
|
+
shu;
|
|
461
514
|
|
|
515
|
+
sh = r.handler.programs.shape_picking;
|
|
516
|
+
p = sh._program;
|
|
517
|
+
shu = p.uniforms;
|
|
518
|
+
sha = p.attributes;
|
|
462
519
|
|
|
520
|
+
sh.activate();
|
|
463
521
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
sh.activate();
|
|
470
|
-
|
|
471
|
-
gl.uniformMatrix4fv(shu.projectionViewMatrix, false, r.activeCamera.getProjectionViewMatrix());
|
|
522
|
+
gl.uniformMatrix4fv(
|
|
523
|
+
shu.projectionViewMatrix,
|
|
524
|
+
false,
|
|
525
|
+
r.activeCamera.getProjectionViewMatrix()
|
|
526
|
+
);
|
|
472
527
|
|
|
473
|
-
gl.uniform4fv(shu.uColor, [
|
|
528
|
+
gl.uniform4fv(shu.uColor, [
|
|
529
|
+
this._pickingColor[0],
|
|
530
|
+
this._pickingColor[1],
|
|
531
|
+
this._pickingColor[2],
|
|
532
|
+
1.0
|
|
533
|
+
]);
|
|
474
534
|
|
|
475
535
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._positionBuffer);
|
|
476
|
-
gl.vertexAttribPointer(
|
|
536
|
+
gl.vertexAttribPointer(
|
|
537
|
+
sha.aVertexPosition,
|
|
538
|
+
this._positionBuffer.itemSize,
|
|
539
|
+
gl.FLOAT,
|
|
540
|
+
false,
|
|
541
|
+
0,
|
|
542
|
+
0
|
|
543
|
+
);
|
|
477
544
|
gl.uniformMatrix4fv(shu.modelMatrix, false, this._mxModel._m);
|
|
478
545
|
|
|
479
546
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
|
|
480
|
-
gl.drawElements(
|
|
547
|
+
gl.drawElements(
|
|
548
|
+
r.handler.gl.TRIANGLES,
|
|
549
|
+
this._indexBuffer.numItems,
|
|
550
|
+
gl.UNSIGNED_SHORT,
|
|
551
|
+
0
|
|
552
|
+
);
|
|
481
553
|
}
|
|
482
554
|
}
|
|
483
555
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @module og/shape/BaseShape
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { BaseShape } from
|
|
7
|
+
import { BaseShape } from "./BaseShape.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @class
|
|
@@ -45,7 +45,11 @@ class Icosphere extends BaseShape {
|
|
|
45
45
|
// add vertex to mesh, fix position to be on unit sphere, return index
|
|
46
46
|
_addVertex(p) {
|
|
47
47
|
var length = Math.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]);
|
|
48
|
-
this._positionData.push(
|
|
48
|
+
this._positionData.push(
|
|
49
|
+
(this._size * p[0]) / length,
|
|
50
|
+
(this._size * p[1]) / length,
|
|
51
|
+
(this._size * p[2]) / length
|
|
52
|
+
);
|
|
49
53
|
return this._index++;
|
|
50
54
|
}
|
|
51
55
|
|
|
@@ -63,9 +67,21 @@ class Icosphere extends BaseShape {
|
|
|
63
67
|
return ret;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
var point1 = [
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
var point1 = [
|
|
71
|
+
this._positionData[p1 * 3],
|
|
72
|
+
this._positionData[p1 * 3 + 1],
|
|
73
|
+
this._positionData[p1 * 3 + 2]
|
|
74
|
+
];
|
|
75
|
+
var point2 = [
|
|
76
|
+
this._positionData[p2 * 3],
|
|
77
|
+
this._positionData[p2 * 3 + 1],
|
|
78
|
+
this._positionData[p2 * 3 + 2]
|
|
79
|
+
];
|
|
80
|
+
var middle = [
|
|
81
|
+
(point1[0] + point2[0]) / 2.0,
|
|
82
|
+
(point1[1] + point2[1]) / 2.0,
|
|
83
|
+
(point1[2] + point2[2]) / 2.0
|
|
84
|
+
];
|
|
69
85
|
|
|
70
86
|
// add vertex makes sure point is on unit sphere
|
|
71
87
|
var i = this._addVertex(middle);
|
|
@@ -79,7 +95,6 @@ class Icosphere extends BaseShape {
|
|
|
79
95
|
* @virtual
|
|
80
96
|
*/
|
|
81
97
|
_createData() {
|
|
82
|
-
|
|
83
98
|
this._positionData = [];
|
|
84
99
|
this._indexData = [];
|
|
85
100
|
this._index = 0;
|
|
@@ -113,7 +128,7 @@ class Icosphere extends BaseShape {
|
|
|
113
128
|
faces.push([0, 7, 10]);
|
|
114
129
|
faces.push([0, 10, 11]);
|
|
115
130
|
|
|
116
|
-
// 5 adjacent faces
|
|
131
|
+
// 5 adjacent faces
|
|
117
132
|
faces.push([1, 5, 9]);
|
|
118
133
|
faces.push([5, 11, 4]);
|
|
119
134
|
faces.push([11, 10, 2]);
|
|
@@ -127,7 +142,7 @@ class Icosphere extends BaseShape {
|
|
|
127
142
|
faces.push([3, 6, 8]);
|
|
128
143
|
faces.push([3, 8, 9]);
|
|
129
144
|
|
|
130
|
-
// 5 adjacent faces
|
|
145
|
+
// 5 adjacent faces
|
|
131
146
|
faces.push([4, 9, 5]);
|
|
132
147
|
faces.push([2, 4, 11]);
|
|
133
148
|
faces.push([6, 2, 10]);
|
|
@@ -161,4 +176,4 @@ class Icosphere extends BaseShape {
|
|
|
161
176
|
}
|
|
162
177
|
}
|
|
163
178
|
|
|
164
|
-
export { Icosphere };
|
|
179
|
+
export { Icosphere };
|
package/src/og/shapes/Sphere.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @module og/shape/BaseShape
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { BaseShape } from
|
|
7
|
+
import { BaseShape } from "./BaseShape.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @class
|
|
@@ -21,11 +21,9 @@ import { BaseShape } from './BaseShape.js';
|
|
|
21
21
|
* @param {number} [options.lonBands=16] - Number of longitude bands.
|
|
22
22
|
*/
|
|
23
23
|
class Sphere extends BaseShape {
|
|
24
|
-
|
|
25
24
|
constructor(options) {
|
|
26
|
-
|
|
27
25
|
super(options);
|
|
28
|
-
|
|
26
|
+
|
|
29
27
|
/**
|
|
30
28
|
* Sphere radius.
|
|
31
29
|
* @protected
|
|
@@ -57,20 +55,19 @@ class Sphere extends BaseShape {
|
|
|
57
55
|
* @virtual
|
|
58
56
|
*/
|
|
59
57
|
_createData() {
|
|
60
|
-
|
|
61
58
|
for (let latNumber = 0; latNumber <= this._latBands; latNumber++) {
|
|
62
|
-
var theta = latNumber * Math.PI / this._latBands;
|
|
59
|
+
var theta = (latNumber * Math.PI) / this._latBands;
|
|
63
60
|
var sinTheta = Math.sin(theta);
|
|
64
61
|
var cosTheta = Math.cos(theta);
|
|
65
62
|
|
|
66
63
|
for (let longNumber = 0; longNumber <= this._lonBands; longNumber++) {
|
|
67
|
-
var phi = longNumber * 2 * Math.PI / this._lonBands;
|
|
64
|
+
var phi = (longNumber * 2 * Math.PI) / this._lonBands;
|
|
68
65
|
var sinPhi = Math.sin(phi);
|
|
69
66
|
var cosPhi = Math.cos(phi);
|
|
70
67
|
var x = cosPhi * sinTheta;
|
|
71
68
|
var y = cosTheta;
|
|
72
69
|
var z = sinPhi * sinTheta;
|
|
73
|
-
var u = 1 -
|
|
70
|
+
var u = 1 - longNumber / this._lonBands;
|
|
74
71
|
var v = latNumber / this._latBands;
|
|
75
72
|
this._normalData.push(x);
|
|
76
73
|
this._normalData.push(y);
|
|
@@ -85,7 +82,7 @@ class Sphere extends BaseShape {
|
|
|
85
82
|
|
|
86
83
|
for (let latNumber = 0; latNumber < this._latBands; latNumber++) {
|
|
87
84
|
for (let longNumber = 0; longNumber < this._lonBands; longNumber++) {
|
|
88
|
-
var first =
|
|
85
|
+
var first = latNumber * (this._lonBands + 1) + longNumber;
|
|
89
86
|
var second = first + this._lonBands + 1;
|
|
90
87
|
|
|
91
88
|
this._indexData.push(first);
|
|
@@ -100,4 +97,4 @@ class Sphere extends BaseShape {
|
|
|
100
97
|
}
|
|
101
98
|
}
|
|
102
99
|
|
|
103
|
-
export { Sphere };
|
|
100
|
+
export { Sphere };
|
|
@@ -138,10 +138,14 @@ class FontAtlas {
|
|
|
138
138
|
|
|
139
139
|
let img = new Image();
|
|
140
140
|
img.onload = () => {
|
|
141
|
-
|
|
141
|
+
this._createTexture(atlas, img);
|
|
142
142
|
def.resolve(index);
|
|
143
143
|
};
|
|
144
144
|
img.src = ARIAL_FONT_B64;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
_createTexture(atlas, img) {
|
|
148
|
+
atlas.createTexture(img);
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
loadFont(faceName, srcDir, atlasUrl) {
|
|
@@ -183,7 +187,7 @@ class FontAtlas {
|
|
|
183
187
|
|
|
184
188
|
let img = new Image();
|
|
185
189
|
img.onload = () => {
|
|
186
|
-
|
|
190
|
+
this._createTexture(atlas, img);
|
|
187
191
|
def.resolve(index);
|
|
188
192
|
};
|
|
189
193
|
|
|
@@ -151,7 +151,11 @@ export class GeoImageCreator {
|
|
|
151
151
|
`precision highp float;
|
|
152
152
|
uniform sampler2D sourceTexture;
|
|
153
153
|
varying vec2 v_texCoords;
|
|
154
|
-
void main () {
|
|
154
|
+
void main () {
|
|
155
|
+
if(v_texCoords.x <= 0.001 || v_texCoords.x >= 0.999 ||
|
|
156
|
+
v_texCoords.y <= 0.001 || v_texCoords.y >= 0.999) {
|
|
157
|
+
discard;
|
|
158
|
+
}
|
|
155
159
|
gl_FragColor = texture2D(sourceTexture, v_texCoords);
|
|
156
160
|
}`
|
|
157
161
|
}));
|
|
@@ -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,7 +13,6 @@ 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
|
|
@@ -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
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
|
*/
|
|
@@ -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
|
@@ -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
|
+
}
|