cesium 0.21 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/Assets/Textures/moonSmall.jpg +0 -0
  3. data/app/assets/javascripts/Cesium.js +10 -1
  4. data/app/assets/javascripts/Core/Cartesian2.js +28 -0
  5. data/app/assets/javascripts/Core/Cartesian3.js +28 -0
  6. data/app/assets/javascripts/Core/Cartesian4.js +28 -0
  7. data/app/assets/javascripts/Core/CatmullRomSpline.js +3 -3
  8. data/app/assets/javascripts/Core/Clock.js +7 -7
  9. data/app/assets/javascripts/Core/Color.js +1 -1
  10. data/app/assets/javascripts/Core/ComponentDatatype.js +11 -7
  11. data/app/assets/javascripts/Core/CorridorGeometryLibrary.js +23 -29
  12. data/app/assets/javascripts/Core/Ellipsoid.js +6 -0
  13. data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +5 -4
  14. data/app/assets/javascripts/Core/Event.js +2 -1
  15. data/app/assets/javascripts/Core/ExtentGeometry.js +1 -1
  16. data/app/assets/javascripts/Core/ExtentOutlineGeometry.js +1 -1
  17. data/app/assets/javascripts/Core/GeometryAttributes.js +1 -1
  18. data/app/assets/javascripts/Core/GeometryInstance.js +2 -2
  19. data/app/assets/javascripts/Core/GeometryPipeline.js +10 -7
  20. data/app/assets/javascripts/Core/HermiteSpline.js +1 -1
  21. data/app/assets/javascripts/Core/Iau2000Orientation.js +132 -0
  22. data/app/assets/javascripts/Core/IauOrientationAxes.js +98 -0
  23. data/app/assets/javascripts/Core/IauOrientationParameters.js +48 -0
  24. data/app/assets/javascripts/Core/IntersectionTests.js +5 -5
  25. data/app/assets/javascripts/Core/JulianDate.js +27 -5
  26. data/app/assets/javascripts/Core/Math.js +9 -0
  27. data/app/assets/javascripts/Core/Matrix2.js +1 -142
  28. data/app/assets/javascripts/Core/Matrix3.js +168 -153
  29. data/app/assets/javascripts/Core/Matrix4.js +0 -249
  30. data/app/assets/javascripts/Core/NearFarScalar.js +13 -0
  31. data/app/assets/javascripts/Core/PolygonGeometry.js +1 -1
  32. data/app/assets/javascripts/Core/PolygonOutlineGeometry.js +2 -2
  33. data/app/assets/javascripts/Core/PolygonPipeline.js +2 -2
  34. data/app/assets/javascripts/Core/PolylinePipeline.js +7 -3
  35. data/app/assets/javascripts/Core/PolylineVolumeGeometry.js +239 -0
  36. data/app/assets/javascripts/Core/PolylineVolumeGeometryLibrary.js +404 -0
  37. data/app/assets/javascripts/Core/PolylineVolumeOutlineGeometry.js +154 -0
  38. data/app/assets/javascripts/Core/Quaternion.js +37 -10
  39. data/app/assets/javascripts/Core/Shapes.js +26 -2
  40. data/app/assets/javascripts/Core/Simon1994PlanetaryPositions.js +3 -3
  41. data/app/assets/javascripts/Core/TimeInterval.js +28 -17
  42. data/app/assets/javascripts/Core/TimeIntervalCollection.js +30 -0
  43. data/app/assets/javascripts/Core/Transforms.js +5 -5
  44. data/app/assets/javascripts/Core/WallGeometryLibrary.js +2 -2
  45. data/app/assets/javascripts/Core/getFilenameFromUri.js +37 -0
  46. data/app/assets/javascripts/DynamicScene/ColorMaterialProperty.js +2 -2
  47. data/app/assets/javascripts/DynamicScene/CzmlDataSource.js +96 -18
  48. data/app/assets/javascripts/DynamicScene/DataSource.js +8 -0
  49. data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +15 -3
  50. data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +6 -1
  51. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +1 -1
  52. data/app/assets/javascripts/DynamicScene/DynamicLabel.js +12 -1
  53. data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +5 -0
  54. data/app/assets/javascripts/DynamicScene/DynamicObject.js +44 -17
  55. data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +3 -3
  56. data/app/assets/javascripts/DynamicScene/DynamicPoint.js +12 -1
  57. data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +11 -2
  58. data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +10 -30
  59. data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +5 -20
  60. data/app/assets/javascripts/DynamicScene/GeoJsonDataSource.js +26 -8
  61. data/app/assets/javascripts/DynamicScene/GridMaterialProperty.js +2 -2
  62. data/app/assets/javascripts/DynamicScene/ImageMaterialProperty.js +2 -2
  63. data/app/assets/javascripts/DynamicScene/PolylineOutlineMaterialProperty.js +66 -0
  64. data/app/assets/javascripts/DynamicScene/PositionProperty.js +3 -3
  65. data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +1 -1
  66. data/app/assets/javascripts/DynamicScene/SampledProperty.js +14 -8
  67. data/app/assets/javascripts/Renderer/AutomaticUniforms.js +4 -3
  68. data/app/assets/javascripts/Renderer/Context.js +16 -2
  69. data/app/assets/javascripts/Renderer/UniformState.js +14 -14
  70. data/app/assets/javascripts/Scene/Billboard.js +102 -26
  71. data/app/assets/javascripts/Scene/BillboardCollection.js +69 -16
  72. data/app/assets/javascripts/Scene/Camera.js +7 -7
  73. data/app/assets/javascripts/Scene/CameraController.js +23 -12
  74. data/app/assets/javascripts/Scene/CameraFlightPath.js +11 -11
  75. data/app/assets/javascripts/Scene/CentralBodySurface.js +1 -1
  76. data/app/assets/javascripts/Scene/CustomSensorVolume.js +17 -2
  77. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +79 -24
  78. data/app/assets/javascripts/Scene/ExtentPrimitive.js +17 -1
  79. data/app/assets/javascripts/Scene/Label.js +94 -18
  80. data/app/assets/javascripts/Scene/LabelCollection.js +6 -2
  81. data/app/assets/javascripts/Scene/Moon.js +150 -0
  82. data/app/assets/javascripts/Scene/Polygon.js +18 -1
  83. data/app/assets/javascripts/Scene/Polyline.js +32 -13
  84. data/app/assets/javascripts/Scene/PolylineCollection.js +7 -6
  85. data/app/assets/javascripts/Scene/Primitive.js +2 -2
  86. data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +12 -0
  87. data/app/assets/javascripts/Scene/Scene.js +122 -14
  88. data/app/assets/javascripts/Scene/SceneTransforms.js +2 -2
  89. data/app/assets/javascripts/Scene/SceneTransitioner.js +4 -4
  90. data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1 -1
  91. data/app/assets/javascripts/Scene/SkyBox.js +53 -48
  92. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +2 -2
  93. data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +36 -14
  94. data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +27 -9
  95. data/app/assets/javascripts/Shaders/Builtin/Functions/phong.glsl +13 -0
  96. data/app/assets/javascripts/Shaders/Builtin/Functions/phong.js +10 -0
  97. data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +24 -0
  98. data/app/assets/javascripts/Shaders/EllipsoidFS.js +21 -1
  99. data/app/assets/javascripts/Widgets/CesiumWidget/CesiumWidget.js +30 -9
  100. data/app/assets/javascripts/Widgets/HomeButton/HomeButtonViewModel.js +6 -5
  101. data/app/assets/javascripts/Widgets/Viewer/Viewer.js +13 -0
  102. data/app/assets/javascripts/Widgets/Viewer/viewerDynamicObjectMixin.js +46 -4
  103. data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +16 -8
  104. data/app/assets/javascripts/Workers/createPolylineVolumeGeometry.js +23 -0
  105. data/app/assets/javascripts/Workers/createPolylineVolumeOutlineGeometry.js +23 -0
  106. data/lib/cesium/version.rb +1 -1
  107. metadata +15 -5
  108. data/test/dummy/tmp/pids/server.pid +0 -1
