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 | 1x 390x 390x 390x 1x 1x 1x 1x 30x 81x 1x 347x 1x 241x 241x 241x 1x 1x 561x 561x 58x 503x 503x 138x 365x 365x 365x 36x 36x 365x 365x 365x 41x 41x 1x 153x 1x 1x 153x 1x 323x 323x 68x 5x 68x 255x 242x 13x 1x 323x 323x 227x 5x 227x 96x 83x 13x 1x 1x 325x 63x 325x 223x 325x 325x 30x 325x 15x 325x 10x 315x 25x 290x | import Check from "../Core/Check.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import GeometryOffsetAttribute from "../Core/GeometryOffsetAttribute.js";
import oneTimeWarning from "../Core/oneTimeWarning.js";
import GroundPrimitive from "../Scene/GroundPrimitive.js";
import HeightReference, {
isHeightReferenceClamp,
} from "../Scene/HeightReference.js";
import CallbackProperty from "./CallbackProperty.js";
import ConstantProperty from "./ConstantProperty.js";
import GeometryUpdater from "./GeometryUpdater.js";
import TerrainOffsetProperty from "./TerrainOffsetProperty.js";
const defaultZIndex = new ConstantProperty(0);
/**
* An abstract class for updating ground geometry entities.
* @constructor
* @alias GroundGeometryUpdater
* @param {object} options An object with the following properties:
* @param {Entity} options.entity The entity containing the geometry to be visualized.
* @param {Scene} options.scene The scene where visualization is taking place.
* @param {object} options.geometryOptions Options for the geometry
* @param {string} options.geometryPropertyName The geometry property name
* @param {string[]} options.observedPropertyNames The entity properties this geometry cares about
*/
function GroundGeometryUpdater(options) {
GeometryUpdater.call(this, options);
this._zIndex = 0;
this._terrainOffsetProperty = undefined;
}
Eif (defined(Object.create)) {
GroundGeometryUpdater.prototype = Object.create(GeometryUpdater.prototype);
GroundGeometryUpdater.prototype.constructor = GroundGeometryUpdater;
}
Object.defineProperties(GroundGeometryUpdater.prototype, {
/**
* Gets the zindex
* @type {number}
* @memberof GroundGeometryUpdater.prototype
* @readonly
*/
zIndex: {
get: function () {
return this._zIndex;
},
},
/**
* Gets the terrain offset property
* @type {TerrainOffsetProperty}
* @memberof GroundGeometryUpdater.prototype
* @readonly
* @private
*/
terrainOffsetProperty: {
get: function () {
return this._terrainOffsetProperty;
},
},
});
GroundGeometryUpdater.prototype._isOnTerrain = function (entity, geometry) {
return (
this._fillEnabled &&
!defined(geometry.height) &&
!defined(geometry.extrudedHeight) &&
GroundPrimitive.isSupported(this._scene)
);
};
GroundGeometryUpdater.prototype._getIsClosed = function (options) {
const height = options.height;
const extrudedHeight = options.extrudedHeight;
return height === 0 || (defined(extrudedHeight) && extrudedHeight !== height);
};
GroundGeometryUpdater.prototype._computeCenter =
DeveloperError.throwInstantiationError;
GroundGeometryUpdater.prototype._onEntityPropertyChanged = function (
entity,
propertyName,
newValue,
oldValue,
) {
GeometryUpdater.prototype._onEntityPropertyChanged.call(
this,
entity,
propertyName,
newValue,
oldValue,
);
if (this._observedPropertyNames.indexOf(propertyName) === -1) {
return;
}
const geometry = this._entity[this._geometryPropertyName];
if (!defined(geometry)) {
return;
}
Iif (
defined(geometry.zIndex) &&
(defined(geometry.height) || defined(geometry.extrudedHeight))
) {
oneTimeWarning(oneTimeWarning.geometryZIndex);
}
this._zIndex = geometry.zIndex ?? defaultZIndex;
if (defined(this._terrainOffsetProperty)) {
this._terrainOffsetProperty.destroy();
this._terrainOffsetProperty = undefined;
}
const heightReferenceProperty = geometry.heightReference;
const extrudedHeightReferenceProperty = geometry.extrudedHeightReference;
if (
defined(heightReferenceProperty) ||
defined(extrudedHeightReferenceProperty)
) {
const centerPosition = new CallbackProperty(
this._computeCenter.bind(this),
!this._dynamic,
);
this._terrainOffsetProperty = new TerrainOffsetProperty(
this._scene,
centerPosition,
heightReferenceProperty,
extrudedHeightReferenceProperty,
);
}
};
/**
* Destroys and resources used by the object. Once an object is destroyed, it should not be used.
*
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
*/
GroundGeometryUpdater.prototype.destroy = function () {
if (defined(this._terrainOffsetProperty)) {
this._terrainOffsetProperty.destroy();
this._terrainOffsetProperty = undefined;
}
GeometryUpdater.prototype.destroy.call(this);
};
/**
* @private
*/
GroundGeometryUpdater.getGeometryHeight = function (height, heightReference) {
//>>includeStart('debug', pragmas.debug);
Check.defined("heightReference", heightReference);
//>>includeEnd('debug');
if (!defined(height)) {
if (heightReference !== HeightReference.NONE) {
oneTimeWarning(oneTimeWarning.geometryHeightReference);
}
return;
}
if (!isHeightReferenceClamp(heightReference)) {
return height;
}
return 0.0;
};
/**
* @private
*/
GroundGeometryUpdater.getGeometryExtrudedHeight = function (
extrudedHeight,
extrudedHeightReference,
) {
//>>includeStart('debug', pragmas.debug);
Check.defined("extrudedHeightReference", extrudedHeightReference);
//>>includeEnd('debug');
if (!defined(extrudedHeight)) {
if (extrudedHeightReference !== HeightReference.NONE) {
oneTimeWarning(oneTimeWarning.geometryExtrudedHeightReference);
}
return;
}
if (!isHeightReferenceClamp(extrudedHeightReference)) {
return extrudedHeight;
}
return GroundGeometryUpdater.CLAMP_TO_GROUND;
};
/**
* @private
*/
GroundGeometryUpdater.CLAMP_TO_GROUND = "clamp";
/**
* @private
*/
GroundGeometryUpdater.computeGeometryOffsetAttribute = function (
height,
heightReference,
extrudedHeight,
extrudedHeightReference,
) {
if (!defined(height) || !defined(heightReference)) {
heightReference = HeightReference.NONE;
}
if (!defined(extrudedHeight) || !defined(extrudedHeightReference)) {
extrudedHeightReference = HeightReference.NONE;
}
let n = 0;
if (heightReference !== HeightReference.NONE) {
n++;
}
if (extrudedHeightReference === HeightReference.RELATIVE_TO_GROUND) {
n++;
}
if (n === 2) {
return GeometryOffsetAttribute.ALL;
}
if (n === 1) {
return GeometryOffsetAttribute.TOP;
}
return undefined;
};
export default GroundGeometryUpdater;
|