@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.
@@ -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
- // check for zoom
1001
- if (this.tileZoom <= MAX_NORMAL_ZOOM) {
1002
- var coord_nw = ellipsoid.geodeticToCartesian(
1003
- extent.southWest.lon,
1004
- extent.northEast.lat
1005
- );
1006
- var coord_se = ellipsoid.geodeticToCartesian(
1007
- extent.northEast.lon,
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
- this._swNorm = coord_sw.normal();
1012
- this._nwNorm = coord_nw.normal();
1013
- this._neNorm = coord_ne.normal();
1014
- this._seNorm = coord_se.normal();
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
- if (this.tileZoom <= MAX_NORMAL_ZOOM) {
1045
- let i0 = gridSize * offsetY;
1046
- let j0 = gridSize * offsetX;
1031
+ let i0 = gridSize * offsetY;
1032
+ let j0 = gridSize * offsetX;
1047
1033
 
1048
- let pnGsOne = pn.segment.gridSize + 1;
1034
+ let pnGsOne = pn.segment.gridSize + 1;
1049
1035
 
1050
- let ind_sw = 3 * ((i0 + gridSize) * pnGsOne + j0),
1051
- ind_nw = 3 * (i0 * pnGsOne + j0),
1052
- ind_ne = 3 * (i0 * pnGsOne + j0 + gridSize),
1053
- ind_se = 3 * ((i0 + gridSize) * pnGsOne + j0 + gridSize);
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
- let pVerts = pn.segment.tempVertices;
1041
+ let pVerts = pn.segment.tempVertices;
1056
1042
 
1057
- let v_sw = new Vec3(pVerts[ind_sw], pVerts[ind_sw + 1], pVerts[ind_sw + 2]),
1058
- v_ne = new Vec3(pVerts[ind_ne], pVerts[ind_ne + 1], pVerts[ind_ne + 2]);
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
- // check for segment zoom
1061
- let v_nw = new Vec3(pVerts[ind_nw], pVerts[ind_nw + 1], pVerts[ind_nw + 2]),
1062
- v_se = new Vec3(pVerts[ind_se], pVerts[ind_se + 1], pVerts[ind_se + 2]);
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, sliceIndex, defaultTexture, isOverlay) {
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
- var slice = this._slices[sliceIndex];
1549
+ gl.uniform1f(shu.height, currHeight);
1569
1550
 
1570
- var notEmpty = false;
1551
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
1552
+ gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
1571
1553
 
1572
- let len = slice.layers.length;
1554
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1555
+ gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1573
1556
 
1574
- for (let n = 0; n < len; n++) {
1575
- notEmpty = true;
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, sliceIndex, defaultTexture, isOverlay) {
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
- var slice = this._slices[sliceIndex];
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
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1721
- gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1642
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
1643
+ gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
1722
1644
 
1723
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexTextureCoordBuffer);
1724
- gl.vertexAttribPointer(sha.aTextureCoord, 2, gl.UNSIGNED_SHORT, true, 0, 0);
1645
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1646
+ gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1725
1647
 
1726
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
1727
- gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
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() {