@@ -704,7 +704,7 @@ define(['Core/defined', 'Core/destroyObject', 'Core/Cartesian2', 'Core/Cartesian
704
704
 
705
705
  if (defined(restrictedAngle)) {
706
706
  var direction = Cartesian3.clone(cameraController._camera.directionWC, rotate3DRestrictedDirection);
707
- var invTransform = transform.inverseTransformation();
707
+ var invTransform = Matrix4.inverseTransformation(transform);
708
708
  Matrix4.multiplyByVector(invTransform, direction, direction);
709
709
 
710
710
  var dot = -Cartesian3.dot(direction, constrainedAxis);
@@ -1,5 +1,6 @@
1
1
  /*global define*/
2
- define(['Core/BoxGeometry', 'Core/Cartesian3', 'Core/defined', 'Core/destroyObject', 'Core/DeveloperError', 'Core/Matrix4', 'Core/GeometryPipeline', 'Core/VertexFormat', 'Core/PrimitiveType', 'Renderer/loadCubeMap', 'Renderer/BufferUsage', 'Renderer/DrawCommand', 'Renderer/BlendingState', 'Scene/SceneMode', 'Shaders/SkyBoxVS', 'Shaders/SkyBoxFS'], function(
2
+ define(['Core/defaultValue', 'Core/BoxGeometry', 'Core/Cartesian3', 'Core/defined', 'Core/destroyObject', 'Core/DeveloperError', 'Core/Matrix4', 'Core/GeometryPipeline', 'Core/VertexFormat', 'Core/PrimitiveType', 'Renderer/loadCubeMap', 'Renderer/BufferUsage', 'Renderer/DrawCommand', 'Renderer/BlendingState', 'Scene/SceneMode', 'Shaders/SkyBoxVS', 'Shaders/SkyBoxFS'], function(
3
+ defaultValue,
3
4
  BoxGeometry,
4
5
  Cartesian3,
5
6
  defined,
@@ -27,47 +28,36 @@ define(['Core/BoxGeometry', 'Core/Cartesian3', 'Core/defined', 'Core/destroyObje
27
28
  * @alias SkyBox
28
29
  * @constructor
29
30
  *
30
- * @param {Object} sources The source URL or <code>Image</code> object for each of the six cube map faces. See the example below.
31
- *
32
- * @exception {DeveloperError} sources is required and must have positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ properties.
33
- * @exception {DeveloperError} sources properties must all be the same type.
31
+ * @param {Object} [options.sources] The source URL or <code>Image</code> object for each of the six cube map faces. See the example below.
32
+ * @param {Boolean} [options.show=true] Determines if this primitive will be shown.
34
33
  *
35
34
  * @example
36
35
  * scene.skyBox = new SkyBox({
36
+ * sources : {
37
37
  * positiveX : 'skybox_px.png',
38
38
  * negativeX : 'skybox_nx.png',
39
39
  * positiveY : 'skybox_py.png',
40
40
  * negativeY : 'skybox_ny.png',
41
41
  * positiveZ : 'skybox_pz.png',
42
42
  * negativeZ : 'skybox_nz.png'
43
+ * }
43
44
  * });
44
45
  *
45
46
  * @see Scene#skyBox
46
47
  * @see Transforms.computeTemeToPseudoFixedMatrix
47
48
  */
48
- var SkyBox = function(sources) {
49
- if ((!defined(sources)) ||
50
- (!defined(sources.positiveX)) ||
51
- (!defined(sources.negativeX)) ||
52
- (!defined(sources.positiveY)) ||
53
- (!defined(sources.negativeY)) ||
54
- (!defined(sources.positiveZ)) ||
55
- (!defined(sources.negativeZ))) {
56
- throw new DeveloperError('sources is required and must have positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ properties.');
57
- }
58
-
59
- if ((typeof sources.positiveX !== typeof sources.negativeX) ||
60
- (typeof sources.positiveX !== typeof sources.positiveY) ||
61
- (typeof sources.positiveX !== typeof sources.negativeY) ||
62
- (typeof sources.positiveX !== typeof sources.positiveZ) ||
63
- (typeof sources.positiveX !== typeof sources.negativeZ)) {
64
- throw new DeveloperError('sources properties must all be the same type.');
65
- }
66
-
67
- this._command = new DrawCommand();
68
- this._command.owner = this;
69
- this._cubeMap = undefined;
70
- this._sources = sources;
49
+ var SkyBox = function(options) {
50
+ /**
51
+ * The sources used to create the cube map faces: an object
52
+ * with <code>positiveX</code>, <code>negativeX</code>, <code>positiveY</code>,
53
+ * <code>negativeY</code>, <code>positiveZ</code>, and <code>negativeZ</code> properties.
54
+ * These can be either URLs or <code>Image</code> objects.
55
+ *
56
+ * @type Object
57
+ * @default undefined
58
+ */
59
+ this.sources = options.sources;
60
+ this._sources = undefined;
71
61
 
72
62
  /**
73
63
  * Determines if the sky box will be shown.
@@ -75,25 +65,17 @@ define(['Core/BoxGeometry', 'Core/Cartesian3', 'Core/defined', 'Core/destroyObje
75
65
  * @type {Boolean}
76
66
  * @default true
77
67
  */
78
- this.show = true;
79
- };
68
+ this.show = defaultValue(options.show, true);
80
69
 
81
- /**
82
- * Returns the sources used to create the cube map faces: an object
83
- * with <code>positiveX</code>, <code>negativeX</code>, <code>positiveY</code>,
84
- * <code>negativeY</code>, <code>positiveZ</code>, and <code>negativeZ</code> properties.
85
- * These are either URLs or <code>Image</code> objects, depending on how the sky box
86
- * was constructed.
87
- *
88
- * @memberof SkyBox
89
- *
90
- * @returns {Object} The sources used to create the cube map faces.
91
- */
92
- SkyBox.prototype.getSources = function() {
93
- return this._sources;
70
+ this._command = new DrawCommand();
71
+ this._command.owner = this;
72
+ this._cubeMap = undefined;
94
73
  };
95
74
 
96
75
  /**
76
+ * @exception {DeveloperError} sources is required and must have positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ properties.
77
+ * @exception {DeveloperError} sources properties must all be the same type.
78
+ *
97
79
  * @private
98
80
  */
99
81
  SkyBox.prototype.update = function(context, frameState) {
@@ -111,22 +93,45 @@ define(['Core/BoxGeometry', 'Core/Cartesian3', 'Core/defined', 'Core/destroyObje
111
93
  return undefined;
112
94
  }
113
95
 
114
- var command = this._command;
96
+ if (this._sources !== this.sources) {
97
+ this._sources = this.sources;
98
+ var sources = this.sources;
99
+
100
+ if ((!defined(sources.positiveX)) ||
101
+ (!defined(sources.negativeX)) ||
102
+ (!defined(sources.positiveY)) ||
103
+ (!defined(sources.negativeY)) ||
104
+ (!defined(sources.positiveZ)) ||
105
+ (!defined(sources.negativeZ))) {
106
+ throw new DeveloperError('sources is required and must have positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ properties.');
107
+ }
115
108
 
116
- if (!defined(command.vertexArray)) {
117
- var sources = this._sources;
118
- var that = this;
109
+ if ((typeof sources.positiveX !== typeof sources.negativeX) ||
110
+ (typeof sources.positiveX !== typeof sources.positiveY) ||
111
+ (typeof sources.positiveX !== typeof sources.negativeY) ||
112
+ (typeof sources.positiveX !== typeof sources.positiveZ) ||
113
+ (typeof sources.positiveX !== typeof sources.negativeZ)) {
114
+ throw new DeveloperError('sources properties must all be the same type.');
115
+ }
119
116
 
120
117
  if (typeof sources.positiveX === 'string') {
121
118
  // Given urls for cube-map images. Load them.
122
119
  loadCubeMap(context, this._sources).then(function(cubeMap) {
120
+ that._cubeMap = that._cubeMap && that._cubeMap.destroy();
123
121
  that._cubeMap = cubeMap;
124
122
  });
125
123
  } else {
124
+ this._cubeMap = this._cubeMap && this._cubeMap.destroy();
126
125
  this._cubeMap = context.createCubeMap({
127
126
  source : sources
128
127
  });
129
128
  }
129
+ }
130
+
131
+ var command = this._command;
132
+
133
+ if (!defined(command.vertexArray)) {
134
+ var that = this;
130
135
 
131
136
  command.uniformMap = {
132
137
  u_cubeMap: function() {
@@ -141,7 +146,7 @@ define(['Core/BoxGeometry', 'Core/Cartesian3', 'Core/defined', 'Core/destroyObje
141
146
  var attributeIndices = GeometryPipeline.createAttributeIndices(geometry);
142
147
 
143
148
  command.primitiveType = PrimitiveType.TRIANGLES;
144
- command.modelMatrix = Matrix4.IDENTITY.clone();
149
+ command.modelMatrix = Matrix4.clone(Matrix4.IDENTITY);
145
150
  command.vertexArray = context.createVertexArrayFromGeometry({
146
151
  geometry: geometry,
147
152
  attributeIndices: attributeIndices,
@@ -108,7 +108,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/Cartographic', 'Core/Develope
108
108
  var ne = Cartographic.fromDegrees(parseFloat(bbox.getAttribute('maxy')), parseFloat(bbox.getAttribute('maxx')));
109
109
  that._extent = new Extent(sw.longitude, sw.latitude, ne.longitude, ne.latitude);
110
110
  } else {
111
- that._extent = that._extent.clone();
111
+ that._extent = Extent.clone(that._extent);
112
112
  }
113
113
 
114
114
  // tiling scheme handling
@@ -366,4 +366,4 @@ define(['Core/defaultValue', 'Core/defined', 'Core/Cartographic', 'Core/Develope
366
366
  };
367
367
 
368
368
  return TileMapServiceImageryProvider;
369
- });
369
+ });
@@ -7,6 +7,7 @@ attribute vec2 pixelOffset;
7
7
  attribute vec4 eyeOffsetAndScale; // eye offset in meters
8
8
  attribute vec4 rotationAndAlignedAxis;
9
9
  attribute vec4 scaleByDistance; // near, nearScale, far, farScale
10
+ attribute vec4 translucencyByDistance; // near, nearTrans, far, farTrans
10
11
 
11
12
  #ifdef RENDER_FOR_PICK
12
13
  attribute vec4 pickColor;
@@ -24,6 +25,23 @@ varying vec4 v_pickColor;
24
25
  varying vec4 v_color;
25
26
  #endif
26
27
 
28
+ float getNearFarScalar(vec4 nearFarScalar, float cameraDistSq)
29
+ {
30
+ float valueAtMin = nearFarScalar.y;
31
+ float valueAtMax = nearFarScalar.w;
32
+ float nearDistanceSq = nearFarScalar.x * nearFarScalar.x;
33
+ float farDistanceSq = nearFarScalar.z * nearFarScalar.z;
34
+
35
+ // ensure that t will fall within the range of [0.0, 1.0]
36
+ cameraDistSq = clamp(cameraDistSq, nearDistanceSq, farDistanceSq);
37
+
38
+ float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);
39
+
40
+ t = pow(t, 0.15);
41
+
42
+ return mix(valueAtMin, valueAtMax, t);
43
+ }
44
+
27
45
  void main()
28
46
  {
29
47
  // Modifying this shader may also require modifications to Billboard.computeScreenSpacePosition
@@ -44,8 +62,7 @@ void main()
44
62
  positionEC.xyz *= show;
45
63
 
46
64
  ///////////////////////////////////////////////////////////////////////////
47
-
48
- #ifdef EYE_DISTANCE_SCALING // scale based on eye distance
65
+
49
66
  float lengthSq;
50
67
  if (czm_sceneMode == czm_sceneMode2D)
51
68
  {
@@ -58,19 +75,23 @@ void main()
58
75
  lengthSq = dot(positionEC.xyz, positionEC.xyz);
59
76
  }
60
77
 
61
- float scaleAtMin = scaleByDistance.y;
62
- float scaleAtMax = scaleByDistance.w;
63
- float nearDistanceSq = scaleByDistance.x * scaleByDistance.x;
64
- float farDistanceSq = scaleByDistance.z * scaleByDistance.z;
65
-
66
- // ensure that t will fall within the range of [0.0, 1.0]
67
- lengthSq = clamp(lengthSq, nearDistanceSq, farDistanceSq);
68
-
69
- float t = (lengthSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);
70
-
71
- t = pow(t, 0.15);
78
+ #ifdef EYE_DISTANCE_SCALING
79
+ scale *= getNearFarScalar(scaleByDistance, lengthSq);
80
+ // push vertex behind near plane for clipping
81
+ if (scale == 0.0)
82
+ {
83
+ positionEC.xyz = vec3(0.0);
84
+ }
85
+ #endif
72
86
 
73
- scale *= mix(scaleAtMin, scaleAtMax, t);
87
+ float translucency = 1.0;
88
+ #ifdef EYE_DISTANCE_TRANSLUCENCY
89
+ translucency = getNearFarScalar(translucencyByDistance, lengthSq);
90
+ // push vertex behind near plane for clipping
91
+ if (translucency == 0.0)
92
+ {
93
+ positionEC.xyz = vec3(0.0);
94
+ }
74
95
  #endif
75
96
 
76
97
  vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
@@ -113,5 +134,6 @@ void main()
113
134
  v_pickColor = pickColor;
114
135
  #else
115
136
  v_color = color;
137
+ v_color.a *= translucency;
116
138
  #endif
117
139
  }
@@ -11,6 +11,7 @@ attribute vec2 pixelOffset;\n\
11
11
  attribute vec4 eyeOffsetAndScale;\n\
12
12
  attribute vec4 rotationAndAlignedAxis;\n\
13
13
  attribute vec4 scaleByDistance;\n\
14
+ attribute vec4 translucencyByDistance;\n\
14
15
  #ifdef RENDER_FOR_PICK\n\
15
16
  attribute vec4 pickColor;\n\
16
17
  #else\n\
@@ -23,6 +24,17 @@ varying vec4 v_pickColor;\n\
23
24
  #else\n\
24
25
  varying vec4 v_color;\n\
25
26
  #endif\n\
27
+ float getNearFarScalar(vec4 nearFarScalar, float cameraDistSq)\n\
28
+ {\n\
29
+ float valueAtMin = nearFarScalar.y;\n\
30
+ float valueAtMax = nearFarScalar.w;\n\
31
+ float nearDistanceSq = nearFarScalar.x * nearFarScalar.x;\n\
32
+ float farDistanceSq = nearFarScalar.z * nearFarScalar.z;\n\
33
+ cameraDistSq = clamp(cameraDistSq, nearDistanceSq, farDistanceSq);\n\
34
+ float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);\n\
35
+ t = pow(t, 0.15);\n\
36
+ return mix(valueAtMin, valueAtMax, t);\n\
37
+ }\n\
26
38
  void main()\n\
27
39
  {\n\
28
40
  vec3 eyeOffset = eyeOffsetAndScale.xyz;\n\
@@ -35,7 +47,6 @@ vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
35
47
  vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
36
48
  positionEC = czm_eyeOffset(positionEC, eyeOffset);\n\
37
49
  positionEC.xyz *= show;\n\
38
- #ifdef EYE_DISTANCE_SCALING\n\
39
50
  float lengthSq;\n\
40
51
  if (czm_sceneMode == czm_sceneMode2D)\n\
41
52
  {\n\
@@ -45,14 +56,20 @@ else\n\
45
56
  {\n\
46
57
  lengthSq = dot(positionEC.xyz, positionEC.xyz);\n\
47
58
  }\n\
48
- float scaleAtMin = scaleByDistance.y;\n\
49
- float scaleAtMax = scaleByDistance.w;\n\
50
- float nearDistanceSq = scaleByDistance.x * scaleByDistance.x;\n\
51
- float farDistanceSq = scaleByDistance.z * scaleByDistance.z;\n\
52
- lengthSq = clamp(lengthSq, nearDistanceSq, farDistanceSq);\n\
53
- float t = (lengthSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);\n\
54
- t = pow(t, 0.15);\n\
55
- scale *= mix(scaleAtMin, scaleAtMax, t);\n\
59
+ #ifdef EYE_DISTANCE_SCALING\n\
60
+ scale *= getNearFarScalar(scaleByDistance, lengthSq);\n\
61
+ if (scale == 0.0)\n\
62
+ {\n\
63
+ positionEC.xyz = vec3(0.0);\n\
64
+ }\n\
65
+ #endif\n\
66
+ float translucency = 1.0;\n\
67
+ #ifdef EYE_DISTANCE_TRANSLUCENCY\n\
68
+ translucency = getNearFarScalar(translucencyByDistance, lengthSq);\n\
69
+ if (translucency == 0.0)\n\
70
+ {\n\
71
+ positionEC.xyz = vec3(0.0);\n\
72
+ }\n\
56
73
  #endif\n\
57
74
  vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);\n\
58
75
  vec2 halfSize = imageSize * scale * czm_highResolutionSnapScale;\n\
@@ -86,6 +103,7 @@ v_textureCoordinates = textureCoordinates;\n\
86
103
  v_pickColor = pickColor;\n\
87
104
  #else\n\
88
105
  v_color = color;\n\
106
+ v_color.a *= translucency;\n\
89
107
  #endif\n\
90
108
  }\n\
91
109
  ";
@@ -41,3 +41,16 @@ vec4 czm_phong(vec3 toEye, czm_material material)
41
41
 
42
42
  return vec4(color, material.alpha);
43
43
  }
44
+
45
+ vec4 czm_private_phong(vec3 toEye, czm_material material)
46
+ {
47
+ float diffuse = czm_private_getLambertDiffuseOfMaterial(czm_sunDirectionEC, material);
48
+ float specular = czm_private_getSpecularOfMaterial(czm_sunDirectionEC, toEye, material);
49
+
50
+ vec3 ambient = vec3(0.0);
51
+ vec3 color = ambient + material.emission;
52
+ color += material.diffuse * diffuse;
53
+ color += material.specular * specular;
54
+
55
+ return vec4(color, material.alpha);
56
+ }
@@ -20,5 +20,15 @@ color += material.diffuse * diffuse;\n\
20
20
  color += material.specular * specular;\n\
21
21
  return vec4(color, material.alpha);\n\
22
22
  }\n\
23
+ vec4 czm_private_phong(vec3 toEye, czm_material material)\n\
24
+ {\n\
25
+ float diffuse = czm_private_getLambertDiffuseOfMaterial(czm_sunDirectionEC, material);\n\
26
+ float specular = czm_private_getSpecularOfMaterial(czm_sunDirectionEC, toEye, material);\n\
27
+ vec3 ambient = vec3(0.0);\n\
28
+ vec3 color = ambient + material.emission;\n\
29
+ color += material.diffuse * diffuse;\n\
30
+ color += material.specular * specular;\n\
31
+ return vec4(color, material.alpha);\n\
32
+ }\n\
23
33
  ";
24
34
  });
@@ -1,3 +1,9 @@
1
+ #ifdef WRITE_DEPTH
2
+ #ifdef GL_EXT_frag_depth
3
+ #extension GL_EXT_frag_depth : enable
4
+ #endif
5
+ #endif
6
+
1
7
  uniform vec3 u_radii;
2
8
  uniform vec3 u_oneOverEllipsoidRadiiSquared;
3
9
 
@@ -24,7 +30,11 @@ vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)
24
30
  materialInput.positionToEyeEC = positionToEyeEC;
25
31
  czm_material material = czm_getMaterial(materialInput);
26
32
 
33
+ #ifdef ONLY_SUN_LIGHTING
34
+ return czm_private_phong(normalize(positionToEyeEC), material);
35
+ #else
27
36
  return czm_phong(normalize(positionToEyeEC), material);
37
+ #endif
28
38
  }
29
39
 
30
40
  void main()
@@ -80,4 +90,18 @@ void main()
80
90
 
81
91
  gl_FragColor = mix(insideFaceColor, outsideFaceColor, outsideFaceColor.a);
82
92
  gl_FragColor.a = 1.0 - (1.0 - insideFaceColor.a) * (1.0 - outsideFaceColor.a);
93
+
94
+ #ifdef WRITE_DEPTH
95
+ #ifdef GL_EXT_frag_depth
96
+ t = (intersection.start != 0.0) ? intersection.start : intersection.stop;
97
+ vec3 positionEC = czm_pointAlongRay(ray, t);
98
+ vec4 positionCC = czm_projection * vec4(positionEC, 1.0);
99
+ float z = positionCC.z / positionCC.w;
100
+
101
+ float n = gl_DepthRange.near;
102
+ float f = gl_DepthRange.far;
103
+
104
+ gl_FragDepthEXT = (z * (f - n) + f + n) * 0.5;
105
+ #endif
106
+ #endif
83
107
  }
@@ -2,7 +2,12 @@
2
2
  /*global define*/
3
3
  define(function() {
4
4
  "use strict";
5
- return "uniform vec3 u_radii;\n\
5
+ return "#ifdef WRITE_DEPTH\n\
6
+ #ifdef GL_EXT_frag_depth\n\
7
+ #extension GL_EXT_frag_depth : enable\n\
8
+ #endif\n\
9
+ #endif\n\
10
+ uniform vec3 u_radii;\n\
6
11
  uniform vec3 u_oneOverEllipsoidRadiiSquared;\n\
7
12
  varying vec3 v_positionEC;\n\
8
13
  vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)\n\
@@ -23,7 +28,11 @@ materialInput.normalEC = normalEC;\n\
23
28
  materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);\n\
24
29
  materialInput.positionToEyeEC = positionToEyeEC;\n\
25
30
  czm_material material = czm_getMaterial(materialInput);\n\
31
+ #ifdef ONLY_SUN_LIGHTING\n\
32
+ return czm_private_phong(normalize(positionToEyeEC), material);\n\
33
+ #else\n\
26
34
  return czm_phong(normalize(positionToEyeEC), material);\n\
35
+ #endif\n\
27
36
  }\n\
28
37
  void main()\n\
29
38
  {\n\
@@ -57,6 +66,17 @@ vec4 outsideFaceColor = (intersection.start != 0.0) ? computeEllipsoidColor(ray,
57
66
  vec4 insideFaceColor = (outsideFaceColor.a < 1.0) ? computeEllipsoidColor(ray, intersection.stop, -1.0) : vec4(0.0);\n\
58
67
  gl_FragColor = mix(insideFaceColor, outsideFaceColor, outsideFaceColor.a);\n\
59
68
  gl_FragColor.a = 1.0 - (1.0 - insideFaceColor.a) * (1.0 - outsideFaceColor.a);\n\
69
+ #ifdef WRITE_DEPTH\n\
70
+ #ifdef GL_EXT_frag_depth\n\
71
+ t = (intersection.start != 0.0) ? intersection.start : intersection.stop;\n\
72
+ vec3 positionEC = czm_pointAlongRay(ray, t);\n\
73
+ vec4 positionCC = czm_projection * vec4(positionEC, 1.0);\n\
74
+ float z = positionCC.z / positionCC.w;\n\
75
+ float n = gl_DepthRange.near;\n\
76
+ float f = gl_DepthRange.far;\n\
77
+ gl_FragDepthEXT = (z * (f - n) + f + n) * 0.5;\n\
78
+ #endif\n\
79
+ #endif\n\
60
80
  }\n\
61
81
  ";
62
82
  });