react-globe.gl 2.27.3 → 2.27.4

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.
@@ -1,4 +1,4 @@
1
- // Version 2.27.3 react-globe.gl - https://github.com/vasturiano/react-globe.gl
1
+ // Version 2.27.4 react-globe.gl - https://github.com/vasturiano/react-globe.gl
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['react'], factory) :
@@ -68368,6 +68368,43 @@ void main() {
68368
68368
  }
68369
68369
  });
68370
68370
 
68371
+ var dashedLineShaders = function dashedLineShaders() {
68372
+ return {
68373
+ uniforms: {
68374
+ // dash param defaults, all relative to full length
68375
+ dashOffset: {
68376
+ value: 0
68377
+ },
68378
+ dashSize: {
68379
+ value: 1
68380
+ },
68381
+ gapSize: {
68382
+ value: 0
68383
+ },
68384
+ dashTranslate: {
68385
+ value: 0
68386
+ } // used for animating the dash
68387
+ },
68388
+ vertexShader: "\n uniform float dashTranslate; \n\n attribute vec4 color;\n varying vec4 vColor;\n \n attribute float relDistance;\n varying float vRelDistance;\n\n void main() {\n // pass through colors and distances\n vColor = color;\n vRelDistance = relDistance + dashTranslate;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",
68389
+ fragmentShader: "\n uniform float dashOffset; \n uniform float dashSize;\n uniform float gapSize; \n \n varying vec4 vColor;\n varying float vRelDistance;\n \n void main() {\n // ignore pixels in the gap\n if (vRelDistance < dashOffset) discard;\n if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;\n \n // set px color: [r, g, b, a], interpolated between vertices \n gl_FragColor = vColor; \n }\n "
68390
+ };
68391
+ };
68392
+ var invisibleUndergroundShaderExtend = function invisibleUndergroundShaderExtend(shader) {
68393
+ shader.uniforms.surfaceRadius = {
68394
+ type: 'float',
68395
+ value: 0
68396
+ };
68397
+ shader.vertexShader = ('attribute float surfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n' + shader.vertexShader).replace('void main() {', ['void main() {', 'vSurfaceRadius = surfaceRadius;', 'vPos = position;'].join('\n'));
68398
+ shader.fragmentShader = ('uniform float surfaceRadius;\nvarying float vSurfaceRadius;\nvarying vec3 vPos;\n' + shader.fragmentShader).replace('void main() {', ['void main() {', 'if (length(vPos) < max(surfaceRadius, vSurfaceRadius)) discard;'].join('\n'));
68399
+ return shader;
68400
+ };
68401
+ var applyShaderExtensionToMaterial = function applyShaderExtensionToMaterial(material, extensionFn) {
68402
+ material.onBeforeCompile = function (shader) {
68403
+ material.userData.shader = extensionFn(shader);
68404
+ };
68405
+ return material;
68406
+ };
68407
+
68371
68408
  var _excluded$1 = ["stroke"];
68372
68409
  var THREE$d = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
