@openglobus/og 0.11.8 → 0.12.0
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 +2 -0
- package/package.json +1 -1
- package/src/og/Globe.js +18 -6
- package/src/og/camera/Camera.js +70 -79
- package/src/og/camera/PlanetCamera.js +25 -30
- package/src/og/control/DebugInfo.js +2 -2
- package/src/og/control/EarthNavigation.js +26 -17
- package/src/og/control/MouseNavigation.js +11 -13
- package/src/og/control/MouseWheelZoomControl.js +5 -5
- package/src/og/control/Sun.js +3 -3
- package/src/og/entity/Entity.js +742 -742
- package/src/og/entity/GeoObjectHandler.js +102 -117
- package/src/og/entity/LabelHandler.js +2 -1
- package/src/og/layer/XYZ.js +20 -21
- package/src/og/math/Vec3.js +18 -2
- package/src/og/quadTree/Node.js +48 -93
- package/src/og/quadTree/quadTree.js +1 -1
- package/src/og/renderer/Renderer.js +3 -5
- package/src/og/scene/Planet.js +105 -118
- package/src/og/segment/Segment.js +57 -136
- package/src/og/shaders/drawnode.js +132 -221
- package/src/og/terrain/EmptyTerrain.js +3 -2
- package/src/og/terrain/GlobusTerrain.js +2 -0
- package/src/og/utils/Loader.js +1 -1
- package/src/og/utils/PlainSegmentWorker.js +0 -13
- package/src/og/webgl/Handler.js +13 -9
|
@@ -14,8 +14,6 @@ import * as segmentHelper from "../segment/segmentHelper.js";
|
|
|
14
14
|
import { getMatrixSubArray } from "../utils/shared.js";
|
|
15
15
|
import { Slice } from "./Slice.js";
|
|
16
16
|
|
|
17
|
-
export const MAX_NORMAL_ZOOM = 7;
|
|
18
|
-
|
|
19
17
|
var _tempHigh = new Vec3();
|
|
20
18
|
var _tempLow = new Vec3();
|
|
21
19
|
|
|
@@ -41,8 +39,6 @@ _V[E] = true;
|
|
|
41
39
|
_V[S] = false;
|
|
42
40
|
_V[W] = true;
|
|
43
41
|
|
|
44
|
-
window.BBSC = 100;
|
|
45
|
-
|
|
46
42
|
/**
|
|
47
43
|
* Planet segment Web Mercator tile class that stored and rendered with quad tree.
|
|
48
44
|
* @class
|
|
@@ -97,10 +93,17 @@ class Segment {
|
|
|
97
93
|
*/
|
|
98
94
|
this.bbox = new Box();
|
|
99
95
|
|
|
100
|
-
this._swNorm = null;
|
|
101
|
-
this._nwNorm = null;
|
|
102
|
-
this._seNorm = null;
|
|
103
|
-
this._neNorm = null;
|
|
96
|
+
//this._swNorm = null;
|
|
97
|
+
//this._nwNorm = null;
|
|
98
|
+
//this._seNorm = null;
|
|
99
|
+
//this._neNorm = null;
|
|
100
|
+
|
|
101
|
+
this._sw = new Vec3();
|
|
102
|
+
this._nw = new Vec3();
|
|
103
|
+
this._se = new Vec3();
|
|
104
|
+
this._ne = new Vec3();
|
|
105
|
+
|
|
106
|
+
this.centerNormal = new Vec3();
|
|
104
107
|
|
|
105
108
|
/**
|
|
106
109
|
* Geographical extent.
|
|
@@ -237,19 +240,6 @@ class Segment {
|
|
|
237
240
|
this.plainProcessing = false;
|
|
238
241
|
}
|
|
239
242
|
|
|
240
|
-
/**
|
|
241
|
-
* Returns that segment good for rendering with camera by current lod ratio.
|
|
242
|
-
* @public
|
|
243
|
-
* @param {Camera} camera - Camera object.
|
|
244
|
-
* @returns {boolean} -
|
|
245
|
-
*/
|
|
246
|
-
acceptForRendering(camera) {
|
|
247
|
-
return (
|
|
248
|
-
camera.projectedSize(this.bsphere.center, this._plainRadius) <
|
|
249
|
-
256 / this.planet._lodRatio
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
243
|
/**
|
|
254
244
|
* Returns entity terrain point.
|
|
255
245
|
* @public
|
|
@@ -997,22 +987,19 @@ class Segment {
|
|
|
997
987
|
var coord_sw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.southWest.lat);
|
|
998
988
|
var coord_ne = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.northEast.lat);
|
|
999
989
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
extent.southWest.lat
|
|
1009
|
-
);
|
|
990
|
+
var coord_nw = ellipsoid.geodeticToCartesian(
|
|
991
|
+
extent.southWest.lon,
|
|
992
|
+
extent.northEast.lat
|
|
993
|
+
);
|
|
994
|
+
var coord_se = ellipsoid.geodeticToCartesian(
|
|
995
|
+
extent.northEast.lon,
|
|
996
|
+
extent.southWest.lat
|
|
997
|
+
);
|
|
1010
998
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
}
|
|
999
|
+
this._sw.copy(coord_sw);
|
|
1000
|
+
this._nw.copy(coord_nw);
|
|
1001
|
+
this._ne.copy(coord_ne);
|
|
1002
|
+
this._se.copy(coord_se);
|
|
1016
1003
|
|
|
1017
1004
|
this.setBoundingVolume3v(coord_sw, coord_ne);
|
|
1018
1005
|
}
|
|
@@ -1041,31 +1028,30 @@ class Segment {
|
|
|
1041
1028
|
this.bsphere.center.z = pn.segment.bsphere.center.z;
|
|
1042
1029
|
this.bsphere.radius = pn.segment.bsphere.radius;
|
|
1043
1030
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
let j0 = gridSize * offsetX;
|
|
1031
|
+
let i0 = gridSize * offsetY;
|
|
1032
|
+
let j0 = gridSize * offsetX;
|
|
1047
1033
|
|
|
1048
|
-
|
|
1034
|
+
let pnGsOne = pn.segment.gridSize + 1;
|
|
1049
1035
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1036
|
+
let ind_sw = 3 * ((i0 + gridSize) * pnGsOne + j0),
|
|
1037
|
+
ind_nw = 3 * (i0 * pnGsOne + j0),
|
|
1038
|
+
ind_ne = 3 * (i0 * pnGsOne + j0 + gridSize),
|
|
1039
|
+
ind_se = 3 * ((i0 + gridSize) * pnGsOne + j0 + gridSize);
|
|
1054
1040
|
|
|
1055
|
-
|
|
1041
|
+
let pVerts = pn.segment.tempVertices;
|
|
1056
1042
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1043
|
+
let v_sw = new Vec3(pVerts[ind_sw], pVerts[ind_sw + 1], pVerts[ind_sw + 2]),
|
|
1044
|
+
v_ne = new Vec3(pVerts[ind_ne], pVerts[ind_ne + 1], pVerts[ind_ne + 2]);
|
|
1059
1045
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1046
|
+
// check for segment zoom
|
|
1047
|
+
let v_nw = new Vec3(pVerts[ind_nw], pVerts[ind_nw + 1], pVerts[ind_nw + 2]),
|
|
1048
|
+
v_se = new Vec3(pVerts[ind_se], pVerts[ind_se + 1], pVerts[ind_se + 2]);
|
|
1049
|
+
|
|
1050
|
+
this._sw.copy(v_sw);
|
|
1051
|
+
this._nw.copy(v_nw);
|
|
1052
|
+
this._ne.copy(v_ne);
|
|
1053
|
+
this._se.copy(v_se);
|
|
1063
1054
|
|
|
1064
|
-
this._swNorm = v_sw.normal();
|
|
1065
|
-
this._nwNorm = v_nw.normal();
|
|
1066
|
-
this._neNorm = v_ne.normal();
|
|
1067
|
-
this._seNorm = v_se.normal();
|
|
1068
|
-
}
|
|
1069
1055
|
} else {
|
|
1070
1056
|
let pseg = pn.segment;
|
|
1071
1057
|
|
|
@@ -1545,7 +1531,7 @@ class Segment {
|
|
|
1545
1531
|
}
|
|
1546
1532
|
}
|
|
1547
1533
|
|
|
1548
|
-
heightPickingRendering(sh, layerSlice
|
|
1534
|
+
heightPickingRendering(sh, layerSlice) {
|
|
1549
1535
|
var gl = this.handler.gl;
|
|
1550
1536
|
var sha = sh.attributes,
|
|
1551
1537
|
shu = sh.uniforms;
|
|
@@ -1553,11 +1539,6 @@ class Segment {
|
|
|
1553
1539
|
var pm = this.materials,
|
|
1554
1540
|
p = this.planet;
|
|
1555
1541
|
|
|
1556
|
-
// First always draw whole planet base layer segment with solid texture.
|
|
1557
|
-
gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE);
|
|
1558
|
-
gl.bindTexture(gl.TEXTURE_2D, defaultTexture || p.solidTextureOne);
|
|
1559
|
-
gl.uniform1i(shu.defaultTexture, p.SLICE_SIZE);
|
|
1560
|
-
|
|
1561
1542
|
var currHeight;
|
|
1562
1543
|
if (layerSlice) {
|
|
1563
1544
|
currHeight = layerSlice[0]._height;
|
|
@@ -1565,42 +1546,16 @@ class Segment {
|
|
|
1565
1546
|
currHeight = 0;
|
|
1566
1547
|
}
|
|
1567
1548
|
|
|
1568
|
-
|
|
1549
|
+
gl.uniform1f(shu.height, currHeight);
|
|
1569
1550
|
|
|
1570
|
-
|
|
1551
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
|
|
1552
|
+
gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
|
|
1571
1553
|
|
|
1572
|
-
|
|
1554
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
|
|
1555
|
+
gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
|
|
1573
1556
|
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
p._samplerArr[n] = n;
|
|
1577
|
-
gl.activeTexture(gl.TEXTURE0 + n);
|
|
1578
|
-
gl.bindTexture(gl.TEXTURE_2D, pm[slice.layers[n]._id].texture || p.transparentTexture);
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
if (notEmpty || !isOverlay) {
|
|
1582
|
-
gl.uniform1i(shu.samplerCount, len);
|
|
1583
|
-
gl.uniform1f(shu.height, currHeight);
|
|
1584
|
-
gl.uniform1iv(shu.samplerArr, p._samplerArr);
|
|
1585
|
-
|
|
1586
|
-
//slice.uniform(gl, shu);
|
|
1587
|
-
|
|
1588
|
-
gl.uniform4fv(shu.tileOffsetArr, slice.tileOffsetArr);
|
|
1589
|
-
gl.uniform1fv(shu.layerOpacityArr, slice.layerOpacityArr);
|
|
1590
|
-
//gl.uniform4fv(shu.visibleExtentOffsetArr, slice.visibleExtentOffsetArr);
|
|
1591
|
-
|
|
1592
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
|
|
1593
|
-
gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
|
|
1594
|
-
|
|
1595
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
|
|
1596
|
-
gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
|
|
1597
|
-
|
|
1598
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexTextureCoordBuffer);
|
|
1599
|
-
gl.vertexAttribPointer(sha.aTextureCoord, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
1600
|
-
|
|
1601
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
|
|
1602
|
-
gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
1603
|
-
}
|
|
1557
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
|
|
1558
|
+
gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
1604
1559
|
}
|
|
1605
1560
|
|
|
1606
1561
|
colorPickingRendering(sh, layerSlice, sliceIndex, defaultTexture, isOverlay) {
|
|
@@ -1670,19 +1625,11 @@ class Segment {
|
|
|
1670
1625
|
}
|
|
1671
1626
|
}
|
|
1672
1627
|
|
|
1673
|
-
depthRendering(sh, layerSlice
|
|
1628
|
+
depthRendering(sh, layerSlice) {
|
|
1674
1629
|
var gl = this.handler.gl;
|
|
1675
1630
|
var sha = sh.attributes,
|
|
1676
1631
|
shu = sh.uniforms;
|
|
1677
1632
|
|
|
1678
|
-
var pm = this.materials,
|
|
1679
|
-
p = this.planet;
|
|
1680
|
-
|
|
1681
|
-
// First always draw whole planet base layer segment with solid texture.
|
|
1682
|
-
gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE);
|
|
1683
|
-
gl.bindTexture(gl.TEXTURE_2D, defaultTexture || p.solidTextureOne);
|
|
1684
|
-
gl.uniform1i(shu.defaultTexture, p.SLICE_SIZE);
|
|
1685
|
-
|
|
1686
1633
|
var currHeight;
|
|
1687
1634
|
if (layerSlice) {
|
|
1688
1635
|
currHeight = layerSlice[0]._height;
|
|
@@ -1690,42 +1637,16 @@ class Segment {
|
|
|
1690
1637
|
currHeight = 0;
|
|
1691
1638
|
}
|
|
1692
1639
|
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
var notEmpty = false;
|
|
1696
|
-
|
|
1697
|
-
let len = slice.layers.length;
|
|
1698
|
-
|
|
1699
|
-
for (let n = 0; n < len; n++) {
|
|
1700
|
-
notEmpty = true;
|
|
1701
|
-
p._samplerArr[n] = n;
|
|
1702
|
-
gl.activeTexture(gl.TEXTURE0 + n);
|
|
1703
|
-
gl.bindTexture(gl.TEXTURE_2D, pm[slice.layers[n]._id].texture || p.transparentTexture);
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
if (notEmpty || !isOverlay) {
|
|
1707
|
-
gl.uniform1i(shu.samplerCount, len);
|
|
1708
|
-
gl.uniform1f(shu.height, currHeight);
|
|
1709
|
-
gl.uniform1iv(shu.samplerArr, p._samplerArr);
|
|
1710
|
-
|
|
1711
|
-
//slice.uniform(gl, shu);
|
|
1712
|
-
|
|
1713
|
-
gl.uniform4fv(shu.tileOffsetArr, slice.tileOffsetArr);
|
|
1714
|
-
gl.uniform1fv(shu.layerOpacityArr, slice.layerOpacityArr);
|
|
1715
|
-
//gl.uniform4fv(shu.visibleExtentOffsetArr, slice.visibleExtentOffsetArr);
|
|
1716
|
-
|
|
1717
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
|
|
1718
|
-
gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
|
|
1640
|
+
gl.uniform1f(shu.height, currHeight);
|
|
1719
1641
|
|
|
1720
|
-
|
|
1721
|
-
|
|
1642
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
|
|
1643
|
+
gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
|
|
1722
1644
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1645
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
|
|
1646
|
+
gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
|
|
1725
1647
|
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1648
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
|
|
1649
|
+
gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
1729
1650
|
}
|
|
1730
1651
|
|
|
1731
1652
|
_getIndexBuffer() {
|