Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | 383x 383x 383x 383x 383x 383x 1x 3160x 97x 97x 790x 95x 95x 95x 790x 64x 64x 790x 68x 68x 68x 790x 63x 63x 790x | import Check from "../Core/Check.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import NearFarScalar from "../Core/NearFarScalar.js";
import Rectangle from "../Core/Rectangle.js";
/**
* Properties for controlling globe translucency.
*
* @alias GlobeTranslucency
* @constructor
*/
function GlobeTranslucency() {
this._enabled = false;
this._frontFaceAlpha = 1.0;
this._frontFaceAlphaByDistance = undefined;
this._backFaceAlpha = 1.0;
this._backFaceAlphaByDistance = undefined;
this._rectangle = Rectangle.clone(Rectangle.MAX_VALUE);
}
Object.defineProperties(GlobeTranslucency.prototype, {
/**
* When true, the globe is rendered as a translucent surface.
* <br /><br />
* The alpha is computed by blending {@link Globe#material}, {@link Globe#imageryLayers},
* and {@link Globe#baseColor}, all of which may contain translucency, and then multiplying by
* {@link GlobeTranslucency#frontFaceAlpha} and {@link GlobeTranslucency#frontFaceAlphaByDistance} for front faces and
* {@link GlobeTranslucency#backFaceAlpha} and {@link GlobeTranslucency#backFaceAlphaByDistance} for back faces.
* When the camera is underground back faces and front faces are swapped, i.e. back-facing geometry
* is considered front facing.
* <br /><br />
* Translucency is disabled by default.
*
* @memberof GlobeTranslucency.prototype
*
* @type {boolean}
* @default false
*
* @see GlobeTranslucency#frontFaceAlpha
* @see GlobeTranslucency#frontFaceAlphaByDistance
* @see GlobeTranslucency#backFaceAlpha
* @see GlobeTranslucency#backFaceAlphaByDistance
*/
enabled: {
get: function () {
return this._enabled;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.bool("enabled", value);
//>>includeEnd('debug');
this._enabled = value;
},
},
/**
* A constant translucency to apply to front faces of the globe.
* <br /><br />
* {@link GlobeTranslucency#enabled} must be set to true for this option to take effect.
*
* @memberof GlobeTranslucency.prototype
*
* @type {number}
* @default 1.0
*
* @see GlobeTranslucency#enabled
* @see GlobeTranslucency#frontFaceAlphaByDistance
*
* @example
* // Set front face translucency to 0.5.
* globe.translucency.frontFaceAlpha = 0.5;
* globe.translucency.enabled = true;
*/
frontFaceAlpha: {
get: function () {
return this._frontFaceAlpha;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals("frontFaceAlpha", value, 0.0);
Check.typeOf.number.lessThanOrEquals("frontFaceAlpha", value, 1.0);
//>>includeEnd('debug');
this._frontFaceAlpha = value;
},
},
/**
* Gets or sets near and far translucency properties of front faces of the globe based on the distance to the camera.
* The translucency will interpolate between the {@link NearFarScalar#nearValue} and
* {@link NearFarScalar#farValue} while the camera distance falls within the lower and upper bounds
* of the specified {@link NearFarScalar#near} and {@link NearFarScalar#far}.
* Outside of these ranges the translucency remains clamped to the nearest bound. If undefined,
* frontFaceAlphaByDistance will be disabled.
* <br /><br />
* {@link GlobeTranslucency#enabled} must be set to true for this option to take effect.
*
* @memberof GlobeTranslucency.prototype
*
* @type {NearFarScalar}
* @default undefined
*
* @see GlobeTranslucency#enabled
* @see GlobeTranslucency#frontFaceAlpha
*
* @example
* // Example 1.
* // Set front face translucency to 0.5 when the
* // camera is 1500 meters from the surface and 1.0
* // as the camera distance approaches 8.0e6 meters.
* globe.translucency.frontFaceAlphaByDistance = new Cesium.NearFarScalar(1.5e2, 0.5, 8.0e6, 1.0);
* globe.translucency.enabled = true;
*
* @example
* // Example 2.
* // Disable front face translucency by distance
* globe.translucency.frontFaceAlphaByDistance = undefined;
*/
frontFaceAlphaByDistance: {
get: function () {
return this._frontFaceAlphaByDistance;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
Iif (defined(value) && value.far < value.near) {
throw new DeveloperError(
"far distance must be greater than near distance.",
);
}
//>>includeEnd('debug');
this._frontFaceAlphaByDistance = NearFarScalar.clone(
value,
this._frontFaceAlphaByDistance,
);
},
},
/**
* A constant translucency to apply to back faces of the globe.
* <br /><br />
* {@link GlobeTranslucency#enabled} must be set to true for this option to take effect.
*
* @memberof GlobeTranslucency.prototype
*
* @type {number}
* @default 1.0
*
* @see GlobeTranslucency#enabled
* @see GlobeTranslucency#backFaceAlphaByDistance
*
* @example
* // Set back face translucency to 0.5.
* globe.translucency.backFaceAlpha = 0.5;
* globe.translucency.enabled = true;
*/
backFaceAlpha: {
get: function () {
return this._backFaceAlpha;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals("backFaceAlpha", value, 0.0);
Check.typeOf.number.lessThanOrEquals("backFaceAlpha", value, 1.0);
//>>includeEnd('debug');
this._backFaceAlpha = value;
},
},
/**
* Gets or sets near and far translucency properties of back faces of the globe based on the distance to the camera.
* The translucency will interpolate between the {@link NearFarScalar#nearValue} and
* {@link NearFarScalar#farValue} while the camera distance falls within the lower and upper bounds
* of the specified {@link NearFarScalar#near} and {@link NearFarScalar#far}.
* Outside of these ranges the translucency remains clamped to the nearest bound. If undefined,
* backFaceAlphaByDistance will be disabled.
* <br /><br />
* {@link GlobeTranslucency#enabled} must be set to true for this option to take effect.
*
* @memberof GlobeTranslucency.prototype
*
* @type {NearFarScalar}
* @default undefined
*
* @see GlobeTranslucency#enabled
* @see GlobeTranslucency#backFaceAlpha
*
* @example
* // Example 1.
* // Set back face translucency to 0.5 when the
* // camera is 1500 meters from the surface and 1.0
* // as the camera distance approaches 8.0e6 meters.
* globe.translucency.backFaceAlphaByDistance = new Cesium.NearFarScalar(1.5e2, 0.5, 8.0e6, 1.0);
* globe.translucency.enabled = true;
*
* @example
* // Example 2.
* // Disable back face translucency by distance
* globe.translucency.backFaceAlphaByDistance = undefined;
*/
backFaceAlphaByDistance: {
get: function () {
return this._backFaceAlphaByDistance;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
Iif (defined(value) && value.far < value.near) {
throw new DeveloperError(
"far distance must be greater than near distance.",
);
}
//>>includeEnd('debug');
this._backFaceAlphaByDistance = NearFarScalar.clone(
value,
this._backFaceAlphaByDistance,
);
},
},
/**
* A property specifying a {@link Rectangle} used to limit translucency to a cartographic area.
* Defaults to the maximum extent of cartographic coordinates.
*
* @memberof GlobeTranslucency.prototype
*
* @type {Rectangle}
* @default {@link Rectangle.MAX_VALUE}
*/
rectangle: {
get: function () {
return this._rectangle;
},
set: function (value) {
if (!defined(value)) {
value = Rectangle.clone(Rectangle.MAX_VALUE);
}
Rectangle.clone(value, this._rectangle);
},
},
});
export default GlobeTranslucency;
|