68373
68410
  : {
@@ -68387,25 +68424,6 @@ void main() {
68387
68424
 
68388
68425
  //
68389
68426
 
68390
- var gradientShaders$1 = {
68391
- uniforms: {
68392
- // dash param defaults, all relative to full length
68393
- dashOffset: {
68394
- value: 0
68395
- },
68396
- dashSize: {
68397
- value: 1
68398
- },
68399
- gapSize: {
68400
- value: 0
68401
- },
68402
- dashTranslate: {
68403
- value: 0
68404
- } // used for animating the dash
68405
- },
68406
- vertexShader: "\n uniform float dashTranslate; \n\n attribute vec4 vertexColor;\n varying vec4 vColor;\n \n attribute float vertexRelDistance;\n varying float vRelDistance;\n\n void main() {\n // pass through colors and distances\n vColor = vertexColor;\n vRelDistance = vertexRelDistance + dashTranslate;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",
68407
- fragmentShader: "\n uniform float dashOffset; \n uniform float dashSize;\n uniform float gapSize; \n \n varying vec4 vColor;\n varying float vRelDistance;\n \n void main() {\n // ignore pixels in the gap\n if (vRelDistance < dashOffset) discard;\n if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;\n \n // set px color: [r, g, b, a], interpolated between vertices \n gl_FragColor = vColor; \n }\n "
68408
- };
68409
68427
  var ArcsLayerKapsule = index$2({
68410
68428
  props: {
68411
68429
  arcsData: {
@@ -68516,7 +68534,7 @@ void main() {
68516
68534
  var dashGapAccessor = index$1(state.arcDashGap);
68517
68535
  var dashInitialGapAccessor = index$1(state.arcDashInitialGap);
68518
68536
  var dashAnimateTimeAccessor = index$1(state.arcDashAnimateTime);
68519
- var sharedMaterial = new THREE$d.ShaderMaterial(_objectSpread2$1(_objectSpread2$1({}, gradientShaders$1), {}, {
68537
+ var sharedMaterial = new THREE$d.ShaderMaterial(_objectSpread2$1(_objectSpread2$1({}, dashedLineShaders()), {}, {
68520
68538
  transparent: true,
68521
68539
  blending: THREE$d.NormalBlending
68522
68540
  }));
@@ -68572,8 +68590,8 @@ void main() {
68572
68590
  // num vertices per segment
68573
68591
  true // run from end to start, to animate in the correct direction
68574
68592
  );
68575
- obj.geometry.setAttribute('vertexColor', vertexColorArray);
68576
- obj.geometry.setAttribute('vertexRelDistance', vertexRelDistanceArray);
68593
+ obj.geometry.setAttribute('color', vertexColorArray);
68594
+ obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
68577
68595
  var applyUpdate = function applyUpdate(td) {
68578
68596
  var _arc$__currentTargetD = arc.__currentTargetD = td,
68579
68597
  stroke = _arc$__currentTargetD.stroke,
@@ -68582,8 +68600,8 @@ void main() {
68582
68600
  if (useTube) {
68583
68601
  obj.geometry && obj.geometry.dispose();
68584
68602
  obj.geometry = new THREE$d.TubeGeometry(curve, state.arcCurveResolution, stroke / 2, state.arcCircularResolution);
68585
- obj.geometry.setAttribute('vertexColor', vertexColorArray);
68586
- obj.geometry.setAttribute('vertexRelDistance', vertexRelDistanceArray);
68603
+ obj.geometry.setAttribute('color', vertexColorArray);
68604
+ obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
68587
68605
  } else {
68588
68606
  obj.geometry.setFromPoints(curve.getPoints(state.arcCurveResolution));
68589
68607
  }
@@ -68861,12 +68879,12 @@ void main() {
68861
68879
  }), 4));
68862
68880
  return geom;
68863
68881
  }));
68864
- var hexPoints = new THREE$c.Mesh(hexPointsGeometry, new THREE$c.MeshLambertMaterial({
68882
+ var hexPoints = new THREE$c.Mesh(hexPointsGeometry, applyShaderExtensionToMaterial(new THREE$c.MeshLambertMaterial({
68865
68883
  color: 0xffffff,
68866
68884
  transparent: true,
68867
68885
  vertexColors: true,
68868
68886
  side: THREE$c.DoubleSide
68869
- }));
68887
+ }), invisibleUndergroundShaderExtend));
68870
68888
  hexPoints.__globeObjType = 'hexBinPoints'; // Add object type
68871
68889
  hexPoints.__data = hexBins; // Attach obj data
68872
68890
 
@@ -68923,6 +68941,12 @@ void main() {
68923
68941
  var _obj$__currentTargetD = obj.__currentTargetD = td,
68924
68942
  alt = _obj$__currentTargetD.alt;
68925
68943
  obj.scale.x = obj.scale.y = obj.scale.z = 1 + alt; // scale according to altitude
68944
+
68945
+ // update surfaceRadius per vertex
68946
+ var vertexSurfaceRadius = GLOBE_RADIUS / (alt + 1);
68947
+ obj.geometry.setAttribute('surfaceRadius', array2BufferAttr(_toConsumableArray$2(new Array(obj.geometry.getAttribute('position').count)).map(function () {
68948
+ return vertexSurfaceRadius;
68949
+ }), 1));
68926
68950
  };
68927
68951
  var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
68928
68952
  alt: -1e-3
@@ -68945,12 +68969,12 @@ void main() {
68945
68969
  [sideColor, topColor].forEach(function (color) {
68946
68970
  if (!hexMaterials.hasOwnProperty(color)) {
68947
68971
  var opacity = colorAlpha(color);
68948
- hexMaterials[color] = new THREE$c.MeshLambertMaterial({
68972
+ hexMaterials[color] = applyShaderExtensionToMaterial(new THREE$c.MeshLambertMaterial({
68949
68973
  color: colorStr2Hex(color),
68950
68974
  transparent: opacity < 1,
68951
68975
  opacity: opacity,
68952
68976
  side: THREE$c.DoubleSide
68953
- });
68977
+ }), invisibleUndergroundShaderExtend);
68954
68978
  }
68955
68979
  });
68956
68980
  obj.material = [sideColor, topColor].map(function (color) {
@@ -69367,10 +69391,10 @@ void main() {
69367
69391
  },
69368
69392
  createObj: function createObj() {
69369
69393
  var obj = new THREE$a.Group();
69370
- obj.__defaultSideMaterial = new THREE$a.MeshBasicMaterial({
69394
+ obj.__defaultSideMaterial = applyShaderExtensionToMaterial(new THREE$a.MeshBasicMaterial({
69371
69395
  side: THREE$a.DoubleSide,
69372
69396
  depthWrite: true
69373
- });
69397
+ }), invisibleUndergroundShaderExtend);
69374
69398
  obj.__defaultCapMaterial = new THREE$a.MeshBasicMaterial({
69375
69399
  side: THREE$a.DoubleSide,
69376
69400
  depthWrite: true
@@ -69452,6 +69476,7 @@ void main() {
69452
69476
  alt = _obj$__currentTargetD.alt;
69453
69477
  conicObj.scale.x = conicObj.scale.y = conicObj.scale.z = 1 + alt;
69454
69478
  addStroke && (strokeObj.scale.x = strokeObj.scale.y = strokeObj.scale.z = 1 + alt + 1e-4); // stroke slightly above the conic mesh
69479
+ obj.__defaultSideMaterial.userData.shader && (obj.__defaultSideMaterial.userData.shader.uniforms.surfaceRadius.value = GLOBE_RADIUS / (alt + 1)); // update side material scale uniform
69455
69480
  };
69456
69481
  var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
69457
69482
  alt: -1e-3
@@ -69736,25 +69761,6 @@ void main() {
69736
69761
 
69737
69762
  //
69738
69763
 
69739
- var gradientShaders = {
69740
- uniforms: {
69741
- // dash param defaults, all relative to full length
69742
- dashOffset: {
69743
- value: 0
69744
- },
69745
- dashSize: {
69746
- value: 1
69747
- },
69748
- gapSize: {
69749
- value: 0
69750
- },
69751
- dashTranslate: {
69752
- value: 0
69753
- } // used for animating the dash
69754
- },
69755
- vertexShader: "\n uniform float dashTranslate;\n\n attribute vec4 vertexColor;\n varying vec4 vColor;\n\n attribute float vertexRelDistance;\n varying float vRelDistance;\n\n void main() {\n // pass through colors and distances\n vColor = vertexColor;\n vRelDistance = vertexRelDistance + dashTranslate;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",
69756
- fragmentShader: "\n uniform float dashOffset;\n uniform float dashSize;\n uniform float gapSize;\n\n varying vec4 vColor;\n varying float vRelDistance;\n\n void main() {\n // ignore pixels in the gap\n if (vRelDistance < dashOffset) discard;\n if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;\n\n // set px color: [r, g, b, a], interpolated between vertices\n gl_FragColor = vColor;\n }\n "
69757
- };
69758
69764
  var PathsLayerKapsule = index$2({
69759
69765
  props: {
69760
69766
  pathsData: {
@@ -69867,7 +69873,7 @@ void main() {
69867
69873
  var dashGapAccessor = index$1(state.pathDashGap);
69868
69874
  var dashInitialGapAccessor = index$1(state.pathDashInitialGap);
69869
69875
  var dashAnimateTimeAccessor = index$1(state.pathDashAnimateTime);
69870
- var sharedShaderMaterial = new THREE$7.ShaderMaterial(_objectSpread2$1(_objectSpread2$1({}, gradientShaders), {}, {
69876
+ var sharedShaderMaterial = new THREE$7.ShaderMaterial(_objectSpread2$1(_objectSpread2$1({}, dashedLineShaders()), {}, {
69871
69877
  transparent: true,
69872
69878
  blending: THREE$7.NormalBlending
69873
69879
  }));
@@ -69922,8 +69928,8 @@ void main() {
69922
69928
  // num vertices per segment
69923
69929
  true // run from end to start, to animate in the correct direction
69924
69930
  );
69925
- obj.geometry.setAttribute('vertexColor', vertexColorArray);
69926
- obj.geometry.setAttribute('vertexRelDistance', vertexRelDistanceArray);
69931
+ obj.geometry.setAttribute('color', vertexColorArray);
69932
+ obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
69927
69933
  } else {
69928
69934
  // fat lines
69929
69935
  obj.material.resolution = state.rendererSize;