vue-cesium
Version:
Vue 3.x components for CesiumJS.
37 lines (35 loc) • 1.19 kB
JavaScript
let isExtended = false;
class RectangleExtend {
static extend(viewer) {
if (isExtended) {
return;
}
const { Rectangle } = Cesium;
Rectangle.prototype.expand = function(widthFactor, heightFactor, result) {
result = result && result instanceof Rectangle ? result : this.clone();
widthFactor = result.width * (1 - widthFactor) / 2;
heightFactor = result.height * (1 - heightFactor) / 2;
result.west += widthFactor;
result.south += heightFactor;
result.east -= widthFactor;
result.north -= heightFactor;
result.west = result.west < -Math.PI ? -Math.PI : result.west;
result.east = result.east > Math.PI ? Math.PI : result.east;
result.north = result.north > Math.PI / 2 ? Math.PI / 2 : result.north;
result.south = result.south < -Math.PI / 2 ? -Math.PI / 2 : result.south;
return result;
};
isExtended = true;
}
static revoke(viewer) {
if (!isExtended) {
return;
}
const { Rectangle } = Cesium;
Rectangle.prototype.expand = void 0;
isExtended = false;
}
}
export { RectangleExtend as default };
//# sourceMappingURL=RectangleExtend.mjs.map
;