import BoundingSphere from "../Core/BoundingSphere.js";
import BoxOutlineGeometry from "../Core/BoxOutlineGeometry.js";
import Cartesian2 from "../Core/Cartesian2.js";
import Cartesian3 from "../Core/Cartesian3.js";
import Cartesian4 from "../Core/Cartesian4.js";
import Cartographic from "../Core/Cartographic.js";
import clone from "../Core/clone.js";
import Color from "../Core/Color.js";
import ColorGeometryInstanceAttribute from "../Core/ColorGeometryInstanceAttribute.js";
import combine from "../Core/combine.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
import GeometryInstance from "../Core/GeometryInstance.js";
import GeometryPipeline from "../Core/GeometryPipeline.js";
import IndexDatatype from "../Core/IndexDatatype.js";
import Intersect from "../Core/Intersect.js";
import CesiumMath from "../Core/Math.js";
import Matrix4 from "../Core/Matrix4.js";
import NearFarScalar from "../Core/NearFarScalar.js";
import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
import OrthographicFrustum from "../Core/OrthographicFrustum.js";
import PrimitiveType from "../Core/PrimitiveType.js";
import Rectangle from "../Core/Rectangle.js";
import SphereOutlineGeometry from "../Core/SphereOutlineGeometry.js";
import TerrainQuantization from "../Core/TerrainQuantization.js";
import Visibility from "../Core/Visibility.js";
import WebMercatorProjection from "../Core/WebMercatorProjection.js";
import Buffer from "../Renderer/Buffer.js";
import BufferUsage from "../Renderer/BufferUsage.js";
import ContextLimits from "../Renderer/ContextLimits.js";
import DrawCommand from "../Renderer/DrawCommand.js";
import Pass from "../Renderer/Pass.js";
import RenderState from "../Renderer/RenderState.js";
import VertexArray from "../Renderer/VertexArray.js";
import BlendingState from "./BlendingState.js";
import ClippingPlaneCollection from "./ClippingPlaneCollection.js";
import MultiClippingPlaneCollection from "./MultiClippingPlaneCollection.js";
import DepthFunction from "./DepthFunction.js";
import GlobeSurfaceTile from "./GlobeSurfaceTile.js";
import ImageryLayer from "./ImageryLayer.js";
import ImageryState from "./ImageryState.js";
import PerInstanceColorAppearance from "./PerInstanceColorAppearance.js";
import Primitive from "./Primitive.js";
import QuadtreeTileLoadState from "./QuadtreeTileLoadState.js";
import SceneMode from "./SceneMode.js";
import ShadowMode from "./ShadowMode.js";
import TerrainFillMesh from "./TerrainFillMesh.js";
import TerrainState from "./TerrainState.js";
import TileBoundingRegion from "./TileBoundingRegion.js";
import TileSelectionResult from "./TileSelectionResult.js";
import Texture from "../Renderer/Texture.js";
import PixelDatatype from "../Renderer/PixelDatatype.js";
import PixelFormat from "../Core/PixelFormat.js";
import Sampler from "../Renderer/Sampler.js";
/**
* Provides quadtree tiles representing the surface of the globe. This type is intended to be used
* with {@link QuadtreePrimitive}.
*
* @alias GlobeSurfaceTileProvider
* @constructor
*
* @param {TerrainProvider} options.terrainProvider The terrain provider that describes the surface geometry.
* @param {ImageryLayerCollection} option.imageryLayers The collection of imagery layers describing the shading of the surface.
* @param {GlobeSurfaceShaderSet} options.surfaceShaderSet The set of shaders used to render the surface.
*
* @private
*/
function GlobeSurfaceTileProvider(options) {
//>>includeStart('debug', pragmas.debug);
if (!defined(options)) {
throw new DeveloperError("options is required.");
}
if (!defined(options.terrainProvider)) {
throw new DeveloperError("options.terrainProvider is required.");
} else if (!defined(options.imageryLayers)) {
throw new DeveloperError("options.imageryLayers is required.");
} else if (!defined(options.surfaceShaderSet)) {
throw new DeveloperError("options.surfaceShaderSet is required.");
}
//>>includeEnd('debug');
this.lightingFadeOutDistance = 6500000.0;
this.lightingFadeInDistance = 9000000.0;
this.hasWaterMask = false;
this.oceanNormalMap = undefined;
this.zoomedOutOceanSpecularIntensity = 0.5;
this.enableLighting = false;
this.dynamicAtmosphereLighting = false;
this.dynamicAtmosphereLightingFromSun = false;
this.showGroundAtmosphere = false;
this.shadows = ShadowMode.RECEIVE_ONLY;
/**
* The color to use to highlight terrain fill tiles. If undefined, fill tiles are not
* highlighted at all. The alpha value is used to alpha blend with the tile's
* actual color. Because terrain fill tiles do not represent the actual terrain surface,
* it may be useful in some applications to indicate visually that they are not to be trusted.
* @type {Color}
* @default undefined
*/
this.fillHighlightColor = undefined;
this.hueShift = 0.0;
this.saturationShift = 0.0;
this.brightnessShift = 0.0;
this.showSkirts = true;
this.backFaceCulling = true;
this.undergroundColor = undefined;
this.undergroundColorAlphaByDistance = undefined;
this.materialUniformMap = undefined;
this._materialUniformMap = undefined;
this._quadtree = undefined;
this._terrainProvider = options.terrainProvider;
this._imageryLayers = options.imageryLayers;
this._surfaceShaderSet = options.surfaceShaderSet;
this._renderState = undefined;
this._blendRenderState = undefined;
this._disableCullingRenderState = undefined;
this._disableCullingBlendRenderState = undefined;
this._errorEvent = new Event();
this._imageryLayers.layerAdded.addEventListener(
GlobeSurfaceTileProvider.prototype._onLayerAdded,
this
);
this._imageryLayers.layerRemoved.addEventListener(
GlobeSurfaceTileProvider.prototype._onLayerRemoved,
this
);
this._imageryLayers.layerMoved.addEventListener(
GlobeSurfaceTileProvider.prototype._onLayerMoved,
this
);
this._imageryLayers.layerShownOrHidden.addEventListener(
GlobeSurfaceTileProvider.prototype._onLayerShownOrHidden,
this
);
this._imageryLayersUpdatedEvent = new Event();
this._layerOrderChanged = false;
this._tilesToRenderByTextureCount = [];
this._drawCommands = [];
this._uniformMaps = [];
this._usedDrawCommands = 0;
this._vertexArraysToDestroy = [];
this._debug = {
wireframe: false,
boundingSphereTile: undefined,
};
this._baseColor = undefined;
this._firstPassInitialColor = undefined;
this.baseColor = new Color(0.0, 0.0, 0.5, 1.0);
/**
* A property specifying a {@link ClippingPlaneCollection} used to selectively disable rendering on the outside of each plane.
* @type {ClippingPlaneCollection}
* @private
*/
this._clippingPlanes = undefined;
/**
* A property specifying a {@link MultiClippingPlaneCollection} array used to selectively disable rendering on the outside of each plane.
* @type {ClippingPlaneCollection}
* @private
*/
this._multiClippingPlanes = undefined;
/**
* A property specifying a {@link Rectangle} used to selectively limit terrain and imagery rendering.
* @type {Rectangle}
*/
this.cartographicLimitRectangle = Rectangle.clone(Rectangle.MAX_VALUE);
this._hasLoadedTilesThisFrame = false;
this._hasFillTilesThisFrame = false;
}
Object.defineProperties(GlobeSurfaceTileProvider.prototype, {
/**
* Gets or sets the color of the globe when no imagery is available.
* @memberof GlobeSurfaceTileProvider.prototype
* @type {Color}
*/
baseColor: {
get: function () {
return this._baseColor;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
if (!defin