{
"version": 3,
"sources": ["../../node_modules/mersenne-twister/src/mersenne-twister.js", "../../node_modules/urijs/src/punycode.js", "../../node_modules/urijs/src/IPv6.js", "../../node_modules/urijs/src/SecondLevelDomains.js", "../../node_modules/urijs/src/URI.js", "../../node_modules/dompurify/src/utils.js", "../../node_modules/dompurify/src/tags.js", "../../node_modules/dompurify/src/attrs.js", "../../node_modules/dompurify/src/regexp.js", "../../node_modules/dompurify/src/purify.js", "../../node_modules/bitmap-sdf/index.js", "../../node_modules/grapheme-splitter/index.js", "../../node_modules/earcut/src/earcut.js", "../../node_modules/rbush/rbush.min.js", "../../node_modules/protobufjs/dist/minimal/lib/prelude.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/aspromise/index.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/base64/index.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/eventemitter/index.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/float/index.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/inquire/index.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/pool/index.js", "../../node_modules/protobufjs/dist/node_modules/@protobufjs/utf8/index.js", "../../node_modules/protobufjs/dist/src/index-minimal", "../../node_modules/protobufjs/dist/src/reader.js", "../../node_modules/protobufjs/dist/src/reader_buffer.js", "../../node_modules/protobufjs/dist/src/roots.js", "../../node_modules/protobufjs/dist/src/rpc.js", "../../node_modules/protobufjs/dist/src/rpc/service.js", "../../node_modules/protobufjs/dist/src/util/longbits.js", "../../node_modules/protobufjs/dist/src/util/minimal.js", "../../node_modules/protobufjs/dist/src/writer.js", "../../node_modules/protobufjs/dist/src/writer_buffer.js", "../../node_modules/lerc/LercDecode.js", "../../node_modules/nosleep.js/src/media.js", "../../node_modules/nosleep.js/src/index.js", "../../Source/Cesium.js", "../../node_modules/@cesium/engine/Source/Core/defined.js", "../../node_modules/@cesium/engine/Source/Core/DeveloperError.js", "../../node_modules/@cesium/engine/Source/Core/Check.js", "../../node_modules/@cesium/engine/Source/Core/defaultValue.js", "../../node_modules/@cesium/engine/Source/Core/Math.js", "../../node_modules/@cesium/engine/Source/Core/Cartesian3.js", "../../node_modules/@cesium/engine/Source/Core/Cartesian4.js", "../../node_modules/@cesium/engine/Source/Core/Matrix3.js", "../../node_modules/@cesium/engine/Source/Core/RuntimeError.js", "../../node_modules/@cesium/engine/Source/Core/Matrix4.js", "../../node_modules/@cesium/engine/Source/Core/WebGLConstants.js", "../../node_modules/@cesium/engine/Source/Renderer/AutomaticUniforms.js", "../../node_modules/@cesium/engine/Source/Core/createGuid.js", "../../node_modules/@cesium/engine/Source/Core/destroyObject.js", "../../node_modules/@cesium/engine/Source/Core/IndexDatatype.js", "../../node_modules/@cesium/engine/Source/Renderer/BufferUsage.js", "../../node_modules/@cesium/engine/Source/Renderer/Buffer.js", "../../node_modules/@cesium/engine/Source/Core/Fullscreen.js", "../../node_modules/@cesium/engine/Source/Core/FeatureDetection.js", "../../node_modules/@cesium/engine/Source/Core/Color.js", "../../node_modules/@cesium/engine/Source/Renderer/ClearCommand.js", "../../node_modules/@cesium/engine/Source/Renderer/Pass.js", "../../node_modules/@cesium/engine/Source/Renderer/ComputeCommand.js", "../../node_modules/@cesium/engine/Source/Core/Cartesian2.js", "../../node_modules/@cesium/engine/Source/Core/scaleToGeodeticSurface.js", "../../node_modules/@cesium/engine/Source/Core/Cartographic.js", "../../node_modules/@cesium/engine/Source/Core/Ellipsoid.js", "../../node_modules/@cesium/engine/Source/Core/GeographicProjection.js", "../../node_modules/@cesium/engine/Source/Core/Intersect.js", "../../node_modules/@cesium/engine/Source/Core/Rectangle.js", "../../node_modules/@cesium/engine/Source/Core/BoundingRectangle.js", "../../node_modules/@cesium/engine/Source/Core/PrimitiveType.js", "../../node_modules/@cesium/engine/Source/Shaders/ViewportQuadVS.js", "../../node_modules/@cesium/engine/Source/Renderer/DrawCommand.js", "../../node_modules/@cesium/engine/Source/Renderer/PixelDatatype.js", "../../node_modules/@cesium/engine/Source/Core/PixelFormat.js", "../../node_modules/@cesium/engine/Source/Renderer/ContextLimits.js", "../../node_modules/@cesium/engine/Source/Renderer/Framebuffer.js", "../../node_modules/@cesium/engine/Source/Core/WindingOrder.js", "../../node_modules/@cesium/engine/Source/Renderer/freezeRenderState.js", "../../node_modules/@cesium/engine/Source/Renderer/RenderState.js", "../../node_modules/@cesium/engine/Source/Core/Matrix2.js", "../../node_modules/@cesium/engine/Source/Renderer/createUniform.js", "../../node_modules/@cesium/engine/Source/Renderer/createUniformArray.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderProgram.js", "../../node_modules/@cesium/engine/Source/Renderer/ComputeEngine.js", "../../node_modules/@cesium/engine/Source/Core/ComponentDatatype.js", "../../node_modules/@cesium/engine/Source/Core/oneTimeWarning.js", "../../node_modules/@cesium/engine/Source/Core/deprecationWarning.js", "../../node_modules/@cesium/engine/Source/Core/GeometryType.js", "../../node_modules/@cesium/engine/Source/Core/Quaternion.js", "../../node_modules/@cesium/engine/Source/Core/binarySearch.js", "../../node_modules/@cesium/engine/Source/Core/EarthOrientationParametersSample.js", "../../node_modules/@cesium/engine/Source/Core/GregorianDate.js", "../../node_modules/@cesium/engine/Source/Core/isLeapYear.js", "../../node_modules/@cesium/engine/Source/Core/LeapSecond.js", "../../node_modules/@cesium/engine/Source/Core/TimeConstants.js", "../../node_modules/@cesium/engine/Source/Core/TimeStandard.js", "../../node_modules/@cesium/engine/Source/Core/JulianDate.js", "../../node_modules/@cesium/engine/Source/Core/Resource.js", "../../node_modules/@cesium/engine/Source/Core/appendForwardSlash.js", "../../node_modules/@cesium/engine/Source/Core/clone.js", "../../node_modules/@cesium/engine/Source/Core/combine.js", "../../node_modules/@cesium/engine/Source/Core/defer.js", "../../node_modules/@cesium/engine/Source/Core/getAbsoluteUri.js", "../../node_modules/@cesium/engine/Source/Core/getBaseUri.js", "../../node_modules/@cesium/engine/Source/Core/getExtensionFromUri.js", "../../node_modules/@cesium/engine/Source/Core/getImagePixels.js", "../../node_modules/@cesium/engine/Source/Core/isBlobUri.js", "../../node_modules/@cesium/engine/Source/Core/isCrossOriginUrl.js", "../../node_modules/@cesium/engine/Source/Core/isDataUri.js", "../../node_modules/@cesium/engine/Source/Core/loadAndExecuteScript.js", "../../node_modules/@cesium/engine/Source/Core/objectToQuery.js", "../../node_modules/@cesium/engine/Source/Core/queryToObject.js", "../../node_modules/@cesium/engine/Source/Core/RequestState.js", "../../node_modules/@cesium/engine/Source/Core/RequestType.js", "../../node_modules/@cesium/engine/Source/Core/Request.js", "../../node_modules/@cesium/engine/Source/Core/parseResponseHeaders.js", "../../node_modules/@cesium/engine/Source/Core/RequestErrorEvent.js", "../../node_modules/@cesium/engine/Source/Core/RequestScheduler.js", "../../node_modules/@cesium/engine/Source/Core/Event.js", "../../node_modules/@cesium/engine/Source/Core/Heap.js", "../../node_modules/@cesium/engine/Source/Core/TrustedServers.js", "../../node_modules/@cesium/engine/Source/Core/EarthOrientationParameters.js", "../../node_modules/@cesium/engine/Source/Core/HeadingPitchRoll.js", "../../node_modules/@cesium/engine/Source/Core/buildModuleUrl.js", "../../node_modules/@cesium/engine/Source/Core/Iau2006XysSample.js", "../../node_modules/@cesium/engine/Source/Core/Iau2006XysData.js", "../../node_modules/@cesium/engine/Source/Core/Transforms.js", "../../node_modules/@cesium/engine/Source/Core/Geometry.js", "../../node_modules/@cesium/engine/Source/Core/GeometryAttribute.js", "../../node_modules/@cesium/engine/Source/Core/CompressedTextureBuffer.js", "../../node_modules/@cesium/engine/Source/Core/TaskProcessor.js", "../../node_modules/@cesium/engine/Source/Core/KTX2Transcoder.js", "../../node_modules/@cesium/engine/Source/Core/loadKTX2.js", "../../node_modules/@cesium/engine/Source/Renderer/CubeMapFace.js", "../../node_modules/@cesium/engine/Source/Renderer/MipmapHint.js", "../../node_modules/@cesium/engine/Source/Renderer/TextureMagnificationFilter.js", "../../node_modules/@cesium/engine/Source/Renderer/TextureMinificationFilter.js", "../../node_modules/@cesium/engine/Source/Renderer/TextureWrap.js", "../../node_modules/@cesium/engine/Source/Renderer/Sampler.js", "../../node_modules/@cesium/engine/Source/Renderer/CubeMap.js", "../../node_modules/@cesium/engine/Source/Renderer/PassState.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/degreesPerRadian.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/depthRange.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon1.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon2.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon3.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon4.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon5.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon6.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/epsilon7.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/infinity.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/oneOverPi.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/oneOverTwoPi.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passCesium3DTile.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passClassification.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passCompute.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passEnvironment.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passGlobe.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passOpaque.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passOverlay.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passTerrainClassification.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passTranslucent.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/passVoxels.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/pi.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/piOverFour.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/piOverSix.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/piOverThree.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/piOverTwo.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/radiansPerDegree.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/sceneMode2D.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/sceneMode3D.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/sceneModeColumbusView.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/sceneModeMorphing.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/solarRadius.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/threePiOver2.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/twoPi.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Constants/webMercatorMaxLatitude.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/depthRangeStruct.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/material.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/materialInput.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/modelMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/modelVertexOutput.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/pbrParameters.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/ray.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/raySegment.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Structs/shadowParameters.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/HSBToRGB.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/HSLToRGB.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/RGBToHSB.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/RGBToHSL.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/RGBToXYZ.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/XYZToRGB.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/acesTonemapping.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/alphaWeight.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/antialias.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/approximateSphericalCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/backFacing.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/branchFreeTernary.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/cascadeColor.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/cascadeDistance.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/cascadeMatrix.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/cascadeWeights.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/columbusViewMorph.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/computePosition.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/cosineAndSine.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/decompressTextureCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/depthClamp.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/eastNorthUpToEyeCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/equalsEpsilon.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/eyeOffset.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/eyeToWindowCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/fastApproximateAtan.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/fog.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/gammaCorrect.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/geodeticSurfaceNormal.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/getDefaultMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/getLambertDiffuse.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/getSpecular.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/getWaterNoise.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/hue.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/inverseGamma.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/isEmpty.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/isFull.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/lineDistance.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/linearToSrgb.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/luminance.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/metersPerPixel.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/multiplyWithColorBalance.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/nearFarScalar.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/octDecode.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/packDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/pbrLighting.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/phong.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/planeDistance.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/pointAlongRay.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/raySphereIntersectionInterval.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/readDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/readNonPerspective.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/reverseLogDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/round.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/sampleOctahedralProjection.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/saturation.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/shadowDepthCompare.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/shadowVisibility.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/signNotZero.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/sphericalHarmonics.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/srgbToLinear.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/tangentToEyeSpaceMatrix.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/textureCube.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/transformPlane.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/translateRelativeToEye.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/translucentPhong.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/transpose.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/unpackDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/unpackFloat.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/unpackUint.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/valueTransform.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/vertexLogDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/writeDepthClamp.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/writeLogDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/Functions/writeNonPerspective.js", "../../node_modules/@cesium/engine/Source/Shaders/Builtin/CzmBuiltins.js", "../../node_modules/@cesium/engine/Source/Renderer/demodernizeShader.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderSource.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderCache.js", "../../node_modules/@cesium/engine/Source/Renderer/Texture.js", "../../node_modules/@cesium/engine/Source/Renderer/TextureCache.js", "../../node_modules/@cesium/engine/Source/Core/EncodedCartesian3.js", "../../node_modules/@cesium/engine/Source/Core/Plane.js", "../../node_modules/@cesium/engine/Source/Core/CullingVolume.js", "../../node_modules/@cesium/engine/Source/Core/OrthographicOffCenterFrustum.js", "../../node_modules/@cesium/engine/Source/Core/OrthographicFrustum.js", "../../node_modules/@cesium/engine/Source/Core/Simon1994PlanetaryPositions.js", "../../node_modules/@cesium/engine/Source/Scene/SceneMode.js", "../../node_modules/@cesium/engine/Source/Scene/SunLight.js", "../../node_modules/@cesium/engine/Source/Renderer/UniformState.js", "../../node_modules/@cesium/engine/Source/Renderer/VertexArray.js", "../../node_modules/@cesium/engine/Source/Renderer/Context.js", "../../node_modules/@cesium/engine/Source/Renderer/MultisampleFramebuffer.js", "../../node_modules/@cesium/engine/Source/Renderer/RenderbufferFormat.js", "../../node_modules/@cesium/engine/Source/Renderer/Renderbuffer.js", "../../node_modules/@cesium/engine/Source/Renderer/FramebufferManager.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderDestination.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderStruct.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderFunction.js", "../../node_modules/@cesium/engine/Source/Renderer/ShaderBuilder.js", "../../node_modules/@cesium/engine/Source/Renderer/VertexArrayFacade.js", "../../node_modules/@cesium/engine/Source/Renderer/loadCubeMap.js", "../../node_modules/@cesium/engine/Source/DataSources/ConstantProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/createPropertyDescriptor.js", "../../node_modules/@cesium/engine/Source/DataSources/BillboardGraphics.js", "../../node_modules/@cesium/engine/Source/Core/AssociativeArray.js", "../../node_modules/@cesium/engine/Source/Core/DistanceDisplayCondition.js", "../../node_modules/@cesium/engine/Source/Core/NearFarScalar.js", "../../node_modules/@cesium/engine/Source/Scene/HeightReference.js", "../../node_modules/@cesium/engine/Source/Scene/HorizontalOrigin.js", "../../node_modules/@cesium/engine/Source/Scene/VerticalOrigin.js", "../../node_modules/@cesium/engine/Source/DataSources/BoundingSphereState.js", "../../node_modules/@cesium/engine/Source/DataSources/Property.js", "../../node_modules/@cesium/engine/Source/DataSources/BillboardVisualizer.js", "../../node_modules/@cesium/engine/Source/Core/Interval.js", "../../node_modules/@cesium/engine/Source/Core/BoundingSphere.js", "../../node_modules/@cesium/engine/Source/Core/GeometryAttributes.js", "../../node_modules/@cesium/engine/Source/Core/GeometryOffsetAttribute.js", "../../node_modules/@cesium/engine/Source/Core/VertexFormat.js", "../../node_modules/@cesium/engine/Source/Core/BoxGeometry.js", "../../node_modules/@cesium/engine/Source/Core/BoxOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Core/ColorGeometryInstanceAttribute.js", "../../node_modules/@cesium/engine/Source/Core/DistanceDisplayConditionGeometryInstanceAttribute.js", "../../node_modules/@cesium/engine/Source/Core/GeometryInstance.js", "../../node_modules/@cesium/engine/Source/Core/TimeInterval.js", "../../node_modules/@cesium/engine/Source/Core/Iso8601.js", "../../node_modules/@cesium/engine/Source/Core/OffsetGeometryInstanceAttribute.js", "../../node_modules/@cesium/engine/Source/Core/ShowGeometryInstanceAttribute.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/AllMaterialAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/AllMaterialAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/BasicMaterialAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/BasicMaterialAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/TexturedMaterialAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/TexturedMaterialAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Scene/BlendEquation.js", "../../node_modules/@cesium/engine/Source/Scene/BlendFunction.js", "../../node_modules/@cesium/engine/Source/Scene/BlendingState.js", "../../node_modules/@cesium/engine/Source/Scene/CullFace.js", "../../node_modules/@cesium/engine/Source/Scene/Appearance.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/AspectRampMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/BumpMapMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/CheckerboardMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/DotMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/ElevationBandMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/ElevationContourMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/ElevationRampMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/FadeMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/GridMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/NormalMapMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/PolylineArrowMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/PolylineDashMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/PolylineGlowMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/PolylineOutlineMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/RimLightingMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/SlopeRampMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/StripeMaterial.js", "../../node_modules/@cesium/engine/Source/Shaders/Materials/Water.js", "../../node_modules/@cesium/engine/Source/Scene/Material.js", "../../node_modules/@cesium/engine/Source/Scene/MaterialAppearance.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/PerInstanceColorAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/PerInstanceColorAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/PerInstanceFlatColorAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/PerInstanceFlatColorAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Scene/PerInstanceColorAppearance.js", "../../node_modules/@cesium/engine/Source/DataSources/ColorMaterialProperty.js", "../../node_modules/@cesium/engine/Source/Core/GeographicTilingScheme.js", "../../node_modules/@cesium/engine/Source/Core/ApproximateTerrainHeights.js", "../../node_modules/@cesium/engine/Source/Core/AxisAlignedBoundingBox.js", "../../node_modules/@cesium/engine/Source/Core/QuadraticRealPolynomial.js", "../../node_modules/@cesium/engine/Source/Core/CubicRealPolynomial.js", "../../node_modules/@cesium/engine/Source/Core/QuarticRealPolynomial.js", "../../node_modules/@cesium/engine/Source/Core/Ray.js", "../../node_modules/@cesium/engine/Source/Core/IntersectionTests.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidTangentPlane.js", "../../node_modules/@cesium/engine/Source/Core/OrientedBoundingBox.js", "../../node_modules/@cesium/engine/Source/Core/TerrainExaggeration.js", "../../node_modules/@cesium/engine/Source/Shaders/ShadowVolumeAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Shaders/ShadowVolumeFS.js", "../../node_modules/@cesium/engine/Source/Scene/ClassificationType.js", "../../node_modules/@cesium/engine/Source/Scene/DepthFunction.js", "../../node_modules/@cesium/engine/Source/Core/subdivideArray.js", "../../node_modules/@cesium/engine/Source/Scene/BatchTable.js", "../../node_modules/@cesium/engine/Source/Scene/AttributeType.js", "../../node_modules/@cesium/engine/Source/Core/AttributeCompression.js", "../../node_modules/@cesium/engine/Source/Core/barycentricCoordinates.js", "../../node_modules/@cesium/engine/Source/Core/Tipsify.js", "../../node_modules/@cesium/engine/Source/Core/GeometryPipeline.js", "../../node_modules/@cesium/engine/Source/Core/WebMercatorProjection.js", "../../node_modules/@cesium/engine/Source/Scene/PrimitivePipeline.js", "../../node_modules/@cesium/engine/Source/Scene/PrimitiveState.js", "../../node_modules/@cesium/engine/Source/Scene/ShadowMode.js", "../../node_modules/@cesium/engine/Source/Scene/Primitive.js", "../../node_modules/@cesium/engine/Source/Core/GeometryInstanceAttribute.js", "../../node_modules/@cesium/engine/Source/Shaders/ShadowVolumeAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Scene/ShadowVolumeAppearance.js", "../../node_modules/@cesium/engine/Source/Scene/StencilFunction.js", "../../node_modules/@cesium/engine/Source/Scene/StencilOperation.js", "../../node_modules/@cesium/engine/Source/Scene/StencilConstants.js", "../../node_modules/@cesium/engine/Source/Scene/ClassificationPrimitive.js", "../../node_modules/@cesium/engine/Source/Scene/GroundPrimitive.js", "../../node_modules/@cesium/engine/Source/DataSources/MaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/DynamicGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/ArcType.js", "../../node_modules/@cesium/engine/Source/Core/arrayRemoveDuplicates.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidGeodesic.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidRhumbLine.js", "../../node_modules/@cesium/engine/Source/Core/GroundPolylineGeometry.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineShadowVolumeFS.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineShadowVolumeMorphFS.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineShadowVolumeMorphVS.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineShadowVolumeVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/PolylineColorAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineCommon.js", "../../node_modules/@cesium/engine/Source/Scene/PolylineColorAppearance.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/PolylineMaterialAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineFS.js", "../../node_modules/@cesium/engine/Source/Scene/PolylineMaterialAppearance.js", "../../node_modules/@cesium/engine/Source/Scene/GroundPolylinePrimitive.js", "../../node_modules/@cesium/engine/Source/DataSources/ImageMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/createMaterialPropertyDescriptor.js", "../../node_modules/@cesium/engine/Source/DataSources/BoxGraphics.js", "../../node_modules/@cesium/engine/Source/Core/ReferenceFrame.js", "../../node_modules/@cesium/engine/Source/DataSources/PositionProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/ConstantPositionProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/CorridorGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/createRawPropertyDescriptor.js", "../../node_modules/@cesium/engine/Source/DataSources/CylinderGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/EllipseGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/EllipsoidGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/LabelGraphics.js", "../../node_modules/@cesium/engine/Source/Core/TranslationRotationScale.js", "../../node_modules/@cesium/engine/Source/DataSources/NodeTransformationProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PropertyBag.js", "../../node_modules/@cesium/engine/Source/DataSources/ModelGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/Cesium3DTilesetGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/PathGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/PlaneGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/PointGraphics.js", "../../node_modules/@cesium/engine/Source/Core/PolygonHierarchy.js", "../../node_modules/@cesium/engine/Source/DataSources/PolygonGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineVolumeGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/RectangleGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/WallGraphics.js", "../../node_modules/@cesium/engine/Source/DataSources/Entity.js", "../../node_modules/@cesium/engine/Source/DataSources/GeometryUpdater.js", "../../node_modules/@cesium/engine/Source/DataSources/CallbackProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/TerrainOffsetProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/heightReferenceOnEntityPropertyChanged.js", "../../node_modules/@cesium/engine/Source/DataSources/BoxGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/Credit.js", "../../node_modules/@cesium/engine/Source/Shaders/OctahedralProjectionAtlasFS.js", "../../node_modules/@cesium/engine/Source/Shaders/OctahedralProjectionFS.js", "../../node_modules/@cesium/engine/Source/Shaders/OctahedralProjectionVS.js", "../../node_modules/@cesium/engine/Source/Scene/OctahedralProjectedCubeMap.js", "../../node_modules/@cesium/engine/Source/Scene/ImageBasedLighting.js", "../../node_modules/@cesium/engine/Source/Core/IonResource.js", "../../node_modules/@cesium/engine/Source/Core/Ion.js", "../../node_modules/@cesium/engine/Source/Core/ManagedArray.js", "../../node_modules/@cesium/engine/Source/Scene/Axis.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DContentGroup.js", "../../node_modules/@cesium/engine/Source/Core/getStringFromTypedArray.js", "../../node_modules/@cesium/engine/Source/Core/getMagic.js", "../../node_modules/@cesium/engine/Source/Scene/Composite3DTileContent.js", "../../node_modules/@cesium/engine/Source/Core/getJsonFromTypedArray.js", "../../node_modules/@cesium/engine/Source/Scene/BatchTexture.js", "../../node_modules/@cesium/engine/Source/Scene/getBinaryAccessor.js", "../../node_modules/@cesium/engine/Source/Scene/BatchTableHierarchy.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileColorBlendMode.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileBatchTable.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTileBatch.js", "../../node_modules/@cesium/engine/Source/Shaders/VectorTileVS.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileFeature.js", "../../node_modules/jsep/dist/jsep.js", "../../node_modules/@cesium/engine/Source/Scene/ExpressionNodeType.js", "../../node_modules/@cesium/engine/Source/Scene/Expression.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTilePrimitive.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTileGeometry.js", "../../node_modules/@cesium/engine/Source/Scene/Geometry3DTileContent.js", "../../node_modules/@cesium/engine/Source/Core/HilbertOrder.js", "../../node_modules/@cesium/engine/Source/Core/S2Cell.js", "../../node_modules/@cesium/engine/Source/Scene/hasExtension.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitAvailabilityBitstream.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitMetadataView.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitSubdivisionScheme.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataEntity.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitSubtreeMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataComponentType.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataType.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataClassProperty.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataTableProperty.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataTable.js", "../../node_modules/@cesium/engine/Source/Scene/ResourceLoader.js", "../../node_modules/@cesium/engine/Source/Scene/ResourceLoaderState.js", "../../node_modules/@cesium/engine/Source/Scene/BufferLoader.js", "../../node_modules/meshoptimizer/meshopt_encoder.module.js", "../../node_modules/meshoptimizer/meshopt_decoder.module.js", "../../node_modules/meshoptimizer/meshopt_simplifier.module.js", "../../node_modules/@cesium/engine/Source/Scene/GltfBufferViewLoader.js", "../../node_modules/@cesium/engine/Source/Scene/DracoLoader.js", "../../node_modules/@cesium/engine/Source/Scene/GltfDracoLoader.js", "../../node_modules/@cesium/engine/Source/Core/loadImageFromTypedArray.js", "../../node_modules/@cesium/engine/Source/Scene/GltfImageLoader.js", "../../node_modules/@cesium/engine/Source/Scene/JobType.js", "../../node_modules/@cesium/engine/Source/Scene/GltfIndexBufferLoader.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/addToArray.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/usesExtension.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/ForEach.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/numberOfComponentsForType.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/getAccessorByteStride.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/addDefaults.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/addPipelineExtras.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/removeExtensionsRequired.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/removeExtensionsUsed.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/parseGlb.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/removePipelineExtras.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/addExtensionsUsed.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/getComponentReader.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/findAccessorMinMax.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/moveTechniqueRenderStates.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/addExtensionsRequired.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/moveTechniquesToExtension.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/forEachTextureInMaterial.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/removeUnusedElements.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/addBuffer.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/readAccessorPacked.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/updateAccessorComponentTypes.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/removeExtension.js", "../../node_modules/@cesium/engine/Source/Scene/GltfPipeline/updateVersion.js", "../../node_modules/@cesium/engine/Source/Scene/VertexAttributeSemantic.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelUtility.js", "../../node_modules/@cesium/engine/Source/Scene/GltfJsonLoader.js", "../../node_modules/@cesium/engine/Source/Scene/AlphaMode.js", "../../node_modules/@cesium/engine/Source/Scene/ModelComponents.js", "../../node_modules/@cesium/engine/Source/Scene/GltfLoaderUtil.js", "../../node_modules/@cesium/engine/Source/Core/resizeImageToNextPowerOfTwo.js", "../../node_modules/@cesium/engine/Source/Scene/GltfTextureLoader.js", "../../node_modules/@cesium/engine/Source/Scene/GltfVertexBufferLoader.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataClass.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataEnumValue.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataEnum.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataSchema.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataSchemaLoader.js", "../../node_modules/@cesium/engine/Source/Scene/ResourceCacheKey.js", "../../node_modules/@cesium/engine/Source/Scene/ResourceCacheStatistics.js", "../../node_modules/@cesium/engine/Source/Scene/ResourceCache.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitSubtree.js", "../../node_modules/@cesium/engine/Source/Scene/MetadataSemantic.js", "../../node_modules/@cesium/engine/Source/Scene/BoundingVolumeSemantics.js", "../../node_modules/@cesium/engine/Source/Scene/Implicit3DTileContent.js", "../../node_modules/@cesium/engine/Source/Scene/ModelAnimationLoop.js", "../../node_modules/@cesium/engine/Source/Scene/ClippingPlane.js", "../../node_modules/@cesium/engine/Source/Scene/ClippingPlaneCollection.js", "../../node_modules/@cesium/engine/Source/Scene/ColorBlendMode.js", "../../node_modules/@cesium/engine/Source/Core/ArticulationStageType.js", "../../node_modules/@cesium/engine/Source/Core/InterpolationType.js", "../../node_modules/@cesium/engine/Source/Scene/JsonMetadataTable.js", "../../node_modules/@cesium/engine/Source/Scene/PropertyTable.js", "../../node_modules/@cesium/engine/Source/Scene/PropertyTextureProperty.js", "../../node_modules/@cesium/engine/Source/Scene/PropertyTexture.js", "../../node_modules/@cesium/engine/Source/Scene/PropertyAttributeProperty.js", "../../node_modules/@cesium/engine/Source/Scene/PropertyAttribute.js", "../../node_modules/@cesium/engine/Source/Scene/StructuralMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/parseStructuralMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/parseFeatureMetadataLegacy.js", "../../node_modules/@cesium/engine/Source/Scene/GltfStructuralMetadataLoader.js", "../../node_modules/@cesium/engine/Source/Scene/InstanceAttributeSemantic.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PrimitiveOutlineGenerator.js", "../../node_modules/@cesium/engine/Source/Scene/PrimitiveLoadPlan.js", "../../node_modules/@cesium/engine/Source/Scene/SupportedImageFormats.js", "../../node_modules/@cesium/engine/Source/Scene/GltfLoader.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/PointCloudEyeDomeLighting.js", "../../node_modules/@cesium/engine/Source/Scene/PointCloudEyeDomeLighting.js", "../../node_modules/@cesium/engine/Source/Scene/PointCloudShading.js", "../../node_modules/@cesium/engine/Source/Scene/SceneTransforms.js", "../../node_modules/@cesium/engine/Source/Scene/SplitDirection.js", "../../node_modules/@cesium/engine/Source/Scene/B3dmParser.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileFeatureTable.js", "../../node_modules/@cesium/engine/Source/Scene/parseBatchTable.js", "../../node_modules/@cesium/engine/Source/Scene/Model/B3dmLoader.js", "../../node_modules/@cesium/engine/Source/Scene/Model/GeoJsonLoader.js", "../../node_modules/@cesium/engine/Source/Scene/I3dmParser.js", "../../node_modules/@cesium/engine/Source/Scene/Model/I3dmLoader.js", "../../node_modules/@cesium/engine/Source/Scene/ModelAnimationState.js", "../../node_modules/@cesium/engine/Source/Core/Spline.js", "../../node_modules/@cesium/engine/Source/Core/ConstantSpline.js", "../../node_modules/@cesium/engine/Source/Core/LinearSpline.js", "../../node_modules/@cesium/engine/Source/Core/TridiagonalSystemSolver.js", "../../node_modules/@cesium/engine/Source/Core/HermiteSpline.js", "../../node_modules/@cesium/engine/Source/Core/SteppedSpline.js", "../../node_modules/@cesium/engine/Source/Core/QuaternionSpline.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelAnimationChannel.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelAnimation.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelAnimationCollection.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelFeature.js", "../../node_modules/@cesium/engine/Source/Scene/Model/StyleCommandsNeeded.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelType.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelFeatureTable.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ClassificationModelDrawCommand.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelDrawCommand.js", "../../node_modules/@cesium/engine/Source/Scene/Model/buildDrawCommand.js", "../../node_modules/@cesium/engine/Source/Scene/Model/TilesetPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ImageBasedLightingStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ImageBasedLightingPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelArticulationStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelArticulation.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelColorStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelColorPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelClippingPlanesStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelClippingPlanesPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelNode.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/InstancingStageCommon.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/InstancingStageVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/LegacyInstancingStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/InstancingPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelMatrixUpdateStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/NodeStatisticsPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelRuntimeNode.js", "../../node_modules/@cesium/engine/Source/Scene/Model/AlphaPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/BatchTexturePipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ClassificationPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/CPUStylingStageVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/CPUStylingStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/CPUStylingPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/CustomShaderMode.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/CustomShaderStageVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/CustomShaderStageFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/FeatureIdStageFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/FeatureIdStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/FeatureIdPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/MetadataStageFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/MetadataStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/MetadataPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/CustomShaderTranslucencyMode.js", "../../node_modules/@cesium/engine/Source/Scene/Model/CustomShaderPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/DequantizationPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/GeometryStageFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/GeometryStageVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/SelectedFeatureIdStageCommon.js", "../../node_modules/@cesium/engine/Source/Scene/Model/SelectedFeatureIdPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/GeometryPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/LightingStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/LightingModel.js", "../../node_modules/@cesium/engine/Source/Scene/Model/LightingPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/MaterialStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/MaterialPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/MorphTargetsStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/MorphTargetsPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PickingPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileRefine.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/PointCloudStylingStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PointCloudStylingPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/PrimitiveOutlineStageVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/PrimitiveOutlineStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PrimitiveOutlinePipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PrimitiveStatisticsPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/SceneMode2DPipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/SkinningStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/SkinningPipelineStage.js", "../../node_modules/@cesium/engine/Source/Core/WireframeIndexGenerator.js", "../../node_modules/@cesium/engine/Source/Scene/Model/WireframePipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelRuntimePrimitive.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelSkin.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelAlphaOptions.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelRenderResources.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelSilhouetteStageFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelSilhouetteStageVS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelSilhouettePipelineStage.js", "../../node_modules/@cesium/engine/Source/Shaders/Model/ModelSplitterStageFS.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelSplitterPipelineStage.js", "../../node_modules/@cesium/engine/Source/Scene/Model/NodeRenderResources.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelLightingOptions.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PrimitiveRenderResources.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelSceneGraph.js", "../../node_modules/@cesium/engine/Source/Scene/Model/ModelStatistics.js", "../../node_modules/@cesium/engine/Source/Scene/Model/PntsLoader.js", "../../node_modules/@cesium/engine/Source/Scene/PntsParser.js", "../../node_modules/@cesium/engine/Source/Scene/Model/Model.js", "../../node_modules/@cesium/engine/Source/Scene/Model/Model3DTileContent.js", "../../node_modules/@cesium/engine/Source/Scene/Tileset3DTileContent.js", "../../node_modules/@cesium/engine/Source/Shaders/BillboardCollectionFS.js", "../../node_modules/@cesium/engine/Source/Shaders/BillboardCollectionVS.js", "../../node_modules/@cesium/engine/Source/Scene/Billboard.js", "../../node_modules/@cesium/engine/Source/Scene/BlendOption.js", "../../node_modules/@cesium/engine/Source/Scene/SDFSettings.js", "../../node_modules/@cesium/engine/Source/Scene/TextureAtlas.js", "../../node_modules/@cesium/engine/Source/Scene/BillboardCollection.js", "../../node_modules/@cesium/engine/Source/Scene/createBillboardPointCallback.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilePointFeature.js", "../../node_modules/@cesium/engine/Source/Core/writeTextToCanvas.js", "../../node_modules/@cesium/engine/Source/Scene/LabelCollection.js", "../../node_modules/@cesium/engine/Source/Scene/LabelStyle.js", "../../node_modules/@cesium/engine/Source/Scene/Label.js", "../../node_modules/@cesium/engine/Source/Shaders/PolylineVS.js", "../../node_modules/@cesium/engine/Source/Core/PolylinePipeline.js", "../../node_modules/@cesium/engine/Source/Scene/Polyline.js", "../../node_modules/@cesium/engine/Source/Scene/PolylineCollection.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTilePoints.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTilePolygons.js", "../../node_modules/@cesium/engine/Source/Shaders/Vector3DTilePolylinesVS.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTilePolylines.js", "../../node_modules/@cesium/engine/Source/Shaders/Vector3DTileClampedPolylinesVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Vector3DTileClampedPolylinesFS.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTileClampedPolylines.js", "../../node_modules/@cesium/engine/Source/Core/decodeVectorPolylinePositions.js", "../../node_modules/@cesium/engine/Source/Scene/Vector3DTileContent.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileContentFactory.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileContentState.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileContentType.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileOptimizationHint.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilePass.js", "../../node_modules/@cesium/engine/Source/Scene/Empty3DTileContent.js", "../../node_modules/@cesium/engine/Source/Scene/ContentMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/findContentMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/findGroupMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/TileMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/findTileMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/preprocess3DTileContent.js", "../../node_modules/@cesium/engine/Source/Scene/Multiple3DTileContent.js", "../../node_modules/@cesium/engine/Source/Core/PolygonPipeline.js", "../../node_modules/@cesium/engine/Source/Core/RectangleGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/RectangleOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Scene/TileBoundingRegion.js", "../../node_modules/@cesium/engine/Source/Core/CoplanarPolygonGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/Queue.js", "../../node_modules/@cesium/engine/Source/Core/PolygonGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/CoplanarPolygonOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Scene/TileBoundingS2Cell.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Core/SphereOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Scene/TileBoundingSphere.js", "../../node_modules/@cesium/engine/Source/Scene/TileOrientedBoundingBox.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTile.js", "../../node_modules/@cesium/engine/Source/Scene/GroupMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/TilesetMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetMetadata.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileOptimizations.js", "../../node_modules/@cesium/engine/Source/Core/DoublyLinkedList.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetCache.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetHeatmap.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetStatistics.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileStyleEngine.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitTileset.js", "../../node_modules/@cesium/engine/Source/Core/MortonOrder.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitTileCoordinates.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetTraversal.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetMostDetailedTraversal.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetBaseTraversal.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesetSkipTraversal.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileset.js", "../../node_modules/@cesium/engine/Source/DataSources/Cesium3DTilesetVisualizer.js", "../../node_modules/@cesium/engine/Source/DataSources/CheckerboardMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/EntityCollection.js", "../../node_modules/@cesium/engine/Source/DataSources/CompositeEntityCollection.js", "../../node_modules/@cesium/engine/Source/Core/EventHelper.js", "../../node_modules/@cesium/engine/Source/Core/TimeIntervalCollection.js", "../../node_modules/@cesium/engine/Source/DataSources/CompositeProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/CompositeMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/CompositePositionProperty.js", "../../node_modules/@cesium/engine/Source/Core/CornerType.js", "../../node_modules/@cesium/engine/Source/Core/PolylineVolumeGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/CorridorGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/CorridorGeometry.js", "../../node_modules/@cesium/engine/Source/Core/CorridorOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/GroundGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/DataSources/CorridorGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/DataSources/DataSource.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidalOccluder.js", "../../node_modules/@cesium/engine/Source/Scene/PointPrimitive.js", "../../node_modules/@cesium/engine/Source/Shaders/PointPrimitiveCollectionFS.js", "../../node_modules/@cesium/engine/Source/Shaders/PointPrimitiveCollectionVS.js", "../../node_modules/@cesium/engine/Source/Scene/PointPrimitiveCollection.js", "../../node_modules/kdbush/index.js", "../../node_modules/@cesium/engine/Source/DataSources/EntityCluster.js", "../../node_modules/@cesium/engine/Source/DataSources/CustomDataSource.js", "../../node_modules/@cesium/engine/Source/Core/CylinderGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/CylinderGeometry.js", "../../node_modules/@cesium/engine/Source/Core/CylinderOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/CylinderGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/ClockRange.js", "../../node_modules/@cesium/engine/Source/Core/ClockStep.js", "../../node_modules/@cesium/engine/Source/Core/ExtrapolationType.js", "../../node_modules/@cesium/engine/Source/Core/getFilenameFromUri.js", "../../node_modules/@cesium/engine/Source/Core/HermitePolynomialApproximation.js", "../../node_modules/@cesium/engine/Source/Core/LagrangePolynomialApproximation.js", "../../node_modules/@cesium/engine/Source/Core/LinearApproximation.js", "../../node_modules/@cesium/engine/Source/Core/Spherical.js", "../../node_modules/@cesium/engine/Source/DataSources/CzmlDataSource.js", "../../node_modules/@cesium/engine/Source/Core/getTimestamp.js", "../../node_modules/@cesium/engine/Source/Core/Clock.js", "../../node_modules/@cesium/engine/Source/DataSources/DataSourceClock.js", "../../node_modules/@cesium/engine/Source/DataSources/GridMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineArrowMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineDashMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineGlowMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineOutlineMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PositionPropertyArray.js", "../../node_modules/@cesium/engine/Source/DataSources/PropertyArray.js", "../../node_modules/@cesium/engine/Source/DataSources/ReferenceProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/Rotation.js", "../../node_modules/@cesium/engine/Source/DataSources/SampledProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/SampledPositionProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/StripeOrientation.js", "../../node_modules/@cesium/engine/Source/DataSources/StripeMaterialProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/TimeIntervalCollectionProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/VelocityVectorProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/VelocityOrientationProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/DataSourceCollection.js", "../../node_modules/@cesium/engine/Source/Scene/PrimitiveCollection.js", "../../node_modules/@cesium/engine/Source/Scene/OrderedGroundPrimitiveCollection.js", "../../node_modules/@cesium/engine/Source/DataSources/DynamicGeometryBatch.js", "../../node_modules/@cesium/engine/Source/Core/EllipseGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/EllipseGeometry.js", "../../node_modules/@cesium/engine/Source/Core/EllipseOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/EllipseGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/EllipsoidGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/PlaneGeometry.js", "../../node_modules/@cesium/engine/Source/Core/PlaneOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/PlaneGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/CoplanarPolygonGeometry.js", "../../node_modules/@cesium/engine/Source/Core/PolygonGeometry.js", "../../node_modules/@cesium/engine/Source/Core/PolygonOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/PolygonGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/PolylineVolumeGeometry.js", "../../node_modules/@cesium/engine/Source/Core/PolylineVolumeOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineVolumeGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/Core/RectangleGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/RectangleGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/DataSources/StaticGeometryColorBatch.js", "../../node_modules/@cesium/engine/Source/DataSources/StaticGeometryPerMaterialBatch.js", "../../node_modules/@cesium/engine/Source/Core/RectangleCollisionChecker.js", "../../node_modules/@cesium/engine/Source/DataSources/StaticGroundGeometryColorBatch.js", "../../node_modules/@cesium/engine/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js", "../../node_modules/@cesium/engine/Source/DataSources/StaticOutlineGeometryBatch.js", "../../node_modules/@cesium/engine/Source/Core/WallGeometryLibrary.js", "../../node_modules/@cesium/engine/Source/Core/WallGeometry.js", "../../node_modules/@cesium/engine/Source/Core/WallOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/WallGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/DataSources/GeometryVisualizer.js", "../../node_modules/@cesium/engine/Source/DataSources/LabelVisualizer.js", "../../node_modules/@cesium/engine/Source/Core/sampleTerrain.js", "../../node_modules/@cesium/engine/Source/Core/sampleTerrainMostDetailed.js", "../../node_modules/@cesium/engine/Source/DataSources/ModelVisualizer.js", "../../node_modules/@cesium/engine/Source/DataSources/ScaledPositionProperty.js", "../../node_modules/@cesium/engine/Source/DataSources/PathVisualizer.js", "../../node_modules/@cesium/engine/Source/DataSources/PointVisualizer.js", "../../node_modules/@cesium/engine/Source/Core/PolylineGeometry.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineGeometryUpdater.js", "../../node_modules/@cesium/engine/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js", "../../node_modules/@cesium/engine/Source/DataSources/PolylineVisualizer.js", "../../node_modules/@cesium/engine/Source/DataSources/DataSourceDisplay.js", "../../node_modules/@cesium/engine/Source/Core/HeadingPitchRange.js", "../../node_modules/@cesium/engine/Source/DataSources/EntityView.js", "../../node_modules/@cesium/engine/Source/Core/PinBuilder.js", "../../node_modules/topojson-client/src/identity.js", "../../node_modules/topojson-client/src/transform.js", "../../node_modules/topojson-client/src/reverse.js", "../../node_modules/topojson-client/src/feature.js", "../../node_modules/@cesium/engine/Source/DataSources/GeoJsonDataSource.js", "../../node_modules/autolinker/src/version.ts", "../../node_modules/autolinker/src/utils.ts", "../../node_modules/autolinker/src/regex-lib.ts", "../../node_modules/autolinker/src/html-tag.ts", "../../node_modules/autolinker/src/truncate/truncate-smart.ts", "../../node_modules/autolinker/src/truncate/truncate-middle.ts", "../../node_modules/autolinker/src/truncate/truncate-end.ts", "../../node_modules/autolinker/src/anchor-tag-builder.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/autolinker/src/match/abstract-match.ts", "../../node_modules/autolinker/src/parser/tld-regex.ts", "../../node_modules/autolinker/src/parser/uri-utils.ts", "../../node_modules/autolinker/src/match/url-match.ts", "../../node_modules/autolinker/src/parser/email-utils.ts", "../../node_modules/autolinker/src/match/email-match.ts", "../../node_modules/autolinker/src/parser/hashtag-utils.ts", "../../node_modules/autolinker/src/match/hashtag-match.ts", "../../node_modules/autolinker/src/parser/mention-utils.ts", "../../node_modules/autolinker/src/match/mention-match.ts", "../../node_modules/autolinker/src/parser/phone-number-utils.ts", "../../node_modules/autolinker/src/match/phone-match.ts", "../../node_modules/autolinker/src/parser/parse-matches.ts", "../../node_modules/autolinker/src/htmlParser/parse-html.ts", "../../node_modules/autolinker/src/autolinker.ts", "../../node_modules/autolinker/src/index.ts", "../../node_modules/@cesium/engine/Source/DataSources/GpxDataSource.js", "../../node_modules/@cesium/engine/Source/DataSources/KmlCamera.js", "../../node_modules/@cesium/engine/Source/DataSources/KmlDataSource.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/deflate.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/inflate.js", "../../node_modules/@zip.js/zip.js/lib/core/configuration.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/crc32.js", "../../node_modules/@zip.js/zip.js/lib/core/util/encode-text.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/sjcl.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/aes-crypto.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/zip-crypto.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/codec.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/codec-pool-worker.js", "../../node_modules/@zip.js/zip.js/lib/core/codecs/codec-pool.js", "../../node_modules/@zip.js/zip.js/lib/core/engine.js", "../../node_modules/@zip.js/zip.js/lib/core/io.js", "../../node_modules/@zip.js/zip.js/lib/core/constants.js", "../../node_modules/@zip.js/zip.js/lib/core/util/cp437-decode.js", "../../node_modules/@zip.js/zip.js/lib/core/util/decode-text.js", "../../node_modules/@zip.js/zip.js/lib/core/zip-entry.js", "../../node_modules/@zip.js/zip.js/lib/core/zip-reader.js", "../../node_modules/@zip.js/zip.js/lib/core/zip-writer.js", "../../node_modules/@zip.js/zip.js/lib/zip-no-worker.js", "../../node_modules/@cesium/engine/Source/DataSources/getElement.js", "../../node_modules/@cesium/engine/Source/DataSources/KmlLookAt.js", "../../node_modules/@cesium/engine/Source/DataSources/KmlTour.js", "../../node_modules/@tweenjs/tween.js/dist/tween.esm.js", "../../node_modules/@cesium/engine/Source/Core/EasingFunction.js", "../../node_modules/@cesium/engine/Source/DataSources/KmlTourFlyTo.js", "../../node_modules/@cesium/engine/Source/DataSources/KmlTourWait.js", "../../node_modules/@cesium/engine/Source/DataSources/Visualizer.js", "../../node_modules/@cesium/engine/Source/DataSources/exportKml.js", "../../node_modules/@cesium/engine/Source/Core/HeightmapEncoding.js", "../../node_modules/@cesium/engine/Source/Core/TerrainQuantization.js", "../../node_modules/@cesium/engine/Source/Core/TerrainEncoding.js", "../../node_modules/@cesium/engine/Source/Core/HeightmapTessellator.js", "../../node_modules/@cesium/engine/Source/Core/TerrainData.js", "../../node_modules/@cesium/engine/Source/Core/TerrainMesh.js", "../../node_modules/@cesium/engine/Source/Core/TerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/HeightmapTerrainData.js", "../../node_modules/@cesium/engine/Source/Core/TileAvailability.js", "../../node_modules/@cesium/engine/Source/Core/formatError.js", "../../node_modules/@cesium/engine/Source/Core/TileProviderError.js", "../../node_modules/@cesium/engine/Source/Core/WebMercatorTilingScheme.js", "../../node_modules/@cesium/engine/Source/Core/ArcGISTiledElevationTerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/BingMapsGeocoderService.js", "../../node_modules/@cesium/engine/Source/Core/CartographicGeocoderService.js", "../../node_modules/@cesium/engine/Source/Core/CatmullRomSpline.js", "../../node_modules/@cesium/engine/Source/Core/Intersections2D.js", "../../node_modules/@cesium/engine/Source/Core/QuantizedMeshTerrainData.js", "../../node_modules/@cesium/engine/Source/Core/CesiumTerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/CircleGeometry.js", "../../node_modules/@cesium/engine/Source/Core/CircleOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Core/CustomHeightmapTerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/DefaultProxy.js", "../../node_modules/@cesium/engine/Source/Core/DoubleEndedPriorityQueue.js", "../../node_modules/@cesium/engine/Source/Core/EllipsoidTerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/PerspectiveOffCenterFrustum.js", "../../node_modules/@cesium/engine/Source/Core/PerspectiveFrustum.js", "../../node_modules/@cesium/engine/Source/Core/FrustumGeometry.js", "../../node_modules/@cesium/engine/Source/Core/FrustumOutlineGeometry.js", "../../node_modules/@cesium/engine/Source/Core/GeocodeType.js", "../../node_modules/@cesium/engine/Source/Core/GeocoderService.js", "../../node_modules/@cesium/engine/Source/Core/GeometryFactory.js", "../../node_modules/@cesium/engine/Source/Core/GoogleEarthEnterpriseMetadata.js", "../../node_modules/@cesium/engine/Source/Core/isBitSet.js", "../../node_modules/@cesium/engine/Source/Core/GoogleEarthEnterpriseTileInformation.js", "../../node_modules/@cesium/engine/Source/Core/GoogleEarthEnterpriseTerrainData.js", "../../node_modules/@cesium/engine/Source/Core/GoogleEarthEnterpriseTerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/GoogleMaps.js", "../../node_modules/@cesium/engine/Source/Core/IauOrientationParameters.js", "../../node_modules/@cesium/engine/Source/Core/Iau2000Orientation.js", "../../node_modules/@cesium/engine/Source/Core/IauOrientationAxes.js", "../../node_modules/@cesium/engine/Source/Core/InterpolationAlgorithm.js", "../../node_modules/@cesium/engine/Source/Core/PeliasGeocoderService.js", "../../node_modules/@cesium/engine/Source/Core/IonGeocoderService.js", "../../node_modules/@cesium/engine/Source/Core/KeyboardEventModifier.js", "../../node_modules/@cesium/engine/Source/Core/MapProjection.js", "../../node_modules/@cesium/engine/Source/Core/MorphWeightSpline.js", "../../node_modules/@cesium/engine/Source/Core/Visibility.js", "../../node_modules/@cesium/engine/Source/Core/Occluder.js", "../../node_modules/@cesium/engine/Source/Core/OpenCageGeocoderService.js", "../../node_modules/@cesium/engine/Source/Core/Packable.js", "../../node_modules/@cesium/engine/Source/Core/PackableForInterpolation.js", "../../node_modules/@cesium/engine/Source/Core/Proxy.js", "../../node_modules/@cesium/engine/Source/Core/ScreenSpaceEventType.js", "../../node_modules/@cesium/engine/Source/Core/ScreenSpaceEventHandler.js", "../../node_modules/@cesium/engine/Source/Core/SimplePolylineGeometry.js", "../../node_modules/@cesium/engine/Source/Core/SphereGeometry.js", "../../node_modules/@cesium/engine/Source/Core/TileEdge.js", "../../node_modules/@cesium/engine/Source/Core/TilingScheme.js", "../../node_modules/@cesium/engine/Source/Core/VRTheWorldTerrainProvider.js", "../../node_modules/@cesium/engine/Source/Core/VideoSynchronizer.js", "../../node_modules/@cesium/engine/Source/Core/VulkanConstants.js", "../../node_modules/@cesium/engine/Source/Core/createWorldTerrainAsync.js", "../../node_modules/@cesium/engine/Source/Core/decodeGoogleEarthEnterpriseData.js", "../../node_modules/@cesium/engine/Source/Core/getImageFromTypedArray.js", "../../node_modules/@cesium/engine/Source/Core/mergeSort.js", "../../node_modules/@cesium/engine/Source/Core/pointInsideTriangle.js", "../../node_modules/@cesium/engine/Source/Core/webGLConstantToGlslType.js", "../../node_modules/@cesium/engine/Source/Core/wrapFunction.js", "../../node_modules/@cesium/engine/Source/Scene/ArcGisBaseMapType.js", "../../node_modules/@cesium/engine/Source/Scene/ArcGisMapService.js", "../../node_modules/@cesium/engine/Source/Scene/DiscardMissingTileImagePolicy.js", "../../node_modules/@cesium/engine/Source/Scene/ImageryLayerFeatureInfo.js", "../../node_modules/@cesium/engine/Source/Scene/ImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/ArcGisMapServerImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/AutoExposure.js", "../../node_modules/@cesium/engine/Source/Scene/BingMapsStyle.js", "../../node_modules/@cesium/engine/Source/Scene/DiscardEmptyTileImagePolicy.js", "../../node_modules/@cesium/engine/Source/Scene/BingMapsImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/BoxEmitter.js", "../../node_modules/@cesium/engine/Source/Shaders/BrdfLutGeneratorFS.js", "../../node_modules/@cesium/engine/Source/Scene/BrdfLutGenerator.js", "../../node_modules/@cesium/engine/Source/Scene/CameraFlightPath.js", "../../node_modules/@cesium/engine/Source/Scene/MapMode2D.js", "../../node_modules/@cesium/engine/Source/Scene/Camera.js", "../../node_modules/@cesium/engine/Source/Scene/CameraEventType.js", "../../node_modules/@cesium/engine/Source/Scene/CameraEventAggregator.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileContent.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilePassState.js", "../../node_modules/@cesium/engine/Source/Scene/ConditionsExpression.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTileStyle.js", "../../node_modules/@cesium/engine/Source/Scene/ImplicitSubtreeCache.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelBoxShape.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelContent.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelCylinderShape.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelEllipsoidShape.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelShapeType.js", "../../node_modules/@cesium/engine/Source/Scene/Cesium3DTilesVoxelProvider.js", "../../node_modules/@cesium/engine/Source/Scene/CircleEmitter.js", "../../node_modules/@cesium/engine/Source/Scene/CloudType.js", "../../node_modules/@cesium/engine/Source/Shaders/CloudCollectionFS.js", "../../node_modules/@cesium/engine/Source/Shaders/CloudCollectionVS.js", "../../node_modules/@cesium/engine/Source/Shaders/CloudNoiseFS.js", "../../node_modules/@cesium/engine/Source/Shaders/CloudNoiseVS.js", "../../node_modules/@cesium/engine/Source/Scene/CumulusCloud.js", "../../node_modules/@cesium/engine/Source/Scene/CloudCollection.js", "../../node_modules/@cesium/engine/Source/Scene/ConeEmitter.js", "../../node_modules/@cesium/engine/Source/Scene/CreditDisplay.js", "../../node_modules/@cesium/engine/Source/Scene/DebugAppearance.js", "../../node_modules/@cesium/engine/Source/Scene/DebugCameraPrimitive.js", "../../node_modules/@cesium/engine/Source/Scene/DebugInspector.js", "../../node_modules/@cesium/engine/Source/Scene/DebugModelMatrixPrimitive.js", "../../node_modules/@cesium/engine/Source/Shaders/DepthPlaneFS.js", "../../node_modules/@cesium/engine/Source/Shaders/DepthPlaneVS.js", "../../node_modules/@cesium/engine/Source/Scene/DepthPlane.js", "../../node_modules/@cesium/engine/Source/Scene/DerivedCommand.js", "../../node_modules/@cesium/engine/Source/Scene/DeviceOrientationCameraController.js", "../../node_modules/@cesium/engine/Source/Scene/DirectionalLight.js", "../../node_modules/@cesium/engine/Source/Shaders/EllipsoidFS.js", "../../node_modules/@cesium/engine/Source/Shaders/EllipsoidVS.js", "../../node_modules/@cesium/engine/Source/Scene/EllipsoidPrimitive.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/EllipsoidSurfaceAppearanceFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Appearances/EllipsoidSurfaceAppearanceVS.js", "../../node_modules/@cesium/engine/Source/Scene/EllipsoidSurfaceAppearance.js", "../../node_modules/@cesium/engine/Source/Scene/Fog.js", "../../node_modules/@cesium/engine/Source/Scene/FrameRateMonitor.js", "../../node_modules/@cesium/engine/Source/Scene/FrameState.js", "../../node_modules/@cesium/engine/Source/Scene/FrustumCommands.js", "../../node_modules/@cesium/engine/Source/Scene/GetFeatureInfoFormat.js", "../../node_modules/@cesium/engine/Source/Shaders/GlobeFS.js", "../../node_modules/@cesium/engine/Source/Shaders/GlobeVS.js", "../../node_modules/@cesium/engine/Source/Shaders/AtmosphereCommon.js", "../../node_modules/@cesium/engine/Source/Shaders/GroundAtmosphere.js", "../../node_modules/@cesium/engine/Source/Scene/getClippingFunction.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeSurfaceShaderSet.js", "../../node_modules/@cesium/engine/Source/Scene/ImageryState.js", "../../node_modules/@cesium/engine/Source/Scene/QuadtreeTileLoadState.js", "../../node_modules/@cesium/engine/Source/Scene/TerrainState.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeSurfaceTile.js", "../../node_modules/@cesium/engine/Source/Scene/UrlTemplateImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/TileMapServiceImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/GoogleEarthEnterpriseMapsProvider.js", "../../node_modules/@cesium/engine/Source/Scene/MapboxImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/SingleTileImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/TimeDynamicImagery.js", "../../node_modules/@cesium/engine/Source/Scene/WebMapServiceImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/WebMapTileServiceImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/IonImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/IonWorldImageryStyle.js", "../../node_modules/@cesium/engine/Source/Scene/createWorldImageryAsync.js", "../../node_modules/@cesium/engine/Source/Shaders/ReprojectWebMercatorFS.js", "../../node_modules/@cesium/engine/Source/Shaders/ReprojectWebMercatorVS.js", "../../node_modules/@cesium/engine/Source/Scene/Imagery.js", "../../node_modules/@cesium/engine/Source/Scene/TileImagery.js", "../../node_modules/@cesium/engine/Source/Scene/ImageryLayer.js", "../../node_modules/@cesium/engine/Source/Scene/TileSelectionResult.js", "../../node_modules/@cesium/engine/Source/Scene/TerrainFillMesh.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeSurfaceTileProvider.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeTranslucency.js", "../../node_modules/@cesium/engine/Source/Scene/ImageryLayerCollection.js", "../../node_modules/@cesium/engine/Source/Scene/QuadtreeOccluders.js", "../../node_modules/@cesium/engine/Source/Scene/QuadtreeTile.js", "../../node_modules/@cesium/engine/Source/Scene/TileReplacementQueue.js", "../../node_modules/@cesium/engine/Source/Scene/QuadtreePrimitive.js", "../../node_modules/@cesium/engine/Source/Scene/Globe.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/PassThrough.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/PassThroughDepth.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeDepth.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeTranslucencyFramebuffer.js", "../../node_modules/@cesium/engine/Source/Scene/GlobeTranslucencyState.js", "../../node_modules/@cesium/engine/Source/Scene/GoogleEarthEnterpriseImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/GridImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/I3SFeature.js", "../../node_modules/@cesium/engine/Source/Scene/I3SField.js", "../../node_modules/@cesium/engine/Source/Scene/I3SGeometry.js", "../../node_modules/@cesium/engine/Source/Scene/I3SNode.js", "../../node_modules/@cesium/engine/Source/Scene/I3SLayer.js", "../../node_modules/@cesium/engine/Source/Scene/I3SDataProvider.js", "../../node_modules/@cesium/engine/Source/Scene/InvertClassification.js", "../../node_modules/@cesium/engine/Source/Scene/JobScheduler.js", "../../node_modules/@cesium/engine/Source/Scene/KeyframeNode.js", "../../node_modules/@cesium/engine/Source/Scene/Light.js", "../../node_modules/@cesium/engine/Source/Scene/MapboxStyleImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/Megatexture.js", "../../node_modules/@cesium/engine/Source/Scene/Moon.js", "../../node_modules/@cesium/engine/Source/Scene/NeverTileDiscardPolicy.js", "../../node_modules/@cesium/engine/Source/Shaders/AdjustTranslucentFS.js", "../../node_modules/@cesium/engine/Source/Shaders/CompositeOITFS.js", "../../node_modules/@cesium/engine/Source/Scene/OIT.js", "../../node_modules/@cesium/engine/Source/Scene/OpenStreetMapImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/Particle.js", "../../node_modules/@cesium/engine/Source/Scene/ParticleBurst.js", "../../node_modules/@cesium/engine/Source/Scene/ParticleEmitter.js", "../../node_modules/@cesium/engine/Source/Scene/ParticleSystem.js", "../../node_modules/@cesium/engine/Source/Scene/PerformanceDisplay.js", "../../node_modules/@cesium/engine/Source/Scene/PickDepth.js", "../../node_modules/@cesium/engine/Source/Scene/PickDepthFramebuffer.js", "../../node_modules/@cesium/engine/Source/Scene/PickFramebuffer.js", "../../node_modules/@cesium/engine/Source/Scene/SceneFramebuffer.js", "../../node_modules/@cesium/engine/Source/Scene/ShadowMapShader.js", "../../node_modules/@cesium/engine/Source/Scene/ShadowMap.js", "../../node_modules/@cesium/engine/Source/Shaders/CompareAndPackTranslucentDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/CompositeTranslucentClassification.js", "../../node_modules/@cesium/engine/Source/Scene/TranslucentTileClassification.js", "../../node_modules/@cesium/engine/Source/Scene/View.js", "../../node_modules/@cesium/engine/Source/Scene/Picking.js", "../../node_modules/@cesium/engine/Source/Scene/PointCloud.js", "../../node_modules/@cesium/engine/Source/Scene/getClipAndStyleCode.js", "../../node_modules/@cesium/engine/Source/Scene/Splitter.js", "../../node_modules/@cesium/engine/Source/Scene/PostProcessStageSampleMode.js", "../../node_modules/@cesium/engine/Source/Scene/PostProcessStage.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/AcesTonemappingStage.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/BlackAndWhite.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/BloomComposite.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/Brightness.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/ContrastBias.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/DepthOfField.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/DepthView.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/EdgeDetection.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/FilmicTonemapping.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/FXAA.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/GaussianBlur1D.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/LensFlare.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/ModifiedReinhardTonemapping.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/NightVision.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/ReinhardTonemapping.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/Silhouette.js", "../../node_modules/@cesium/engine/Source/Shaders/FXAA3_11.js", "../../node_modules/@cesium/engine/Source/Scene/PostProcessStageComposite.js", "../../node_modules/@cesium/engine/Source/Scene/PostProcessStageLibrary.js", "../../node_modules/@cesium/engine/Source/Scene/PostProcessStageTextureCache.js", "../../node_modules/@cesium/engine/Source/Scene/Tonemapper.js", "../../node_modules/@cesium/engine/Source/Scene/PostProcessStageCollection.js", "../../node_modules/@cesium/engine/Source/Scene/QuadtreeTileProvider.js", "../../node_modules/@cesium/engine/Source/Scene/SceneTransitioner.js", "../../node_modules/@cesium/engine/Source/Scene/TweenCollection.js", "../../node_modules/@cesium/engine/Source/Scene/ScreenSpaceCameraController.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/AdditiveBlend.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/BrightPass.js", "../../node_modules/@cesium/engine/Source/Scene/SunPostProcess.js", "../../node_modules/@cesium/engine/Source/Scene/Scene.js", "../../node_modules/@cesium/engine/Source/Shaders/SkyAtmosphereCommon.js", "../../node_modules/@cesium/engine/Source/Shaders/SkyAtmosphereFS.js", "../../node_modules/@cesium/engine/Source/Shaders/SkyAtmosphereVS.js", "../../node_modules/@cesium/engine/Source/Scene/SkyAtmosphere.js", "../../node_modules/@cesium/engine/Source/Shaders/SkyBoxFS.js", "../../node_modules/@cesium/engine/Source/Shaders/SkyBoxVS.js", "../../node_modules/@cesium/engine/Source/Scene/SkyBox.js", "../../node_modules/@cesium/engine/Source/Scene/SpatialNode.js", "../../node_modules/@cesium/engine/Source/Scene/SphereEmitter.js", "../../node_modules/@cesium/engine/Source/Scene/StyleExpression.js", "../../node_modules/@cesium/engine/Source/Shaders/SunFS.js", "../../node_modules/@cesium/engine/Source/Shaders/SunTextureFS.js", "../../node_modules/@cesium/engine/Source/Shaders/SunVS.js", "../../node_modules/@cesium/engine/Source/Scene/Sun.js", "../../node_modules/@cesium/engine/Source/Scene/Terrain.js", "../../node_modules/@cesium/engine/Source/Scene/TileBoundingVolume.js", "../../node_modules/@cesium/engine/Source/Scene/TileCoordinatesImageryProvider.js", "../../node_modules/@cesium/engine/Source/Scene/TileDiscardPolicy.js", "../../node_modules/@cesium/engine/Source/Scene/TileState.js", "../../node_modules/@cesium/engine/Source/Scene/TimeDynamicPointCloud.js", "../../node_modules/@cesium/engine/Source/Shaders/ViewportQuadFS.js", "../../node_modules/@cesium/engine/Source/Scene/ViewportQuad.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/VoxelFS.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/VoxelVS.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/IntersectionUtils.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/IntersectDepth.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/IntersectClippingPlanes.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/IntersectBox.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/IntersectCylinder.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/IntersectEllipsoid.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/Intersection.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/convertUvToBox.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/convertUvToCylinder.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/convertUvToEllipsoid.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/Octree.js", "../../node_modules/@cesium/engine/Source/Shaders/Voxels/Megatexture.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelRenderResources.js", "../../node_modules/@cesium/engine/Source/Scene/processVoxelProperties.js", "../../node_modules/@cesium/engine/Source/Scene/buildVoxelDrawCommands.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelTraversal.js", "../../node_modules/@cesium/engine/Source/Scene/Model/UniformType.js", "../../node_modules/@cesium/engine/Source/Scene/Model/TextureManager.js", "../../node_modules/@cesium/engine/Source/Scene/Model/CustomShader.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelPrimitive.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelProvider.js", "../../node_modules/@cesium/engine/Source/Scene/VoxelShape.js", "../../node_modules/@cesium/engine/Source/Scene/computeFlyToLocationForRectangle.js", "../../node_modules/@cesium/engine/Source/Scene/createElevationBandMaterial.js", "../../node_modules/@cesium/engine/Source/Scene/createGooglePhotorealistic3DTileset.js", "../../node_modules/@cesium/engine/Source/Scene/createOsmBuildingsAsync.js", "../../node_modules/@cesium/engine/Source/Scene/createTangentSpaceDebugPrimitive.js", "../../node_modules/@cesium/engine/Source/Widget/CesiumWidget.js", "../../node_modules/@cesium/engine/Source/Scene/Model/TextureUniform.js", "../../node_modules/@cesium/engine/Source/Scene/Model/VaryingType.js", "../../node_modules/@cesium/engine/Source/Shaders/PostProcessStages/DepthViewPacked.js", "../../node_modules/@cesium/engine/Source/WorkersES6/createTaskProcessorWorker.js", "../../node_modules/@cesium/engine/index.js", "../../node_modules/@cesium/widgets/Source/ThirdParty/knockout-3.5.1.js", "../../node_modules/@cesium/widgets/Source/ThirdParty/knockout-es5.js", "../../node_modules/@cesium/widgets/Source/SvgPathBindingHandler.js", "../../node_modules/@cesium/widgets/Source/ThirdParty/knockout.js", "../../node_modules/@cesium/widgets/Source/ClockViewModel.js", "../../node_modules/@cesium/widgets/Source/Command.js", "../../node_modules/@cesium/widgets/Source/InspectorShared.js", "../../node_modules/@cesium/widgets/Source/ToggleButtonViewModel.js", "../../node_modules/@cesium/widgets/Source/createCommand.js", "../../node_modules/@cesium/widgets/Source/subscribeAndEvaluate.js", "../../node_modules/@cesium/widgets/Source/Animation/Animation.js", "../../node_modules/@cesium/widgets/Source/Animation/AnimationViewModel.js", "../../node_modules/@cesium/widgets/Source/BaseLayerPicker/BaseLayerPickerViewModel.js", "../../node_modules/@cesium/widgets/Source/BaseLayerPicker/BaseLayerPicker.js", "../../node_modules/@cesium/widgets/Source/BaseLayerPicker/ProviderViewModel.js", "../../node_modules/@cesium/widgets/Source/BaseLayerPicker/createDefaultImageryProviderViewModels.js", "../../node_modules/@cesium/widgets/Source/BaseLayerPicker/createDefaultTerrainProviderViewModels.js", "../../node_modules/@cesium/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js", "../../node_modules/@cesium/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspector.js", "../../node_modules/@cesium/widgets/Source/CesiumInspector/CesiumInspectorViewModel.js", "../../node_modules/@cesium/widgets/Source/CesiumInspector/CesiumInspector.js", "../../node_modules/@cesium/widgets/Source/FullscreenButton/FullscreenButtonViewModel.js", "../../node_modules/@cesium/widgets/Source/FullscreenButton/FullscreenButton.js", "../../node_modules/@cesium/widgets/Source/Geocoder/GeocoderViewModel.js", "../../node_modules/@cesium/widgets/Source/Geocoder/Geocoder.js", "../../node_modules/@cesium/widgets/Source/HomeButton/HomeButtonViewModel.js", "../../node_modules/@cesium/widgets/Source/HomeButton/HomeButton.js", "../../node_modules/@cesium/widgets/Source/InfoBox/InfoBoxViewModel.js", "../../node_modules/@cesium/widgets/Source/InfoBox/InfoBox.js", "../../node_modules/@cesium/widgets/Source/NavigationHelpButton/NavigationHelpButtonViewModel.js", "../../node_modules/@cesium/widgets/Source/NavigationHelpButton/NavigationHelpButton.js", "../../node_modules/@cesium/widgets/Source/PerformanceWatchdog/PerformanceWatchdogViewModel.js", "../../node_modules/@cesium/widgets/Source/PerformanceWatchdog/PerformanceWatchdog.js", "../../node_modules/@cesium/widgets/Source/ProjectionPicker/ProjectionPickerViewModel.js", "../../node_modules/@cesium/widgets/Source/ProjectionPicker/ProjectionPicker.js", "../../node_modules/@cesium/widgets/Source/SceneModePicker/SceneModePickerViewModel.js", "../../node_modules/@cesium/widgets/Source/SceneModePicker/SceneModePicker.js", "../../node_modules/@cesium/widgets/Source/SelectionIndicator/SelectionIndicatorViewModel.js", "../../node_modules/@cesium/widgets/Source/SelectionIndicator/SelectionIndicator.js", "../../node_modules/@cesium/widgets/Source/Timeline/TimelineHighlightRange.js", "../../node_modules/@cesium/widgets/Source/Timeline/TimelineTrack.js", "../../node_modules/@cesium/widgets/Source/Timeline/Timeline.js", "../../node_modules/@cesium/widgets/Source/VRButton/VRButtonViewModel.js", "../../node_modules/@cesium/widgets/Source/VRButton/VRButton.js", "../../node_modules/@cesium/widgets/Source/Viewer/Viewer.js", "../../node_modules/@cesium/widgets/Source/Viewer/viewerCesium3DTilesInspectorMixin.js", "../../node_modules/@cesium/widgets/Source/Viewer/viewerCesiumInspectorMixin.js", "../../node_modules/@cesium/widgets/Source/Viewer/viewerDragDropMixin.js", "../../node_modules/@cesium/widgets/Source/Viewer/viewerPerformanceWatchdogMixin.js", "../../node_modules/@cesium/widgets/Source/VoxelInspector/VoxelInspectorViewModel.js", "../../node_modules/@cesium/widgets/Source/VoxelInspector/VoxelInspector.js", "../../node_modules/@cesium/widgets/Source/Viewer/viewerVoxelInspectorMixin.js", "../../node_modules/@cesium/widgets/index.js"],
"sourcesContent": ["/*\n https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace\n so it's better encapsulated. Now you can have multiple random number generators\n and they won't stomp all over eachother's state.\n\n If you want to use this as a substitute for Math.random(), use the random()\n method like so:\n\n var m = new MersenneTwister();\n var randomNumber = m.random();\n\n You can also call the other genrand_{foo}() methods on the instance.\n\n If you want to use a specific seed in order to get a repeatable random\n sequence, pass an integer into the constructor:\n\n var m = new MersenneTwister(123);\n\n and that will always produce the same random sequence.\n\n Sean McCullough (banksean@gmail.com)\n*/\n\n/*\n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n\n Before using, initialize the state by using init_seed(seed)\n or init_by_array(init_key, key_length).\n\n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n 3. The names of its contributors may not be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nvar MersenneTwister = function(seed) {\n\tif (seed == undefined) {\n\t\tseed = new Date().getTime();\n\t}\n\n\t/* Period parameters */\n\tthis.N = 624;\n\tthis.M = 397;\n\tthis.MATRIX_A = 0x9908b0df; /* constant vector a */\n\tthis.UPPER_MASK = 0x80000000; /* most significant w-r bits */\n\tthis.LOWER_MASK = 0x7fffffff; /* least significant r bits */\n\n\tthis.mt = new Array(this.N); /* the array for the state vector */\n\tthis.mti=this.N+1; /* mti==N+1 means mt[N] is not initialized */\n\n\tif (seed.constructor == Array) {\n\t\tthis.init_by_array(seed, seed.length);\n\t}\n\telse {\n\t\tthis.init_seed(seed);\n\t}\n}\n\n/* initializes mt[N] with a seed */\n/* origin name init_genrand */\nMersenneTwister.prototype.init_seed = function(s) {\n\tthis.mt[0] = s >>> 0;\n\tfor (this.mti=1; this.mti>> 30);\n\t\tthis.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253)\n\t\t+ this.mti;\n\t\t/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n\t\t/* In the previous versions, MSBs of the seed affect */\n\t\t/* only MSBs of the array mt[]. */\n\t\t/* 2002/01/09 modified by Makoto Matsumoto */\n\t\tthis.mt[this.mti] >>>= 0;\n\t\t/* for >32 bit machines */\n\t}\n}\n\n/* initialize by an array with array-length */\n/* init_key is the array for initializing keys */\n/* key_length is its length */\n/* slight change for C++, 2004/2/26 */\nMersenneTwister.prototype.init_by_array = function(init_key, key_length) {\n\tvar i, j, k;\n\tthis.init_seed(19650218);\n\ti=1; j=0;\n\tk = (this.N>key_length ? this.N : key_length);\n\tfor (; k; k--) {\n\t\tvar s = this.mt[i-1] ^ (this.mt[i-1] >>> 30)\n\t\tthis.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + ((s & 0x0000ffff) * 1664525)))\n\t\t+ init_key[j] + j; /* non linear */\n\t\tthis.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n\t\ti++; j++;\n\t\tif (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }\n\t\tif (j>=key_length) j=0;\n\t}\n\tfor (k=this.N-1; k; k--) {\n\t\tvar s = this.mt[i-1] ^ (this.mt[i-1] >>> 30);\n\t\tthis.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941))\n\t\t- i; /* non linear */\n\t\tthis.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n\t\ti++;\n\t\tif (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }\n\t}\n\n\tthis.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */\n}\n\n/* generates a random number on [0,0xffffffff]-interval */\n/* origin name genrand_int32 */\nMersenneTwister.prototype.random_int = function() {\n\tvar y;\n\tvar mag01 = new Array(0x0, this.MATRIX_A);\n\t/* mag01[x] = x * MATRIX_A for x=0,1 */\n\n\tif (this.mti >= this.N) { /* generate N words at one time */\n\t\tvar kk;\n\n\t\tif (this.mti == this.N+1) /* if init_seed() has not been called, */\n\t\t\tthis.init_seed(5489); /* a default initial seed is used */\n\n\t\tfor (kk=0;kk>> 1) ^ mag01[y & 0x1];\n\t\t}\n\t\tfor (;kk>> 1) ^ mag01[y & 0x1];\n\t\t}\n\t\ty = (this.mt[this.N-1]&this.UPPER_MASK)|(this.mt[0]&this.LOWER_MASK);\n\t\tthis.mt[this.N-1] = this.mt[this.M-1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n\t\tthis.mti = 0;\n\t}\n\n\ty = this.mt[this.mti++];\n\n\t/* Tempering */\n\ty ^= (y >>> 11);\n\ty ^= (y << 7) & 0x9d2c5680;\n\ty ^= (y << 15) & 0xefc60000;\n\ty ^= (y >>> 18);\n\n\treturn y >>> 0;\n}\n\n/* generates a random number on [0,0x7fffffff]-interval */\n/* origin name genrand_int31 */\nMersenneTwister.prototype.random_int31 = function() {\n\treturn (this.random_int()>>>1);\n}\n\n/* generates a random number on [0,1]-real-interval */\n/* origin name genrand_real1 */\nMersenneTwister.prototype.random_incl = function() {\n\treturn this.random_int()*(1.0/4294967295.0);\n\t/* divided by 2^32-1 */\n}\n\n/* generates a random number on [0,1)-real-interval */\nMersenneTwister.prototype.random = function() {\n\treturn this.random_int()*(1.0/4294967296.0);\n\t/* divided by 2^32 */\n}\n\n/* generates a random number on (0,1)-real-interval */\n/* origin name genrand_real3 */\nMersenneTwister.prototype.random_excl = function() {\n\treturn (this.random_int() + 0.5)*(1.0/4294967296.0);\n\t/* divided by 2^32 */\n}\n\n/* generates a random number on [0,1) with 53-bit resolution*/\n/* origin name genrand_res53 */\nMersenneTwister.prototype.random_long = function() {\n\tvar a=this.random_int()>>>5, b=this.random_int()>>>6;\n\treturn(a*67108864.0+b)*(1.0/9007199254740992.0);\n}\n\n/* These real versions are due to Isaku Wada, 2002/01/09 added */\n\nmodule.exports = MersenneTwister;\n", "/*! https://mths.be/punycode v1.4.0 by @mathias */\n;(function(root) {\n\n\t/** Detect free variables */\n\tvar freeExports = typeof exports == 'object' && exports &&\n\t\t!exports.nodeType && exports;\n\tvar freeModule = typeof module == 'object' && module &&\n\t\t!module.nodeType && module;\n\tvar freeGlobal = typeof global == 'object' && global;\n\tif (\n\t\tfreeGlobal.global === freeGlobal ||\n\t\tfreeGlobal.window === freeGlobal ||\n\t\tfreeGlobal.self === freeGlobal\n\t) {\n\t\troot = freeGlobal;\n\t}\n\n\t/**\n\t * The `punycode` object.\n\t * @name punycode\n\t * @type Object\n\t */\n\tvar punycode,\n\n\t/** Highest positive signed 32-bit float value */\n\tmaxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1\n\n\t/** Bootstring parameters */\n\tbase = 36,\n\ttMin = 1,\n\ttMax = 26,\n\tskew = 38,\n\tdamp = 700,\n\tinitialBias = 72,\n\tinitialN = 128, // 0x80\n\tdelimiter = '-', // '\\x2D'\n\n\t/** Regular expressions */\n\tregexPunycode = /^xn--/,\n\tregexNonASCII = /[^\\x20-\\x7E]/, // unprintable ASCII chars + non-ASCII chars\n\tregexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g, // RFC 3490 separators\n\n\t/** Error messages */\n\terrors = {\n\t\t'overflow': 'Overflow: input needs wider integers to process',\n\t\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t\t'invalid-input': 'Invalid input'\n\t},\n\n\t/** Convenience shortcuts */\n\tbaseMinusTMin = base - tMin,\n\tfloor = Math.floor,\n\tstringFromCharCode = String.fromCharCode,\n\n\t/** Temporary variable */\n\tkey;\n\n\t/*--------------------------------------------------------------------------*/\n\n\t/**\n\t * A generic error utility function.\n\t * @private\n\t * @param {String} type The error type.\n\t * @returns {Error} Throws a `RangeError` with the applicable error message.\n\t */\n\tfunction error(type) {\n\t\tthrow new RangeError(errors[type]);\n\t}\n\n\t/**\n\t * A generic `Array#map` utility function.\n\t * @private\n\t * @param {Array} array The array to iterate over.\n\t * @param {Function} callback The function that gets called for every array\n\t * item.\n\t * @returns {Array} A new array of values returned by the callback function.\n\t */\n\tfunction map(array, fn) {\n\t\tvar length = array.length;\n\t\tvar result = [];\n\t\twhile (length--) {\n\t\t\tresult[length] = fn(array[length]);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * A simple `Array#map`-like wrapper to work with domain name strings or email\n\t * addresses.\n\t * @private\n\t * @param {String} domain The domain name or email address.\n\t * @param {Function} callback The function that gets called for every\n\t * character.\n\t * @returns {Array} A new string of characters returned by the callback\n\t * function.\n\t */\n\tfunction mapDomain(string, fn) {\n\t\tvar parts = string.split('@');\n\t\tvar result = '';\n\t\tif (parts.length > 1) {\n\t\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t\t// the local part (i.e. everything up to `@`) intact.\n\t\t\tresult = parts[0] + '@';\n\t\t\tstring = parts[1];\n\t\t}\n\t\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\t\tstring = string.replace(regexSeparators, '\\x2E');\n\t\tvar labels = string.split('.');\n\t\tvar encoded = map(labels, fn).join('.');\n\t\treturn result + encoded;\n\t}\n\n\t/**\n\t * Creates an array containing the numeric code points of each Unicode\n\t * character in the string. While JavaScript uses UCS-2 internally,\n\t * this function will convert a pair of surrogate halves (each of which\n\t * UCS-2 exposes as separate characters) into a single code point,\n\t * matching UTF-16.\n\t * @see `punycode.ucs2.encode`\n\t * @see \n\t * @memberOf punycode.ucs2\n\t * @name decode\n\t * @param {String} string The Unicode input string (UCS-2).\n\t * @returns {Array} The new array of code points.\n\t */\n\tfunction ucs2decode(string) {\n\t\tvar output = [],\n\t\t counter = 0,\n\t\t length = string.length,\n\t\t value,\n\t\t extra;\n\t\twhile (counter < length) {\n\t\t\tvalue = string.charCodeAt(counter++);\n\t\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t\t// high surrogate, and there is a next character\n\t\t\t\textra = string.charCodeAt(counter++);\n\t\t\t\tif ((extra & 0xFC00) == 0xDC00) { // low surrogate\n\t\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t\t} else {\n\t\t\t\t\t// unmatched surrogate; only append this code unit, in case the next\n\t\t\t\t\t// code unit is the high surrogate of a surrogate pair\n\t\t\t\t\toutput.push(value);\n\t\t\t\t\tcounter--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toutput.push(value);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t/**\n\t * Creates a string based on an array of numeric code points.\n\t * @see `punycode.ucs2.decode`\n\t * @memberOf punycode.ucs2\n\t * @name encode\n\t * @param {Array} codePoints The array of numeric code points.\n\t * @returns {String} The new Unicode string (UCS-2).\n\t */\n\tfunction ucs2encode(array) {\n\t\treturn map(array, function(value) {\n\t\t\tvar output = '';\n\t\t\tif (value > 0xFFFF) {\n\t\t\t\tvalue -= 0x10000;\n\t\t\t\toutput += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n\t\t\t\tvalue = 0xDC00 | value & 0x3FF;\n\t\t\t}\n\t\t\toutput += stringFromCharCode(value);\n\t\t\treturn output;\n\t\t}).join('');\n\t}\n\n\t/**\n\t * Converts a basic code point into a digit/integer.\n\t * @see `digitToBasic()`\n\t * @private\n\t * @param {Number} codePoint The basic numeric code point value.\n\t * @returns {Number} The numeric value of a basic code point (for use in\n\t * representing integers) in the range `0` to `base - 1`, or `base` if\n\t * the code point does not represent a value.\n\t */\n\tfunction basicToDigit(codePoint) {\n\t\tif (codePoint - 48 < 10) {\n\t\t\treturn codePoint - 22;\n\t\t}\n\t\tif (codePoint - 65 < 26) {\n\t\t\treturn codePoint - 65;\n\t\t}\n\t\tif (codePoint - 97 < 26) {\n\t\t\treturn codePoint - 97;\n\t\t}\n\t\treturn base;\n\t}\n\n\t/**\n\t * Converts a digit/integer into a basic code point.\n\t * @see `basicToDigit()`\n\t * @private\n\t * @param {Number} digit The numeric value of a basic code point.\n\t * @returns {Number} The basic code point whose value (when used for\n\t * representing integers) is `digit`, which needs to be in the range\n\t * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n\t * used; else, the lowercase form is used. The behavior is undefined\n\t * if `flag` is non-zero and `digit` has no uppercase form.\n\t */\n\tfunction digitToBasic(digit, flag) {\n\t\t// 0..25 map to ASCII a..z or A..Z\n\t\t// 26..35 map to ASCII 0..9\n\t\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n\t}\n\n\t/**\n\t * Bias adaptation function as per section 3.4 of RFC 3492.\n\t * https://tools.ietf.org/html/rfc3492#section-3.4\n\t * @private\n\t */\n\tfunction adapt(delta, numPoints, firstTime) {\n\t\tvar k = 0;\n\t\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\t\tdelta += floor(delta / numPoints);\n\t\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\t\tdelta = floor(delta / baseMinusTMin);\n\t\t}\n\t\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n\t}\n\n\t/**\n\t * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n\t * symbols.\n\t * @memberOf punycode\n\t * @param {String} input The Punycode string of ASCII-only symbols.\n\t * @returns {String} The resulting string of Unicode symbols.\n\t */\n\tfunction decode(input) {\n\t\t// Don't use UCS-2\n\t\tvar output = [],\n\t\t inputLength = input.length,\n\t\t out,\n\t\t i = 0,\n\t\t n = initialN,\n\t\t bias = initialBias,\n\t\t basic,\n\t\t j,\n\t\t index,\n\t\t oldi,\n\t\t w,\n\t\t k,\n\t\t digit,\n\t\t t,\n\t\t /** Cached calculation results */\n\t\t baseMinusT;\n\n\t\t// Handle the basic code points: let `basic` be the number of input code\n\t\t// points before the last delimiter, or `0` if there is none, then copy\n\t\t// the first basic code points to the output.\n\n\t\tbasic = input.lastIndexOf(delimiter);\n\t\tif (basic < 0) {\n\t\t\tbasic = 0;\n\t\t}\n\n\t\tfor (j = 0; j < basic; ++j) {\n\t\t\t// if it's not a basic code point\n\t\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\t\terror('not-basic');\n\t\t\t}\n\t\t\toutput.push(input.charCodeAt(j));\n\t\t}\n\n\t\t// Main decoding loop: start just after the last delimiter if any basic code\n\t\t// points were copied; start at the beginning otherwise.\n\n\t\tfor (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t\t// `index` is the index of the next character to be consumed.\n\t\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t\t// which gets added to `i`. The overflow checking is easier\n\t\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t\t// value at the end to obtain `delta`.\n\t\t\tfor (oldi = i, w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\t\tif (index >= inputLength) {\n\t\t\t\t\terror('invalid-input');\n\t\t\t\t}\n\n\t\t\t\tdigit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\t\tif (digit >= base || digit > floor((maxInt - i) / w)) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\ti += digit * w;\n\t\t\t\tt = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\t\tif (digit < t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbaseMinusT = base - t;\n\t\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\tw *= baseMinusT;\n\n\t\t\t}\n\n\t\t\tout = output.length + 1;\n\t\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t\t// incrementing `n` each time, so we'll fix that now:\n\t\t\tif (floor(i / out) > maxInt - n) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tn += floor(i / out);\n\t\t\ti %= out;\n\n\t\t\t// Insert `n` at position `i` of the output\n\t\t\toutput.splice(i++, 0, n);\n\n\t\t}\n\n\t\treturn ucs2encode(output);\n\t}\n\n\t/**\n\t * Converts a string of Unicode symbols (e.g. a domain name label) to a\n\t * Punycode string of ASCII-only symbols.\n\t * @memberOf punycode\n\t * @param {String} input The string of Unicode symbols.\n\t * @returns {String} The resulting Punycode string of ASCII-only symbols.\n\t */\n\tfunction encode(input) {\n\t\tvar n,\n\t\t delta,\n\t\t handledCPCount,\n\t\t basicLength,\n\t\t bias,\n\t\t j,\n\t\t m,\n\t\t q,\n\t\t k,\n\t\t t,\n\t\t currentValue,\n\t\t output = [],\n\t\t /** `inputLength` will hold the number of code points in `input`. */\n\t\t inputLength,\n\t\t /** Cached calculation results */\n\t\t handledCPCountPlusOne,\n\t\t baseMinusT,\n\t\t qMinusT;\n\n\t\t// Convert the input in UCS-2 to Unicode\n\t\tinput = ucs2decode(input);\n\n\t\t// Cache the length\n\t\tinputLength = input.length;\n\n\t\t// Initialize the state\n\t\tn = initialN;\n\t\tdelta = 0;\n\t\tbias = initialBias;\n\n\t\t// Handle the basic code points\n\t\tfor (j = 0; j < inputLength; ++j) {\n\t\t\tcurrentValue = input[j];\n\t\t\tif (currentValue < 0x80) {\n\t\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t\t}\n\t\t}\n\n\t\thandledCPCount = basicLength = output.length;\n\n\t\t// `handledCPCount` is the number of code points that have been handled;\n\t\t// `basicLength` is the number of basic code points.\n\n\t\t// Finish the basic string - if it is not empty - with a delimiter\n\t\tif (basicLength) {\n\t\t\toutput.push(delimiter);\n\t\t}\n\n\t\t// Main encoding loop:\n\t\twhile (handledCPCount < inputLength) {\n\n\t\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t\t// larger one:\n\t\t\tfor (m = maxInt, j = 0; j < inputLength; ++j) {\n\t\t\t\tcurrentValue = input[j];\n\t\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\t\tm = currentValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Increase `delta` enough to advance the decoder's state to ,\n\t\t\t// but guard against overflow\n\t\t\thandledCPCountPlusOne = handledCPCount + 1;\n\t\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\t\tn = m;\n\n\t\t\tfor (j = 0; j < inputLength; ++j) {\n\t\t\t\tcurrentValue = input[j];\n\n\t\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\tif (currentValue == n) {\n\t\t\t\t\t// Represent delta as a generalized variable-length integer\n\t\t\t\t\tfor (q = delta, k = base; /* no condition */; k += base) {\n\t\t\t\t\t\tt = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqMinusT = q - t;\n\t\t\t\t\t\tbaseMinusT = base - t;\n\t\t\t\t\t\toutput.push(\n\t\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t\t);\n\t\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t\t}\n\n\t\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n\t\t\t\t\tdelta = 0;\n\t\t\t\t\t++handledCPCount;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t++delta;\n\t\t\t++n;\n\n\t\t}\n\t\treturn output.join('');\n\t}\n\n\t/**\n\t * Converts a Punycode string representing a domain name or an email address\n\t * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n\t * it doesn't matter if you call it on a string that has already been\n\t * converted to Unicode.\n\t * @memberOf punycode\n\t * @param {String} input The Punycoded domain name or email address to\n\t * convert to Unicode.\n\t * @returns {String} The Unicode representation of the given Punycode\n\t * string.\n\t */\n\tfunction toUnicode(input) {\n\t\treturn mapDomain(input, function(string) {\n\t\t\treturn regexPunycode.test(string)\n\t\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t\t: string;\n\t\t});\n\t}\n\n\t/**\n\t * Converts a Unicode string representing a domain name or an email address to\n\t * Punycode. Only the non-ASCII parts of the domain name will be converted,\n\t * i.e. it doesn't matter if you call it with a domain that's already in\n\t * ASCII.\n\t * @memberOf punycode\n\t * @param {String} input The domain name or email address to convert, as a\n\t * Unicode string.\n\t * @returns {String} The Punycode representation of the given domain name or\n\t * email address.\n\t */\n\tfunction toASCII(input) {\n\t\treturn mapDomain(input, function(string) {\n\t\t\treturn regexNonASCII.test(string)\n\t\t\t\t? 'xn--' + encode(string)\n\t\t\t\t: string;\n\t\t});\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\t/** Define the public API */\n\tpunycode = {\n\t\t/**\n\t\t * A string representing the current Punycode.js version number.\n\t\t * @memberOf punycode\n\t\t * @type String\n\t\t */\n\t\t'version': '1.3.2',\n\t\t/**\n\t\t * An object of methods to convert from JavaScript's internal character\n\t\t * representation (UCS-2) to Unicode code points, and back.\n\t\t * @see \n\t\t * @memberOf punycode\n\t\t * @type Object\n\t\t */\n\t\t'ucs2': {\n\t\t\t'decode': ucs2decode,\n\t\t\t'encode': ucs2encode\n\t\t},\n\t\t'decode': decode,\n\t\t'encode': encode,\n\t\t'toASCII': toASCII,\n\t\t'toUnicode': toUnicode\n\t};\n\n\t/** Expose `punycode` */\n\t// Some AMD build optimizers, like r.js, check for specific condition patterns\n\t// like the following:\n\tif (\n\t\ttypeof define == 'function' &&\n\t\ttypeof define.amd == 'object' &&\n\t\tdefine.amd\n\t) {\n\t\tdefine('punycode', function() {\n\t\t\treturn punycode;\n\t\t});\n\t} else if (freeExports && freeModule) {\n\t\tif (module.exports == freeExports) {\n\t\t\t// in Node.js, io.js, or RingoJS v0.8.0+\n\t\t\tfreeModule.exports = punycode;\n\t\t} else {\n\t\t\t// in Narwhal or RingoJS v0.7.0-\n\t\t\tfor (key in punycode) {\n\t\t\t\tpunycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// in Rhino or a web browser\n\t\troot.punycode = punycode;\n\t}\n\n}(this));\n", "/*!\n * URI.js - Mutating URLs\n * IPv6 Support\n *\n * Version: 1.19.11\n *\n * Author: Rodney Rehm\n * Web: http://medialize.github.io/URI.js/\n *\n * Licensed under\n * MIT License http://www.opensource.org/licenses/mit-license\n *\n */\n\n(function (root, factory) {\n 'use strict';\n // https://github.com/umdjs/umd/blob/master/returnExports.js\n if (typeof module === 'object' && module.exports) {\n // Node\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory);\n } else {\n // Browser globals (root is window)\n root.IPv6 = factory(root);\n }\n}(this, function (root) {\n 'use strict';\n\n /*\n var _in = \"fe80:0000:0000:0000:0204:61ff:fe9d:f156\";\n var _out = IPv6.best(_in);\n var _expected = \"fe80::204:61ff:fe9d:f156\";\n\n console.log(_in, _out, _expected, _out === _expected);\n */\n\n // save current IPv6 variable, if any\n var _IPv6 = root && root.IPv6;\n\n function bestPresentation(address) {\n // based on:\n // Javascript to test an IPv6 address for proper format, and to\n // present the \"best text representation\" according to IETF Draft RFC at\n // http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04\n // 8 Feb 2010 Rich Brown, Dartware, LLC\n // Please feel free to use this code as long as you provide a link to\n // http://www.intermapper.com\n // http://intermapper.com/support/tools/IPV6-Validator.aspx\n // http://download.dartware.com/thirdparty/ipv6validator.js\n\n var _address = address.toLowerCase();\n var segments = _address.split(':');\n var length = segments.length;\n var total = 8;\n\n // trim colons (:: or ::a:b:c\u2026 or \u2026a:b:c::)\n if (segments[0] === '' && segments[1] === '' && segments[2] === '') {\n // must have been ::\n // remove first two items\n segments.shift();\n segments.shift();\n } else if (segments[0] === '' && segments[1] === '') {\n // must have been ::xxxx\n // remove the first item\n segments.shift();\n } else if (segments[length - 1] === '' && segments[length - 2] === '') {\n // must have been xxxx::\n segments.pop();\n }\n\n length = segments.length;\n\n // adjust total segments for IPv4 trailer\n if (segments[length - 1].indexOf('.') !== -1) {\n // found a \".\" which means IPv4\n total = 7;\n }\n\n // fill empty segments them with \"0000\"\n var pos;\n for (pos = 0; pos < length; pos++) {\n if (segments[pos] === '') {\n break;\n }\n }\n\n if (pos < total) {\n segments.splice(pos, 1, '0000');\n while (segments.length < total) {\n segments.splice(pos, 0, '0000');\n }\n }\n\n // strip leading zeros\n var _segments;\n for (var i = 0; i < total; i++) {\n _segments = segments[i].split('');\n for (var j = 0; j < 3 ; j++) {\n if (_segments[0] === '0' && _segments.length > 1) {\n _segments.splice(0,1);\n } else {\n break;\n }\n }\n\n segments[i] = _segments.join('');\n }\n\n // find longest sequence of zeroes and coalesce them into one segment\n var best = -1;\n var _best = 0;\n var _current = 0;\n var current = -1;\n var inzeroes = false;\n // i; already declared\n\n for (i = 0; i < total; i++) {\n if (inzeroes) {\n if (segments[i] === '0') {\n _current += 1;\n } else {\n inzeroes = false;\n if (_current > _best) {\n best = current;\n _best = _current;\n }\n }\n } else {\n if (segments[i] === '0') {\n inzeroes = true;\n current = i;\n _current = 1;\n }\n }\n }\n\n if (_current > _best) {\n best = current;\n _best = _current;\n }\n\n if (_best > 1) {\n segments.splice(best, _best, '');\n }\n\n length = segments.length;\n\n // assemble remaining segments\n var result = '';\n if (segments[0] === '') {\n result = ':';\n }\n\n for (i = 0; i < length; i++) {\n result += segments[i];\n if (i === length - 1) {\n break;\n }\n\n result += ':';\n }\n\n if (segments[length - 1] === '') {\n result += ':';\n }\n\n return result;\n }\n\n function noConflict() {\n /*jshint validthis: true */\n if (root.IPv6 === this) {\n root.IPv6 = _IPv6;\n }\n\n return this;\n }\n\n return {\n best: bestPresentation,\n noConflict: noConflict\n };\n}));\n", "/*!\n * URI.js - Mutating URLs\n * Second Level Domain (SLD) Support\n *\n * Version: 1.19.11\n *\n * Author: Rodney Rehm\n * Web: http://medialize.github.io/URI.js/\n *\n * Licensed under\n * MIT License http://www.opensource.org/licenses/mit-license\n *\n */\n\n(function (root, factory) {\n 'use strict';\n // https://github.com/umdjs/umd/blob/master/returnExports.js\n if (typeof module === 'object' && module.exports) {\n // Node\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory);\n } else {\n // Browser globals (root is window)\n root.SecondLevelDomains = factory(root);\n }\n}(this, function (root) {\n 'use strict';\n\n // save current SecondLevelDomains variable, if any\n var _SecondLevelDomains = root && root.SecondLevelDomains;\n\n var SLD = {\n // list of known Second Level Domains\n // converted list of SLDs from https://github.com/gavingmiller/second-level-domains\n // ----\n // publicsuffix.org is more current and actually used by a couple of browsers internally.\n // downside is it also contains domains like \"dyndns.org\" - which is fine for the security\n // issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js\n // ----\n list: {\n 'ac':' com gov mil net org ',\n 'ae':' ac co gov mil name net org pro sch ',\n 'af':' com edu gov net org ',\n 'al':' com edu gov mil net org ',\n 'ao':' co ed gv it og pb ',\n 'ar':' com edu gob gov int mil net org tur ',\n 'at':' ac co gv or ',\n 'au':' asn com csiro edu gov id net org ',\n 'ba':' co com edu gov mil net org rs unbi unmo unsa untz unze ',\n 'bb':' biz co com edu gov info net org store tv ',\n 'bh':' biz cc com edu gov info net org ',\n 'bn':' com edu gov net org ',\n 'bo':' com edu gob gov int mil net org tv ',\n 'br':' adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ',\n 'bs':' com edu gov net org ',\n 'bz':' du et om ov rg ',\n 'ca':' ab bc mb nb nf nl ns nt nu on pe qc sk yk ',\n 'ck':' biz co edu gen gov info net org ',\n 'cn':' ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ',\n 'co':' com edu gov mil net nom org ',\n 'cr':' ac c co ed fi go or sa ',\n 'cy':' ac biz com ekloges gov ltd name net org parliament press pro tm ',\n 'do':' art com edu gob gov mil net org sld web ',\n 'dz':' art asso com edu gov net org pol ',\n 'ec':' com edu fin gov info med mil net org pro ',\n 'eg':' com edu eun gov mil name net org sci ',\n 'er':' com edu gov ind mil net org rochest w ',\n 'es':' com edu gob nom org ',\n 'et':' biz com edu gov info name net org ',\n 'fj':' ac biz com info mil name net org pro ',\n 'fk':' ac co gov net nom org ',\n 'fr':' asso com f gouv nom prd presse tm ',\n 'gg':' co net org ',\n 'gh':' com edu gov mil org ',\n 'gn':' ac com gov net org ',\n 'gr':' com edu gov mil net org ',\n 'gt':' com edu gob ind mil net org ',\n 'gu':' com edu gov net org ',\n 'hk':' com edu gov idv net org ',\n 'hu':' 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ',\n 'id':' ac co go mil net or sch web ',\n 'il':' ac co gov idf k12 muni net org ',\n 'in':' ac co edu ernet firm gen gov i ind mil net nic org res ',\n 'iq':' com edu gov i mil net org ',\n 'ir':' ac co dnssec gov i id net org sch ',\n 'it':' edu gov ',\n 'je':' co net org ',\n 'jo':' com edu gov mil name net org sch ',\n 'jp':' ac ad co ed go gr lg ne or ',\n 'ke':' ac co go info me mobi ne or sc ',\n 'kh':' com edu gov mil net org per ',\n 'ki':' biz com de edu gov info mob net org tel ',\n 'km':' asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ',\n 'kn':' edu gov net org ',\n 'kr':' ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ',\n 'kw':' com edu gov net org ',\n 'ky':' com edu gov net org ',\n 'kz':' com edu gov mil net org ',\n 'lb':' com edu gov net org ',\n 'lk':' assn com edu gov grp hotel int ltd net ngo org sch soc web ',\n 'lr':' com edu gov net org ',\n 'lv':' asn com conf edu gov id mil net org ',\n 'ly':' com edu gov id med net org plc sch ',\n 'ma':' ac co gov m net org press ',\n 'mc':' asso tm ',\n 'me':' ac co edu gov its net org priv ',\n 'mg':' com edu gov mil nom org prd tm ',\n 'mk':' com edu gov inf name net org pro ',\n 'ml':' com edu gov net org presse ',\n 'mn':' edu gov org ',\n 'mo':' com edu gov net org ',\n 'mt':' com edu gov net org ',\n 'mv':' aero biz com coop edu gov info int mil museum name net org pro ',\n 'mw':' ac co com coop edu gov int museum net org ',\n 'mx':' com edu gob net org ',\n 'my':' com edu gov mil name net org sch ',\n 'nf':' arts com firm info net other per rec store web ',\n 'ng':' biz com edu gov mil mobi name net org sch ',\n 'ni':' ac co com edu gob mil net nom org ',\n 'np':' com edu gov mil net org ',\n 'nr':' biz com edu gov info net org ',\n 'om':' ac biz co com edu gov med mil museum net org pro sch ',\n 'pe':' com edu gob mil net nom org sld ',\n 'ph':' com edu gov i mil net ngo org ',\n 'pk':' biz com edu fam gob gok gon gop gos gov net org web ',\n 'pl':' art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ',\n 'pr':' ac biz com edu est gov info isla name net org pro prof ',\n 'ps':' com edu gov net org plo sec ',\n 'pw':' belau co ed go ne or ',\n 'ro':' arts com firm info nom nt org rec store tm www ',\n 'rs':' ac co edu gov in org ',\n 'sb':' com edu gov net org ',\n 'sc':' com edu gov net org ',\n 'sh':' co com edu gov net nom org ',\n 'sl':' com edu gov net org ',\n 'st':' co com consulado edu embaixada gov mil net org principe saotome store ',\n 'sv':' com edu gob org red ',\n 'sz':' ac co org ',\n 'tr':' av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ',\n 'tt':' aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ',\n 'tw':' club com ebiz edu game gov idv mil net org ',\n 'mu':' ac co com gov net or org ',\n 'mz':' ac co edu gov org ',\n 'na':' co com ',\n 'nz':' ac co cri geek gen govt health iwi maori mil net org parliament school ',\n 'pa':' abo ac com edu gob ing med net nom org sld ',\n 'pt':' com edu gov int net nome org publ ',\n 'py':' com edu gov mil net org ',\n 'qa':' com edu gov mil net org ',\n 're':' asso com nom ',\n 'ru':' ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ',\n 'rw':' ac co com edu gouv gov int mil net ',\n 'sa':' com edu gov med net org pub sch ',\n 'sd':' com edu gov info med net org tv ',\n 'se':' a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ',\n 'sg':' com edu gov idn net org per ',\n 'sn':' art com edu gouv org perso univ ',\n 'sy':' com edu gov mil net news org ',\n 'th':' ac co go in mi net or ',\n 'tj':' ac biz co com edu go gov info int mil name net nic org test web ',\n 'tn':' agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ',\n 'tz':' ac co go ne or ',\n 'ua':' biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ',\n 'ug':' ac co go ne or org sc ',\n 'uk':' ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ',\n 'us':' dni fed isa kids nsn ',\n 'uy':' com edu gub mil net org ',\n 've':' co com edu gob info mil net org web ',\n 'vi':' co com k12 net org ',\n 'vn':' ac biz com edu gov health info int name net org pro ',\n 'ye':' co com gov ltd me net org plc ',\n 'yu':' ac co edu gov org ',\n 'za':' ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ',\n 'zm':' ac co com edu gov net org sch ',\n // https://en.wikipedia.org/wiki/CentralNic#Second-level_domains\n 'com': 'ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ',\n 'net': 'gb jp se uk ',\n 'org': 'ae',\n 'de': 'com '\n },\n // gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost\n // in both performance and memory footprint. No initialization required.\n // http://jsperf.com/uri-js-sld-regex-vs-binary-search/4\n // Following methods use lastIndexOf() rather than array.split() in order\n // to avoid any memory allocations.\n has: function(domain) {\n var tldOffset = domain.lastIndexOf('.');\n if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {\n return false;\n }\n var sldOffset = domain.lastIndexOf('.', tldOffset-1);\n if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {\n return false;\n }\n var sldList = SLD.list[domain.slice(tldOffset+1)];\n if (!sldList) {\n return false;\n }\n return sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') >= 0;\n },\n is: function(domain) {\n var tldOffset = domain.lastIndexOf('.');\n if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {\n return false;\n }\n var sldOffset = domain.lastIndexOf('.', tldOffset-1);\n if (sldOffset >= 0) {\n return false;\n }\n var sldList = SLD.list[domain.slice(tldOffset+1)];\n if (!sldList) {\n return false;\n }\n return sldList.indexOf(' ' + domain.slice(0, tldOffset) + ' ') >= 0;\n },\n get: function(domain) {\n var tldOffset = domain.lastIndexOf('.');\n if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {\n return null;\n }\n var sldOffset = domain.lastIndexOf('.', tldOffset-1);\n if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {\n return null;\n }\n var sldList = SLD.list[domain.slice(tldOffset+1)];\n if (!sldList) {\n return null;\n }\n if (sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') < 0) {\n return null;\n }\n return domain.slice(sldOffset+1);\n },\n noConflict: function(){\n if (root.SecondLevelDomains === this) {\n root.SecondLevelDomains = _SecondLevelDomains;\n }\n return this;\n }\n };\n\n return SLD;\n}));\n", "/*!\n * URI.js - Mutating URLs\n *\n * Version: 1.19.11\n *\n * Author: Rodney Rehm\n * Web: http://medialize.github.io/URI.js/\n *\n * Licensed under\n * MIT License http://www.opensource.org/licenses/mit-license\n *\n */\n(function (root, factory) {\n 'use strict';\n // https://github.com/umdjs/umd/blob/master/returnExports.js\n if (typeof module === 'object' && module.exports) {\n // Node\n module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains'));\n } else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(['./punycode', './IPv6', './SecondLevelDomains'], factory);\n } else {\n // Browser globals (root is window)\n root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root);\n }\n}(this, function (punycode, IPv6, SLD, root) {\n 'use strict';\n /*global location, escape, unescape */\n // FIXME: v2.0.0 renamce non-camelCase properties to uppercase\n /*jshint camelcase: false */\n\n // save current URI variable, if any\n var _URI = root && root.URI;\n\n function URI(url, base) {\n var _urlSupplied = arguments.length >= 1;\n var _baseSupplied = arguments.length >= 2;\n\n // Allow instantiation without the 'new' keyword\n if (!(this instanceof URI)) {\n if (_urlSupplied) {\n if (_baseSupplied) {\n return new URI(url, base);\n }\n\n return new URI(url);\n }\n\n return new URI();\n }\n\n if (url === undefined) {\n if (_urlSupplied) {\n throw new TypeError('undefined is not a valid argument for URI');\n }\n\n if (typeof location !== 'undefined') {\n url = location.href + '';\n } else {\n url = '';\n }\n }\n\n if (url === null) {\n if (_urlSupplied) {\n throw new TypeError('null is not a valid argument for URI');\n }\n }\n\n this.href(url);\n\n // resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor\n if (base !== undefined) {\n return this.absoluteTo(base);\n }\n\n return this;\n }\n\n function isInteger(value) {\n return /^[0-9]+$/.test(value);\n }\n\n URI.version = '1.19.11';\n\n var p = URI.prototype;\n var hasOwn = Object.prototype.hasOwnProperty;\n\n function escapeRegEx(string) {\n // https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963\n return string.replace(/([.*+?^=!:${}()|[\\]\\/\\\\])/g, '\\\\$1');\n }\n\n function getType(value) {\n // IE8 doesn't return [Object Undefined] but [Object Object] for undefined value\n if (value === undefined) {\n return 'Undefined';\n }\n\n return String(Object.prototype.toString.call(value)).slice(8, -1);\n }\n\n function isArray(obj) {\n return getType(obj) === 'Array';\n }\n\n function filterArrayValues(data, value) {\n var lookup = {};\n var i, length;\n\n if (getType(value) === 'RegExp') {\n lookup = null;\n } else if (isArray(value)) {\n for (i = 0, length = value.length; i < length; i++) {\n lookup[value[i]] = true;\n }\n } else {\n lookup[value] = true;\n }\n\n for (i = 0, length = data.length; i < length; i++) {\n /*jshint laxbreak: true */\n var _match = lookup && lookup[data[i]] !== undefined\n || !lookup && value.test(data[i]);\n /*jshint laxbreak: false */\n if (_match) {\n data.splice(i, 1);\n length--;\n i--;\n }\n }\n\n return data;\n }\n\n function arrayContains(list, value) {\n var i, length;\n\n // value may be string, number, array, regexp\n if (isArray(value)) {\n // Note: this can be optimized to O(n) (instead of current O(m * n))\n for (i = 0, length = value.length; i < length; i++) {\n if (!arrayContains(list, value[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n var _type = getType(value);\n for (i = 0, length = list.length; i < length; i++) {\n if (_type === 'RegExp') {\n if (typeof list[i] === 'string' && list[i].match(value)) {\n return true;\n }\n } else if (list[i] === value) {\n return true;\n }\n }\n\n return false;\n }\n\n function arraysEqual(one, two) {\n if (!isArray(one) || !isArray(two)) {\n return false;\n }\n\n // arrays can't be equal if they have different amount of content\n if (one.length !== two.length) {\n return false;\n }\n\n one.sort();\n two.sort();\n\n for (var i = 0, l = one.length; i < l; i++) {\n if (one[i] !== two[i]) {\n return false;\n }\n }\n\n return true;\n }\n\n function trimSlashes(text) {\n var trim_expression = /^\\/+|\\/+$/g;\n return text.replace(trim_expression, '');\n }\n\n URI._parts = function() {\n return {\n protocol: null,\n username: null,\n password: null,\n hostname: null,\n urn: null,\n port: null,\n path: null,\n query: null,\n fragment: null,\n // state\n preventInvalidHostname: URI.preventInvalidHostname,\n duplicateQueryParameters: URI.duplicateQueryParameters,\n escapeQuerySpace: URI.escapeQuerySpace\n };\n };\n // state: throw on invalid hostname\n // see https://github.com/medialize/URI.js/pull/345\n // and https://github.com/medialize/URI.js/issues/354\n URI.preventInvalidHostname = false;\n // state: allow duplicate query parameters (a=1&a=1)\n URI.duplicateQueryParameters = false;\n // state: replaces + with %20 (space in query strings)\n URI.escapeQuerySpace = true;\n // static properties\n URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;\n URI.idn_expression = /[^a-z0-9\\._-]/i;\n URI.punycode_expression = /(xn--)/i;\n // well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care?\n URI.ip4_expression = /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/;\n // credits to Rich Brown\n // source: http://forums.intermapper.com/viewtopic.php?p=1096#1096\n // specification: http://www.ietf.org/rfc/rfc4291.txt\n URI.ip6_expression = /^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$/;\n // expression used is \"gruber revised\" (@gruber v2) determined to be the\n // best solution in a regex-golf we did a couple of ages ago at\n // * http://mathiasbynens.be/demo/url-regex\n // * http://rodneyrehm.de/t/url-regex.html\n URI.find_uri_expression = /\\b((?:[a-z][\\w-]+:(?:\\/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}\\/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]))/ig;\n URI.findUri = {\n // valid \"scheme://\" or \"www.\"\n start: /\\b(?:([a-z][a-z0-9.+-]*:\\/\\/)|www\\.)/gi,\n // everything up to the next whitespace\n end: /[\\s\\r\\n]|$/,\n // trim trailing punctuation captured by end RegExp\n trim: /[`!()\\[\\]{};:'\".,<>?\u00AB\u00BB\u201C\u201D\u201E\u2018\u2019]+$/,\n // balanced parens inclusion (), [], {}, <>\n parens: /(\\([^\\)]*\\)|\\[[^\\]]*\\]|\\{[^}]*\\}|<[^>]*>)/g,\n };\n URI.leading_whitespace_expression = /^[\\x00-\\x20\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]+/\n // https://infra.spec.whatwg.org/#ascii-tab-or-newline\n URI.ascii_tab_whitespace = /[\\u0009\\u000A\\u000D]+/g\n // http://www.iana.org/assignments/uri-schemes.html\n // http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports\n URI.defaultPorts = {\n http: '80',\n https: '443',\n ftp: '21',\n gopher: '70',\n ws: '80',\n wss: '443'\n };\n // list of protocols which always require a hostname\n URI.hostProtocols = [\n 'http',\n 'https'\n ];\n\n // allowed hostname characters according to RFC 3986\n // ALPHA DIGIT \"-\" \".\" \"_\" \"~\" \"!\" \"$\" \"&\" \"'\" \"(\" \")\" \"*\" \"+\" \",\" \";\" \"=\" %encoded\n // I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . - _\n URI.invalid_hostname_characters = /[^a-zA-Z0-9\\.\\-:_]/;\n // map DOM Elements to their URI attribute\n URI.domAttributes = {\n 'a': 'href',\n 'blockquote': 'cite',\n 'link': 'href',\n 'base': 'href',\n 'script': 'src',\n 'form': 'action',\n 'img': 'src',\n 'area': 'href',\n 'iframe': 'src',\n 'embed': 'src',\n 'source': 'src',\n 'track': 'src',\n 'input': 'src', // but only if type=\"image\"\n 'audio': 'src',\n 'video': 'src'\n };\n URI.getDomAttribute = function(node) {\n if (!node || !node.nodeName) {\n return undefined;\n }\n\n var nodeName = node.nodeName.toLowerCase();\n // should only expose src for type=\"image\"\n if (nodeName === 'input' && node.type !== 'image') {\n return undefined;\n }\n\n return URI.domAttributes[nodeName];\n };\n\n function escapeForDumbFirefox36(value) {\n // https://github.com/medialize/URI.js/issues/91\n return escape(value);\n }\n\n // encoding / decoding according to RFC3986\n function strictEncodeURIComponent(string) {\n // see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent\n return encodeURIComponent(string)\n .replace(/[!'()*]/g, escapeForDumbFirefox36)\n .replace(/\\*/g, '%2A');\n }\n URI.encode = strictEncodeURIComponent;\n URI.decode = decodeURIComponent;\n URI.iso8859 = function() {\n URI.encode = escape;\n URI.decode = unescape;\n };\n URI.unicode = function() {\n URI.encode = strictEncodeURIComponent;\n URI.decode = decodeURIComponent;\n };\n URI.characters = {\n pathname: {\n encode: {\n // RFC3986 2.1: For consistency, URI producers and normalizers should\n // use uppercase hexadecimal digits for all percent-encodings.\n expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,\n map: {\n // -._~!'()*\n '%24': '$',\n '%26': '&',\n '%2B': '+',\n '%2C': ',',\n '%3B': ';',\n '%3D': '=',\n '%3A': ':',\n '%40': '@'\n }\n },\n decode: {\n expression: /[\\/\\?#]/g,\n map: {\n '/': '%2F',\n '?': '%3F',\n '#': '%23'\n }\n }\n },\n reserved: {\n encode: {\n // RFC3986 2.1: For consistency, URI producers and normalizers should\n // use uppercase hexadecimal digits for all percent-encodings.\n expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,\n map: {\n // gen-delims\n '%3A': ':',\n '%2F': '/',\n '%3F': '?',\n '%23': '#',\n '%5B': '[',\n '%5D': ']',\n '%40': '@',\n // sub-delims\n '%21': '!',\n '%24': '$',\n '%26': '&',\n '%27': '\\'',\n '%28': '(',\n '%29': ')',\n '%2A': '*',\n '%2B': '+',\n '%2C': ',',\n '%3B': ';',\n '%3D': '='\n }\n }\n },\n urnpath: {\n // The characters under `encode` are the characters called out by RFC 2141 as being acceptable\n // for usage in a URN. RFC2141 also calls out \"-\", \".\", and \"_\" as acceptable characters, but\n // these aren't encoded by encodeURIComponent, so we don't have to call them out here. Also\n // note that the colon character is not featured in the encoding map; this is because URI.js\n // gives the colons in URNs semantic meaning as the delimiters of path segements, and so it\n // should not appear unencoded in a segment itself.\n // See also the note above about RFC3986 and capitalalized hex digits.\n encode: {\n expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,\n map: {\n '%21': '!',\n '%24': '$',\n '%27': '\\'',\n '%28': '(',\n '%29': ')',\n '%2A': '*',\n '%2B': '+',\n '%2C': ',',\n '%3B': ';',\n '%3D': '=',\n '%40': '@'\n }\n },\n // These characters are the characters called out by RFC2141 as \"reserved\" characters that\n // should never appear in a URN, plus the colon character (see note above).\n decode: {\n expression: /[\\/\\?#:]/g,\n map: {\n '/': '%2F',\n '?': '%3F',\n '#': '%23',\n ':': '%3A'\n }\n }\n }\n };\n URI.encodeQuery = function(string, escapeQuerySpace) {\n var escaped = URI.encode(string + '');\n if (escapeQuerySpace === undefined) {\n escapeQuerySpace = URI.escapeQuerySpace;\n }\n\n return escapeQuerySpace ? escaped.replace(/%20/g, '+') : escaped;\n };\n URI.decodeQuery = function(string, escapeQuerySpace) {\n string += '';\n if (escapeQuerySpace === undefined) {\n escapeQuerySpace = URI.escapeQuerySpace;\n }\n\n try {\n return URI.decode(escapeQuerySpace ? string.replace(/\\+/g, '%20') : string);\n } catch(e) {\n // we're not going to mess with weird encodings,\n // give up and return the undecoded original string\n // see https://github.com/medialize/URI.js/issues/87\n // see https://github.com/medialize/URI.js/issues/92\n return string;\n }\n };\n // generate encode/decode path functions\n var _parts = {'encode':'encode', 'decode':'decode'};\n var _part;\n var generateAccessor = function(_group, _part) {\n return function(string) {\n try {\n return URI[_part](string + '').replace(URI.characters[_group][_part].expression, function(c) {\n return URI.characters[_group][_part].map[c];\n });\n } catch (e) {\n // we're not going to mess with weird encodings,\n // give up and return the undecoded original string\n // see https://github.com/medialize/URI.js/issues/87\n // see https://github.com/medialize/URI.js/issues/92\n return string;\n }\n };\n };\n\n for (_part in _parts) {\n URI[_part + 'PathSegment'] = generateAccessor('pathname', _parts[_part]);\n URI[_part + 'UrnPathSegment'] = generateAccessor('urnpath', _parts[_part]);\n }\n\n var generateSegmentedPathFunction = function(_sep, _codingFuncName, _innerCodingFuncName) {\n return function(string) {\n // Why pass in names of functions, rather than the function objects themselves? The\n // definitions of some functions (but in particular, URI.decode) will occasionally change due\n // to URI.js having ISO8859 and Unicode modes. Passing in the name and getting it will ensure\n // that the functions we use here are \"fresh\".\n var actualCodingFunc;\n if (!_innerCodingFuncName) {\n actualCodingFunc = URI[_codingFuncName];\n } else {\n actualCodingFunc = function(string) {\n return URI[_codingFuncName](URI[_innerCodingFuncName](string));\n };\n }\n\n var segments = (string + '').split(_sep);\n\n for (var i = 0, length = segments.length; i < length; i++) {\n segments[i] = actualCodingFunc(segments[i]);\n }\n\n return segments.join(_sep);\n };\n };\n\n // This takes place outside the above loop because we don't want, e.g., encodeUrnPath functions.\n URI.decodePath = generateSegmentedPathFunction('/', 'decodePathSegment');\n URI.decodeUrnPath = generateSegmentedPathFunction(':', 'decodeUrnPathSegment');\n URI.recodePath = generateSegmentedPathFunction('/', 'encodePathSegment', 'decode');\n URI.recodeUrnPath = generateSegmentedPathFunction(':', 'encodeUrnPathSegment', 'decode');\n\n URI.encodeReserved = generateAccessor('reserved', 'encode');\n\n URI.parse = function(string, parts) {\n var pos;\n if (!parts) {\n parts = {\n preventInvalidHostname: URI.preventInvalidHostname\n };\n }\n\n string = string.replace(URI.leading_whitespace_expression, '')\n // https://infra.spec.whatwg.org/#ascii-tab-or-newline\n string = string.replace(URI.ascii_tab_whitespace, '')\n\n // [protocol\"://\"[username[\":\"password]\"@\"]hostname[\":\"port]\"/\"?][path][\"?\"querystring][\"#\"fragment]\n\n // extract fragment\n pos = string.indexOf('#');\n if (pos > -1) {\n // escaping?\n parts.fragment = string.substring(pos + 1) || null;\n string = string.substring(0, pos);\n }\n\n // extract query\n pos = string.indexOf('?');\n if (pos > -1) {\n // escaping?\n parts.query = string.substring(pos + 1) || null;\n string = string.substring(0, pos);\n }\n\n // slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws)\n string = string.replace(/^(https?|ftp|wss?)?:+[/\\\\]*/i, '$1://');\n // slashes and backslashes have lost all meaning for scheme relative URLs\n string = string.replace(/^[/\\\\]{2,}/i, '//');\n\n // extract protocol\n if (string.substring(0, 2) === '//') {\n // relative-scheme\n parts.protocol = null;\n string = string.substring(2);\n // extract \"user:pass@host:port\"\n string = URI.parseAuthority(string, parts);\n } else {\n pos = string.indexOf(':');\n if (pos > -1) {\n parts.protocol = string.substring(0, pos) || null;\n if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {\n // : may be within the path\n parts.protocol = undefined;\n } else if (string.substring(pos + 1, pos + 3).replace(/\\\\/g, '/') === '//') {\n string = string.substring(pos + 3);\n\n // extract \"user:pass@host:port\"\n string = URI.parseAuthority(string, parts);\n } else {\n string = string.substring(pos + 1);\n parts.urn = true;\n }\n }\n }\n\n // what's left must be the path\n parts.path = string;\n\n // and we're done\n return parts;\n };\n URI.parseHost = function(string, parts) {\n if (!string) {\n string = '';\n }\n\n // Copy chrome, IE, opera backslash-handling behavior.\n // Back slashes before the query string get converted to forward slashes\n // See: https://github.com/joyent/node/blob/386fd24f49b0e9d1a8a076592a404168faeecc34/lib/url.js#L115-L124\n // See: https://code.google.com/p/chromium/issues/detail?id=25916\n // https://github.com/medialize/URI.js/pull/233\n string = string.replace(/\\\\/g, '/');\n\n // extract host:port\n var pos = string.indexOf('/');\n var bracketPos;\n var t;\n\n if (pos === -1) {\n pos = string.length;\n }\n\n if (string.charAt(0) === '[') {\n // IPv6 host - http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04#section-6\n // I claim most client software breaks on IPv6 anyways. To simplify things, URI only accepts\n // IPv6+port in the format [2001:db8::1]:80 (for the time being)\n bracketPos = string.indexOf(']');\n parts.hostname = string.substring(1, bracketPos) || null;\n parts.port = string.substring(bracketPos + 2, pos) || null;\n if (parts.port === '/') {\n parts.port = null;\n }\n } else {\n var firstColon = string.indexOf(':');\n var firstSlash = string.indexOf('/');\n var nextColon = string.indexOf(':', firstColon + 1);\n if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {\n // IPv6 host contains multiple colons - but no port\n // this notation is actually not allowed by RFC 3986, but we're a liberal parser\n parts.hostname = string.substring(0, pos) || null;\n parts.port = null;\n } else {\n t = string.substring(0, pos).split(':');\n parts.hostname = t[0] || null;\n parts.port = t[1] || null;\n }\n }\n\n if (parts.hostname && string.substring(pos).charAt(0) !== '/') {\n pos++;\n string = '/' + string;\n }\n\n if (parts.preventInvalidHostname) {\n URI.ensureValidHostname(parts.hostname, parts.protocol);\n }\n\n if (parts.port) {\n URI.ensureValidPort(parts.port);\n }\n\n return string.substring(pos) || '/';\n };\n URI.parseAuthority = function(string, parts) {\n string = URI.parseUserinfo(string, parts);\n return URI.parseHost(string, parts);\n };\n URI.parseUserinfo = function(string, parts) {\n // extract username:password\n var _string = string\n var firstBackSlash = string.indexOf('\\\\');\n if (firstBackSlash !== -1) {\n string = string.replace(/\\\\/g, '/')\n }\n var firstSlash = string.indexOf('/');\n var pos = string.lastIndexOf('@', firstSlash > -1 ? firstSlash : string.length - 1);\n var t;\n\n // authority@ must come before /path or \\path\n if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {\n t = string.substring(0, pos).split(':');\n parts.username = t[0] ? URI.decode(t[0]) : null;\n t.shift();\n parts.password = t[0] ? URI.decode(t.join(':')) : null;\n string = _string.substring(pos + 1);\n } else {\n parts.username = null;\n parts.password = null;\n }\n\n return string;\n };\n URI.parseQuery = function(string, escapeQuerySpace) {\n if (!string) {\n return {};\n }\n\n // throw out the funky business - \"?\"[name\"=\"value\"&\"]+\n string = string.replace(/&+/g, '&').replace(/^\\?*&*|&+$/g, '');\n\n if (!string) {\n return {};\n }\n\n var items = {};\n var splits = string.split('&');\n var length = splits.length;\n var v, name, value;\n\n for (var i = 0; i < length; i++) {\n v = splits[i].split('=');\n name = URI.decodeQuery(v.shift(), escapeQuerySpace);\n // no \"=\" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters\n value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null;\n\n if (name === '__proto__') {\n // ignore attempt at exploiting JavaScript internals\n continue;\n } else if (hasOwn.call(items, name)) {\n if (typeof items[name] === 'string' || items[name] === null) {\n items[name] = [items[name]];\n }\n\n items[name].push(value);\n } else {\n items[name] = value;\n }\n }\n\n return items;\n };\n\n URI.build = function(parts) {\n var t = '';\n var requireAbsolutePath = false\n\n if (parts.protocol) {\n t += parts.protocol + ':';\n }\n\n if (!parts.urn && (t || parts.hostname)) {\n t += '//';\n requireAbsolutePath = true\n }\n\n t += (URI.buildAuthority(parts) || '');\n\n if (typeof parts.path === 'string') {\n if (parts.path.charAt(0) !== '/' && requireAbsolutePath) {\n t += '/';\n }\n\n t += parts.path;\n }\n\n if (typeof parts.query === 'string' && parts.query) {\n t += '?' + parts.query;\n }\n\n if (typeof parts.fragment === 'string' && parts.fragment) {\n t += '#' + parts.fragment;\n }\n return t;\n };\n URI.buildHost = function(parts) {\n var t = '';\n\n if (!parts.hostname) {\n return '';\n } else if (URI.ip6_expression.test(parts.hostname)) {\n t += '[' + parts.hostname + ']';\n } else {\n t += parts.hostname;\n }\n\n if (parts.port) {\n t += ':' + parts.port;\n }\n\n return t;\n };\n URI.buildAuthority = function(parts) {\n return URI.buildUserinfo(parts) + URI.buildHost(parts);\n };\n URI.buildUserinfo = function(parts) {\n var t = '';\n\n if (parts.username) {\n t += URI.encode(parts.username);\n }\n\n if (parts.password) {\n t += ':' + URI.encode(parts.password);\n }\n\n if (t) {\n t += '@';\n }\n\n return t;\n };\n URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) {\n // according to http://tools.ietf.org/html/rfc3986 or http://labs.apache.org/webarch/uri/rfc/rfc3986.html\n // being \u00BB-._~!$&'()*+,;=:@/?\u00AB %HEX and alnum are allowed\n // the RFC explicitly states ?/foo being a valid use case, no mention of parameter syntax!\n // URI.js treats the query string as being application/x-www-form-urlencoded\n // see http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type\n\n var t = '';\n var unique, key, i, length;\n for (key in data) {\n if (key === '__proto__') {\n // ignore attempt at exploiting JavaScript internals\n continue;\n } else if (hasOwn.call(data, key)) {\n if (isArray(data[key])) {\n unique = {};\n for (i = 0, length = data[key].length; i < length; i++) {\n if (data[key][i] !== undefined && unique[data[key][i] + ''] === undefined) {\n t += '&' + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);\n if (duplicateQueryParameters !== true) {\n unique[data[key][i] + ''] = true;\n }\n }\n }\n } else if (data[key] !== undefined) {\n t += '&' + URI.buildQueryParameter(key, data[key], escapeQuerySpace);\n }\n }\n }\n\n return t.substring(1);\n };\n URI.buildQueryParameter = function(name, value, escapeQuerySpace) {\n // http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type -- application/x-www-form-urlencoded\n // don't append \"=\" for null values, according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization\n return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? '=' + URI.encodeQuery(value, escapeQuerySpace) : '');\n };\n\n URI.addQuery = function(data, name, value) {\n if (typeof name === 'object') {\n for (var key in name) {\n if (hasOwn.call(name, key)) {\n URI.addQuery(data, key, name[key]);\n }\n }\n } else if (typeof name === 'string') {\n if (data[name] === undefined) {\n data[name] = value;\n return;\n } else if (typeof data[name] === 'string') {\n data[name] = [data[name]];\n }\n\n if (!isArray(value)) {\n value = [value];\n }\n\n data[name] = (data[name] || []).concat(value);\n } else {\n throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');\n }\n };\n\n URI.setQuery = function(data, name, value) {\n if (typeof name === 'object') {\n for (var key in name) {\n if (hasOwn.call(name, key)) {\n URI.setQuery(data, key, name[key]);\n }\n }\n } else if (typeof name === 'string') {\n data[name] = value === undefined ? null : value;\n } else {\n throw new TypeError('URI.setQuery() accepts an object, string as the name parameter');\n }\n };\n\n URI.removeQuery = function(data, name, value) {\n var i, length, key;\n\n if (isArray(name)) {\n for (i = 0, length = name.length; i < length; i++) {\n data[name[i]] = undefined;\n }\n } else if (getType(name) === 'RegExp') {\n for (key in data) {\n if (name.test(key)) {\n data[key] = undefined;\n }\n }\n } else if (typeof name === 'object') {\n for (key in name) {\n if (hasOwn.call(name, key)) {\n URI.removeQuery(data, key, name[key]);\n }\n }\n } else if (typeof name === 'string') {\n if (value !== undefined) {\n if (getType(value) === 'RegExp') {\n if (!isArray(data[name]) && value.test(data[name])) {\n data[name] = undefined;\n } else {\n data[name] = filterArrayValues(data[name], value);\n }\n } else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {\n data[name] = undefined;\n } else if (isArray(data[name])) {\n data[name] = filterArrayValues(data[name], value);\n }\n } else {\n data[name] = undefined;\n }\n } else {\n throw new TypeError('URI.removeQuery() accepts an object, string, RegExp as the first parameter');\n }\n };\n URI.hasQuery = function(data, name, value, withinArray) {\n switch (getType(name)) {\n case 'String':\n // Nothing to do here\n break;\n\n case 'RegExp':\n for (var key in data) {\n if (hasOwn.call(data, key)) {\n if (name.test(key) && (value === undefined || URI.hasQuery(data, key, value))) {\n return true;\n }\n }\n }\n\n return false;\n\n case 'Object':\n for (var _key in name) {\n if (hasOwn.call(name, _key)) {\n if (!URI.hasQuery(data, _key, name[_key])) {\n return false;\n }\n }\n }\n\n return true;\n\n default:\n throw new TypeError('URI.hasQuery() accepts a string, regular expression or object as the name parameter');\n }\n\n switch (getType(value)) {\n case 'Undefined':\n // true if exists (but may be empty)\n return name in data; // data[name] !== undefined;\n\n case 'Boolean':\n // true if exists and non-empty\n var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);\n return value === _booly;\n\n case 'Function':\n // allow complex comparison\n return !!value(data[name], name, data);\n\n case 'Array':\n if (!isArray(data[name])) {\n return false;\n }\n\n var op = withinArray ? arrayContains : arraysEqual;\n return op(data[name], value);\n\n case 'RegExp':\n if (!isArray(data[name])) {\n return Boolean(data[name] && data[name].match(value));\n }\n\n if (!withinArray) {\n return false;\n }\n\n return arrayContains(data[name], value);\n\n case 'Number':\n value = String(value);\n /* falls through */\n case 'String':\n if (!isArray(data[name])) {\n return data[name] === value;\n }\n\n if (!withinArray) {\n return false;\n }\n\n return arrayContains(data[name], value);\n\n default:\n throw new TypeError('URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter');\n }\n };\n\n\n URI.joinPaths = function() {\n var input = [];\n var segments = [];\n var nonEmptySegments = 0;\n\n for (var i = 0; i < arguments.length; i++) {\n var url = new URI(arguments[i]);\n input.push(url);\n var _segments = url.segment();\n for (var s = 0; s < _segments.length; s++) {\n if (typeof _segments[s] === 'string') {\n segments.push(_segments[s]);\n }\n\n if (_segments[s]) {\n nonEmptySegments++;\n }\n }\n }\n\n if (!segments.length || !nonEmptySegments) {\n return new URI('');\n }\n\n var uri = new URI('').segment(segments);\n\n if (input[0].path() === '' || input[0].path().slice(0, 1) === '/') {\n uri.path('/' + uri.path());\n }\n\n return uri.normalize();\n };\n\n URI.commonPath = function(one, two) {\n var length = Math.min(one.length, two.length);\n var pos;\n\n // find first non-matching character\n for (pos = 0; pos < length; pos++) {\n if (one.charAt(pos) !== two.charAt(pos)) {\n pos--;\n break;\n }\n }\n\n if (pos < 1) {\n return one.charAt(0) === two.charAt(0) && one.charAt(0) === '/' ? '/' : '';\n }\n\n // revert to last /\n if (one.charAt(pos) !== '/' || two.charAt(pos) !== '/') {\n pos = one.substring(0, pos).lastIndexOf('/');\n }\n\n return one.substring(0, pos + 1);\n };\n\n URI.withinString = function(string, callback, options) {\n options || (options = {});\n var _start = options.start || URI.findUri.start;\n var _end = options.end || URI.findUri.end;\n var _trim = options.trim || URI.findUri.trim;\n var _parens = options.parens || URI.findUri.parens;\n var _attributeOpen = /[a-z0-9-]=[\"']?$/i;\n\n _start.lastIndex = 0;\n while (true) {\n var match = _start.exec(string);\n if (!match) {\n break;\n }\n\n var start = match.index;\n if (options.ignoreHtml) {\n // attribut(e=[\"']?$)\n var attributeOpen = string.slice(Math.max(start - 3, 0), start);\n if (attributeOpen && _attributeOpen.test(attributeOpen)) {\n continue;\n }\n }\n\n var end = start + string.slice(start).search(_end);\n var slice = string.slice(start, end);\n // make sure we include well balanced parens\n var parensEnd = -1;\n while (true) {\n var parensMatch = _parens.exec(slice);\n if (!parensMatch) {\n break;\n }\n\n var parensMatchEnd = parensMatch.index + parensMatch[0].length;\n parensEnd = Math.max(parensEnd, parensMatchEnd);\n }\n\n if (parensEnd > -1) {\n slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, '');\n } else {\n slice = slice.replace(_trim, '');\n }\n\n if (slice.length <= match[0].length) {\n // the extract only contains the starting marker of a URI,\n // e.g. \"www\" or \"http://\"\n continue;\n }\n\n if (options.ignore && options.ignore.test(slice)) {\n continue;\n }\n\n end = start + slice.length;\n var result = callback(slice, start, end, string);\n if (result === undefined) {\n _start.lastIndex = end;\n continue;\n }\n\n result = String(result);\n string = string.slice(0, start) + result + string.slice(end);\n _start.lastIndex = start + result.length;\n }\n\n _start.lastIndex = 0;\n return string;\n };\n\n URI.ensureValidHostname = function(v, protocol) {\n // Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986)\n // they are not part of DNS and therefore ignored by URI.js\n\n var hasHostname = !!v; // not null and not an empty string\n var hasProtocol = !!protocol;\n var rejectEmptyHostname = false;\n\n if (hasProtocol) {\n rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);\n }\n\n if (rejectEmptyHostname && !hasHostname) {\n throw new TypeError('Hostname cannot be empty, if protocol is ' + protocol);\n } else if (v && v.match(URI.invalid_hostname_characters)) {\n // test punycode\n if (!punycode) {\n throw new TypeError('Hostname \"' + v + '\" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');\n }\n if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {\n throw new TypeError('Hostname \"' + v + '\" contains characters other than [A-Z0-9.-:_]');\n }\n }\n };\n\n URI.ensureValidPort = function (v) {\n if (!v) {\n return;\n }\n\n var port = Number(v);\n if (isInteger(port) && (port > 0) && (port < 65536)) {\n return;\n }\n\n throw new TypeError('Port \"' + v + '\" is not a valid port');\n };\n\n // noConflict\n URI.noConflict = function(removeAll) {\n if (removeAll) {\n var unconflicted = {\n URI: this.noConflict()\n };\n\n if (root.URITemplate && typeof root.URITemplate.noConflict === 'function') {\n unconflicted.URITemplate = root.URITemplate.noConflict();\n }\n\n if (root.IPv6 && typeof root.IPv6.noConflict === 'function') {\n unconflicted.IPv6 = root.IPv6.noConflict();\n }\n\n if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === 'function') {\n unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict();\n }\n\n return unconflicted;\n } else if (root.URI === this) {\n root.URI = _URI;\n }\n\n return this;\n };\n\n p.build = function(deferBuild) {\n if (deferBuild === true) {\n this._deferred_build = true;\n } else if (deferBuild === undefined || this._deferred_build) {\n this._string = URI.build(this._parts);\n this._deferred_build = false;\n }\n\n return this;\n };\n\n p.clone = function() {\n return new URI(this);\n };\n\n p.valueOf = p.toString = function() {\n return this.build(false)._string;\n };\n\n\n function generateSimpleAccessor(_part){\n return function(v, build) {\n if (v === undefined) {\n return this._parts[_part] || '';\n } else {\n this._parts[_part] = v || null;\n this.build(!build);\n return this;\n }\n };\n }\n\n function generatePrefixAccessor(_part, _key){\n return function(v, build) {\n if (v === undefined) {\n return this._parts[_part] || '';\n } else {\n if (v !== null) {\n v = v + '';\n if (v.charAt(0) === _key) {\n v = v.substring(1);\n }\n }\n\n this._parts[_part] = v;\n this.build(!build);\n return this;\n }\n };\n }\n\n p.protocol = generateSimpleAccessor('protocol');\n p.username = generateSimpleAccessor('username');\n p.password = generateSimpleAccessor('password');\n p.hostname = generateSimpleAccessor('hostname');\n p.port = generateSimpleAccessor('port');\n p.query = generatePrefixAccessor('query', '?');\n p.fragment = generatePrefixAccessor('fragment', '#');\n\n p.search = function(v, build) {\n var t = this.query(v, build);\n return typeof t === 'string' && t.length ? ('?' + t) : t;\n };\n p.hash = function(v, build) {\n var t = this.fragment(v, build);\n return typeof t === 'string' && t.length ? ('#' + t) : t;\n };\n\n p.pathname = function(v, build) {\n if (v === undefined || v === true) {\n var res = this._parts.path || (this._parts.hostname ? '/' : '');\n return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;\n } else {\n if (this._parts.urn) {\n this._parts.path = v ? URI.recodeUrnPath(v) : '';\n } else {\n this._parts.path = v ? URI.recodePath(v) : '/';\n }\n this.build(!build);\n return this;\n }\n };\n p.path = p.pathname;\n p.href = function(href, build) {\n var key;\n\n if (href === undefined) {\n return this.toString();\n }\n\n this._string = '';\n this._parts = URI._parts();\n\n var _URI = href instanceof URI;\n var _object = typeof href === 'object' && (href.hostname || href.path || href.pathname);\n if (href.nodeName) {\n var attribute = URI.getDomAttribute(href);\n href = href[attribute] || '';\n _object = false;\n }\n\n // window.location is reported to be an object, but it's not the sort\n // of object we're looking for:\n // * location.protocol ends with a colon\n // * location.query != object.search\n // * location.hash != object.fragment\n // simply serializing the unknown object should do the trick\n // (for location, not for everything...)\n if (!_URI && _object && href.pathname !== undefined) {\n href = href.toString();\n }\n\n if (typeof href === 'string' || href instanceof String) {\n this._parts = URI.parse(String(href), this._parts);\n } else if (_URI || _object) {\n var src = _URI ? href._parts : href;\n for (key in src) {\n if (key === 'query') { continue; }\n if (hasOwn.call(this._parts, key)) {\n this._parts[key] = src[key];\n }\n }\n if (src.query) {\n this.query(src.query, false);\n }\n } else {\n throw new TypeError('invalid input');\n }\n\n this.build(!build);\n return this;\n };\n\n // identification accessors\n p.is = function(what) {\n var ip = false;\n var ip4 = false;\n var ip6 = false;\n var name = false;\n var sld = false;\n var idn = false;\n var punycode = false;\n var relative = !this._parts.urn;\n\n if (this._parts.hostname) {\n relative = false;\n ip4 = URI.ip4_expression.test(this._parts.hostname);\n ip6 = URI.ip6_expression.test(this._parts.hostname);\n ip = ip4 || ip6;\n name = !ip;\n sld = name && SLD && SLD.has(this._parts.hostname);\n idn = name && URI.idn_expression.test(this._parts.hostname);\n punycode = name && URI.punycode_expression.test(this._parts.hostname);\n }\n\n switch (what.toLowerCase()) {\n case 'relative':\n return relative;\n\n case 'absolute':\n return !relative;\n\n // hostname identification\n case 'domain':\n case 'name':\n return name;\n\n case 'sld':\n return sld;\n\n case 'ip':\n return ip;\n\n case 'ip4':\n case 'ipv4':\n case 'inet4':\n return ip4;\n\n case 'ip6':\n case 'ipv6':\n case 'inet6':\n return ip6;\n\n case 'idn':\n return idn;\n\n case 'url':\n return !this._parts.urn;\n\n case 'urn':\n return !!this._parts.urn;\n\n case 'punycode':\n return punycode;\n }\n\n return null;\n };\n\n // component specific input validation\n var _protocol = p.protocol;\n var _port = p.port;\n var _hostname = p.hostname;\n\n p.protocol = function(v, build) {\n if (v) {\n // accept trailing ://\n v = v.replace(/:(\\/\\/)?$/, '');\n\n if (!v.match(URI.protocol_expression)) {\n throw new TypeError('Protocol \"' + v + '\" contains characters other than [A-Z0-9.+-] or doesn\\'t start with [A-Z]');\n }\n }\n\n return _protocol.call(this, v, build);\n };\n p.scheme = p.protocol;\n p.port = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v !== undefined) {\n if (v === 0) {\n v = null;\n }\n\n if (v) {\n v += '';\n if (v.charAt(0) === ':') {\n v = v.substring(1);\n }\n\n URI.ensureValidPort(v);\n }\n }\n return _port.call(this, v, build);\n };\n p.hostname = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v !== undefined) {\n var x = { preventInvalidHostname: this._parts.preventInvalidHostname };\n var res = URI.parseHost(v, x);\n if (res !== '/') {\n throw new TypeError('Hostname \"' + v + '\" contains characters other than [A-Z0-9.-]');\n }\n\n v = x.hostname;\n if (this._parts.preventInvalidHostname) {\n URI.ensureValidHostname(v, this._parts.protocol);\n }\n }\n\n return _hostname.call(this, v, build);\n };\n\n // compound accessors\n p.origin = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v === undefined) {\n var protocol = this.protocol();\n var authority = this.authority();\n if (!authority) {\n return '';\n }\n\n return (protocol ? protocol + '://' : '') + this.authority();\n } else {\n var origin = URI(v);\n this\n .protocol(origin.protocol())\n .authority(origin.authority())\n .build(!build);\n return this;\n }\n };\n p.host = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v === undefined) {\n return this._parts.hostname ? URI.buildHost(this._parts) : '';\n } else {\n var res = URI.parseHost(v, this._parts);\n if (res !== '/') {\n throw new TypeError('Hostname \"' + v + '\" contains characters other than [A-Z0-9.-]');\n }\n\n this.build(!build);\n return this;\n }\n };\n p.authority = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v === undefined) {\n return this._parts.hostname ? URI.buildAuthority(this._parts) : '';\n } else {\n var res = URI.parseAuthority(v, this._parts);\n if (res !== '/') {\n throw new TypeError('Hostname \"' + v + '\" contains characters other than [A-Z0-9.-]');\n }\n\n this.build(!build);\n return this;\n }\n };\n p.userinfo = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v === undefined) {\n var t = URI.buildUserinfo(this._parts);\n return t ? t.substring(0, t.length -1) : t;\n } else {\n if (v[v.length-1] !== '@') {\n v += '@';\n }\n\n URI.parseUserinfo(v, this._parts);\n this.build(!build);\n return this;\n }\n };\n p.resource = function(v, build) {\n var parts;\n\n if (v === undefined) {\n return this.path() + this.search() + this.hash();\n }\n\n parts = URI.parse(v);\n this._parts.path = parts.path;\n this._parts.query = parts.query;\n this._parts.fragment = parts.fragment;\n this.build(!build);\n return this;\n };\n\n // fraction accessors\n p.subdomain = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n // convenience, return \"www\" from \"www.example.org\"\n if (v === undefined) {\n if (!this._parts.hostname || this.is('IP')) {\n return '';\n }\n\n // grab domain and add another segment\n var end = this._parts.hostname.length - this.domain().length - 1;\n return this._parts.hostname.substring(0, end) || '';\n } else {\n var e = this._parts.hostname.length - this.domain().length;\n var sub = this._parts.hostname.substring(0, e);\n var replace = new RegExp('^' + escapeRegEx(sub));\n\n if (v && v.charAt(v.length - 1) !== '.') {\n v += '.';\n }\n\n if (v.indexOf(':') !== -1) {\n throw new TypeError('Domains cannot contain colons');\n }\n\n if (v) {\n URI.ensureValidHostname(v, this._parts.protocol);\n }\n\n this._parts.hostname = this._parts.hostname.replace(replace, v);\n this.build(!build);\n return this;\n }\n };\n p.domain = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (typeof v === 'boolean') {\n build = v;\n v = undefined;\n }\n\n // convenience, return \"example.org\" from \"www.example.org\"\n if (v === undefined) {\n if (!this._parts.hostname || this.is('IP')) {\n return '';\n }\n\n // if hostname consists of 1 or 2 segments, it must be the domain\n var t = this._parts.hostname.match(/\\./g);\n if (t && t.length < 2) {\n return this._parts.hostname;\n }\n\n // grab tld and add another segment\n var end = this._parts.hostname.length - this.tld(build).length - 1;\n end = this._parts.hostname.lastIndexOf('.', end -1) + 1;\n return this._parts.hostname.substring(end) || '';\n } else {\n if (!v) {\n throw new TypeError('cannot set domain empty');\n }\n\n if (v.indexOf(':') !== -1) {\n throw new TypeError('Domains cannot contain colons');\n }\n\n URI.ensureValidHostname(v, this._parts.protocol);\n\n if (!this._parts.hostname || this.is('IP')) {\n this._parts.hostname = v;\n } else {\n var replace = new RegExp(escapeRegEx(this.domain()) + '$');\n this._parts.hostname = this._parts.hostname.replace(replace, v);\n }\n\n this.build(!build);\n return this;\n }\n };\n p.tld = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (typeof v === 'boolean') {\n build = v;\n v = undefined;\n }\n\n // return \"org\" from \"www.example.org\"\n if (v === undefined) {\n if (!this._parts.hostname || this.is('IP')) {\n return '';\n }\n\n var pos = this._parts.hostname.lastIndexOf('.');\n var tld = this._parts.hostname.substring(pos + 1);\n\n if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {\n return SLD.get(this._parts.hostname) || tld;\n }\n\n return tld;\n } else {\n var replace;\n\n if (!v) {\n throw new TypeError('cannot set TLD empty');\n } else if (v.match(/[^a-zA-Z0-9-]/)) {\n if (SLD && SLD.is(v)) {\n replace = new RegExp(escapeRegEx(this.tld()) + '$');\n this._parts.hostname = this._parts.hostname.replace(replace, v);\n } else {\n throw new TypeError('TLD \"' + v + '\" contains characters other than [A-Z0-9]');\n }\n } else if (!this._parts.hostname || this.is('IP')) {\n throw new ReferenceError('cannot set TLD on non-domain host');\n } else {\n replace = new RegExp(escapeRegEx(this.tld()) + '$');\n this._parts.hostname = this._parts.hostname.replace(replace, v);\n }\n\n this.build(!build);\n return this;\n }\n };\n p.directory = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v === undefined || v === true) {\n if (!this._parts.path && !this._parts.hostname) {\n return '';\n }\n\n if (this._parts.path === '/') {\n return '/';\n }\n\n var end = this._parts.path.length - this.filename().length - 1;\n var res = this._parts.path.substring(0, end) || (this._parts.hostname ? '/' : '');\n\n return v ? URI.decodePath(res) : res;\n\n } else {\n var e = this._parts.path.length - this.filename().length;\n var directory = this._parts.path.substring(0, e);\n var replace = new RegExp('^' + escapeRegEx(directory));\n\n // fully qualifier directories begin with a slash\n if (!this.is('relative')) {\n if (!v) {\n v = '/';\n }\n\n if (v.charAt(0) !== '/') {\n v = '/' + v;\n }\n }\n\n // directories always end with a slash\n if (v && v.charAt(v.length - 1) !== '/') {\n v += '/';\n }\n\n v = URI.recodePath(v);\n this._parts.path = this._parts.path.replace(replace, v);\n this.build(!build);\n return this;\n }\n };\n p.filename = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (typeof v !== 'string') {\n if (!this._parts.path || this._parts.path === '/') {\n return '';\n }\n\n var pos = this._parts.path.lastIndexOf('/');\n var res = this._parts.path.substring(pos+1);\n\n return v ? URI.decodePathSegment(res) : res;\n } else {\n var mutatedDirectory = false;\n\n if (v.charAt(0) === '/') {\n v = v.substring(1);\n }\n\n if (v.match(/\\.?\\//)) {\n mutatedDirectory = true;\n }\n\n var replace = new RegExp(escapeRegEx(this.filename()) + '$');\n v = URI.recodePath(v);\n this._parts.path = this._parts.path.replace(replace, v);\n\n if (mutatedDirectory) {\n this.normalizePath(build);\n } else {\n this.build(!build);\n }\n\n return this;\n }\n };\n p.suffix = function(v, build) {\n if (this._parts.urn) {\n return v === undefined ? '' : this;\n }\n\n if (v === undefined || v === true) {\n if (!this._parts.path || this._parts.path === '/') {\n return '';\n }\n\n var filename = this.filename();\n var pos = filename.lastIndexOf('.');\n var s, res;\n\n if (pos === -1) {\n return '';\n }\n\n // suffix may only contain alnum characters (yup, I made this up.)\n s = filename.substring(pos+1);\n res = (/^[a-z0-9%]+$/i).test(s) ? s : '';\n return v ? URI.decodePathSegment(res) : res;\n } else {\n if (v.charAt(0) === '.') {\n v = v.substring(1);\n }\n\n var suffix = this.suffix();\n var replace;\n\n if (!suffix) {\n if (!v) {\n return this;\n }\n\n this._parts.path += '.' + URI.recodePath(v);\n } else if (!v) {\n replace = new RegExp(escapeRegEx('.' + suffix) + '$');\n } else {\n replace = new RegExp(escapeRegEx(suffix) + '$');\n }\n\n if (replace) {\n v = URI.recodePath(v);\n this._parts.path = this._parts.path.replace(replace, v);\n }\n\n this.build(!build);\n return this;\n }\n };\n p.segment = function(segment, v, build) {\n var separator = this._parts.urn ? ':' : '/';\n var path = this.path();\n var absolute = path.substring(0, 1) === '/';\n var segments = path.split(separator);\n\n if (segment !== undefined && typeof segment !== 'number') {\n build = v;\n v = segment;\n segment = undefined;\n }\n\n if (segment !== undefined && typeof segment !== 'number') {\n throw new Error('Bad segment \"' + segment + '\", must be 0-based integer');\n }\n\n if (absolute) {\n segments.shift();\n }\n\n if (segment < 0) {\n // allow negative indexes to address from the end\n segment = Math.max(segments.length + segment, 0);\n }\n\n if (v === undefined) {\n /*jshint laxbreak: true */\n return segment === undefined\n ? segments\n : segments[segment];\n /*jshint laxbreak: false */\n } else if (segment === null || segments[segment] === undefined) {\n if (isArray(v)) {\n segments = [];\n // collapse empty elements within array\n for (var i=0, l=v.length; i < l; i++) {\n if (!v[i].length && (!segments.length || !segments[segments.length -1].length)) {\n continue;\n }\n\n if (segments.length && !segments[segments.length -1].length) {\n segments.pop();\n }\n\n segments.push(trimSlashes(v[i]));\n }\n } else if (v || typeof v === 'string') {\n v = trimSlashes(v);\n if (segments[segments.length -1] === '') {\n // empty trailing elements have to be overwritten\n // to prevent results such as /foo//bar\n segments[segments.length -1] = v;\n } else {\n segments.push(v);\n }\n }\n } else {\n if (v) {\n segments[segment] = trimSlashes(v);\n } else {\n segments.splice(segment, 1);\n }\n }\n\n if (absolute) {\n segments.unshift('');\n }\n\n return this.path(segments.join(separator), build);\n };\n p.segmentCoded = function(segment, v, build) {\n var segments, i, l;\n\n if (typeof segment !== 'number') {\n build = v;\n v = segment;\n segment = undefined;\n }\n\n if (v === undefined) {\n segments = this.segment(segment, v, build);\n if (!isArray(segments)) {\n segments = segments !== undefined ? URI.decode(segments) : undefined;\n } else {\n for (i = 0, l = segments.length; i < l; i++) {\n segments[i] = URI.decode(segments[i]);\n }\n }\n\n return segments;\n }\n\n if (!isArray(v)) {\n v = (typeof v === 'string' || v instanceof String) ? URI.encode(v) : v;\n } else {\n for (i = 0, l = v.length; i < l; i++) {\n v[i] = URI.encode(v[i]);\n }\n }\n\n return this.segment(segment, v, build);\n };\n\n // mutating query string\n var q = p.query;\n p.query = function(v, build) {\n if (v === true) {\n return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);\n } else if (typeof v === 'function') {\n var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);\n var result = v.call(this, data);\n this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);\n this.build(!build);\n return this;\n } else if (v !== undefined && typeof v !== 'string') {\n this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);\n this.build(!build);\n return this;\n } else {\n return q.call(this, v, build);\n }\n };\n p.setQuery = function(name, value, build) {\n var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);\n\n if (typeof name === 'string' || name instanceof String) {\n data[name] = value !== undefined ? value : null;\n } else if (typeof name === 'object') {\n for (var key in name) {\n if (hasOwn.call(name, key)) {\n data[key] = name[key];\n }\n }\n } else {\n throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');\n }\n\n this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);\n if (typeof name !== 'string') {\n build = value;\n }\n\n this.build(!build);\n return this;\n };\n p.addQuery = function(name, value, build) {\n var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);\n URI.addQuery(data, name, value === undefined ? null : value);\n this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);\n if (typeof name !== 'string') {\n build = value;\n }\n\n this.build(!build);\n return this;\n };\n p.removeQuery = function(name, value, build) {\n var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);\n URI.removeQuery(data, name, value);\n this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);\n if (typeof name !== 'string') {\n build = value;\n }\n\n this.build(!build);\n return this;\n };\n p.hasQuery = function(name, value, withinArray) {\n var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);\n return URI.hasQuery(data, name, value, withinArray);\n };\n p.setSearch = p.setQuery;\n p.addSearch = p.addQuery;\n p.removeSearch = p.removeQuery;\n p.hasSearch = p.hasQuery;\n\n // sanitizing URLs\n p.normalize = function() {\n if (this._parts.urn) {\n return this\n .normalizeProtocol(false)\n .normalizePath(false)\n .normalizeQuery(false)\n .normalizeFragment(false)\n .build();\n }\n\n return this\n .normalizeProtocol(false)\n .normalizeHostname(false)\n .normalizePort(false)\n .normalizePath(false)\n .normalizeQuery(false)\n .normalizeFragment(false)\n .build();\n };\n p.normalizeProtocol = function(build) {\n if (typeof this._parts.protocol === 'string') {\n this._parts.protocol = this._parts.protocol.toLowerCase();\n this.build(!build);\n }\n\n return this;\n };\n p.normalizeHostname = function(build) {\n if (this._parts.hostname) {\n if (this.is('IDN') && punycode) {\n this._parts.hostname = punycode.toASCII(this._parts.hostname);\n } else if (this.is('IPv6') && IPv6) {\n this._parts.hostname = IPv6.best(this._parts.hostname);\n }\n\n this._parts.hostname = this._parts.hostname.toLowerCase();\n this.build(!build);\n }\n\n return this;\n };\n p.normalizePort = function(build) {\n // remove port of it's the protocol's default\n if (typeof this._parts.protocol === 'string' && this._parts.port === URI.defaultPorts[this._parts.protocol]) {\n this._parts.port = null;\n this.build(!build);\n }\n\n return this;\n };\n p.normalizePath = function(build) {\n var _path = this._parts.path;\n if (!_path) {\n return this;\n }\n\n if (this._parts.urn) {\n this._parts.path = URI.recodeUrnPath(this._parts.path);\n this.build(!build);\n return this;\n }\n\n if (this._parts.path === '/') {\n return this;\n }\n\n _path = URI.recodePath(_path);\n\n var _was_relative;\n var _leadingParents = '';\n var _parent, _pos;\n\n // handle relative paths\n if (_path.charAt(0) !== '/') {\n _was_relative = true;\n _path = '/' + _path;\n }\n\n // handle relative files (as opposed to directories)\n if (_path.slice(-3) === '/..' || _path.slice(-2) === '/.') {\n _path += '/';\n }\n\n // resolve simples\n _path = _path\n .replace(/(\\/(\\.\\/)+)|(\\/\\.$)/g, '/')\n .replace(/\\/{2,}/g, '/');\n\n // remember leading parents\n if (_was_relative) {\n _leadingParents = _path.substring(1).match(/^(\\.\\.\\/)+/) || '';\n if (_leadingParents) {\n _leadingParents = _leadingParents[0];\n }\n }\n\n // resolve parents\n while (true) {\n _parent = _path.search(/\\/\\.\\.(\\/|$)/);\n if (_parent === -1) {\n // no more ../ to resolve\n break;\n } else if (_parent === 0) {\n // top level cannot be relative, skip it\n _path = _path.substring(3);\n continue;\n }\n\n _pos = _path.substring(0, _parent).lastIndexOf('/');\n if (_pos === -1) {\n _pos = _parent;\n }\n _path = _path.substring(0, _pos) + _path.substring(_parent + 3);\n }\n\n // revert to relative\n if (_was_relative && this.is('relative')) {\n _path = _leadingParents + _path.substring(1);\n }\n\n this._parts.path = _path;\n this.build(!build);\n return this;\n };\n p.normalizePathname = p.normalizePath;\n p.normalizeQuery = function(build) {\n if (typeof this._parts.query === 'string') {\n if (!this._parts.query.length) {\n this._parts.query = null;\n } else {\n this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));\n }\n\n this.build(!build);\n }\n\n return this;\n };\n p.normalizeFragment = function(build) {\n if (!this._parts.fragment) {\n this._parts.fragment = null;\n this.build(!build);\n }\n\n return this;\n };\n p.normalizeSearch = p.normalizeQuery;\n p.normalizeHash = p.normalizeFragment;\n\n p.iso8859 = function() {\n // expect unicode input, iso8859 output\n var e = URI.encode;\n var d = URI.decode;\n\n URI.encode = escape;\n URI.decode = decodeURIComponent;\n try {\n this.normalize();\n } finally {\n URI.encode = e;\n URI.decode = d;\n }\n return this;\n };\n\n p.unicode = function() {\n // expect iso8859 input, unicode output\n var e = URI.encode;\n var d = URI.decode;\n\n URI.encode = strictEncodeURIComponent;\n URI.decode = unescape;\n try {\n this.normalize();\n } finally {\n URI.encode = e;\n URI.decode = d;\n }\n return this;\n };\n\n p.readable = function() {\n var uri = this.clone();\n // removing username, password, because they shouldn't be displayed according to RFC 3986\n uri.username('').password('').normalize();\n var t = '';\n if (uri._parts.protocol) {\n t += uri._parts.protocol + '://';\n }\n\n if (uri._parts.hostname) {\n if (uri.is('punycode') && punycode) {\n t += punycode.toUnicode(uri._parts.hostname);\n if (uri._parts.port) {\n t += ':' + uri._parts.port;\n }\n } else {\n t += uri.host();\n }\n }\n\n if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== '/') {\n t += '/';\n }\n\n t += uri.path(true);\n if (uri._parts.query) {\n var q = '';\n for (var i = 0, qp = uri._parts.query.split('&'), l = qp.length; i < l; i++) {\n var kv = (qp[i] || '').split('=');\n q += '&' + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace)\n .replace(/&/g, '%26');\n\n if (kv[1] !== undefined) {\n q += '=' + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace)\n .replace(/&/g, '%26');\n }\n }\n t += '?' + q.substring(1);\n }\n\n t += URI.decodeQuery(uri.hash(), true);\n return t;\n };\n\n // resolving relative and absolute URLs\n p.absoluteTo = function(base) {\n var resolved = this.clone();\n var properties = ['protocol', 'username', 'password', 'hostname', 'port'];\n var basedir, i, p;\n\n if (this._parts.urn) {\n throw new Error('URNs do not have any generally defined hierarchical components');\n }\n\n if (!(base instanceof URI)) {\n base = new URI(base);\n }\n\n if (resolved._parts.protocol) {\n // Directly returns even if this._parts.hostname is empty.\n return resolved;\n } else {\n resolved._parts.protocol = base._parts.protocol;\n }\n\n if (this._parts.hostname) {\n return resolved;\n }\n\n for (i = 0; (p = properties[i]); i++) {\n resolved._parts[p] = base._parts[p];\n }\n\n if (!resolved._parts.path) {\n resolved._parts.path = base._parts.path;\n if (!resolved._parts.query) {\n resolved._parts.query = base._parts.query;\n }\n } else {\n if (resolved._parts.path.substring(-2) === '..') {\n resolved._parts.path += '/';\n }\n\n if (resolved.path().charAt(0) !== '/') {\n basedir = base.directory();\n basedir = basedir ? basedir : base.path().indexOf('/') === 0 ? '/' : '';\n resolved._parts.path = (basedir ? (basedir + '/') : '') + resolved._parts.path;\n resolved.normalizePath();\n }\n }\n\n resolved.build();\n return resolved;\n };\n p.relativeTo = function(base) {\n var relative = this.clone().normalize();\n var relativeParts, baseParts, common, relativePath, basePath;\n\n if (relative._parts.urn) {\n throw new Error('URNs do not have any generally defined hierarchical components');\n }\n\n base = new URI(base).normalize();\n relativeParts = relative._parts;\n baseParts = base._parts;\n relativePath = relative.path();\n basePath = base.path();\n\n if (relativePath.charAt(0) !== '/') {\n throw new Error('URI is already relative');\n }\n\n if (basePath.charAt(0) !== '/') {\n throw new Error('Cannot calculate a URI relative to another relative URI');\n }\n\n if (relativeParts.protocol === baseParts.protocol) {\n relativeParts.protocol = null;\n }\n\n if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {\n return relative.build();\n }\n\n if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {\n return relative.build();\n }\n\n if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {\n relativeParts.hostname = null;\n relativeParts.port = null;\n } else {\n return relative.build();\n }\n\n if (relativePath === basePath) {\n relativeParts.path = '';\n return relative.build();\n }\n\n // determine common sub path\n common = URI.commonPath(relativePath, basePath);\n\n // If the paths have nothing in common, return a relative URL with the absolute path.\n if (!common) {\n return relative.build();\n }\n\n var parents = baseParts.path\n .substring(common.length)\n .replace(/[^\\/]*$/, '')\n .replace(/.*?\\//g, '../');\n\n relativeParts.path = (parents + relativeParts.path.substring(common.length)) || './';\n\n return relative.build();\n };\n\n // comparing URIs\n p.equals = function(uri) {\n var one = this.clone();\n var two = new URI(uri);\n var one_map = {};\n var two_map = {};\n var checked = {};\n var one_query, two_query, key;\n\n one.normalize();\n two.normalize();\n\n // exact match\n if (one.toString() === two.toString()) {\n return true;\n }\n\n // extract query string\n one_query = one.query();\n two_query = two.query();\n one.query('');\n two.query('');\n\n // definitely not equal if not even non-query parts match\n if (one.toString() !== two.toString()) {\n return false;\n }\n\n // query parameters have the same length, even if they're permuted\n if (one_query.length !== two_query.length) {\n return false;\n }\n\n one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);\n two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);\n\n for (key in one_map) {\n if (hasOwn.call(one_map, key)) {\n if (!isArray(one_map[key])) {\n if (one_map[key] !== two_map[key]) {\n return false;\n }\n } else if (!arraysEqual(one_map[key], two_map[key])) {\n return false;\n }\n\n checked[key] = true;\n }\n }\n\n for (key in two_map) {\n if (hasOwn.call(two_map, key)) {\n if (!checked[key]) {\n // two contains a parameter not present in one\n return false;\n }\n }\n }\n\n return true;\n };\n\n // state\n p.preventInvalidHostname = function(v) {\n this._parts.preventInvalidHostname = !!v;\n return this;\n };\n\n p.duplicateQueryParameters = function(v) {\n this._parts.duplicateQueryParameters = !!v;\n return this;\n };\n\n p.escapeQuerySpace = function(v) {\n this._parts.escapeQuerySpace = !!v;\n return this;\n };\n\n return URI;\n}));\n", "const {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n} = Object;\n\nlet { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports\nlet { apply, construct } = typeof Reflect !== 'undefined' && Reflect;\n\nif (!apply) {\n apply = function (fun, thisValue, args) {\n return fun.apply(thisValue, args);\n };\n}\n\nif (!freeze) {\n freeze = function (x) {\n return x;\n };\n}\n\nif (!seal) {\n seal = function (x) {\n return x;\n };\n}\n\nif (!construct) {\n construct = function (Func, args) {\n return new Func(...args);\n };\n}\n\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayIndexOf = unapply(Array.prototype.indexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySlice = unapply(Array.prototype.slice);\n\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\n\nconst regExpTest = unapply(RegExp.prototype.test);\n\nconst typeErrorCreate = unconstruct(TypeError);\n\nexport function unapply(func) {\n return (thisArg, ...args) => apply(func, thisArg, args);\n}\n\nexport function unconstruct(func) {\n return (...args) => construct(func, args);\n}\n\n/* Add properties to a lookup table */\nexport function addToSet(set, array, transformCaseFunc) {\n transformCaseFunc = transformCaseFunc ?? stringToLowerCase;\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n\n element = lcElement;\n }\n }\n\n set[element] = true;\n }\n\n return set;\n}\n\n/* Shallow clone an object */\nexport function clone(object) {\n const newObject = create(null);\n\n for (const [property, value] of entries(object)) {\n newObject[property] = value;\n }\n\n return newObject;\n}\n\n/* This method automatically checks if the prop is function\n * or getter and behaves accordingly. */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n\n object = getPrototypeOf(object);\n }\n\n function fallbackValue(element) {\n console.warn('fallback value for', element);\n return null;\n }\n\n return fallbackValue;\n}\n\nexport {\n // Array\n arrayForEach,\n arrayIndexOf,\n arrayPop,\n arrayPush,\n arraySlice,\n // Object\n entries,\n freeze,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n isFrozen,\n setPrototypeOf,\n seal,\n // RegExp\n regExpTest,\n // String\n stringIndexOf,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringTrim,\n // Errors\n typeErrorCreate,\n // Other\n lookupGetter,\n};\n", "import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'a',\n 'abbr',\n 'acronym',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blink',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'content',\n 'data',\n 'datalist',\n 'dd',\n 'decorator',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'element',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'font',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'map',\n 'mark',\n 'marquee',\n 'menu',\n 'menuitem',\n 'meter',\n 'nav',\n 'nobr',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'section',\n 'select',\n 'shadow',\n 'small',\n 'source',\n 'spacer',\n 'span',\n 'strike',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'track',\n 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n]);\n\n// SVG\nexport const svg = freeze([\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern',\n]);\n\nexport const svgFilters = freeze([\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n]);\n\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nexport const svgDisallowed = freeze([\n 'animate',\n 'color-profile',\n 'cursor',\n 'discard',\n 'font-face',\n 'font-face-format',\n 'font-face-name',\n 'font-face-src',\n 'font-face-uri',\n 'foreignobject',\n 'hatch',\n 'hatchpath',\n 'mesh',\n 'meshgradient',\n 'meshpatch',\n 'meshrow',\n 'missing-glyph',\n 'script',\n 'set',\n 'solidcolor',\n 'unknown',\n 'use',\n]);\n\nexport const mathMl = freeze([\n 'math',\n 'menclose',\n 'merror',\n 'mfenced',\n 'mfrac',\n 'mglyph',\n 'mi',\n 'mlabeledtr',\n 'mmultiscripts',\n 'mn',\n 'mo',\n 'mover',\n 'mpadded',\n 'mphantom',\n 'mroot',\n 'mrow',\n 'ms',\n 'mspace',\n 'msqrt',\n 'mstyle',\n 'msub',\n 'msup',\n 'msubsup',\n 'mtable',\n 'mtd',\n 'mtext',\n 'mtr',\n 'munder',\n 'munderover',\n 'mprescripts',\n]);\n\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nexport const mathMlDisallowed = freeze([\n 'maction',\n 'maligngroup',\n 'malignmark',\n 'mlongdiv',\n 'mscarries',\n 'mscarry',\n 'msgroup',\n 'mstack',\n 'msline',\n 'msrow',\n 'semantics',\n 'annotation',\n 'annotation-xml',\n 'mprescripts',\n 'none',\n]);\n\nexport const text = freeze(['#text']);\n", "import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'accept',\n 'action',\n 'align',\n 'alt',\n 'autocapitalize',\n 'autocomplete',\n 'autopictureinpicture',\n 'autoplay',\n 'background',\n 'bgcolor',\n 'border',\n 'capture',\n 'cellpadding',\n 'cellspacing',\n 'checked',\n 'cite',\n 'class',\n 'clear',\n 'color',\n 'cols',\n 'colspan',\n 'controls',\n 'controlslist',\n 'coords',\n 'crossorigin',\n 'datetime',\n 'decoding',\n 'default',\n 'dir',\n 'disabled',\n 'disablepictureinpicture',\n 'disableremoteplayback',\n 'download',\n 'draggable',\n 'enctype',\n 'enterkeyhint',\n 'face',\n 'for',\n 'headers',\n 'height',\n 'hidden',\n 'high',\n 'href',\n 'hreflang',\n 'id',\n 'inputmode',\n 'integrity',\n 'ismap',\n 'kind',\n 'label',\n 'lang',\n 'list',\n 'loading',\n 'loop',\n 'low',\n 'max',\n 'maxlength',\n 'media',\n 'method',\n 'min',\n 'minlength',\n 'multiple',\n 'muted',\n 'name',\n 'nonce',\n 'noshade',\n 'novalidate',\n 'nowrap',\n 'open',\n 'optimum',\n 'pattern',\n 'placeholder',\n 'playsinline',\n 'poster',\n 'preload',\n 'pubdate',\n 'radiogroup',\n 'readonly',\n 'rel',\n 'required',\n 'rev',\n 'reversed',\n 'role',\n 'rows',\n 'rowspan',\n 'spellcheck',\n 'scope',\n 'selected',\n 'shape',\n 'size',\n 'sizes',\n 'span',\n 'srclang',\n 'start',\n 'src',\n 'srcset',\n 'step',\n 'style',\n 'summary',\n 'tabindex',\n 'title',\n 'translate',\n 'type',\n 'usemap',\n 'valign',\n 'value',\n 'width',\n 'xmlns',\n 'slot',\n]);\n\nexport const svg = freeze([\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan',\n]);\n\nexport const mathMl = freeze([\n 'accent',\n 'accentunder',\n 'align',\n 'bevelled',\n 'close',\n 'columnsalign',\n 'columnlines',\n 'columnspan',\n 'denomalign',\n 'depth',\n 'dir',\n 'display',\n 'displaystyle',\n 'encoding',\n 'fence',\n 'frame',\n 'height',\n 'href',\n 'id',\n 'largeop',\n 'length',\n 'linethickness',\n 'lspace',\n 'lquote',\n 'mathbackground',\n 'mathcolor',\n 'mathsize',\n 'mathvariant',\n 'maxsize',\n 'minsize',\n 'movablelimits',\n 'notation',\n 'numalign',\n 'open',\n 'rowalign',\n 'rowlines',\n 'rowspacing',\n 'rowspan',\n 'rspace',\n 'rquote',\n 'scriptlevel',\n 'scriptminsize',\n 'scriptsizemultiplier',\n 'selection',\n 'separator',\n 'separators',\n 'stretchy',\n 'subscriptshift',\n 'supscriptshift',\n 'symmetric',\n 'voffset',\n 'width',\n 'xmlns',\n]);\n\nexport const xml = freeze([\n 'xlink:href',\n 'xml:id',\n 'xlink:title',\n 'xml:space',\n 'xmlns:xlink',\n]);\n", "import { seal } from './utils.js';\n\n// eslint-disable-next-line unicorn/better-regex\nexport const MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode\nexport const ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\nexport const TMPLIT_EXPR = seal(/\\${[\\w\\W]*}/gm);\nexport const DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]/); // eslint-disable-line no-useless-escape\nexport const ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nexport const IS_ALLOWED_URI = seal(\n /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nexport const IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nexport const ATTR_WHITESPACE = seal(\n /[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nexport const DOCTYPE_NAME = seal(/^html$/i);\n", "import * as TAGS from './tags.js';\nimport * as ATTRS from './attrs.js';\nimport * as EXPRESSIONS from './regexp.js';\nimport {\n addToSet,\n clone,\n entries,\n freeze,\n arrayForEach,\n arrayPop,\n arrayPush,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringIndexOf,\n stringTrim,\n regExpTest,\n typeErrorCreate,\n lookupGetter,\n} from './utils.js';\n\nconst getGlobal = () => (typeof window === 'undefined' ? null : window);\n\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.\n * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function (trustedTypes, purifyHostElement) {\n if (\n typeof trustedTypes !== 'object' ||\n typeof trustedTypes.createPolicy !== 'function'\n ) {\n return null;\n }\n\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n },\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn(\n 'TrustedTypes policy ' + policyName + ' could not be created.'\n );\n return null;\n }\n};\n\nfunction createDOMPurify(window = getGlobal()) {\n const DOMPurify = (root) => createDOMPurify(root);\n\n /**\n * Version label, exposed for easier checks\n * if DOMPurify is up to date or not\n */\n DOMPurify.version = VERSION;\n\n /**\n * Array of elements that DOMPurify removed during sanitation.\n * Empty if nothing was removed.\n */\n DOMPurify.removed = [];\n\n if (!window || !window.document || window.document.nodeType !== 9) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n\n return DOMPurify;\n }\n\n const originalDocument = window.document;\n const currentScript = originalDocument.currentScript;\n\n let { document } = window;\n const {\n DocumentFragment,\n HTMLTemplateElement,\n Node,\n Element,\n NodeFilter,\n NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,\n HTMLFormElement,\n DOMParser,\n trustedTypes,\n } = window;\n\n const ElementPrototype = Element.prototype;\n\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n\n let trustedTypesPolicy;\n let emptyHTML = '';\n\n const {\n implementation,\n createNodeIterator,\n createDocumentFragment,\n getElementsByTagName,\n } = document;\n const { importNode } = originalDocument;\n\n let hooks = {};\n\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported =\n typeof entries === 'function' &&\n typeof getParentNode === 'function' &&\n implementation &&\n implementation.createHTMLDocument !== undefined;\n\n const {\n MUSTACHE_EXPR,\n ERB_EXPR,\n TMPLIT_EXPR,\n DATA_ATTR,\n ARIA_ATTR,\n IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE,\n } = EXPRESSIONS;\n\n let { IS_ALLOWED_URI } = EXPRESSIONS;\n\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [\n ...TAGS.html,\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.mathMl,\n ...TAGS.text,\n ]);\n\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [\n ...ATTRS.html,\n ...ATTRS.svg,\n ...ATTRS.mathMl,\n ...ATTRS.xml,\n ]);\n\n /*\n * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(\n Object.create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false,\n },\n })\n );\n\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n\n /* Decide if document with ... should be returned */\n let WHOLE_DOCUMENT = false;\n\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, [\n 'annotation-xml',\n 'audio',\n 'colgroup',\n 'desc',\n 'foreignobject',\n 'head',\n 'iframe',\n 'math',\n 'mi',\n 'mn',\n 'mo',\n 'ms',\n 'mtext',\n 'noembed',\n 'noframes',\n 'noscript',\n 'plaintext',\n 'script',\n 'style',\n 'svg',\n 'template',\n 'thead',\n 'title',\n 'video',\n 'xmp',\n ]);\n\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, [\n 'audio',\n 'video',\n 'img',\n 'source',\n 'image',\n 'track',\n ]);\n\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [\n 'alt',\n 'class',\n 'for',\n 'id',\n 'label',\n 'name',\n 'pattern',\n 'placeholder',\n 'role',\n 'summary',\n 'title',\n 'value',\n 'style',\n 'xmlns',\n ]);\n\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet(\n {},\n [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE],\n stringToString\n );\n\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc;\n\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n\n const formElement = document.createElement('form');\n\n const isRegexOrFunction = function (testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n\n /**\n * _parseConfig\n *\n * @param {Object} cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function (cfg) {\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1\n ? (PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE)\n : (PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE);\n\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc =\n PARSER_MEDIA_TYPE === 'application/xhtml+xml'\n ? stringToString\n : stringToLowerCase;\n\n /* Set configuration parameters */\n ALLOWED_TAGS =\n 'ALLOWED_TAGS' in cfg\n ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc)\n : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR =\n 'ALLOWED_ATTR' in cfg\n ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc)\n : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES =\n 'ALLOWED_NAMESPACES' in cfg\n ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString)\n : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES =\n 'ADD_URI_SAFE_ATTR' in cfg\n ? addToSet(\n clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent\n cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent\n transformCaseFunc // eslint-disable-line indent\n ) // eslint-disable-line indent\n : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS =\n 'ADD_DATA_URI_TAGS' in cfg\n ? addToSet(\n clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent\n cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent\n transformCaseFunc // eslint-disable-line indent\n ) // eslint-disable-line indent\n : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS =\n 'FORBID_CONTENTS' in cfg\n ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc)\n : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS =\n 'FORBID_TAGS' in cfg\n ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc)\n : {};\n FORBID_ATTR =\n 'FORBID_ATTR' in cfg\n ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc)\n : {};\n USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI = cfg.ALLOWED_URI_REGEXP || EXPRESSIONS.IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements ===\n 'boolean'\n ) {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements =\n cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, [...TAGS.text]);\n ALLOWED_ATTR = [];\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, TAGS.html);\n addToSet(ALLOWED_ATTR, ATTRS.html);\n }\n\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, TAGS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, TAGS.svgFilters);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, TAGS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n }\n\n /* Merge configuration parameters */\n if (cfg.ADD_TAGS) {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n\n if (cfg.ADD_ATTR) {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.'\n );\n }\n\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.'\n );\n }\n\n // Overwrite existing TrustedTypes policy.\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n\n // Sign local variables required by `sanitize`.\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n // Uninitialized policy, attempt to initialize the internal dompurify policy.\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(\n trustedTypes,\n currentScript\n );\n }\n\n // If creating the internal policy succeeded sign internal variables.\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n\n CONFIG = cfg;\n };\n\n const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [\n 'mi',\n 'mo',\n 'mn',\n 'ms',\n 'mtext',\n ]);\n\n const HTML_INTEGRATION_POINTS = addToSet({}, [\n 'foreignobject',\n 'desc',\n 'title',\n 'annotation-xml',\n ]);\n\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [\n 'title',\n 'style',\n 'font',\n 'a',\n 'script',\n ]);\n\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, TAGS.svg);\n addToSet(ALL_SVG_TAGS, TAGS.svgFilters);\n addToSet(ALL_SVG_TAGS, TAGS.svgDisallowed);\n\n const ALL_MATHML_TAGS = addToSet({}, TAGS.mathMl);\n addToSet(ALL_MATHML_TAGS, TAGS.mathMlDisallowed);\n\n /**\n *\n *\n * @param {Element} element a DOM element whose namespace is being checked\n * @returns {boolean} Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function (element) {\n let parent = getParentNode(element);\n\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template',\n };\n }\n\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n\n if (element.namespaceURI === SVG_NAMESPACE) {\n // The only way to switch from HTML namespace to SVG\n // is via
\n *\n * @function\n * @param {number} value The number whose hyperbolic sine is to be returned.\n * @returns {number} The hyperbolic sine of value.\n */\n// eslint-disable-next-line es/no-math-sinh\nCesiumMath.sinh = defaultValue(Math.sinh, function sinh(value) {\n return (Math.exp(value) - Math.exp(-value)) / 2.0;\n});\n\n/**\n * Returns the hyperbolic cosine of a number.\n * The hyperbolic cosine of value is defined to be\n * (ex + e-x)/2.0\n * where e is Euler's number, approximately 2.71828183.\n *\n *
Special cases:\n *
\n *
If the argument is NaN, then the result is NaN.
\n *\n *
If the argument is infinite, then the result is positive infinity.
\n *\n *
If the argument is zero, then the result is 1.0.
\n *
\n *\n *\n * @function\n * @param {number} value The number whose hyperbolic cosine is to be returned.\n * @returns {number} The hyperbolic cosine of value.\n */\n// eslint-disable-next-line es/no-math-cosh\nCesiumMath.cosh = defaultValue(Math.cosh, function cosh(value) {\n return (Math.exp(value) + Math.exp(-value)) / 2.0;\n});\n\n/**\n * Computes the linear interpolation of two values.\n *\n * @param {number} p The start value to interpolate.\n * @param {number} q The end value to interpolate.\n * @param {number} time The time of interpolation generally in the range [0.0, 1.0].\n * @returns {number} The linearly interpolated value.\n *\n * @example\n * const n = Cesium.Math.lerp(0.0, 2.0, 0.5); // returns 1.0\n */\nCesiumMath.lerp = function (p, q, time) {\n return (1.0 - time) * p + time * q;\n};\n\n/**\n * pi\n *\n * @type {number}\n * @constant\n */\nCesiumMath.PI = Math.PI;\n\n/**\n * 1/pi\n *\n * @type {number}\n * @constant\n */\nCesiumMath.ONE_OVER_PI = 1.0 / Math.PI;\n\n/**\n * pi/2\n *\n * @type {number}\n * @constant\n */\nCesiumMath.PI_OVER_TWO = Math.PI / 2.0;\n\n/**\n * pi/3\n *\n * @type {number}\n * @constant\n */\nCesiumMath.PI_OVER_THREE = Math.PI / 3.0;\n\n/**\n * pi/4\n *\n * @type {number}\n * @constant\n */\nCesiumMath.PI_OVER_FOUR = Math.PI / 4.0;\n\n/**\n * pi/6\n *\n * @type {number}\n * @constant\n */\nCesiumMath.PI_OVER_SIX = Math.PI / 6.0;\n\n/**\n * 3pi/2\n *\n * @type {number}\n * @constant\n */\nCesiumMath.THREE_PI_OVER_TWO = (3.0 * Math.PI) / 2.0;\n\n/**\n * 2pi\n *\n * @type {number}\n * @constant\n */\nCesiumMath.TWO_PI = 2.0 * Math.PI;\n\n/**\n * 1/2pi\n *\n * @type {number}\n * @constant\n */\nCesiumMath.ONE_OVER_TWO_PI = 1.0 / (2.0 * Math.PI);\n\n/**\n * The number of radians in a degree.\n *\n * @type {number}\n * @constant\n */\nCesiumMath.RADIANS_PER_DEGREE = Math.PI / 180.0;\n\n/**\n * The number of degrees in a radian.\n *\n * @type {number}\n * @constant\n */\nCesiumMath.DEGREES_PER_RADIAN = 180.0 / Math.PI;\n\n/**\n * The number of radians in an arc second.\n *\n * @type {number}\n * @constant\n */\nCesiumMath.RADIANS_PER_ARCSECOND = CesiumMath.RADIANS_PER_DEGREE / 3600.0;\n\n/**\n * Converts degrees to radians.\n * @param {number} degrees The angle to convert in degrees.\n * @returns {number} The corresponding angle in radians.\n */\nCesiumMath.toRadians = function (degrees) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(degrees)) {\n throw new DeveloperError(\"degrees is required.\");\n }\n //>>includeEnd('debug');\n return degrees * CesiumMath.RADIANS_PER_DEGREE;\n};\n\n/**\n * Converts radians to degrees.\n * @param {number} radians The angle to convert in radians.\n * @returns {number} The corresponding angle in degrees.\n */\nCesiumMath.toDegrees = function (radians) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(radians)) {\n throw new DeveloperError(\"radians is required.\");\n }\n //>>includeEnd('debug');\n return radians * CesiumMath.DEGREES_PER_RADIAN;\n};\n\n/**\n * Converts a longitude value, in radians, to the range [-Math.PI, Math.PI).\n *\n * @param {number} angle The longitude value, in radians, to convert to the range [-Math.PI, Math.PI).\n * @returns {number} The equivalent longitude value in the range [-Math.PI, Math.PI).\n *\n * @example\n * // Convert 270 degrees to -90 degrees longitude\n * const longitude = Cesium.Math.convertLongitudeRange(Cesium.Math.toRadians(270.0));\n */\nCesiumMath.convertLongitudeRange = function (angle) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(angle)) {\n throw new DeveloperError(\"angle is required.\");\n }\n //>>includeEnd('debug');\n const twoPi = CesiumMath.TWO_PI;\n\n const simplified = angle - Math.floor(angle / twoPi) * twoPi;\n\n if (simplified < -Math.PI) {\n return simplified + twoPi;\n }\n if (simplified >= Math.PI) {\n return simplified - twoPi;\n }\n\n return simplified;\n};\n\n/**\n * Convenience function that clamps a latitude value, in radians, to the range [-Math.PI/2, Math.PI/2).\n * Useful for sanitizing data before use in objects requiring correct range.\n *\n * @param {number} angle The latitude value, in radians, to clamp to the range [-Math.PI/2, Math.PI/2).\n * @returns {number} The latitude value clamped to the range [-Math.PI/2, Math.PI/2).\n *\n * @example\n * // Clamp 108 degrees latitude to 90 degrees latitude\n * const latitude = Cesium.Math.clampToLatitudeRange(Cesium.Math.toRadians(108.0));\n */\nCesiumMath.clampToLatitudeRange = function (angle) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(angle)) {\n throw new DeveloperError(\"angle is required.\");\n }\n //>>includeEnd('debug');\n\n return CesiumMath.clamp(\n angle,\n -1 * CesiumMath.PI_OVER_TWO,\n CesiumMath.PI_OVER_TWO\n );\n};\n\n/**\n * Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.\n *\n * @param {number} angle in radians\n * @returns {number} The angle in the range [-CesiumMath.PI, CesiumMath.PI].\n */\nCesiumMath.negativePiToPi = function (angle) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(angle)) {\n throw new DeveloperError(\"angle is required.\");\n }\n //>>includeEnd('debug');\n if (angle >= -CesiumMath.PI && angle <= CesiumMath.PI) {\n // Early exit if the input is already inside the range. This avoids\n // unnecessary math which could introduce floating point error.\n return angle;\n }\n return CesiumMath.zeroToTwoPi(angle + CesiumMath.PI) - CesiumMath.PI;\n};\n\n/**\n * Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.\n *\n * @param {number} angle in radians\n * @returns {number} The angle in the range [0, CesiumMath.TWO_PI].\n */\nCesiumMath.zeroToTwoPi = function (angle) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(angle)) {\n throw new DeveloperError(\"angle is required.\");\n }\n //>>includeEnd('debug');\n if (angle >= 0 && angle <= CesiumMath.TWO_PI) {\n // Early exit if the input is already inside the range. This avoids\n // unnecessary math which could introduce floating point error.\n return angle;\n }\n const mod = CesiumMath.mod(angle, CesiumMath.TWO_PI);\n if (\n Math.abs(mod) < CesiumMath.EPSILON14 &&\n Math.abs(angle) > CesiumMath.EPSILON14\n ) {\n return CesiumMath.TWO_PI;\n }\n return mod;\n};\n\n/**\n * The modulo operation that also works for negative dividends.\n *\n * @param {number} m The dividend.\n * @param {number} n The divisor.\n * @returns {number} The remainder.\n */\nCesiumMath.mod = function (m, n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(m)) {\n throw new DeveloperError(\"m is required.\");\n }\n if (!defined(n)) {\n throw new DeveloperError(\"n is required.\");\n }\n if (n === 0.0) {\n throw new DeveloperError(\"divisor cannot be 0.\");\n }\n //>>includeEnd('debug');\n if (CesiumMath.sign(m) === CesiumMath.sign(n) && Math.abs(m) < Math.abs(n)) {\n // Early exit if the input does not need to be modded. This avoids\n // unnecessary math which could introduce floating point error.\n return m;\n }\n\n return ((m % n) + n) % n;\n};\n\n/**\n * Determines if two values are equal using an absolute or relative tolerance test. This is useful\n * to avoid problems due to roundoff error when comparing floating-point values directly. The values are\n * first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed.\n * Use this test if you are unsure of the magnitudes of left and right.\n *\n * @param {number} left The first value to compare.\n * @param {number} right The other value to compare.\n * @param {number} [relativeEpsilon=0] The maximum inclusive delta between left and right for the relative tolerance test.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The maximum inclusive delta between left and right for the absolute tolerance test.\n * @returns {boolean} true if the values are equal within the epsilon; otherwise, false.\n *\n * @example\n * const a = Cesium.Math.equalsEpsilon(0.0, 0.01, Cesium.Math.EPSILON2); // true\n * const b = Cesium.Math.equalsEpsilon(0.0, 0.1, Cesium.Math.EPSILON2); // false\n * const c = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON7); // true\n * const d = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON9); // false\n */\nCesiumMath.equalsEpsilon = function (\n left,\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"left is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"right is required.\");\n }\n //>>includeEnd('debug');\n\n relativeEpsilon = defaultValue(relativeEpsilon, 0.0);\n absoluteEpsilon = defaultValue(absoluteEpsilon, relativeEpsilon);\n const absDiff = Math.abs(left - right);\n return (\n absDiff <= absoluteEpsilon ||\n absDiff <= relativeEpsilon * Math.max(Math.abs(left), Math.abs(right))\n );\n};\n\n/**\n * Determines if the left value is less than the right value. If the two values are within\n * absoluteEpsilon of each other, they are considered equal and this function returns false.\n *\n * @param {number} left The first number to compare.\n * @param {number} right The second number to compare.\n * @param {number} absoluteEpsilon The absolute epsilon to use in comparison.\n * @returns {boolean} true if left is less than right by more than\n * absoluteEpsilon. false if left is greater or if the two\n * values are nearly equal.\n */\nCesiumMath.lessThan = function (left, right, absoluteEpsilon) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"first is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"second is required.\");\n }\n if (!defined(absoluteEpsilon)) {\n throw new DeveloperError(\"absoluteEpsilon is required.\");\n }\n //>>includeEnd('debug');\n return left - right < -absoluteEpsilon;\n};\n\n/**\n * Determines if the left value is less than or equal to the right value. If the two values are within\n * absoluteEpsilon of each other, they are considered equal and this function returns true.\n *\n * @param {number} left The first number to compare.\n * @param {number} right The second number to compare.\n * @param {number} absoluteEpsilon The absolute epsilon to use in comparison.\n * @returns {boolean} true if left is less than right or if the\n * the values are nearly equal.\n */\nCesiumMath.lessThanOrEquals = function (left, right, absoluteEpsilon) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"first is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"second is required.\");\n }\n if (!defined(absoluteEpsilon)) {\n throw new DeveloperError(\"absoluteEpsilon is required.\");\n }\n //>>includeEnd('debug');\n return left - right < absoluteEpsilon;\n};\n\n/**\n * Determines if the left value is greater the right value. If the two values are within\n * absoluteEpsilon of each other, they are considered equal and this function returns false.\n *\n * @param {number} left The first number to compare.\n * @param {number} right The second number to compare.\n * @param {number} absoluteEpsilon The absolute epsilon to use in comparison.\n * @returns {boolean} true if left is greater than right by more than\n * absoluteEpsilon. false if left is less or if the two\n * values are nearly equal.\n */\nCesiumMath.greaterThan = function (left, right, absoluteEpsilon) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"first is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"second is required.\");\n }\n if (!defined(absoluteEpsilon)) {\n throw new DeveloperError(\"absoluteEpsilon is required.\");\n }\n //>>includeEnd('debug');\n return left - right > absoluteEpsilon;\n};\n\n/**\n * Determines if the left value is greater than or equal to the right value. If the two values are within\n * absoluteEpsilon of each other, they are considered equal and this function returns true.\n *\n * @param {number} left The first number to compare.\n * @param {number} right The second number to compare.\n * @param {number} absoluteEpsilon The absolute epsilon to use in comparison.\n * @returns {boolean} true if left is greater than right or if the\n * the values are nearly equal.\n */\nCesiumMath.greaterThanOrEquals = function (left, right, absoluteEpsilon) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"first is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"second is required.\");\n }\n if (!defined(absoluteEpsilon)) {\n throw new DeveloperError(\"absoluteEpsilon is required.\");\n }\n //>>includeEnd('debug');\n return left - right > -absoluteEpsilon;\n};\n\nconst factorials = [1];\n\n/**\n * Computes the factorial of the provided number.\n *\n * @param {number} n The number whose factorial is to be computed.\n * @returns {number} The factorial of the provided number or undefined if the number is less than 0.\n *\n * @exception {DeveloperError} A number greater than or equal to 0 is required.\n *\n *\n * @example\n * //Compute 7!, which is equal to 5040\n * const computedFactorial = Cesium.Math.factorial(7);\n *\n * @see {@link http://en.wikipedia.org/wiki/Factorial|Factorial on Wikipedia}\n */\nCesiumMath.factorial = function (n) {\n //>>includeStart('debug', pragmas.debug);\n if (typeof n !== \"number\" || n < 0) {\n throw new DeveloperError(\n \"A number greater than or equal to 0 is required.\"\n );\n }\n //>>includeEnd('debug');\n\n const length = factorials.length;\n if (n >= length) {\n let sum = factorials[length - 1];\n for (let i = length; i <= n; i++) {\n const next = sum * i;\n factorials.push(next);\n sum = next;\n }\n }\n return factorials[n];\n};\n\n/**\n * Increments a number with a wrapping to a minimum value if the number exceeds the maximum value.\n *\n * @param {number} [n] The number to be incremented.\n * @param {number} [maximumValue] The maximum incremented value before rolling over to the minimum value.\n * @param {number} [minimumValue=0.0] The number reset to after the maximum value has been exceeded.\n * @returns {number} The incremented number.\n *\n * @exception {DeveloperError} Maximum value must be greater than minimum value.\n *\n * @example\n * const n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6\n * const m = Cesium.Math.incrementWrap(10, 10, 0); // returns 0\n */\nCesiumMath.incrementWrap = function (n, maximumValue, minimumValue) {\n minimumValue = defaultValue(minimumValue, 0.0);\n\n //>>includeStart('debug', pragmas.debug);\n if (!defined(n)) {\n throw new DeveloperError(\"n is required.\");\n }\n if (maximumValue <= minimumValue) {\n throw new DeveloperError(\"maximumValue must be greater than minimumValue.\");\n }\n //>>includeEnd('debug');\n\n ++n;\n if (n > maximumValue) {\n n = minimumValue;\n }\n return n;\n};\n\n/**\n * Determines if a non-negative integer is a power of two.\n * The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.\n *\n * @param {number} n The integer to test in the range [0, (2^32)-1].\n * @returns {boolean} true if the number if a power of two; otherwise, false.\n *\n * @exception {DeveloperError} A number between 0 and (2^32)-1 is required.\n *\n * @example\n * const t = Cesium.Math.isPowerOfTwo(16); // true\n * const f = Cesium.Math.isPowerOfTwo(20); // false\n */\nCesiumMath.isPowerOfTwo = function (n) {\n //>>includeStart('debug', pragmas.debug);\n if (typeof n !== \"number\" || n < 0 || n > 4294967295) {\n throw new DeveloperError(\"A number between 0 and (2^32)-1 is required.\");\n }\n //>>includeEnd('debug');\n\n return n !== 0 && (n & (n - 1)) === 0;\n};\n\n/**\n * Computes the next power-of-two integer greater than or equal to the provided non-negative integer.\n * The maximum allowed input is 2^31 due to 32-bit bitwise operator limitation in Javascript.\n *\n * @param {number} n The integer to test in the range [0, 2^31].\n * @returns {number} The next power-of-two integer.\n *\n * @exception {DeveloperError} A number between 0 and 2^31 is required.\n *\n * @example\n * const n = Cesium.Math.nextPowerOfTwo(29); // 32\n * const m = Cesium.Math.nextPowerOfTwo(32); // 32\n */\nCesiumMath.nextPowerOfTwo = function (n) {\n //>>includeStart('debug', pragmas.debug);\n if (typeof n !== \"number\" || n < 0 || n > 2147483648) {\n throw new DeveloperError(\"A number between 0 and 2^31 is required.\");\n }\n //>>includeEnd('debug');\n\n // From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2\n --n;\n n |= n >> 1;\n n |= n >> 2;\n n |= n >> 4;\n n |= n >> 8;\n n |= n >> 16;\n ++n;\n\n return n;\n};\n\n/**\n * Computes the previous power-of-two integer less than or equal to the provided non-negative integer.\n * The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.\n *\n * @param {number} n The integer to test in the range [0, (2^32)-1].\n * @returns {number} The previous power-of-two integer.\n *\n * @exception {DeveloperError} A number between 0 and (2^32)-1 is required.\n *\n * @example\n * const n = Cesium.Math.previousPowerOfTwo(29); // 16\n * const m = Cesium.Math.previousPowerOfTwo(32); // 32\n */\nCesiumMath.previousPowerOfTwo = function (n) {\n //>>includeStart('debug', pragmas.debug);\n if (typeof n !== \"number\" || n < 0 || n > 4294967295) {\n throw new DeveloperError(\"A number between 0 and (2^32)-1 is required.\");\n }\n //>>includeEnd('debug');\n\n n |= n >> 1;\n n |= n >> 2;\n n |= n >> 4;\n n |= n >> 8;\n n |= n >> 16;\n n |= n >> 32;\n\n // The previous bitwise operations implicitly convert to signed 32-bit. Use `>>>` to convert to unsigned\n n = (n >>> 0) - (n >>> 1);\n\n return n;\n};\n\n/**\n * Constraint a value to lie between two values.\n *\n * @param {number} value The value to clamp.\n * @param {number} min The minimum value.\n * @param {number} max The maximum value.\n * @returns {number} The clamped value such that min <= result <= max.\n */\nCesiumMath.clamp = function (value, min, max) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"value\", value);\n Check.typeOf.number(\"min\", min);\n Check.typeOf.number(\"max\", max);\n //>>includeEnd('debug');\n\n return value < min ? min : value > max ? max : value;\n};\n\nlet randomNumberGenerator = new MersenneTwister();\n\n/**\n * Sets the seed used by the random number generator\n * in {@link CesiumMath#nextRandomNumber}.\n *\n * @param {number} seed An integer used as the seed.\n */\nCesiumMath.setRandomNumberSeed = function (seed) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(seed)) {\n throw new DeveloperError(\"seed is required.\");\n }\n //>>includeEnd('debug');\n\n randomNumberGenerator = new MersenneTwister(seed);\n};\n\n/**\n * Generates a random floating point number in the range of [0.0, 1.0)\n * using a Mersenne twister.\n *\n * @returns {number} A random number in the range of [0.0, 1.0).\n *\n * @see CesiumMath.setRandomNumberSeed\n * @see {@link http://en.wikipedia.org/wiki/Mersenne_twister|Mersenne twister on Wikipedia}\n */\nCesiumMath.nextRandomNumber = function () {\n return randomNumberGenerator.random();\n};\n\n/**\n * Generates a random number between two numbers.\n *\n * @param {number} min The minimum value.\n * @param {number} max The maximum value.\n * @returns {number} A random number between the min and max.\n */\nCesiumMath.randomBetween = function (min, max) {\n return CesiumMath.nextRandomNumber() * (max - min) + min;\n};\n\n/**\n * Computes Math.acos(value), but first clamps value to the range [-1.0, 1.0]\n * so that the function will never return NaN.\n *\n * @param {number} value The value for which to compute acos.\n * @returns {number} The acos of the value if the value is in the range [-1.0, 1.0], or the acos of -1.0 or 1.0,\n * whichever is closer, if the value is outside the range.\n */\nCesiumMath.acosClamped = function (value) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(value)) {\n throw new DeveloperError(\"value is required.\");\n }\n //>>includeEnd('debug');\n return Math.acos(CesiumMath.clamp(value, -1.0, 1.0));\n};\n\n/**\n * Computes Math.asin(value), but first clamps value to the range [-1.0, 1.0]\n * so that the function will never return NaN.\n *\n * @param {number} value The value for which to compute asin.\n * @returns {number} The asin of the value if the value is in the range [-1.0, 1.0], or the asin of -1.0 or 1.0,\n * whichever is closer, if the value is outside the range.\n */\nCesiumMath.asinClamped = function (value) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(value)) {\n throw new DeveloperError(\"value is required.\");\n }\n //>>includeEnd('debug');\n return Math.asin(CesiumMath.clamp(value, -1.0, 1.0));\n};\n\n/**\n * Finds the chord length between two points given the circle's radius and the angle between the points.\n *\n * @param {number} angle The angle between the two points.\n * @param {number} radius The radius of the circle.\n * @returns {number} The chord length.\n */\nCesiumMath.chordLength = function (angle, radius) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(angle)) {\n throw new DeveloperError(\"angle is required.\");\n }\n if (!defined(radius)) {\n throw new DeveloperError(\"radius is required.\");\n }\n //>>includeEnd('debug');\n return 2.0 * radius * Math.sin(angle * 0.5);\n};\n\n/**\n * Finds the logarithm of a number to a base.\n *\n * @param {number} number The number.\n * @param {number} base The base.\n * @returns {number} The result.\n */\nCesiumMath.logBase = function (number, base) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(number)) {\n throw new DeveloperError(\"number is required.\");\n }\n if (!defined(base)) {\n throw new DeveloperError(\"base is required.\");\n }\n //>>includeEnd('debug');\n return Math.log(number) / Math.log(base);\n};\n\n/**\n * Finds the cube root of a number.\n * Returns NaN if number is not provided.\n *\n * @function\n * @param {number} [number] The number.\n * @returns {number} The result.\n */\n// eslint-disable-next-line es/no-math-cbrt\nCesiumMath.cbrt = defaultValue(Math.cbrt, function cbrt(number) {\n const result = Math.pow(Math.abs(number), 1.0 / 3.0);\n return number < 0.0 ? -result : result;\n});\n\n/**\n * Finds the base 2 logarithm of a number.\n *\n * @function\n * @param {number} number The number.\n * @returns {number} The result.\n */\n// eslint-disable-next-line es/no-math-log2\nCesiumMath.log2 = defaultValue(Math.log2, function log2(number) {\n return Math.log(number) * Math.LOG2E;\n});\n\n/**\n * @private\n */\nCesiumMath.fog = function (distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n};\n\n/**\n * Computes a fast approximation of Atan for input in the range [-1, 1].\n *\n * Based on Michal Drobot's approximation from ShaderFastLibs,\n * which in turn is based on \"Efficient approximations for the arctangent function,\"\n * Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006.\n * Adapted from ShaderFastLibs under MIT License.\n *\n * @param {number} x An input number in the range [-1, 1]\n * @returns {number} An approximation of atan(x)\n */\nCesiumMath.fastApproximateAtan = function (x) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"x\", x);\n //>>includeEnd('debug');\n\n return x * (-0.1784 * Math.abs(x) - 0.0663 * x * x + 1.0301);\n};\n\n/**\n * Computes a fast approximation of Atan2(x, y) for arbitrary input scalars.\n *\n * Range reduction math based on nvidia's cg reference implementation: http://developer.download.nvidia.com/cg/atan2.html\n *\n * @param {number} x An input number that isn't zero if y is zero.\n * @param {number} y An input number that isn't zero if x is zero.\n * @returns {number} An approximation of atan2(x, y)\n */\nCesiumMath.fastApproximateAtan2 = function (x, y) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"x\", x);\n Check.typeOf.number(\"y\", y);\n //>>includeEnd('debug');\n\n // atan approximations are usually only reliable over [-1, 1]\n // So reduce the range by flipping whether x or y is on top based on which is bigger.\n let opposite;\n let t = Math.abs(x); // t used as swap and atan result.\n opposite = Math.abs(y);\n const adjacent = Math.max(t, opposite);\n opposite = Math.min(t, opposite);\n\n const oppositeOverAdjacent = opposite / adjacent;\n //>>includeStart('debug', pragmas.debug);\n if (isNaN(oppositeOverAdjacent)) {\n throw new DeveloperError(\"either x or y must be nonzero\");\n }\n //>>includeEnd('debug');\n t = CesiumMath.fastApproximateAtan(oppositeOverAdjacent);\n\n // Undo range reduction\n t = Math.abs(y) > Math.abs(x) ? CesiumMath.PI_OVER_TWO - t : t;\n t = x < 0.0 ? CesiumMath.PI - t : t;\n t = y < 0.0 ? -t : t;\n return t;\n};\nexport default CesiumMath;\n", "import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\n\n/**\n * A 3D Cartesian point.\n * @alias Cartesian3\n * @constructor\n *\n * @param {number} [x=0.0] The X component.\n * @param {number} [y=0.0] The Y component.\n * @param {number} [z=0.0] The Z component.\n *\n * @see Cartesian2\n * @see Cartesian4\n * @see Packable\n */\nfunction Cartesian3(x, y, z) {\n /**\n * The X component.\n * @type {number}\n * @default 0.0\n */\n this.x = defaultValue(x, 0.0);\n\n /**\n * The Y component.\n * @type {number}\n * @default 0.0\n */\n this.y = defaultValue(y, 0.0);\n\n /**\n * The Z component.\n * @type {number}\n * @default 0.0\n */\n this.z = defaultValue(z, 0.0);\n}\n\n/**\n * Converts the provided Spherical into Cartesian3 coordinates.\n *\n * @param {Spherical} spherical The Spherical to be converted to Cartesian3.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.\n */\nCartesian3.fromSpherical = function (spherical, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"spherical\", spherical);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n\n const clock = spherical.clock;\n const cone = spherical.cone;\n const magnitude = defaultValue(spherical.magnitude, 1.0);\n const radial = magnitude * Math.sin(cone);\n result.x = radial * Math.cos(clock);\n result.y = radial * Math.sin(clock);\n result.z = magnitude * Math.cos(cone);\n return result;\n};\n\n/**\n * Creates a Cartesian3 instance from x, y and z coordinates.\n *\n * @param {number} x The x coordinate.\n * @param {number} y The y coordinate.\n * @param {number} z The z coordinate.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.\n */\nCartesian3.fromElements = function (x, y, z, result) {\n if (!defined(result)) {\n return new Cartesian3(x, y, z);\n }\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Duplicates a Cartesian3 instance.\n *\n * @param {Cartesian3} cartesian The Cartesian to duplicate.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. (Returns undefined if cartesian is undefined)\n */\nCartesian3.clone = function (cartesian, result) {\n if (!defined(cartesian)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Cartesian3(cartesian.x, cartesian.y, cartesian.z);\n }\n\n result.x = cartesian.x;\n result.y = cartesian.y;\n result.z = cartesian.z;\n return result;\n};\n\n/**\n * Creates a Cartesian3 instance from an existing Cartesian4. This simply takes the\n * x, y, and z properties of the Cartesian4 and drops w.\n * @function\n *\n * @param {Cartesian4} cartesian The Cartesian4 instance to create a Cartesian3 instance from.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.\n */\nCartesian3.fromCartesian4 = Cartesian3.clone;\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nCartesian3.packedLength = 3;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Cartesian3} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nCartesian3.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value.x;\n array[startingIndex++] = value.y;\n array[startingIndex] = value.z;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Cartesian3} [result] The object into which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.\n */\nCartesian3.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n result.x = array[startingIndex++];\n result.y = array[startingIndex++];\n result.z = array[startingIndex];\n return result;\n};\n\n/**\n * Flattens an array of Cartesian3s into an array of components.\n *\n * @param {Cartesian3[]} array The array of cartesians to pack.\n * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 3 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 3) elements.\n * @returns {number[]} The packed array.\n */\nCartesian3.packArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n const length = array.length;\n const resultLength = length * 3;\n if (!defined(result)) {\n result = new Array(resultLength);\n } else if (!Array.isArray(result) && result.length !== resultLength) {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"If result is a typed array, it must have exactly array.length * 3 elements\"\n );\n //>>includeEnd('debug');\n } else if (result.length !== resultLength) {\n result.length = resultLength;\n }\n\n for (let i = 0; i < length; ++i) {\n Cartesian3.pack(array[i], result, i * 3);\n }\n return result;\n};\n\n/**\n * Unpacks an array of cartesian components into an array of Cartesian3s.\n *\n * @param {number[]} array The array of components to unpack.\n * @param {Cartesian3[]} [result] The array onto which to store the result.\n * @returns {Cartesian3[]} The unpacked array.\n */\nCartesian3.unpackArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.typeOf.number.greaterThanOrEquals(\"array.length\", array.length, 3);\n if (array.length % 3 !== 0) {\n throw new DeveloperError(\"array length must be a multiple of 3.\");\n }\n //>>includeEnd('debug');\n\n const length = array.length;\n if (!defined(result)) {\n result = new Array(length / 3);\n } else {\n result.length = length / 3;\n }\n\n for (let i = 0; i < length; i += 3) {\n const index = i / 3;\n result[index] = Cartesian3.unpack(array, i, result[index]);\n }\n return result;\n};\n\n/**\n * Creates a Cartesian3 from three consecutive elements in an array.\n * @function\n *\n * @param {number[]} array The array whose three consecutive elements correspond to the x, y, and z components, respectively.\n * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.\n *\n * @example\n * // Create a Cartesian3 with (1.0, 2.0, 3.0)\n * const v = [1.0, 2.0, 3.0];\n * const p = Cesium.Cartesian3.fromArray(v);\n *\n * // Create a Cartesian3 with (1.0, 2.0, 3.0) using an offset into an array\n * const v2 = [0.0, 0.0, 1.0, 2.0, 3.0];\n * const p2 = Cesium.Cartesian3.fromArray(v2, 2);\n */\nCartesian3.fromArray = Cartesian3.unpack;\n\n/**\n * Computes the value of the maximum component for the supplied Cartesian.\n *\n * @param {Cartesian3} cartesian The cartesian to use.\n * @returns {number} The value of the maximum component.\n */\nCartesian3.maximumComponent = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return Math.max(cartesian.x, cartesian.y, cartesian.z);\n};\n\n/**\n * Computes the value of the minimum component for the supplied Cartesian.\n *\n * @param {Cartesian3} cartesian The cartesian to use.\n * @returns {number} The value of the minimum component.\n */\nCartesian3.minimumComponent = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return Math.min(cartesian.x, cartesian.y, cartesian.z);\n};\n\n/**\n * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.\n *\n * @param {Cartesian3} first A cartesian to compare.\n * @param {Cartesian3} second A cartesian to compare.\n * @param {Cartesian3} result The object into which to store the result.\n * @returns {Cartesian3} A cartesian with the minimum components.\n */\nCartesian3.minimumByComponent = function (first, second, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"first\", first);\n Check.typeOf.object(\"second\", second);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.min(first.x, second.x);\n result.y = Math.min(first.y, second.y);\n result.z = Math.min(first.z, second.z);\n\n return result;\n};\n\n/**\n * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.\n *\n * @param {Cartesian3} first A cartesian to compare.\n * @param {Cartesian3} second A cartesian to compare.\n * @param {Cartesian3} result The object into which to store the result.\n * @returns {Cartesian3} A cartesian with the maximum components.\n */\nCartesian3.maximumByComponent = function (first, second, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"first\", first);\n Check.typeOf.object(\"second\", second);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.max(first.x, second.x);\n result.y = Math.max(first.y, second.y);\n result.z = Math.max(first.z, second.z);\n return result;\n};\n\n/**\n * Constrain a value to lie between two values.\n *\n * @param {Cartesian3} cartesian The value to clamp.\n * @param {Cartesian3} min The minimum bound.\n * @param {Cartesian3} max The maximum bound.\n * @param {Cartesian3} result The object into which to store the result.\n * @returns {Cartesian3} The clamped value such that min <= value <= max.\n */\nCartesian3.clamp = function (value, min, max, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.typeOf.object(\"min\", min);\n Check.typeOf.object(\"max\", max);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = CesiumMath.clamp(value.x, min.x, max.x);\n const y = CesiumMath.clamp(value.y, min.y, max.y);\n const z = CesiumMath.clamp(value.z, min.z, max.z);\n\n result.x = x;\n result.y = y;\n result.z = z;\n\n return result;\n};\n\n/**\n * Computes the provided Cartesian's squared magnitude.\n *\n * @param {Cartesian3} cartesian The Cartesian instance whose squared magnitude is to be computed.\n * @returns {number} The squared magnitude.\n */\nCartesian3.magnitudeSquared = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return (\n cartesian.x * cartesian.x +\n cartesian.y * cartesian.y +\n cartesian.z * cartesian.z\n );\n};\n\n/**\n * Computes the Cartesian's magnitude (length).\n *\n * @param {Cartesian3} cartesian The Cartesian instance whose magnitude is to be computed.\n * @returns {number} The magnitude.\n */\nCartesian3.magnitude = function (cartesian) {\n return Math.sqrt(Cartesian3.magnitudeSquared(cartesian));\n};\n\nconst distanceScratch = new Cartesian3();\n\n/**\n * Computes the distance between two points.\n *\n * @param {Cartesian3} left The first point to compute the distance from.\n * @param {Cartesian3} right The second point to compute the distance to.\n * @returns {number} The distance between two points.\n *\n * @example\n * // Returns 1.0\n * const d = Cesium.Cartesian3.distance(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(2.0, 0.0, 0.0));\n */\nCartesian3.distance = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian3.subtract(left, right, distanceScratch);\n return Cartesian3.magnitude(distanceScratch);\n};\n\n/**\n * Computes the squared distance between two points. Comparing squared distances\n * using this function is more efficient than comparing distances using {@link Cartesian3#distance}.\n *\n * @param {Cartesian3} left The first point to compute the distance from.\n * @param {Cartesian3} right The second point to compute the distance to.\n * @returns {number} The distance between two points.\n *\n * @example\n * // Returns 4.0, not 2.0\n * const d = Cesium.Cartesian3.distanceSquared(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(3.0, 0.0, 0.0));\n */\nCartesian3.distanceSquared = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian3.subtract(left, right, distanceScratch);\n return Cartesian3.magnitudeSquared(distanceScratch);\n};\n\n/**\n * Computes the normalized form of the supplied Cartesian.\n *\n * @param {Cartesian3} cartesian The Cartesian to be normalized.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.normalize = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const magnitude = Cartesian3.magnitude(cartesian);\n\n result.x = cartesian.x / magnitude;\n result.y = cartesian.y / magnitude;\n result.z = cartesian.z / magnitude;\n\n //>>includeStart('debug', pragmas.debug);\n if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z)) {\n throw new DeveloperError(\"normalized result is not a number\");\n }\n //>>includeEnd('debug');\n\n return result;\n};\n\n/**\n * Computes the dot (scalar) product of two Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @returns {number} The dot product.\n */\nCartesian3.dot = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n return left.x * right.x + left.y * right.y + left.z * right.z;\n};\n\n/**\n * Computes the componentwise product of two Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.multiplyComponents = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x * right.x;\n result.y = left.y * right.y;\n result.z = left.z * right.z;\n return result;\n};\n\n/**\n * Computes the componentwise quotient of two Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.divideComponents = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x / right.x;\n result.y = left.y / right.y;\n result.z = left.z / right.z;\n return result;\n};\n\n/**\n * Computes the componentwise sum of two Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x + right.x;\n result.y = left.y + right.y;\n result.z = left.z + right.z;\n return result;\n};\n\n/**\n * Computes the componentwise difference of two Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x - right.x;\n result.y = left.y - right.y;\n result.z = left.z - right.z;\n return result;\n};\n\n/**\n * Multiplies the provided Cartesian componentwise by the provided scalar.\n *\n * @param {Cartesian3} cartesian The Cartesian to be scaled.\n * @param {number} scalar The scalar to multiply with.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.multiplyByScalar = function (cartesian, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = cartesian.x * scalar;\n result.y = cartesian.y * scalar;\n result.z = cartesian.z * scalar;\n return result;\n};\n\n/**\n * Divides the provided Cartesian componentwise by the provided scalar.\n *\n * @param {Cartesian3} cartesian The Cartesian to be divided.\n * @param {number} scalar The scalar to divide by.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.divideByScalar = function (cartesian, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = cartesian.x / scalar;\n result.y = cartesian.y / scalar;\n result.z = cartesian.z / scalar;\n return result;\n};\n\n/**\n * Negates the provided Cartesian.\n *\n * @param {Cartesian3} cartesian The Cartesian to be negated.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.negate = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = -cartesian.x;\n result.y = -cartesian.y;\n result.z = -cartesian.z;\n return result;\n};\n\n/**\n * Computes the absolute value of the provided Cartesian.\n *\n * @param {Cartesian3} cartesian The Cartesian whose absolute value is to be computed.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.abs = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.abs(cartesian.x);\n result.y = Math.abs(cartesian.y);\n result.z = Math.abs(cartesian.z);\n return result;\n};\n\nconst lerpScratch = new Cartesian3();\n/**\n * Computes the linear interpolation or extrapolation at t using the provided cartesians.\n *\n * @param {Cartesian3} start The value corresponding to t at 0.0.\n * @param {Cartesian3} end The value corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nCartesian3.lerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n Cartesian3.multiplyByScalar(end, t, lerpScratch);\n result = Cartesian3.multiplyByScalar(start, 1.0 - t, result);\n return Cartesian3.add(lerpScratch, result, result);\n};\n\nconst angleBetweenScratch = new Cartesian3();\nconst angleBetweenScratch2 = new Cartesian3();\n/**\n * Returns the angle, in radians, between the provided Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @returns {number} The angle between the Cartesians.\n */\nCartesian3.angleBetween = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian3.normalize(left, angleBetweenScratch);\n Cartesian3.normalize(right, angleBetweenScratch2);\n const cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);\n const sine = Cartesian3.magnitude(\n Cartesian3.cross(\n angleBetweenScratch,\n angleBetweenScratch2,\n angleBetweenScratch\n )\n );\n return Math.atan2(sine, cosine);\n};\n\nconst mostOrthogonalAxisScratch = new Cartesian3();\n/**\n * Returns the axis that is most orthogonal to the provided Cartesian.\n *\n * @param {Cartesian3} cartesian The Cartesian on which to find the most orthogonal axis.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The most orthogonal axis.\n */\nCartesian3.mostOrthogonalAxis = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const f = Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch);\n Cartesian3.abs(f, f);\n\n if (f.x <= f.y) {\n if (f.x <= f.z) {\n result = Cartesian3.clone(Cartesian3.UNIT_X, result);\n } else {\n result = Cartesian3.clone(Cartesian3.UNIT_Z, result);\n }\n } else if (f.y <= f.z) {\n result = Cartesian3.clone(Cartesian3.UNIT_Y, result);\n } else {\n result = Cartesian3.clone(Cartesian3.UNIT_Z, result);\n }\n\n return result;\n};\n\n/**\n * Projects vector a onto vector b\n * @param {Cartesian3} a The vector that needs projecting\n * @param {Cartesian3} b The vector to project onto\n * @param {Cartesian3} result The result cartesian\n * @returns {Cartesian3} The modified result parameter\n */\nCartesian3.projectVector = function (a, b, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"a\", a);\n Check.defined(\"b\", b);\n Check.defined(\"result\", result);\n //>>includeEnd('debug');\n\n const scalar = Cartesian3.dot(a, b) / Cartesian3.dot(b, b);\n return Cartesian3.multiplyByScalar(b, scalar, result);\n};\n\n/**\n * Compares the provided Cartesians componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartesian3} [left] The first Cartesian.\n * @param {Cartesian3} [right] The second Cartesian.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nCartesian3.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.x === right.x &&\n left.y === right.y &&\n left.z === right.z)\n );\n};\n\n/**\n * @private\n */\nCartesian3.equalsArray = function (cartesian, array, offset) {\n return (\n cartesian.x === array[offset] &&\n cartesian.y === array[offset + 1] &&\n cartesian.z === array[offset + 2]\n );\n};\n\n/**\n * Compares the provided Cartesians componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Cartesian3} [left] The first Cartesian.\n * @param {Cartesian3} [right] The second Cartesian.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nCartesian3.equalsEpsilon = function (\n left,\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n CesiumMath.equalsEpsilon(\n left.x,\n right.x,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.y,\n right.y,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.z,\n right.z,\n relativeEpsilon,\n absoluteEpsilon\n ))\n );\n};\n\n/**\n * Computes the cross (outer) product of two Cartesians.\n *\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The cross product.\n */\nCartesian3.cross = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const leftX = left.x;\n const leftY = left.y;\n const leftZ = left.z;\n const rightX = right.x;\n const rightY = right.y;\n const rightZ = right.z;\n\n const x = leftY * rightZ - leftZ * rightY;\n const y = leftZ * rightX - leftX * rightZ;\n const z = leftX * rightY - leftY * rightX;\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Computes the midpoint between the right and left Cartesian.\n * @param {Cartesian3} left The first Cartesian.\n * @param {Cartesian3} right The second Cartesian.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The midpoint.\n */\nCartesian3.midpoint = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = (left.x + right.x) * 0.5;\n result.y = (left.y + right.y) * 0.5;\n result.z = (left.z + right.z) * 0.5;\n\n return result;\n};\n\n/**\n * Returns a Cartesian3 position from longitude and latitude values given in degrees.\n *\n * @param {number} longitude The longitude, in degrees\n * @param {number} latitude The latitude, in degrees\n * @param {number} [height=0.0] The height, in meters, above the ellipsoid.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The position\n *\n * @example\n * const position = Cesium.Cartesian3.fromDegrees(-115.0, 37.0);\n */\nCartesian3.fromDegrees = function (\n longitude,\n latitude,\n height,\n ellipsoid,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"longitude\", longitude);\n Check.typeOf.number(\"latitude\", latitude);\n //>>includeEnd('debug');\n\n longitude = CesiumMath.toRadians(longitude);\n latitude = CesiumMath.toRadians(latitude);\n return Cartesian3.fromRadians(longitude, latitude, height, ellipsoid, result);\n};\n\nlet scratchN = new Cartesian3();\nlet scratchK = new Cartesian3();\nconst wgs84RadiiSquared = new Cartesian3(\n 6378137.0 * 6378137.0,\n 6378137.0 * 6378137.0,\n 6356752.3142451793 * 6356752.3142451793\n);\n\n/**\n * Returns a Cartesian3 position from longitude and latitude values given in radians.\n *\n * @param {number} longitude The longitude, in radians\n * @param {number} latitude The latitude, in radians\n * @param {number} [height=0.0] The height, in meters, above the ellipsoid.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The position\n *\n * @example\n * const position = Cesium.Cartesian3.fromRadians(-2.007, 0.645);\n */\nCartesian3.fromRadians = function (\n longitude,\n latitude,\n height,\n ellipsoid,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"longitude\", longitude);\n Check.typeOf.number(\"latitude\", latitude);\n //>>includeEnd('debug');\n\n height = defaultValue(height, 0.0);\n const radiiSquared = defined(ellipsoid)\n ? ellipsoid.radiiSquared\n : wgs84RadiiSquared;\n\n const cosLatitude = Math.cos(latitude);\n scratchN.x = cosLatitude * Math.cos(longitude);\n scratchN.y = cosLatitude * Math.sin(longitude);\n scratchN.z = Math.sin(latitude);\n scratchN = Cartesian3.normalize(scratchN, scratchN);\n\n Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);\n const gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK));\n scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK);\n scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n return Cartesian3.add(scratchK, scratchN, result);\n};\n\n/**\n * Returns an array of Cartesian3 positions given an array of longitude and latitude values given in degrees.\n *\n * @param {number[]} coordinates A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the coordinates lie.\n * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.\n * @returns {Cartesian3[]} The array of positions.\n *\n * @example\n * const positions = Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -107.0, 33.0]);\n */\nCartesian3.fromDegreesArray = function (coordinates, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"coordinates\", coordinates);\n if (coordinates.length < 2 || coordinates.length % 2 !== 0) {\n throw new DeveloperError(\n \"the number of coordinates must be a multiple of 2 and at least 2\"\n );\n }\n //>>includeEnd('debug');\n\n const length = coordinates.length;\n if (!defined(result)) {\n result = new Array(length / 2);\n } else {\n result.length = length / 2;\n }\n\n for (let i = 0; i < length; i += 2) {\n const longitude = coordinates[i];\n const latitude = coordinates[i + 1];\n const index = i / 2;\n result[index] = Cartesian3.fromDegrees(\n longitude,\n latitude,\n 0,\n ellipsoid,\n result[index]\n );\n }\n\n return result;\n};\n\n/**\n * Returns an array of Cartesian3 positions given an array of longitude and latitude values given in radians.\n *\n * @param {number[]} coordinates A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the coordinates lie.\n * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.\n * @returns {Cartesian3[]} The array of positions.\n *\n * @example\n * const positions = Cesium.Cartesian3.fromRadiansArray([-2.007, 0.645, -1.867, .575]);\n */\nCartesian3.fromRadiansArray = function (coordinates, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"coordinates\", coordinates);\n if (coordinates.length < 2 || coordinates.length % 2 !== 0) {\n throw new DeveloperError(\n \"the number of coordinates must be a multiple of 2 and at least 2\"\n );\n }\n //>>includeEnd('debug');\n\n const length = coordinates.length;\n if (!defined(result)) {\n result = new Array(length / 2);\n } else {\n result.length = length / 2;\n }\n\n for (let i = 0; i < length; i += 2) {\n const longitude = coordinates[i];\n const latitude = coordinates[i + 1];\n const index = i / 2;\n result[index] = Cartesian3.fromRadians(\n longitude,\n latitude,\n 0,\n ellipsoid,\n result[index]\n );\n }\n\n return result;\n};\n\n/**\n * Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in degrees.\n *\n * @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.\n * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.\n * @returns {Cartesian3[]} The array of positions.\n *\n * @example\n * const positions = Cesium.Cartesian3.fromDegreesArrayHeights([-115.0, 37.0, 100000.0, -107.0, 33.0, 150000.0]);\n */\nCartesian3.fromDegreesArrayHeights = function (coordinates, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"coordinates\", coordinates);\n if (coordinates.length < 3 || coordinates.length % 3 !== 0) {\n throw new DeveloperError(\n \"the number of coordinates must be a multiple of 3 and at least 3\"\n );\n }\n //>>includeEnd('debug');\n\n const length = coordinates.length;\n if (!defined(result)) {\n result = new Array(length / 3);\n } else {\n result.length = length / 3;\n }\n\n for (let i = 0; i < length; i += 3) {\n const longitude = coordinates[i];\n const latitude = coordinates[i + 1];\n const height = coordinates[i + 2];\n const index = i / 3;\n result[index] = Cartesian3.fromDegrees(\n longitude,\n latitude,\n height,\n ellipsoid,\n result[index]\n );\n }\n\n return result;\n};\n\n/**\n * Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in radians.\n *\n * @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.\n * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.\n * @returns {Cartesian3[]} The array of positions.\n *\n * @example\n * const positions = Cesium.Cartesian3.fromRadiansArrayHeights([-2.007, 0.645, 100000.0, -1.867, .575, 150000.0]);\n */\nCartesian3.fromRadiansArrayHeights = function (coordinates, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"coordinates\", coordinates);\n if (coordinates.length < 3 || coordinates.length % 3 !== 0) {\n throw new DeveloperError(\n \"the number of coordinates must be a multiple of 3 and at least 3\"\n );\n }\n //>>includeEnd('debug');\n\n const length = coordinates.length;\n if (!defined(result)) {\n result = new Array(length / 3);\n } else {\n result.length = length / 3;\n }\n\n for (let i = 0; i < length; i += 3) {\n const longitude = coordinates[i];\n const latitude = coordinates[i + 1];\n const height = coordinates[i + 2];\n const index = i / 3;\n result[index] = Cartesian3.fromRadians(\n longitude,\n latitude,\n height,\n ellipsoid,\n result[index]\n );\n }\n\n return result;\n};\n\n/**\n * An immutable Cartesian3 instance initialized to (0.0, 0.0, 0.0).\n *\n * @type {Cartesian3}\n * @constant\n */\nCartesian3.ZERO = Object.freeze(new Cartesian3(0.0, 0.0, 0.0));\n\n/**\n * An immutable Cartesian3 instance initialized to (1.0, 1.0, 1.0).\n *\n * @type {Cartesian3}\n * @constant\n */\nCartesian3.ONE = Object.freeze(new Cartesian3(1.0, 1.0, 1.0));\n\n/**\n * An immutable Cartesian3 instance initialized to (1.0, 0.0, 0.0).\n *\n * @type {Cartesian3}\n * @constant\n */\nCartesian3.UNIT_X = Object.freeze(new Cartesian3(1.0, 0.0, 0.0));\n\n/**\n * An immutable Cartesian3 instance initialized to (0.0, 1.0, 0.0).\n *\n * @type {Cartesian3}\n * @constant\n */\nCartesian3.UNIT_Y = Object.freeze(new Cartesian3(0.0, 1.0, 0.0));\n\n/**\n * An immutable Cartesian3 instance initialized to (0.0, 0.0, 1.0).\n *\n * @type {Cartesian3}\n * @constant\n */\nCartesian3.UNIT_Z = Object.freeze(new Cartesian3(0.0, 0.0, 1.0));\n\n/**\n * Duplicates this Cartesian3 instance.\n *\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.\n */\nCartesian3.prototype.clone = function (result) {\n return Cartesian3.clone(this, result);\n};\n\n/**\n * Compares this Cartesian against the provided Cartesian componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartesian3} [right] The right hand side Cartesian.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nCartesian3.prototype.equals = function (right) {\n return Cartesian3.equals(this, right);\n};\n\n/**\n * Compares this Cartesian against the provided Cartesian componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Cartesian3} [right] The right hand side Cartesian.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nCartesian3.prototype.equalsEpsilon = function (\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return Cartesian3.equalsEpsilon(\n this,\n right,\n relativeEpsilon,\n absoluteEpsilon\n );\n};\n\n/**\n * Creates a string representing this Cartesian in the format '(x, y, z)'.\n *\n * @returns {string} A string representing this Cartesian in the format '(x, y, z)'.\n */\nCartesian3.prototype.toString = function () {\n return `(${this.x}, ${this.y}, ${this.z})`;\n};\nexport default Cartesian3;\n", "import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\n\n/**\n * A 4D Cartesian point.\n * @alias Cartesian4\n * @constructor\n *\n * @param {number} [x=0.0] The X component.\n * @param {number} [y=0.0] The Y component.\n * @param {number} [z=0.0] The Z component.\n * @param {number} [w=0.0] The W component.\n *\n * @see Cartesian2\n * @see Cartesian3\n * @see Packable\n */\nfunction Cartesian4(x, y, z, w) {\n /**\n * The X component.\n * @type {number}\n * @default 0.0\n */\n this.x = defaultValue(x, 0.0);\n\n /**\n * The Y component.\n * @type {number}\n * @default 0.0\n */\n this.y = defaultValue(y, 0.0);\n\n /**\n * The Z component.\n * @type {number}\n * @default 0.0\n */\n this.z = defaultValue(z, 0.0);\n\n /**\n * The W component.\n * @type {number}\n * @default 0.0\n */\n this.w = defaultValue(w, 0.0);\n}\n\n/**\n * Creates a Cartesian4 instance from x, y, z and w coordinates.\n *\n * @param {number} x The x coordinate.\n * @param {number} y The y coordinate.\n * @param {number} z The z coordinate.\n * @param {number} w The w coordinate.\n * @param {Cartesian4} [result] The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.\n */\nCartesian4.fromElements = function (x, y, z, w, result) {\n if (!defined(result)) {\n return new Cartesian4(x, y, z, w);\n }\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\n/**\n * Creates a Cartesian4 instance from a {@link Color}. red, green, blue,\n * and alpha map to x, y, z, and w, respectively.\n *\n * @param {Color} color The source color.\n * @param {Cartesian4} [result] The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.\n */\nCartesian4.fromColor = function (color, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"color\", color);\n //>>includeEnd('debug');\n if (!defined(result)) {\n return new Cartesian4(color.red, color.green, color.blue, color.alpha);\n }\n\n result.x = color.red;\n result.y = color.green;\n result.z = color.blue;\n result.w = color.alpha;\n return result;\n};\n\n/**\n * Duplicates a Cartesian4 instance.\n *\n * @param {Cartesian4} cartesian The Cartesian to duplicate.\n * @param {Cartesian4} [result] The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)\n */\nCartesian4.clone = function (cartesian, result) {\n if (!defined(cartesian)) {\n return undefined;\n }\n\n if (!defined(result)) {\n return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);\n }\n\n result.x = cartesian.x;\n result.y = cartesian.y;\n result.z = cartesian.z;\n result.w = cartesian.w;\n return result;\n};\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nCartesian4.packedLength = 4;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Cartesian4} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nCartesian4.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value.x;\n array[startingIndex++] = value.y;\n array[startingIndex++] = value.z;\n array[startingIndex] = value.w;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Cartesian4} [result] The object into which to store the result.\n * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.\n */\nCartesian4.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Cartesian4();\n }\n result.x = array[startingIndex++];\n result.y = array[startingIndex++];\n result.z = array[startingIndex++];\n result.w = array[startingIndex];\n return result;\n};\n\n/**\n * Flattens an array of Cartesian4s into an array of components.\n *\n * @param {Cartesian4[]} array The array of cartesians to pack.\n * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.\n * @returns {number[]} The packed array.\n */\nCartesian4.packArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n const length = array.length;\n const resultLength = length * 4;\n if (!defined(result)) {\n result = new Array(resultLength);\n } else if (!Array.isArray(result) && result.length !== resultLength) {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"If result is a typed array, it must have exactly array.length * 4 elements\"\n );\n //>>includeEnd('debug');\n } else if (result.length !== resultLength) {\n result.length = resultLength;\n }\n\n for (let i = 0; i < length; ++i) {\n Cartesian4.pack(array[i], result, i * 4);\n }\n return result;\n};\n\n/**\n * Unpacks an array of cartesian components into an array of Cartesian4s.\n *\n * @param {number[]} array The array of components to unpack.\n * @param {Cartesian4[]} [result] The array onto which to store the result.\n * @returns {Cartesian4[]} The unpacked array.\n */\nCartesian4.unpackArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.typeOf.number.greaterThanOrEquals(\"array.length\", array.length, 4);\n if (array.length % 4 !== 0) {\n throw new DeveloperError(\"array length must be a multiple of 4.\");\n }\n //>>includeEnd('debug');\n\n const length = array.length;\n if (!defined(result)) {\n result = new Array(length / 4);\n } else {\n result.length = length / 4;\n }\n\n for (let i = 0; i < length; i += 4) {\n const index = i / 4;\n result[index] = Cartesian4.unpack(array, i, result[index]);\n }\n return result;\n};\n\n/**\n * Creates a Cartesian4 from four consecutive elements in an array.\n * @function\n *\n * @param {number[]} array The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.\n * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.\n * @param {Cartesian4} [result] The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.\n *\n * @example\n * // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)\n * const v = [1.0, 2.0, 3.0, 4.0];\n * const p = Cesium.Cartesian4.fromArray(v);\n *\n * // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array\n * const v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];\n * const p2 = Cesium.Cartesian4.fromArray(v2, 2);\n */\nCartesian4.fromArray = Cartesian4.unpack;\n\n/**\n * Computes the value of the maximum component for the supplied Cartesian.\n *\n * @param {Cartesian4} cartesian The cartesian to use.\n * @returns {number} The value of the maximum component.\n */\nCartesian4.maximumComponent = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);\n};\n\n/**\n * Computes the value of the minimum component for the supplied Cartesian.\n *\n * @param {Cartesian4} cartesian The cartesian to use.\n * @returns {number} The value of the minimum component.\n */\nCartesian4.minimumComponent = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);\n};\n\n/**\n * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.\n *\n * @param {Cartesian4} first A cartesian to compare.\n * @param {Cartesian4} second A cartesian to compare.\n * @param {Cartesian4} result The object into which to store the result.\n * @returns {Cartesian4} A cartesian with the minimum components.\n */\nCartesian4.minimumByComponent = function (first, second, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"first\", first);\n Check.typeOf.object(\"second\", second);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.min(first.x, second.x);\n result.y = Math.min(first.y, second.y);\n result.z = Math.min(first.z, second.z);\n result.w = Math.min(first.w, second.w);\n\n return result;\n};\n\n/**\n * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.\n *\n * @param {Cartesian4} first A cartesian to compare.\n * @param {Cartesian4} second A cartesian to compare.\n * @param {Cartesian4} result The object into which to store the result.\n * @returns {Cartesian4} A cartesian with the maximum components.\n */\nCartesian4.maximumByComponent = function (first, second, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"first\", first);\n Check.typeOf.object(\"second\", second);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.max(first.x, second.x);\n result.y = Math.max(first.y, second.y);\n result.z = Math.max(first.z, second.z);\n result.w = Math.max(first.w, second.w);\n\n return result;\n};\n\n/**\n * Constrain a value to lie between two values.\n *\n * @param {Cartesian4} value The value to clamp.\n * @param {Cartesian4} min The minimum bound.\n * @param {Cartesian4} max The maximum bound.\n * @param {Cartesian4} result The object into which to store the result.\n * @returns {Cartesian4} The clamped value such that min <= result <= max.\n */\nCartesian4.clamp = function (value, min, max, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.typeOf.object(\"min\", min);\n Check.typeOf.object(\"max\", max);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = CesiumMath.clamp(value.x, min.x, max.x);\n const y = CesiumMath.clamp(value.y, min.y, max.y);\n const z = CesiumMath.clamp(value.z, min.z, max.z);\n const w = CesiumMath.clamp(value.w, min.w, max.w);\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n\n return result;\n};\n\n/**\n * Computes the provided Cartesian's squared magnitude.\n *\n * @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.\n * @returns {number} The squared magnitude.\n */\nCartesian4.magnitudeSquared = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return (\n cartesian.x * cartesian.x +\n cartesian.y * cartesian.y +\n cartesian.z * cartesian.z +\n cartesian.w * cartesian.w\n );\n};\n\n/**\n * Computes the Cartesian's magnitude (length).\n *\n * @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.\n * @returns {number} The magnitude.\n */\nCartesian4.magnitude = function (cartesian) {\n return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));\n};\n\nconst distanceScratch = new Cartesian4();\n\n/**\n * Computes the 4-space distance between two points.\n *\n * @param {Cartesian4} left The first point to compute the distance from.\n * @param {Cartesian4} right The second point to compute the distance to.\n * @returns {number} The distance between two points.\n *\n * @example\n * // Returns 1.0\n * const d = Cesium.Cartesian4.distance(\n * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),\n * new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));\n */\nCartesian4.distance = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian4.subtract(left, right, distanceScratch);\n return Cartesian4.magnitude(distanceScratch);\n};\n\n/**\n * Computes the squared distance between two points. Comparing squared distances\n * using this function is more efficient than comparing distances using {@link Cartesian4#distance}.\n *\n * @param {Cartesian4} left The first point to compute the distance from.\n * @param {Cartesian4} right The second point to compute the distance to.\n * @returns {number} The distance between two points.\n *\n * @example\n * // Returns 4.0, not 2.0\n * const d = Cesium.Cartesian4.distance(\n * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),\n * new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));\n */\nCartesian4.distanceSquared = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian4.subtract(left, right, distanceScratch);\n return Cartesian4.magnitudeSquared(distanceScratch);\n};\n\n/**\n * Computes the normalized form of the supplied Cartesian.\n *\n * @param {Cartesian4} cartesian The Cartesian to be normalized.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.normalize = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const magnitude = Cartesian4.magnitude(cartesian);\n\n result.x = cartesian.x / magnitude;\n result.y = cartesian.y / magnitude;\n result.z = cartesian.z / magnitude;\n result.w = cartesian.w / magnitude;\n\n //>>includeStart('debug', pragmas.debug);\n if (\n isNaN(result.x) ||\n isNaN(result.y) ||\n isNaN(result.z) ||\n isNaN(result.w)\n ) {\n throw new DeveloperError(\"normalized result is not a number\");\n }\n //>>includeEnd('debug');\n\n return result;\n};\n\n/**\n * Computes the dot (scalar) product of two Cartesians.\n *\n * @param {Cartesian4} left The first Cartesian.\n * @param {Cartesian4} right The second Cartesian.\n * @returns {number} The dot product.\n */\nCartesian4.dot = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n return (\n left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w\n );\n};\n\n/**\n * Computes the componentwise product of two Cartesians.\n *\n * @param {Cartesian4} left The first Cartesian.\n * @param {Cartesian4} right The second Cartesian.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.multiplyComponents = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x * right.x;\n result.y = left.y * right.y;\n result.z = left.z * right.z;\n result.w = left.w * right.w;\n return result;\n};\n\n/**\n * Computes the componentwise quotient of two Cartesians.\n *\n * @param {Cartesian4} left The first Cartesian.\n * @param {Cartesian4} right The second Cartesian.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.divideComponents = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x / right.x;\n result.y = left.y / right.y;\n result.z = left.z / right.z;\n result.w = left.w / right.w;\n return result;\n};\n\n/**\n * Computes the componentwise sum of two Cartesians.\n *\n * @param {Cartesian4} left The first Cartesian.\n * @param {Cartesian4} right The second Cartesian.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x + right.x;\n result.y = left.y + right.y;\n result.z = left.z + right.z;\n result.w = left.w + right.w;\n return result;\n};\n\n/**\n * Computes the componentwise difference of two Cartesians.\n *\n * @param {Cartesian4} left The first Cartesian.\n * @param {Cartesian4} right The second Cartesian.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x - right.x;\n result.y = left.y - right.y;\n result.z = left.z - right.z;\n result.w = left.w - right.w;\n return result;\n};\n\n/**\n * Multiplies the provided Cartesian componentwise by the provided scalar.\n *\n * @param {Cartesian4} cartesian The Cartesian to be scaled.\n * @param {number} scalar The scalar to multiply with.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.multiplyByScalar = function (cartesian, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = cartesian.x * scalar;\n result.y = cartesian.y * scalar;\n result.z = cartesian.z * scalar;\n result.w = cartesian.w * scalar;\n return result;\n};\n\n/**\n * Divides the provided Cartesian componentwise by the provided scalar.\n *\n * @param {Cartesian4} cartesian The Cartesian to be divided.\n * @param {number} scalar The scalar to divide by.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.divideByScalar = function (cartesian, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = cartesian.x / scalar;\n result.y = cartesian.y / scalar;\n result.z = cartesian.z / scalar;\n result.w = cartesian.w / scalar;\n return result;\n};\n\n/**\n * Negates the provided Cartesian.\n *\n * @param {Cartesian4} cartesian The Cartesian to be negated.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.negate = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = -cartesian.x;\n result.y = -cartesian.y;\n result.z = -cartesian.z;\n result.w = -cartesian.w;\n return result;\n};\n\n/**\n * Computes the absolute value of the provided Cartesian.\n *\n * @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.abs = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.abs(cartesian.x);\n result.y = Math.abs(cartesian.y);\n result.z = Math.abs(cartesian.z);\n result.w = Math.abs(cartesian.w);\n return result;\n};\n\nconst lerpScratch = new Cartesian4();\n/**\n * Computes the linear interpolation or extrapolation at t using the provided cartesians.\n *\n * @param {Cartesian4} start The value corresponding to t at 0.0.\n * @param {Cartesian4}end The value corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nCartesian4.lerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n Cartesian4.multiplyByScalar(end, t, lerpScratch);\n result = Cartesian4.multiplyByScalar(start, 1.0 - t, result);\n return Cartesian4.add(lerpScratch, result, result);\n};\n\nconst mostOrthogonalAxisScratch = new Cartesian4();\n/**\n * Returns the axis that is most orthogonal to the provided Cartesian.\n *\n * @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The most orthogonal axis.\n */\nCartesian4.mostOrthogonalAxis = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);\n Cartesian4.abs(f, f);\n\n if (f.x <= f.y) {\n if (f.x <= f.z) {\n if (f.x <= f.w) {\n result = Cartesian4.clone(Cartesian4.UNIT_X, result);\n } else {\n result = Cartesian4.clone(Cartesian4.UNIT_W, result);\n }\n } else if (f.z <= f.w) {\n result = Cartesian4.clone(Cartesian4.UNIT_Z, result);\n } else {\n result = Cartesian4.clone(Cartesian4.UNIT_W, result);\n }\n } else if (f.y <= f.z) {\n if (f.y <= f.w) {\n result = Cartesian4.clone(Cartesian4.UNIT_Y, result);\n } else {\n result = Cartesian4.clone(Cartesian4.UNIT_W, result);\n }\n } else if (f.z <= f.w) {\n result = Cartesian4.clone(Cartesian4.UNIT_Z, result);\n } else {\n result = Cartesian4.clone(Cartesian4.UNIT_W, result);\n }\n\n return result;\n};\n\n/**\n * Compares the provided Cartesians componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartesian4} [left] The first Cartesian.\n * @param {Cartesian4} [right] The second Cartesian.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nCartesian4.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.x === right.x &&\n left.y === right.y &&\n left.z === right.z &&\n left.w === right.w)\n );\n};\n\n/**\n * @private\n */\nCartesian4.equalsArray = function (cartesian, array, offset) {\n return (\n cartesian.x === array[offset] &&\n cartesian.y === array[offset + 1] &&\n cartesian.z === array[offset + 2] &&\n cartesian.w === array[offset + 3]\n );\n};\n\n/**\n * Compares the provided Cartesians componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Cartesian4} [left] The first Cartesian.\n * @param {Cartesian4} [right] The second Cartesian.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nCartesian4.equalsEpsilon = function (\n left,\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n CesiumMath.equalsEpsilon(\n left.x,\n right.x,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.y,\n right.y,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.z,\n right.z,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.w,\n right.w,\n relativeEpsilon,\n absoluteEpsilon\n ))\n );\n};\n\n/**\n * An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 0.0).\n *\n * @type {Cartesian4}\n * @constant\n */\nCartesian4.ZERO = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 0.0));\n\n/**\n * An immutable Cartesian4 instance initialized to (1.0, 1.0, 1.0, 1.0).\n *\n * @type {Cartesian4}\n * @constant\n */\nCartesian4.ONE = Object.freeze(new Cartesian4(1.0, 1.0, 1.0, 1.0));\n\n/**\n * An immutable Cartesian4 instance initialized to (1.0, 0.0, 0.0, 0.0).\n *\n * @type {Cartesian4}\n * @constant\n */\nCartesian4.UNIT_X = Object.freeze(new Cartesian4(1.0, 0.0, 0.0, 0.0));\n\n/**\n * An immutable Cartesian4 instance initialized to (0.0, 1.0, 0.0, 0.0).\n *\n * @type {Cartesian4}\n * @constant\n */\nCartesian4.UNIT_Y = Object.freeze(new Cartesian4(0.0, 1.0, 0.0, 0.0));\n\n/**\n * An immutable Cartesian4 instance initialized to (0.0, 0.0, 1.0, 0.0).\n *\n * @type {Cartesian4}\n * @constant\n */\nCartesian4.UNIT_Z = Object.freeze(new Cartesian4(0.0, 0.0, 1.0, 0.0));\n\n/**\n * An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 1.0).\n *\n * @type {Cartesian4}\n * @constant\n */\nCartesian4.UNIT_W = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 1.0));\n\n/**\n * Duplicates this Cartesian4 instance.\n *\n * @param {Cartesian4} [result] The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.\n */\nCartesian4.prototype.clone = function (result) {\n return Cartesian4.clone(this, result);\n};\n\n/**\n * Compares this Cartesian against the provided Cartesian componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartesian4} [right] The right hand side Cartesian.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nCartesian4.prototype.equals = function (right) {\n return Cartesian4.equals(this, right);\n};\n\n/**\n * Compares this Cartesian against the provided Cartesian componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Cartesian4} [right] The right hand side Cartesian.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nCartesian4.prototype.equalsEpsilon = function (\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return Cartesian4.equalsEpsilon(\n this,\n right,\n relativeEpsilon,\n absoluteEpsilon\n );\n};\n\n/**\n * Creates a string representing this Cartesian in the format '(x, y, z, w)'.\n *\n * @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.\n */\nCartesian4.prototype.toString = function () {\n return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;\n};\n\n// scratchU8Array and scratchF32Array are views into the same buffer\nconst scratchF32Array = new Float32Array(1);\nconst scratchU8Array = new Uint8Array(scratchF32Array.buffer);\n\nconst testU32 = new Uint32Array([0x11223344]);\nconst testU8 = new Uint8Array(testU32.buffer);\nconst littleEndian = testU8[0] === 0x44;\n\n/**\n * Packs an arbitrary floating point value to 4 values representable using uint8.\n *\n * @param {number} value A floating point number.\n * @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.\n * @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.\n */\nCartesian4.packFloat = function (value, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"value\", value);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Cartesian4();\n }\n\n // scratchU8Array and scratchF32Array are views into the same buffer\n scratchF32Array[0] = value;\n\n if (littleEndian) {\n result.x = scratchU8Array[0];\n result.y = scratchU8Array[1];\n result.z = scratchU8Array[2];\n result.w = scratchU8Array[3];\n } else {\n // convert from big-endian to little-endian\n result.x = scratchU8Array[3];\n result.y = scratchU8Array[2];\n result.z = scratchU8Array[1];\n result.w = scratchU8Array[0];\n }\n return result;\n};\n\n/**\n * Unpacks a float packed using Cartesian4.packFloat.\n *\n * @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.\n * @returns {number} The unpacked float.\n * @private\n */\nCartesian4.unpackFloat = function (packedFloat) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"packedFloat\", packedFloat);\n //>>includeEnd('debug');\n\n // scratchU8Array and scratchF32Array are views into the same buffer\n if (littleEndian) {\n scratchU8Array[0] = packedFloat.x;\n scratchU8Array[1] = packedFloat.y;\n scratchU8Array[2] = packedFloat.z;\n scratchU8Array[3] = packedFloat.w;\n } else {\n // convert from little-endian to big-endian\n scratchU8Array[0] = packedFloat.w;\n scratchU8Array[1] = packedFloat.z;\n scratchU8Array[2] = packedFloat.y;\n scratchU8Array[3] = packedFloat.x;\n }\n return scratchF32Array[0];\n};\nexport default Cartesian4;\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\n\n/**\n * A 3x3 matrix, indexable as a column-major order array.\n * Constructor parameters are in row-major order for code readability.\n * @alias Matrix3\n * @constructor\n * @implements {ArrayLike}\n *\n * @param {number} [column0Row0=0.0] The value for column 0, row 0.\n * @param {number} [column1Row0=0.0] The value for column 1, row 0.\n * @param {number} [column2Row0=0.0] The value for column 2, row 0.\n * @param {number} [column0Row1=0.0] The value for column 0, row 1.\n * @param {number} [column1Row1=0.0] The value for column 1, row 1.\n * @param {number} [column2Row1=0.0] The value for column 2, row 1.\n * @param {number} [column0Row2=0.0] The value for column 0, row 2.\n * @param {number} [column1Row2=0.0] The value for column 1, row 2.\n * @param {number} [column2Row2=0.0] The value for column 2, row 2.\n *\n * @see Matrix3.fromArray\n * @see Matrix3.fromColumnMajorArray\n * @see Matrix3.fromRowMajorArray\n * @see Matrix3.fromQuaternion\n * @see Matrix3.fromHeadingPitchRoll\n * @see Matrix3.fromScale\n * @see Matrix3.fromUniformScale\n * @see Matrix3.fromCrossProduct\n * @see Matrix3.fromRotationX\n * @see Matrix3.fromRotationY\n * @see Matrix3.fromRotationZ\n * @see Matrix2\n * @see Matrix4\n */\nfunction Matrix3(\n column0Row0,\n column1Row0,\n column2Row0,\n column0Row1,\n column1Row1,\n column2Row1,\n column0Row2,\n column1Row2,\n column2Row2\n) {\n this[0] = defaultValue(column0Row0, 0.0);\n this[1] = defaultValue(column0Row1, 0.0);\n this[2] = defaultValue(column0Row2, 0.0);\n this[3] = defaultValue(column1Row0, 0.0);\n this[4] = defaultValue(column1Row1, 0.0);\n this[5] = defaultValue(column1Row2, 0.0);\n this[6] = defaultValue(column2Row0, 0.0);\n this[7] = defaultValue(column2Row1, 0.0);\n this[8] = defaultValue(column2Row2, 0.0);\n}\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nMatrix3.packedLength = 9;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Matrix3} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nMatrix3.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value[0];\n array[startingIndex++] = value[1];\n array[startingIndex++] = value[2];\n array[startingIndex++] = value[3];\n array[startingIndex++] = value[4];\n array[startingIndex++] = value[5];\n array[startingIndex++] = value[6];\n array[startingIndex++] = value[7];\n array[startingIndex++] = value[8];\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Matrix3} [result] The object into which to store the result.\n * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.\n */\nMatrix3.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Matrix3();\n }\n\n result[0] = array[startingIndex++];\n result[1] = array[startingIndex++];\n result[2] = array[startingIndex++];\n result[3] = array[startingIndex++];\n result[4] = array[startingIndex++];\n result[5] = array[startingIndex++];\n result[6] = array[startingIndex++];\n result[7] = array[startingIndex++];\n result[8] = array[startingIndex++];\n return result;\n};\n\n/**\n * Flattens an array of Matrix3s into an array of components. The components\n * are stored in column-major order.\n *\n * @param {Matrix3[]} array The array of matrices to pack.\n * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 9 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 9) elements.\n * @returns {number[]} The packed array.\n */\nMatrix3.packArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n const length = array.length;\n const resultLength = length * 9;\n if (!defined(result)) {\n result = new Array(resultLength);\n } else if (!Array.isArray(result) && result.length !== resultLength) {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"If result is a typed array, it must have exactly array.length * 9 elements\"\n );\n //>>includeEnd('debug');\n } else if (result.length !== resultLength) {\n result.length = resultLength;\n }\n\n for (let i = 0; i < length; ++i) {\n Matrix3.pack(array[i], result, i * 9);\n }\n return result;\n};\n\n/**\n * Unpacks an array of column-major matrix components into an array of Matrix3s.\n *\n * @param {number[]} array The array of components to unpack.\n * @param {Matrix3[]} [result] The array onto which to store the result.\n * @returns {Matrix3[]} The unpacked array.\n */\nMatrix3.unpackArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.typeOf.number.greaterThanOrEquals(\"array.length\", array.length, 9);\n if (array.length % 9 !== 0) {\n throw new DeveloperError(\"array length must be a multiple of 9.\");\n }\n //>>includeEnd('debug');\n\n const length = array.length;\n if (!defined(result)) {\n result = new Array(length / 9);\n } else {\n result.length = length / 9;\n }\n\n for (let i = 0; i < length; i += 9) {\n const index = i / 9;\n result[index] = Matrix3.unpack(array, i, result[index]);\n }\n return result;\n};\n\n/**\n * Duplicates a Matrix3 instance.\n *\n * @param {Matrix3} matrix The matrix to duplicate.\n * @param {Matrix3} [result] The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined)\n */\nMatrix3.clone = function (matrix, result) {\n if (!defined(matrix)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Matrix3(\n matrix[0],\n matrix[3],\n matrix[6],\n matrix[1],\n matrix[4],\n matrix[7],\n matrix[2],\n matrix[5],\n matrix[8]\n );\n }\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n result[4] = matrix[4];\n result[5] = matrix[5];\n result[6] = matrix[6];\n result[7] = matrix[7];\n result[8] = matrix[8];\n return result;\n};\n\n/**\n * Creates a Matrix3 from 9 consecutive elements in an array.\n *\n * @function\n * @param {number[]} array The array whose 9 consecutive elements correspond to the positions of the matrix. Assumes column-major order.\n * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to first column first row position in the matrix.\n * @param {Matrix3} [result] The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Create the Matrix3:\n * // [1.0, 2.0, 3.0]\n * // [1.0, 2.0, 3.0]\n * // [1.0, 2.0, 3.0]\n *\n * const v = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];\n * const m = Cesium.Matrix3.fromArray(v);\n *\n * // Create same Matrix3 with using an offset into an array\n * const v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];\n * const m2 = Cesium.Matrix3.fromArray(v2, 2);\n */\nMatrix3.fromArray = Matrix3.unpack;\n\n/**\n * Creates a Matrix3 instance from a column-major order array.\n *\n * @param {number[]} values The column-major order array.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n */\nMatrix3.fromColumnMajorArray = function (values, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"values\", values);\n //>>includeEnd('debug');\n\n return Matrix3.clone(values, result);\n};\n\n/**\n * Creates a Matrix3 instance from a row-major order array.\n * The resulting matrix will be in column-major order.\n *\n * @param {number[]} values The row-major order array.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n */\nMatrix3.fromRowMajorArray = function (values, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"values\", values);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix3(\n values[0],\n values[1],\n values[2],\n values[3],\n values[4],\n values[5],\n values[6],\n values[7],\n values[8]\n );\n }\n result[0] = values[0];\n result[1] = values[3];\n result[2] = values[6];\n result[3] = values[1];\n result[4] = values[4];\n result[5] = values[7];\n result[6] = values[2];\n result[7] = values[5];\n result[8] = values[8];\n return result;\n};\n\n/**\n * Computes a 3x3 rotation matrix from the provided quaternion.\n *\n * @param {Quaternion} quaternion the quaternion to use.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The 3x3 rotation matrix from this quaternion.\n */\nMatrix3.fromQuaternion = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n //>>includeEnd('debug');\n\n const x2 = quaternion.x * quaternion.x;\n const xy = quaternion.x * quaternion.y;\n const xz = quaternion.x * quaternion.z;\n const xw = quaternion.x * quaternion.w;\n const y2 = quaternion.y * quaternion.y;\n const yz = quaternion.y * quaternion.z;\n const yw = quaternion.y * quaternion.w;\n const z2 = quaternion.z * quaternion.z;\n const zw = quaternion.z * quaternion.w;\n const w2 = quaternion.w * quaternion.w;\n\n const m00 = x2 - y2 - z2 + w2;\n const m01 = 2.0 * (xy - zw);\n const m02 = 2.0 * (xz + yw);\n\n const m10 = 2.0 * (xy + zw);\n const m11 = -x2 + y2 - z2 + w2;\n const m12 = 2.0 * (yz - xw);\n\n const m20 = 2.0 * (xz - yw);\n const m21 = 2.0 * (yz + xw);\n const m22 = -x2 - y2 + z2 + w2;\n\n if (!defined(result)) {\n return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);\n }\n result[0] = m00;\n result[1] = m10;\n result[2] = m20;\n result[3] = m01;\n result[4] = m11;\n result[5] = m21;\n result[6] = m02;\n result[7] = m12;\n result[8] = m22;\n return result;\n};\n\n/**\n * Computes a 3x3 rotation matrix from the provided headingPitchRoll. (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles )\n *\n * @param {HeadingPitchRoll} headingPitchRoll the headingPitchRoll to use.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The 3x3 rotation matrix from this headingPitchRoll.\n */\nMatrix3.fromHeadingPitchRoll = function (headingPitchRoll, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"headingPitchRoll\", headingPitchRoll);\n //>>includeEnd('debug');\n\n const cosTheta = Math.cos(-headingPitchRoll.pitch);\n const cosPsi = Math.cos(-headingPitchRoll.heading);\n const cosPhi = Math.cos(headingPitchRoll.roll);\n const sinTheta = Math.sin(-headingPitchRoll.pitch);\n const sinPsi = Math.sin(-headingPitchRoll.heading);\n const sinPhi = Math.sin(headingPitchRoll.roll);\n\n const m00 = cosTheta * cosPsi;\n const m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;\n const m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;\n\n const m10 = cosTheta * sinPsi;\n const m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;\n const m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;\n\n const m20 = -sinTheta;\n const m21 = sinPhi * cosTheta;\n const m22 = cosPhi * cosTheta;\n\n if (!defined(result)) {\n return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);\n }\n result[0] = m00;\n result[1] = m10;\n result[2] = m20;\n result[3] = m01;\n result[4] = m11;\n result[5] = m21;\n result[6] = m02;\n result[7] = m12;\n result[8] = m22;\n return result;\n};\n\n/**\n * Computes a Matrix3 instance representing a non-uniform scale.\n *\n * @param {Cartesian3} scale The x, y, and z scale factors.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [7.0, 0.0, 0.0]\n * // [0.0, 8.0, 0.0]\n * // [0.0, 0.0, 9.0]\n * const m = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));\n */\nMatrix3.fromScale = function (scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix3(scale.x, 0.0, 0.0, 0.0, scale.y, 0.0, 0.0, 0.0, scale.z);\n }\n\n result[0] = scale.x;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = scale.y;\n result[5] = 0.0;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = scale.z;\n return result;\n};\n\n/**\n * Computes a Matrix3 instance representing a uniform scale.\n *\n * @param {number} scale The uniform scale factor.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [2.0, 0.0, 0.0]\n * // [0.0, 2.0, 0.0]\n * // [0.0, 0.0, 2.0]\n * const m = Cesium.Matrix3.fromUniformScale(2.0);\n */\nMatrix3.fromUniformScale = function (scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix3(scale, 0.0, 0.0, 0.0, scale, 0.0, 0.0, 0.0, scale);\n }\n\n result[0] = scale;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = scale;\n result[5] = 0.0;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = scale;\n return result;\n};\n\n/**\n * Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.\n *\n * @param {Cartesian3} vector the vector on the left hand side of the cross product operation.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [0.0, -9.0, 8.0]\n * // [9.0, 0.0, -7.0]\n * // [-8.0, 7.0, 0.0]\n * const m = Cesium.Matrix3.fromCrossProduct(new Cesium.Cartesian3(7.0, 8.0, 9.0));\n */\nMatrix3.fromCrossProduct = function (vector, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"vector\", vector);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix3(\n 0.0,\n -vector.z,\n vector.y,\n vector.z,\n 0.0,\n -vector.x,\n -vector.y,\n vector.x,\n 0.0\n );\n }\n\n result[0] = 0.0;\n result[1] = vector.z;\n result[2] = -vector.y;\n result[3] = -vector.z;\n result[4] = 0.0;\n result[5] = vector.x;\n result[6] = vector.y;\n result[7] = -vector.x;\n result[8] = 0.0;\n return result;\n};\n\n/**\n * Creates a rotation matrix around the x-axis.\n *\n * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Rotate a point 45 degrees counterclockwise around the x-axis.\n * const p = new Cesium.Cartesian3(5, 6, 7);\n * const m = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45.0));\n * const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());\n */\nMatrix3.fromRotationX = function (angle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"angle\", angle);\n //>>includeEnd('debug');\n\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n\n if (!defined(result)) {\n return new Matrix3(\n 1.0,\n 0.0,\n 0.0,\n 0.0,\n cosAngle,\n -sinAngle,\n 0.0,\n sinAngle,\n cosAngle\n );\n }\n\n result[0] = 1.0;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = cosAngle;\n result[5] = sinAngle;\n result[6] = 0.0;\n result[7] = -sinAngle;\n result[8] = cosAngle;\n\n return result;\n};\n\n/**\n * Creates a rotation matrix around the y-axis.\n *\n * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Rotate a point 45 degrees counterclockwise around the y-axis.\n * const p = new Cesium.Cartesian3(5, 6, 7);\n * const m = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(45.0));\n * const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());\n */\nMatrix3.fromRotationY = function (angle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"angle\", angle);\n //>>includeEnd('debug');\n\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n\n if (!defined(result)) {\n return new Matrix3(\n cosAngle,\n 0.0,\n sinAngle,\n 0.0,\n 1.0,\n 0.0,\n -sinAngle,\n 0.0,\n cosAngle\n );\n }\n\n result[0] = cosAngle;\n result[1] = 0.0;\n result[2] = -sinAngle;\n result[3] = 0.0;\n result[4] = 1.0;\n result[5] = 0.0;\n result[6] = sinAngle;\n result[7] = 0.0;\n result[8] = cosAngle;\n\n return result;\n};\n\n/**\n * Creates a rotation matrix around the z-axis.\n *\n * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.\n * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.\n *\n * @example\n * // Rotate a point 45 degrees counterclockwise around the z-axis.\n * const p = new Cesium.Cartesian3(5, 6, 7);\n * const m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0));\n * const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());\n */\nMatrix3.fromRotationZ = function (angle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"angle\", angle);\n //>>includeEnd('debug');\n\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n\n if (!defined(result)) {\n return new Matrix3(\n cosAngle,\n -sinAngle,\n 0.0,\n sinAngle,\n cosAngle,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n );\n }\n\n result[0] = cosAngle;\n result[1] = sinAngle;\n result[2] = 0.0;\n result[3] = -sinAngle;\n result[4] = cosAngle;\n result[5] = 0.0;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 1.0;\n\n return result;\n};\n\n/**\n * Creates an Array from the provided Matrix3 instance.\n * The array will be in column-major order.\n *\n * @param {Matrix3} matrix The matrix to use..\n * @param {number[]} [result] The Array onto which to store the result.\n * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.\n */\nMatrix3.toArray = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return [\n matrix[0],\n matrix[1],\n matrix[2],\n matrix[3],\n matrix[4],\n matrix[5],\n matrix[6],\n matrix[7],\n matrix[8],\n ];\n }\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n result[4] = matrix[4];\n result[5] = matrix[5];\n result[6] = matrix[6];\n result[7] = matrix[7];\n result[8] = matrix[8];\n return result;\n};\n\n/**\n * Computes the array index of the element at the provided row and column.\n *\n * @param {number} column The zero-based index of the column.\n * @param {number} row The zero-based index of the row.\n * @returns {number} The index of the element at the provided row and column.\n *\n * @exception {DeveloperError} row must be 0, 1, or 2.\n * @exception {DeveloperError} column must be 0, 1, or 2.\n *\n * @example\n * const myMatrix = new Cesium.Matrix3();\n * const column1Row0Index = Cesium.Matrix3.getElementIndex(1, 0);\n * const column1Row0 = myMatrix[column1Row0Index]\n * myMatrix[column1Row0Index] = 10.0;\n */\nMatrix3.getElementIndex = function (column, row) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThanOrEquals(\"row\", row, 0);\n Check.typeOf.number.lessThanOrEquals(\"row\", row, 2);\n Check.typeOf.number.greaterThanOrEquals(\"column\", column, 0);\n Check.typeOf.number.lessThanOrEquals(\"column\", column, 2);\n //>>includeEnd('debug');\n\n return column * 3 + row;\n};\n\n/**\n * Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @param {number} index The zero-based index of the column to retrieve.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, or 2.\n */\nMatrix3.getColumn = function (matrix, index, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 2);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const startIndex = index * 3;\n const x = matrix[startIndex];\n const y = matrix[startIndex + 1];\n const z = matrix[startIndex + 2];\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @param {number} index The zero-based index of the column to set.\n * @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified column.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, or 2.\n */\nMatrix3.setColumn = function (matrix, index, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 2);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result = Matrix3.clone(matrix, result);\n const startIndex = index * 3;\n result[startIndex] = cartesian.x;\n result[startIndex + 1] = cartesian.y;\n result[startIndex + 2] = cartesian.z;\n return result;\n};\n\n/**\n * Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @param {number} index The zero-based index of the row to retrieve.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, or 2.\n */\nMatrix3.getRow = function (matrix, index, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 2);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = matrix[index];\n const y = matrix[index + 3];\n const z = matrix[index + 6];\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @param {number} index The zero-based index of the row to set.\n * @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified row.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, or 2.\n */\nMatrix3.setRow = function (matrix, index, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 2);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result = Matrix3.clone(matrix, result);\n result[index] = cartesian.x;\n result[index + 3] = cartesian.y;\n result[index + 6] = cartesian.z;\n return result;\n};\n\nconst scaleScratch1 = new Cartesian3();\n\n/**\n * Computes a new matrix that replaces the scale with the provided scale.\n * This assumes the matrix is an affine transformation.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @param {Cartesian3} scale The scale that replaces the scale of the provided matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @see Matrix3.setUniformScale\n * @see Matrix3.fromScale\n * @see Matrix3.fromUniformScale\n * @see Matrix3.multiplyByScale\n * @see Matrix3.multiplyByUniformScale\n * @see Matrix3.getScale\n */\nMatrix3.setScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const existingScale = Matrix3.getScale(matrix, scaleScratch1);\n const scaleRatioX = scale.x / existingScale.x;\n const scaleRatioY = scale.y / existingScale.y;\n const scaleRatioZ = scale.z / existingScale.z;\n\n result[0] = matrix[0] * scaleRatioX;\n result[1] = matrix[1] * scaleRatioX;\n result[2] = matrix[2] * scaleRatioX;\n result[3] = matrix[3] * scaleRatioY;\n result[4] = matrix[4] * scaleRatioY;\n result[5] = matrix[5] * scaleRatioY;\n result[6] = matrix[6] * scaleRatioZ;\n result[7] = matrix[7] * scaleRatioZ;\n result[8] = matrix[8] * scaleRatioZ;\n\n return result;\n};\n\nconst scaleScratch2 = new Cartesian3();\n\n/**\n * Computes a new matrix that replaces the scale with the provided uniform scale.\n * This assumes the matrix is an affine transformation.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @param {number} scale The uniform scale that replaces the scale of the provided matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @see Matrix3.setScale\n * @see Matrix3.fromScale\n * @see Matrix3.fromUniformScale\n * @see Matrix3.multiplyByScale\n * @see Matrix3.multiplyByUniformScale\n * @see Matrix3.getScale\n */\nMatrix3.setUniformScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const existingScale = Matrix3.getScale(matrix, scaleScratch2);\n const scaleRatioX = scale / existingScale.x;\n const scaleRatioY = scale / existingScale.y;\n const scaleRatioZ = scale / existingScale.z;\n\n result[0] = matrix[0] * scaleRatioX;\n result[1] = matrix[1] * scaleRatioX;\n result[2] = matrix[2] * scaleRatioX;\n result[3] = matrix[3] * scaleRatioY;\n result[4] = matrix[4] * scaleRatioY;\n result[5] = matrix[5] * scaleRatioY;\n result[6] = matrix[6] * scaleRatioZ;\n result[7] = matrix[7] * scaleRatioZ;\n result[8] = matrix[8] * scaleRatioZ;\n\n return result;\n};\n\nconst scratchColumn = new Cartesian3();\n\n/**\n * Extracts the non-uniform scale assuming the matrix is an affine transformation.\n *\n * @param {Matrix3} matrix The matrix.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n *\n * @see Matrix3.multiplyByScale\n * @see Matrix3.multiplyByUniformScale\n * @see Matrix3.fromScale\n * @see Matrix3.fromUniformScale\n * @see Matrix3.setScale\n * @see Matrix3.setUniformScale\n */\nMatrix3.getScale = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Cartesian3.magnitude(\n Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)\n );\n result.y = Cartesian3.magnitude(\n Cartesian3.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn)\n );\n result.z = Cartesian3.magnitude(\n Cartesian3.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn)\n );\n return result;\n};\n\nconst scaleScratch3 = new Cartesian3();\n\n/**\n * Computes the maximum scale assuming the matrix is an affine transformation.\n * The maximum scale is the maximum length of the column vectors.\n *\n * @param {Matrix3} matrix The matrix.\n * @returns {number} The maximum scale.\n */\nMatrix3.getMaximumScale = function (matrix) {\n Matrix3.getScale(matrix, scaleScratch3);\n return Cartesian3.maximumComponent(scaleScratch3);\n};\n\nconst scaleScratch4 = new Cartesian3();\n\n/**\n * Sets the rotation assuming the matrix is an affine transformation.\n *\n * @param {Matrix3} matrix The matrix.\n * @param {Matrix3} rotation The rotation matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @see Matrix3.getRotation\n */\nMatrix3.setRotation = function (matrix, rotation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scale = Matrix3.getScale(matrix, scaleScratch4);\n\n result[0] = rotation[0] * scale.x;\n result[1] = rotation[1] * scale.x;\n result[2] = rotation[2] * scale.x;\n result[3] = rotation[3] * scale.y;\n result[4] = rotation[4] * scale.y;\n result[5] = rotation[5] * scale.y;\n result[6] = rotation[6] * scale.z;\n result[7] = rotation[7] * scale.z;\n result[8] = rotation[8] * scale.z;\n\n return result;\n};\n\nconst scaleScratch5 = new Cartesian3();\n\n/**\n * Extracts the rotation matrix assuming the matrix is an affine transformation.\n *\n * @param {Matrix3} matrix The matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @see Matrix3.setRotation\n */\nMatrix3.getRotation = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scale = Matrix3.getScale(matrix, scaleScratch5);\n\n result[0] = matrix[0] / scale.x;\n result[1] = matrix[1] / scale.x;\n result[2] = matrix[2] / scale.x;\n result[3] = matrix[3] / scale.y;\n result[4] = matrix[4] / scale.y;\n result[5] = matrix[5] / scale.y;\n result[6] = matrix[6] / scale.z;\n result[7] = matrix[7] / scale.z;\n result[8] = matrix[8] / scale.z;\n\n return result;\n};\n\n/**\n * Computes the product of two matrices.\n *\n * @param {Matrix3} left The first matrix.\n * @param {Matrix3} right The second matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.multiply = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const column0Row0 =\n left[0] * right[0] + left[3] * right[1] + left[6] * right[2];\n const column0Row1 =\n left[1] * right[0] + left[4] * right[1] + left[7] * right[2];\n const column0Row2 =\n left[2] * right[0] + left[5] * right[1] + left[8] * right[2];\n\n const column1Row0 =\n left[0] * right[3] + left[3] * right[4] + left[6] * right[5];\n const column1Row1 =\n left[1] * right[3] + left[4] * right[4] + left[7] * right[5];\n const column1Row2 =\n left[2] * right[3] + left[5] * right[4] + left[8] * right[5];\n\n const column2Row0 =\n left[0] * right[6] + left[3] * right[7] + left[6] * right[8];\n const column2Row1 =\n left[1] * right[6] + left[4] * right[7] + left[7] * right[8];\n const column2Row2 =\n left[2] * right[6] + left[5] * right[7] + left[8] * right[8];\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column0Row2;\n result[3] = column1Row0;\n result[4] = column1Row1;\n result[5] = column1Row2;\n result[6] = column2Row0;\n result[7] = column2Row1;\n result[8] = column2Row2;\n return result;\n};\n\n/**\n * Computes the sum of two matrices.\n *\n * @param {Matrix3} left The first matrix.\n * @param {Matrix3} right The second matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = left[0] + right[0];\n result[1] = left[1] + right[1];\n result[2] = left[2] + right[2];\n result[3] = left[3] + right[3];\n result[4] = left[4] + right[4];\n result[5] = left[5] + right[5];\n result[6] = left[6] + right[6];\n result[7] = left[7] + right[7];\n result[8] = left[8] + right[8];\n return result;\n};\n\n/**\n * Computes the difference of two matrices.\n *\n * @param {Matrix3} left The first matrix.\n * @param {Matrix3} right The second matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = left[0] - right[0];\n result[1] = left[1] - right[1];\n result[2] = left[2] - right[2];\n result[3] = left[3] - right[3];\n result[4] = left[4] - right[4];\n result[5] = left[5] - right[5];\n result[6] = left[6] - right[6];\n result[7] = left[7] - right[7];\n result[8] = left[8] - right[8];\n return result;\n};\n\n/**\n * Computes the product of a matrix and a column vector.\n *\n * @param {Matrix3} matrix The matrix.\n * @param {Cartesian3} cartesian The column.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nMatrix3.multiplyByVector = function (matrix, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const vX = cartesian.x;\n const vY = cartesian.y;\n const vZ = cartesian.z;\n\n const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;\n const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;\n const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Computes the product of a matrix and a scalar.\n *\n * @param {Matrix3} matrix The matrix.\n * @param {number} scalar The number to multiply by.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.multiplyByScalar = function (matrix, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scalar;\n result[1] = matrix[1] * scalar;\n result[2] = matrix[2] * scalar;\n result[3] = matrix[3] * scalar;\n result[4] = matrix[4] * scalar;\n result[5] = matrix[5] * scalar;\n result[6] = matrix[6] * scalar;\n result[7] = matrix[7] * scalar;\n result[8] = matrix[8] * scalar;\n return result;\n};\n\n/**\n * Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.\n *\n * @param {Matrix3} matrix The matrix on the left-hand side.\n * @param {Cartesian3} scale The non-uniform scale on the right-hand side.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n *\n * @example\n * // Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromScale(scale), m);\n * Cesium.Matrix3.multiplyByScale(m, scale, m);\n *\n * @see Matrix3.multiplyByUniformScale\n * @see Matrix3.fromScale\n * @see Matrix3.fromUniformScale\n * @see Matrix3.setScale\n * @see Matrix3.setUniformScale\n * @see Matrix3.getScale\n */\nMatrix3.multiplyByScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scale.x;\n result[1] = matrix[1] * scale.x;\n result[2] = matrix[2] * scale.x;\n result[3] = matrix[3] * scale.y;\n result[4] = matrix[4] * scale.y;\n result[5] = matrix[5] * scale.y;\n result[6] = matrix[6] * scale.z;\n result[7] = matrix[7] * scale.z;\n result[8] = matrix[8] * scale.z;\n\n return result;\n};\n\n/**\n * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.\n *\n * @param {Matrix3} matrix The matrix on the left-hand side.\n * @param {number} scale The uniform scale on the right-hand side.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @example\n * // Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromUniformScale(scale), m);\n * Cesium.Matrix3.multiplyByUniformScale(m, scale, m);\n *\n * @see Matrix3.multiplyByScale\n * @see Matrix3.fromScale\n * @see Matrix3.fromUniformScale\n * @see Matrix3.setScale\n * @see Matrix3.setUniformScale\n * @see Matrix3.getScale\n */\nMatrix3.multiplyByUniformScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scale;\n result[1] = matrix[1] * scale;\n result[2] = matrix[2] * scale;\n result[3] = matrix[3] * scale;\n result[4] = matrix[4] * scale;\n result[5] = matrix[5] * scale;\n result[6] = matrix[6] * scale;\n result[7] = matrix[7] * scale;\n result[8] = matrix[8] * scale;\n\n return result;\n};\n\n/**\n * Creates a negated copy of the provided matrix.\n *\n * @param {Matrix3} matrix The matrix to negate.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.negate = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = -matrix[0];\n result[1] = -matrix[1];\n result[2] = -matrix[2];\n result[3] = -matrix[3];\n result[4] = -matrix[4];\n result[5] = -matrix[5];\n result[6] = -matrix[6];\n result[7] = -matrix[7];\n result[8] = -matrix[8];\n return result;\n};\n\n/**\n * Computes the transpose of the provided matrix.\n *\n * @param {Matrix3} matrix The matrix to transpose.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.transpose = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const column0Row0 = matrix[0];\n const column0Row1 = matrix[3];\n const column0Row2 = matrix[6];\n const column1Row0 = matrix[1];\n const column1Row1 = matrix[4];\n const column1Row2 = matrix[7];\n const column2Row0 = matrix[2];\n const column2Row1 = matrix[5];\n const column2Row2 = matrix[8];\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column0Row2;\n result[3] = column1Row0;\n result[4] = column1Row1;\n result[5] = column1Row2;\n result[6] = column2Row0;\n result[7] = column2Row1;\n result[8] = column2Row2;\n return result;\n};\n\nfunction computeFrobeniusNorm(matrix) {\n let norm = 0.0;\n for (let i = 0; i < 9; ++i) {\n const temp = matrix[i];\n norm += temp * temp;\n }\n\n return Math.sqrt(norm);\n}\n\nconst rowVal = [1, 0, 0];\nconst colVal = [2, 2, 1];\n\nfunction offDiagonalFrobeniusNorm(matrix) {\n // Computes the \"off-diagonal\" Frobenius norm.\n // Assumes matrix is symmetric.\n\n let norm = 0.0;\n for (let i = 0; i < 3; ++i) {\n const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];\n norm += 2.0 * temp * temp;\n }\n\n return Math.sqrt(norm);\n}\n\nfunction shurDecomposition(matrix, result) {\n // This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,\n // section 8.4.2 The 2by2 Symmetric Schur Decomposition.\n //\n // The routine takes a matrix, which is assumed to be symmetric, and\n // finds the largest off-diagonal term, and then creates\n // a matrix (result) which can be used to help reduce it\n\n const tolerance = CesiumMath.EPSILON15;\n\n let maxDiagonal = 0.0;\n let rotAxis = 1;\n\n // find pivot (rotAxis) based on max diagonal of matrix\n for (let i = 0; i < 3; ++i) {\n const temp = Math.abs(\n matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]\n );\n if (temp > maxDiagonal) {\n rotAxis = i;\n maxDiagonal = temp;\n }\n }\n\n let c = 1.0;\n let s = 0.0;\n\n const p = rowVal[rotAxis];\n const q = colVal[rotAxis];\n\n if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {\n const qq = matrix[Matrix3.getElementIndex(q, q)];\n const pp = matrix[Matrix3.getElementIndex(p, p)];\n const qp = matrix[Matrix3.getElementIndex(q, p)];\n\n const tau = (qq - pp) / 2.0 / qp;\n let t;\n\n if (tau < 0.0) {\n t = -1.0 / (-tau + Math.sqrt(1.0 + tau * tau));\n } else {\n t = 1.0 / (tau + Math.sqrt(1.0 + tau * tau));\n }\n\n c = 1.0 / Math.sqrt(1.0 + t * t);\n s = t * c;\n }\n\n result = Matrix3.clone(Matrix3.IDENTITY, result);\n\n result[Matrix3.getElementIndex(p, p)] = result[\n Matrix3.getElementIndex(q, q)\n ] = c;\n result[Matrix3.getElementIndex(q, p)] = s;\n result[Matrix3.getElementIndex(p, q)] = -s;\n\n return result;\n}\n\nconst jMatrix = new Matrix3();\nconst jMatrixTranspose = new Matrix3();\n\n/**\n * Computes the eigenvectors and eigenvalues of a symmetric matrix.\n *
\n * Returns a diagonal matrix and unitary matrix such that:\n * matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)\n *
\n *
\n * The values along the diagonal of the diagonal matrix are the eigenvalues. The columns\n * of the unitary matrix are the corresponding eigenvectors.\n *
\n *\n * @param {Matrix3} matrix The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.\n * @param {object} [result] An object with unitary and diagonal properties which are matrices onto which to store the result.\n * @returns {object} An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.\n *\n * @example\n * const a = //... symetric matrix\n * const result = {\n * unitary : new Cesium.Matrix3(),\n * diagonal : new Cesium.Matrix3()\n * };\n * Cesium.Matrix3.computeEigenDecomposition(a, result);\n *\n * const unitaryTranspose = Cesium.Matrix3.transpose(result.unitary, new Cesium.Matrix3());\n * const b = Cesium.Matrix3.multiply(result.unitary, result.diagonal, new Cesium.Matrix3());\n * Cesium.Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a\n *\n * const lambda = Cesium.Matrix3.getColumn(result.diagonal, 0, new Cesium.Cartesian3()).x; // first eigenvalue\n * const v = Cesium.Matrix3.getColumn(result.unitary, 0, new Cesium.Cartesian3()); // first eigenvector\n * const c = Cesium.Cartesian3.multiplyByScalar(v, lambda, new Cesium.Cartesian3()); // equal to Cesium.Matrix3.multiplyByVector(a, v)\n */\nMatrix3.computeEigenDecomposition = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n //>>includeEnd('debug');\n\n // This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,\n // section 8.4.3 The Classical Jacobi Algorithm\n\n const tolerance = CesiumMath.EPSILON20;\n const maxSweeps = 10;\n\n let count = 0;\n let sweep = 0;\n\n if (!defined(result)) {\n result = {};\n }\n\n const unitaryMatrix = (result.unitary = Matrix3.clone(\n Matrix3.IDENTITY,\n result.unitary\n ));\n const diagMatrix = (result.diagonal = Matrix3.clone(matrix, result.diagonal));\n\n const epsilon = tolerance * computeFrobeniusNorm(diagMatrix);\n\n while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {\n shurDecomposition(diagMatrix, jMatrix);\n Matrix3.transpose(jMatrix, jMatrixTranspose);\n Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);\n Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);\n Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);\n\n if (++count > 2) {\n ++sweep;\n count = 0;\n }\n }\n\n return result;\n};\n\n/**\n * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.\n *\n * @param {Matrix3} matrix The matrix with signed elements.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.abs = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = Math.abs(matrix[0]);\n result[1] = Math.abs(matrix[1]);\n result[2] = Math.abs(matrix[2]);\n result[3] = Math.abs(matrix[3]);\n result[4] = Math.abs(matrix[4]);\n result[5] = Math.abs(matrix[5]);\n result[6] = Math.abs(matrix[6]);\n result[7] = Math.abs(matrix[7]);\n result[8] = Math.abs(matrix[8]);\n\n return result;\n};\n\n/**\n * Computes the determinant of the provided matrix.\n *\n * @param {Matrix3} matrix The matrix to use.\n * @returns {number} The value of the determinant of the matrix.\n */\nMatrix3.determinant = function (matrix) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n //>>includeEnd('debug');\n\n const m11 = matrix[0];\n const m21 = matrix[3];\n const m31 = matrix[6];\n const m12 = matrix[1];\n const m22 = matrix[4];\n const m32 = matrix[7];\n const m13 = matrix[2];\n const m23 = matrix[5];\n const m33 = matrix[8];\n\n return (\n m11 * (m22 * m33 - m23 * m32) +\n m12 * (m23 * m31 - m21 * m33) +\n m13 * (m21 * m32 - m22 * m31)\n );\n};\n\n/**\n * Computes the inverse of the provided matrix.\n *\n * @param {Matrix3} matrix The matrix to invert.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @exception {DeveloperError} matrix is not invertible.\n */\nMatrix3.inverse = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const m11 = matrix[0];\n const m21 = matrix[1];\n const m31 = matrix[2];\n const m12 = matrix[3];\n const m22 = matrix[4];\n const m32 = matrix[5];\n const m13 = matrix[6];\n const m23 = matrix[7];\n const m33 = matrix[8];\n\n const determinant = Matrix3.determinant(matrix);\n\n //>>includeStart('debug', pragmas.debug);\n if (Math.abs(determinant) <= CesiumMath.EPSILON15) {\n throw new DeveloperError(\"matrix is not invertible\");\n }\n //>>includeEnd('debug');\n\n result[0] = m22 * m33 - m23 * m32;\n result[1] = m23 * m31 - m21 * m33;\n result[2] = m21 * m32 - m22 * m31;\n result[3] = m13 * m32 - m12 * m33;\n result[4] = m11 * m33 - m13 * m31;\n result[5] = m12 * m31 - m11 * m32;\n result[6] = m12 * m23 - m13 * m22;\n result[7] = m13 * m21 - m11 * m23;\n result[8] = m11 * m22 - m12 * m21;\n\n const scale = 1.0 / determinant;\n return Matrix3.multiplyByScalar(result, scale, result);\n};\n\nconst scratchTransposeMatrix = new Matrix3();\n\n/**\n * Computes the inverse transpose of a matrix.\n *\n * @param {Matrix3} matrix The matrix to transpose and invert.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n */\nMatrix3.inverseTranspose = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n return Matrix3.inverse(\n Matrix3.transpose(matrix, scratchTransposeMatrix),\n result\n );\n};\n\n/**\n * Compares the provided matrices componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Matrix3} [left] The first matrix.\n * @param {Matrix3} [right] The second matrix.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nMatrix3.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left[0] === right[0] &&\n left[1] === right[1] &&\n left[2] === right[2] &&\n left[3] === right[3] &&\n left[4] === right[4] &&\n left[5] === right[5] &&\n left[6] === right[6] &&\n left[7] === right[7] &&\n left[8] === right[8])\n );\n};\n\n/**\n * Compares the provided matrices componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Matrix3} [left] The first matrix.\n * @param {Matrix3} [right] The second matrix.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nMatrix3.equalsEpsilon = function (left, right, epsilon) {\n epsilon = defaultValue(epsilon, 0);\n\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(left[0] - right[0]) <= epsilon &&\n Math.abs(left[1] - right[1]) <= epsilon &&\n Math.abs(left[2] - right[2]) <= epsilon &&\n Math.abs(left[3] - right[3]) <= epsilon &&\n Math.abs(left[4] - right[4]) <= epsilon &&\n Math.abs(left[5] - right[5]) <= epsilon &&\n Math.abs(left[6] - right[6]) <= epsilon &&\n Math.abs(left[7] - right[7]) <= epsilon &&\n Math.abs(left[8] - right[8]) <= epsilon)\n );\n};\n\n/**\n * An immutable Matrix3 instance initialized to the identity matrix.\n *\n * @type {Matrix3}\n * @constant\n */\nMatrix3.IDENTITY = Object.freeze(\n new Matrix3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)\n);\n\n/**\n * An immutable Matrix3 instance initialized to the zero matrix.\n *\n * @type {Matrix3}\n * @constant\n */\nMatrix3.ZERO = Object.freeze(\n new Matrix3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)\n);\n\n/**\n * The index into Matrix3 for column 0, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN0ROW0 = 0;\n\n/**\n * The index into Matrix3 for column 0, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN0ROW1 = 1;\n\n/**\n * The index into Matrix3 for column 0, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN0ROW2 = 2;\n\n/**\n * The index into Matrix3 for column 1, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN1ROW0 = 3;\n\n/**\n * The index into Matrix3 for column 1, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN1ROW1 = 4;\n\n/**\n * The index into Matrix3 for column 1, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN1ROW2 = 5;\n\n/**\n * The index into Matrix3 for column 2, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN2ROW0 = 6;\n\n/**\n * The index into Matrix3 for column 2, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN2ROW1 = 7;\n\n/**\n * The index into Matrix3 for column 2, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix3.COLUMN2ROW2 = 8;\n\nObject.defineProperties(Matrix3.prototype, {\n /**\n * Gets the number of items in the collection.\n * @memberof Matrix3.prototype\n *\n * @type {number}\n */\n length: {\n get: function () {\n return Matrix3.packedLength;\n },\n },\n});\n\n/**\n * Duplicates the provided Matrix3 instance.\n *\n * @param {Matrix3} [result] The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.\n */\nMatrix3.prototype.clone = function (result) {\n return Matrix3.clone(this, result);\n};\n\n/**\n * Compares this matrix to the provided matrix componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Matrix3} [right] The right hand side matrix.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nMatrix3.prototype.equals = function (right) {\n return Matrix3.equals(this, right);\n};\n\n/**\n * @private\n */\nMatrix3.equalsArray = function (matrix, array, offset) {\n return (\n matrix[0] === array[offset] &&\n matrix[1] === array[offset + 1] &&\n matrix[2] === array[offset + 2] &&\n matrix[3] === array[offset + 3] &&\n matrix[4] === array[offset + 4] &&\n matrix[5] === array[offset + 5] &&\n matrix[6] === array[offset + 6] &&\n matrix[7] === array[offset + 7] &&\n matrix[8] === array[offset + 8]\n );\n};\n\n/**\n * Compares this matrix to the provided matrix componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Matrix3} [right] The right hand side matrix.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nMatrix3.prototype.equalsEpsilon = function (right, epsilon) {\n return Matrix3.equalsEpsilon(this, right, epsilon);\n};\n\n/**\n * Creates a string representing this Matrix with each row being\n * on a separate line and in the format '(column0, column1, column2)'.\n *\n * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2)'.\n */\nMatrix3.prototype.toString = function () {\n return (\n `(${this[0]}, ${this[3]}, ${this[6]})\\n` +\n `(${this[1]}, ${this[4]}, ${this[7]})\\n` +\n `(${this[2]}, ${this[5]}, ${this[8]})`\n );\n};\nexport default Matrix3;\n", "import defined from \"./defined.js\";\n\n/**\n * Constructs an exception object that is thrown due to an error that can occur at runtime, e.g.,\n * out of memory, could not compile shader, etc. If a function may throw this\n * exception, the calling code should be prepared to catch it.\n *
\n * On the other hand, a {@link DeveloperError} indicates an exception due\n * to a developer error, e.g., invalid argument, that usually indicates a bug in the\n * calling code.\n *\n * @alias RuntimeError\n * @constructor\n * @extends Error\n *\n * @param {string} [message] The error message for this exception.\n *\n * @see DeveloperError\n */\nfunction RuntimeError(message) {\n /**\n * 'RuntimeError' indicating that this exception was thrown due to a runtime error.\n * @type {string}\n * @readonly\n */\n this.name = \"RuntimeError\";\n\n /**\n * The explanation for why this exception was thrown.\n * @type {string}\n * @readonly\n */\n this.message = message;\n\n //Browsers such as IE don't have a stack property until you actually throw the error.\n let stack;\n try {\n throw new Error();\n } catch (e) {\n stack = e.stack;\n }\n\n /**\n * The stack trace of this exception, if available.\n * @type {string}\n * @readonly\n */\n this.stack = stack;\n}\n\nif (defined(Object.create)) {\n RuntimeError.prototype = Object.create(Error.prototype);\n RuntimeError.prototype.constructor = RuntimeError;\n}\n\nRuntimeError.prototype.toString = function () {\n let str = `${this.name}: ${this.message}`;\n\n if (defined(this.stack)) {\n str += `\\n${this.stack.toString()}`;\n }\n\n return str;\n};\nexport default RuntimeError;\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport Cartesian4 from \"./Cartesian4.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\nimport Matrix3 from \"./Matrix3.js\";\nimport RuntimeError from \"./RuntimeError.js\";\n\n/**\n * A 4x4 matrix, indexable as a column-major order array.\n * Constructor parameters are in row-major order for code readability.\n * @alias Matrix4\n * @constructor\n * @implements {ArrayLike}\n *\n * @param {number} [column0Row0=0.0] The value for column 0, row 0.\n * @param {number} [column1Row0=0.0] The value for column 1, row 0.\n * @param {number} [column2Row0=0.0] The value for column 2, row 0.\n * @param {number} [column3Row0=0.0] The value for column 3, row 0.\n * @param {number} [column0Row1=0.0] The value for column 0, row 1.\n * @param {number} [column1Row1=0.0] The value for column 1, row 1.\n * @param {number} [column2Row1=0.0] The value for column 2, row 1.\n * @param {number} [column3Row1=0.0] The value for column 3, row 1.\n * @param {number} [column0Row2=0.0] The value for column 0, row 2.\n * @param {number} [column1Row2=0.0] The value for column 1, row 2.\n * @param {number} [column2Row2=0.0] The value for column 2, row 2.\n * @param {number} [column3Row2=0.0] The value for column 3, row 2.\n * @param {number} [column0Row3=0.0] The value for column 0, row 3.\n * @param {number} [column1Row3=0.0] The value for column 1, row 3.\n * @param {number} [column2Row3=0.0] The value for column 2, row 3.\n * @param {number} [column3Row3=0.0] The value for column 3, row 3.\n *\n * @see Matrix4.fromArray\n * @see Matrix4.fromColumnMajorArray\n * @see Matrix4.fromRowMajorArray\n * @see Matrix4.fromRotationTranslation\n * @see Matrix4.fromTranslationQuaternionRotationScale\n * @see Matrix4.fromTranslationRotationScale\n * @see Matrix4.fromTranslation\n * @see Matrix4.fromScale\n * @see Matrix4.fromUniformScale\n * @see Matrix4.fromRotation\n * @see Matrix4.fromCamera\n * @see Matrix4.computePerspectiveFieldOfView\n * @see Matrix4.computeOrthographicOffCenter\n * @see Matrix4.computePerspectiveOffCenter\n * @see Matrix4.computeInfinitePerspectiveOffCenter\n * @see Matrix4.computeViewportTransformation\n * @see Matrix4.computeView\n * @see Matrix2\n * @see Matrix3\n * @see Packable\n */\nfunction Matrix4(\n column0Row0,\n column1Row0,\n column2Row0,\n column3Row0,\n column0Row1,\n column1Row1,\n column2Row1,\n column3Row1,\n column0Row2,\n column1Row2,\n column2Row2,\n column3Row2,\n column0Row3,\n column1Row3,\n column2Row3,\n column3Row3\n) {\n this[0] = defaultValue(column0Row0, 0.0);\n this[1] = defaultValue(column0Row1, 0.0);\n this[2] = defaultValue(column0Row2, 0.0);\n this[3] = defaultValue(column0Row3, 0.0);\n this[4] = defaultValue(column1Row0, 0.0);\n this[5] = defaultValue(column1Row1, 0.0);\n this[6] = defaultValue(column1Row2, 0.0);\n this[7] = defaultValue(column1Row3, 0.0);\n this[8] = defaultValue(column2Row0, 0.0);\n this[9] = defaultValue(column2Row1, 0.0);\n this[10] = defaultValue(column2Row2, 0.0);\n this[11] = defaultValue(column2Row3, 0.0);\n this[12] = defaultValue(column3Row0, 0.0);\n this[13] = defaultValue(column3Row1, 0.0);\n this[14] = defaultValue(column3Row2, 0.0);\n this[15] = defaultValue(column3Row3, 0.0);\n}\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nMatrix4.packedLength = 16;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Matrix4} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nMatrix4.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value[0];\n array[startingIndex++] = value[1];\n array[startingIndex++] = value[2];\n array[startingIndex++] = value[3];\n array[startingIndex++] = value[4];\n array[startingIndex++] = value[5];\n array[startingIndex++] = value[6];\n array[startingIndex++] = value[7];\n array[startingIndex++] = value[8];\n array[startingIndex++] = value[9];\n array[startingIndex++] = value[10];\n array[startingIndex++] = value[11];\n array[startingIndex++] = value[12];\n array[startingIndex++] = value[13];\n array[startingIndex++] = value[14];\n array[startingIndex] = value[15];\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Matrix4} [result] The object into which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.\n */\nMatrix4.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Matrix4();\n }\n\n result[0] = array[startingIndex++];\n result[1] = array[startingIndex++];\n result[2] = array[startingIndex++];\n result[3] = array[startingIndex++];\n result[4] = array[startingIndex++];\n result[5] = array[startingIndex++];\n result[6] = array[startingIndex++];\n result[7] = array[startingIndex++];\n result[8] = array[startingIndex++];\n result[9] = array[startingIndex++];\n result[10] = array[startingIndex++];\n result[11] = array[startingIndex++];\n result[12] = array[startingIndex++];\n result[13] = array[startingIndex++];\n result[14] = array[startingIndex++];\n result[15] = array[startingIndex];\n return result;\n};\n\n/**\n * Flattens an array of Matrix4s into an array of components. The components\n * are stored in column-major order.\n *\n * @param {Matrix4[]} array The array of matrices to pack.\n * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 16 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 16) elements.\n * @returns {number[]} The packed array.\n */\nMatrix4.packArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n const length = array.length;\n const resultLength = length * 16;\n if (!defined(result)) {\n result = new Array(resultLength);\n } else if (!Array.isArray(result) && result.length !== resultLength) {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"If result is a typed array, it must have exactly array.length * 16 elements\"\n );\n //>>includeEnd('debug');\n } else if (result.length !== resultLength) {\n result.length = resultLength;\n }\n\n for (let i = 0; i < length; ++i) {\n Matrix4.pack(array[i], result, i * 16);\n }\n return result;\n};\n\n/**\n * Unpacks an array of column-major matrix components into an array of Matrix4s.\n *\n * @param {number[]} array The array of components to unpack.\n * @param {Matrix4[]} [result] The array onto which to store the result.\n * @returns {Matrix4[]} The unpacked array.\n */\nMatrix4.unpackArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.typeOf.number.greaterThanOrEquals(\"array.length\", array.length, 16);\n if (array.length % 16 !== 0) {\n throw new DeveloperError(\"array length must be a multiple of 16.\");\n }\n //>>includeEnd('debug');\n\n const length = array.length;\n if (!defined(result)) {\n result = new Array(length / 16);\n } else {\n result.length = length / 16;\n }\n\n for (let i = 0; i < length; i += 16) {\n const index = i / 16;\n result[index] = Matrix4.unpack(array, i, result[index]);\n }\n return result;\n};\n\n/**\n * Duplicates a Matrix4 instance.\n *\n * @param {Matrix4} matrix The matrix to duplicate.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided. (Returns undefined if matrix is undefined)\n */\nMatrix4.clone = function (matrix, result) {\n if (!defined(matrix)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Matrix4(\n matrix[0],\n matrix[4],\n matrix[8],\n matrix[12],\n matrix[1],\n matrix[5],\n matrix[9],\n matrix[13],\n matrix[2],\n matrix[6],\n matrix[10],\n matrix[14],\n matrix[3],\n matrix[7],\n matrix[11],\n matrix[15]\n );\n }\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n result[4] = matrix[4];\n result[5] = matrix[5];\n result[6] = matrix[6];\n result[7] = matrix[7];\n result[8] = matrix[8];\n result[9] = matrix[9];\n result[10] = matrix[10];\n result[11] = matrix[11];\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n return result;\n};\n\n/**\n * Creates a Matrix4 from 16 consecutive elements in an array.\n * @function\n *\n * @param {number[]} array The array whose 16 consecutive elements correspond to the positions of the matrix. Assumes column-major order.\n * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to first column first row position in the matrix.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.\n *\n * @example\n * // Create the Matrix4:\n * // [1.0, 2.0, 3.0, 4.0]\n * // [1.0, 2.0, 3.0, 4.0]\n * // [1.0, 2.0, 3.0, 4.0]\n * // [1.0, 2.0, 3.0, 4.0]\n *\n * const v = [1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0];\n * const m = Cesium.Matrix4.fromArray(v);\n *\n * // Create same Matrix4 with using an offset into an array\n * const v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0];\n * const m2 = Cesium.Matrix4.fromArray(v2, 2);\n */\nMatrix4.fromArray = Matrix4.unpack;\n\n/**\n * Computes a Matrix4 instance from a column-major order array.\n *\n * @param {number[]} values The column-major order array.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n */\nMatrix4.fromColumnMajorArray = function (values, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"values\", values);\n //>>includeEnd('debug');\n\n return Matrix4.clone(values, result);\n};\n\n/**\n * Computes a Matrix4 instance from a row-major order array.\n * The resulting matrix will be in column-major order.\n *\n * @param {number[]} values The row-major order array.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n */\nMatrix4.fromRowMajorArray = function (values, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"values\", values);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix4(\n values[0],\n values[1],\n values[2],\n values[3],\n values[4],\n values[5],\n values[6],\n values[7],\n values[8],\n values[9],\n values[10],\n values[11],\n values[12],\n values[13],\n values[14],\n values[15]\n );\n }\n result[0] = values[0];\n result[1] = values[4];\n result[2] = values[8];\n result[3] = values[12];\n result[4] = values[1];\n result[5] = values[5];\n result[6] = values[9];\n result[7] = values[13];\n result[8] = values[2];\n result[9] = values[6];\n result[10] = values[10];\n result[11] = values[14];\n result[12] = values[3];\n result[13] = values[7];\n result[14] = values[11];\n result[15] = values[15];\n return result;\n};\n\n/**\n * Computes a Matrix4 instance from a Matrix3 representing the rotation\n * and a Cartesian3 representing the translation.\n *\n * @param {Matrix3} rotation The upper left portion of the matrix representing the rotation.\n * @param {Cartesian3} [translation=Cartesian3.ZERO] The upper right portion of the matrix representing the translation.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n */\nMatrix4.fromRotationTranslation = function (rotation, translation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rotation\", rotation);\n //>>includeEnd('debug');\n\n translation = defaultValue(translation, Cartesian3.ZERO);\n\n if (!defined(result)) {\n return new Matrix4(\n rotation[0],\n rotation[3],\n rotation[6],\n translation.x,\n rotation[1],\n rotation[4],\n rotation[7],\n translation.y,\n rotation[2],\n rotation[5],\n rotation[8],\n translation.z,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n );\n }\n\n result[0] = rotation[0];\n result[1] = rotation[1];\n result[2] = rotation[2];\n result[3] = 0.0;\n result[4] = rotation[3];\n result[5] = rotation[4];\n result[6] = rotation[5];\n result[7] = 0.0;\n result[8] = rotation[6];\n result[9] = rotation[7];\n result[10] = rotation[8];\n result[11] = 0.0;\n result[12] = translation.x;\n result[13] = translation.y;\n result[14] = translation.z;\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance from a translation, rotation, and scale (TRS)\n * representation with the rotation represented as a quaternion.\n *\n * @param {Cartesian3} translation The translation transformation.\n * @param {Quaternion} rotation The rotation transformation.\n * @param {Cartesian3} scale The non-uniform scale transformation.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n *\n * @example\n * const result = Cesium.Matrix4.fromTranslationQuaternionRotationScale(\n * new Cesium.Cartesian3(1.0, 2.0, 3.0), // translation\n * Cesium.Quaternion.IDENTITY, // rotation\n * new Cesium.Cartesian3(7.0, 8.0, 9.0), // scale\n * result);\n */\nMatrix4.fromTranslationQuaternionRotationScale = function (\n translation,\n rotation,\n scale,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"translation\", translation);\n Check.typeOf.object(\"rotation\", rotation);\n Check.typeOf.object(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Matrix4();\n }\n\n const scaleX = scale.x;\n const scaleY = scale.y;\n const scaleZ = scale.z;\n\n const x2 = rotation.x * rotation.x;\n const xy = rotation.x * rotation.y;\n const xz = rotation.x * rotation.z;\n const xw = rotation.x * rotation.w;\n const y2 = rotation.y * rotation.y;\n const yz = rotation.y * rotation.z;\n const yw = rotation.y * rotation.w;\n const z2 = rotation.z * rotation.z;\n const zw = rotation.z * rotation.w;\n const w2 = rotation.w * rotation.w;\n\n const m00 = x2 - y2 - z2 + w2;\n const m01 = 2.0 * (xy - zw);\n const m02 = 2.0 * (xz + yw);\n\n const m10 = 2.0 * (xy + zw);\n const m11 = -x2 + y2 - z2 + w2;\n const m12 = 2.0 * (yz - xw);\n\n const m20 = 2.0 * (xz - yw);\n const m21 = 2.0 * (yz + xw);\n const m22 = -x2 - y2 + z2 + w2;\n\n result[0] = m00 * scaleX;\n result[1] = m10 * scaleX;\n result[2] = m20 * scaleX;\n result[3] = 0.0;\n result[4] = m01 * scaleY;\n result[5] = m11 * scaleY;\n result[6] = m21 * scaleY;\n result[7] = 0.0;\n result[8] = m02 * scaleZ;\n result[9] = m12 * scaleZ;\n result[10] = m22 * scaleZ;\n result[11] = 0.0;\n result[12] = translation.x;\n result[13] = translation.y;\n result[14] = translation.z;\n result[15] = 1.0;\n\n return result;\n};\n\n/**\n * Creates a Matrix4 instance from a {@link TranslationRotationScale} instance.\n *\n * @param {TranslationRotationScale} translationRotationScale The instance.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n */\nMatrix4.fromTranslationRotationScale = function (\n translationRotationScale,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"translationRotationScale\", translationRotationScale);\n //>>includeEnd('debug');\n\n return Matrix4.fromTranslationQuaternionRotationScale(\n translationRotationScale.translation,\n translationRotationScale.rotation,\n translationRotationScale.scale,\n result\n );\n};\n\n/**\n * Creates a Matrix4 instance from a Cartesian3 representing the translation.\n *\n * @param {Cartesian3} translation The upper right portion of the matrix representing the translation.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n *\n * @see Matrix4.multiplyByTranslation\n */\nMatrix4.fromTranslation = function (translation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"translation\", translation);\n //>>includeEnd('debug');\n\n return Matrix4.fromRotationTranslation(Matrix3.IDENTITY, translation, result);\n};\n\n/**\n * Computes a Matrix4 instance representing a non-uniform scale.\n *\n * @param {Cartesian3} scale The x, y, and z scale factors.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [7.0, 0.0, 0.0, 0.0]\n * // [0.0, 8.0, 0.0, 0.0]\n * // [0.0, 0.0, 9.0, 0.0]\n * // [0.0, 0.0, 0.0, 1.0]\n * const m = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));\n */\nMatrix4.fromScale = function (scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix4(\n scale.x,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n scale.y,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n scale.z,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n );\n }\n\n result[0] = scale.x;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = scale.y;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 0.0;\n result[9] = 0.0;\n result[10] = scale.z;\n result[11] = 0.0;\n result[12] = 0.0;\n result[13] = 0.0;\n result[14] = 0.0;\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance representing a uniform scale.\n *\n * @param {number} scale The uniform scale factor.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [2.0, 0.0, 0.0, 0.0]\n * // [0.0, 2.0, 0.0, 0.0]\n * // [0.0, 0.0, 2.0, 0.0]\n * // [0.0, 0.0, 0.0, 1.0]\n * const m = Cesium.Matrix4.fromUniformScale(2.0);\n */\nMatrix4.fromUniformScale = function (scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix4(\n scale,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n scale,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n scale,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n );\n }\n\n result[0] = scale;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = scale;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 0.0;\n result[9] = 0.0;\n result[10] = scale;\n result[11] = 0.0;\n result[12] = 0.0;\n result[13] = 0.0;\n result[14] = 0.0;\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Creates a rotation matrix.\n *\n * @param {Matrix3} rotation The rotation matrix.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n */\nMatrix4.fromRotation = function (rotation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rotation\", rotation);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Matrix4();\n }\n result[0] = rotation[0];\n result[1] = rotation[1];\n result[2] = rotation[2];\n result[3] = 0.0;\n\n result[4] = rotation[3];\n result[5] = rotation[4];\n result[6] = rotation[5];\n result[7] = 0.0;\n\n result[8] = rotation[6];\n result[9] = rotation[7];\n result[10] = rotation[8];\n result[11] = 0.0;\n\n result[12] = 0.0;\n result[13] = 0.0;\n result[14] = 0.0;\n result[15] = 1.0;\n\n return result;\n};\n\nconst fromCameraF = new Cartesian3();\nconst fromCameraR = new Cartesian3();\nconst fromCameraU = new Cartesian3();\n\n/**\n * Computes a Matrix4 instance from a Camera.\n *\n * @param {Camera} camera The camera to use.\n * @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix4} The modified result parameter, or a new Matrix4 instance if one was not provided.\n */\nMatrix4.fromCamera = function (camera, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"camera\", camera);\n //>>includeEnd('debug');\n\n const position = camera.position;\n const direction = camera.direction;\n const up = camera.up;\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"camera.position\", position);\n Check.typeOf.object(\"camera.direction\", direction);\n Check.typeOf.object(\"camera.up\", up);\n //>>includeEnd('debug');\n\n Cartesian3.normalize(direction, fromCameraF);\n Cartesian3.normalize(\n Cartesian3.cross(fromCameraF, up, fromCameraR),\n fromCameraR\n );\n Cartesian3.normalize(\n Cartesian3.cross(fromCameraR, fromCameraF, fromCameraU),\n fromCameraU\n );\n\n const sX = fromCameraR.x;\n const sY = fromCameraR.y;\n const sZ = fromCameraR.z;\n const fX = fromCameraF.x;\n const fY = fromCameraF.y;\n const fZ = fromCameraF.z;\n const uX = fromCameraU.x;\n const uY = fromCameraU.y;\n const uZ = fromCameraU.z;\n const positionX = position.x;\n const positionY = position.y;\n const positionZ = position.z;\n const t0 = sX * -positionX + sY * -positionY + sZ * -positionZ;\n const t1 = uX * -positionX + uY * -positionY + uZ * -positionZ;\n const t2 = fX * positionX + fY * positionY + fZ * positionZ;\n\n // The code below this comment is an optimized\n // version of the commented lines.\n // Rather that create two matrices and then multiply,\n // we just bake in the multiplcation as part of creation.\n // const rotation = new Matrix4(\n // sX, sY, sZ, 0.0,\n // uX, uY, uZ, 0.0,\n // -fX, -fY, -fZ, 0.0,\n // 0.0, 0.0, 0.0, 1.0);\n // const translation = new Matrix4(\n // 1.0, 0.0, 0.0, -position.x,\n // 0.0, 1.0, 0.0, -position.y,\n // 0.0, 0.0, 1.0, -position.z,\n // 0.0, 0.0, 0.0, 1.0);\n // return rotation.multiply(translation);\n if (!defined(result)) {\n return new Matrix4(\n sX,\n sY,\n sZ,\n t0,\n uX,\n uY,\n uZ,\n t1,\n -fX,\n -fY,\n -fZ,\n t2,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n );\n }\n result[0] = sX;\n result[1] = uX;\n result[2] = -fX;\n result[3] = 0.0;\n result[4] = sY;\n result[5] = uY;\n result[6] = -fY;\n result[7] = 0.0;\n result[8] = sZ;\n result[9] = uZ;\n result[10] = -fZ;\n result[11] = 0.0;\n result[12] = t0;\n result[13] = t1;\n result[14] = t2;\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance representing a perspective transformation matrix.\n *\n * @param {number} fovY The field of view along the Y axis in radians.\n * @param {number} aspectRatio The aspect ratio.\n * @param {number} near The distance to the near plane in meters.\n * @param {number} far The distance to the far plane in meters.\n * @param {Matrix4} result The object in which the result will be stored.\n * @returns {Matrix4} The modified result parameter.\n *\n * @exception {DeveloperError} fovY must be in (0, PI].\n * @exception {DeveloperError} aspectRatio must be greater than zero.\n * @exception {DeveloperError} near must be greater than zero.\n * @exception {DeveloperError} far must be greater than zero.\n */\nMatrix4.computePerspectiveFieldOfView = function (\n fovY,\n aspectRatio,\n near,\n far,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThan(\"fovY\", fovY, 0.0);\n Check.typeOf.number.lessThan(\"fovY\", fovY, Math.PI);\n Check.typeOf.number.greaterThan(\"near\", near, 0.0);\n Check.typeOf.number.greaterThan(\"far\", far, 0.0);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const bottom = Math.tan(fovY * 0.5);\n\n const column1Row1 = 1.0 / bottom;\n const column0Row0 = column1Row1 / aspectRatio;\n const column2Row2 = (far + near) / (near - far);\n const column3Row2 = (2.0 * far * near) / (near - far);\n\n result[0] = column0Row0;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = column1Row1;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 0.0;\n result[9] = 0.0;\n result[10] = column2Row2;\n result[11] = -1.0;\n result[12] = 0.0;\n result[13] = 0.0;\n result[14] = column3Row2;\n result[15] = 0.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance representing an orthographic transformation matrix.\n *\n * @param {number} left The number of meters to the left of the camera that will be in view.\n * @param {number} right The number of meters to the right of the camera that will be in view.\n * @param {number} bottom The number of meters below of the camera that will be in view.\n * @param {number} top The number of meters above of the camera that will be in view.\n * @param {number} near The distance to the near plane in meters.\n * @param {number} far The distance to the far plane in meters.\n * @param {Matrix4} result The object in which the result will be stored.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.computeOrthographicOffCenter = function (\n left,\n right,\n bottom,\n top,\n near,\n far,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"left\", left);\n Check.typeOf.number(\"right\", right);\n Check.typeOf.number(\"bottom\", bottom);\n Check.typeOf.number(\"top\", top);\n Check.typeOf.number(\"near\", near);\n Check.typeOf.number(\"far\", far);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n let a = 1.0 / (right - left);\n let b = 1.0 / (top - bottom);\n let c = 1.0 / (far - near);\n\n const tx = -(right + left) * a;\n const ty = -(top + bottom) * b;\n const tz = -(far + near) * c;\n a *= 2.0;\n b *= 2.0;\n c *= -2.0;\n\n result[0] = a;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = b;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 0.0;\n result[9] = 0.0;\n result[10] = c;\n result[11] = 0.0;\n result[12] = tx;\n result[13] = ty;\n result[14] = tz;\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance representing an off center perspective transformation.\n *\n * @param {number} left The number of meters to the left of the camera that will be in view.\n * @param {number} right The number of meters to the right of the camera that will be in view.\n * @param {number} bottom The number of meters below of the camera that will be in view.\n * @param {number} top The number of meters above of the camera that will be in view.\n * @param {number} near The distance to the near plane in meters.\n * @param {number} far The distance to the far plane in meters.\n * @param {Matrix4} result The object in which the result will be stored.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.computePerspectiveOffCenter = function (\n left,\n right,\n bottom,\n top,\n near,\n far,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"left\", left);\n Check.typeOf.number(\"right\", right);\n Check.typeOf.number(\"bottom\", bottom);\n Check.typeOf.number(\"top\", top);\n Check.typeOf.number(\"near\", near);\n Check.typeOf.number(\"far\", far);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const column0Row0 = (2.0 * near) / (right - left);\n const column1Row1 = (2.0 * near) / (top - bottom);\n const column2Row0 = (right + left) / (right - left);\n const column2Row1 = (top + bottom) / (top - bottom);\n const column2Row2 = -(far + near) / (far - near);\n const column2Row3 = -1.0;\n const column3Row2 = (-2.0 * far * near) / (far - near);\n\n result[0] = column0Row0;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = column1Row1;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = column2Row0;\n result[9] = column2Row1;\n result[10] = column2Row2;\n result[11] = column2Row3;\n result[12] = 0.0;\n result[13] = 0.0;\n result[14] = column3Row2;\n result[15] = 0.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance representing an infinite off center perspective transformation.\n *\n * @param {number} left The number of meters to the left of the camera that will be in view.\n * @param {number} right The number of meters to the right of the camera that will be in view.\n * @param {number} bottom The number of meters below of the camera that will be in view.\n * @param {number} top The number of meters above of the camera that will be in view.\n * @param {number} near The distance to the near plane in meters.\n * @param {Matrix4} result The object in which the result will be stored.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.computeInfinitePerspectiveOffCenter = function (\n left,\n right,\n bottom,\n top,\n near,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"left\", left);\n Check.typeOf.number(\"right\", right);\n Check.typeOf.number(\"bottom\", bottom);\n Check.typeOf.number(\"top\", top);\n Check.typeOf.number(\"near\", near);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const column0Row0 = (2.0 * near) / (right - left);\n const column1Row1 = (2.0 * near) / (top - bottom);\n const column2Row0 = (right + left) / (right - left);\n const column2Row1 = (top + bottom) / (top - bottom);\n const column2Row2 = -1.0;\n const column2Row3 = -1.0;\n const column3Row2 = -2.0 * near;\n\n result[0] = column0Row0;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = column1Row1;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = column2Row0;\n result[9] = column2Row1;\n result[10] = column2Row2;\n result[11] = column2Row3;\n result[12] = 0.0;\n result[13] = 0.0;\n result[14] = column3Row2;\n result[15] = 0.0;\n return result;\n};\n\n/**\n * Computes a Matrix4 instance that transforms from normalized device coordinates to window coordinates.\n *\n * @param {object} [viewport = { x : 0.0, y : 0.0, width : 0.0, height : 0.0 }] The viewport's corners as shown in Example 1.\n * @param {number} [nearDepthRange=0.0] The near plane distance in window coordinates.\n * @param {number} [farDepthRange=1.0] The far plane distance in window coordinates.\n * @param {Matrix4} [result] The object in which the result will be stored.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * // Create viewport transformation using an explicit viewport and depth range.\n * const m = Cesium.Matrix4.computeViewportTransformation({\n * x : 0.0,\n * y : 0.0,\n * width : 1024.0,\n * height : 768.0\n * }, 0.0, 1.0, new Cesium.Matrix4());\n */\nMatrix4.computeViewportTransformation = function (\n viewport,\n nearDepthRange,\n farDepthRange,\n result\n) {\n if (!defined(result)) {\n result = new Matrix4();\n }\n\n viewport = defaultValue(viewport, defaultValue.EMPTY_OBJECT);\n const x = defaultValue(viewport.x, 0.0);\n const y = defaultValue(viewport.y, 0.0);\n const width = defaultValue(viewport.width, 0.0);\n const height = defaultValue(viewport.height, 0.0);\n nearDepthRange = defaultValue(nearDepthRange, 0.0);\n farDepthRange = defaultValue(farDepthRange, 1.0);\n\n const halfWidth = width * 0.5;\n const halfHeight = height * 0.5;\n const halfDepth = (farDepthRange - nearDepthRange) * 0.5;\n\n const column0Row0 = halfWidth;\n const column1Row1 = halfHeight;\n const column2Row2 = halfDepth;\n const column3Row0 = x + halfWidth;\n const column3Row1 = y + halfHeight;\n const column3Row2 = nearDepthRange + halfDepth;\n const column3Row3 = 1.0;\n\n result[0] = column0Row0;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = column1Row1;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 0.0;\n result[9] = 0.0;\n result[10] = column2Row2;\n result[11] = 0.0;\n result[12] = column3Row0;\n result[13] = column3Row1;\n result[14] = column3Row2;\n result[15] = column3Row3;\n\n return result;\n};\n\n/**\n * Computes a Matrix4 instance that transforms from world space to view space.\n *\n * @param {Cartesian3} position The position of the camera.\n * @param {Cartesian3} direction The forward direction.\n * @param {Cartesian3} up The up direction.\n * @param {Cartesian3} right The right direction.\n * @param {Matrix4} result The object in which the result will be stored.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.computeView = function (position, direction, up, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"position\", position);\n Check.typeOf.object(\"direction\", direction);\n Check.typeOf.object(\"up\", up);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = right.x;\n result[1] = up.x;\n result[2] = -direction.x;\n result[3] = 0.0;\n result[4] = right.y;\n result[5] = up.y;\n result[6] = -direction.y;\n result[7] = 0.0;\n result[8] = right.z;\n result[9] = up.z;\n result[10] = -direction.z;\n result[11] = 0.0;\n result[12] = -Cartesian3.dot(right, position);\n result[13] = -Cartesian3.dot(up, position);\n result[14] = Cartesian3.dot(direction, position);\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Computes an Array from the provided Matrix4 instance.\n * The array will be in column-major order.\n *\n * @param {Matrix4} matrix The matrix to use..\n * @param {number[]} [result] The Array onto which to store the result.\n * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.\n *\n * @example\n * //create an array from an instance of Matrix4\n * // m = [10.0, 14.0, 18.0, 22.0]\n * // [11.0, 15.0, 19.0, 23.0]\n * // [12.0, 16.0, 20.0, 24.0]\n * // [13.0, 17.0, 21.0, 25.0]\n * const a = Cesium.Matrix4.toArray(m);\n *\n * // m remains the same\n * //creates a = [10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0]\n */\nMatrix4.toArray = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return [\n matrix[0],\n matrix[1],\n matrix[2],\n matrix[3],\n matrix[4],\n matrix[5],\n matrix[6],\n matrix[7],\n matrix[8],\n matrix[9],\n matrix[10],\n matrix[11],\n matrix[12],\n matrix[13],\n matrix[14],\n matrix[15],\n ];\n }\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n result[4] = matrix[4];\n result[5] = matrix[5];\n result[6] = matrix[6];\n result[7] = matrix[7];\n result[8] = matrix[8];\n result[9] = matrix[9];\n result[10] = matrix[10];\n result[11] = matrix[11];\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n return result;\n};\n\n/**\n * Computes the array index of the element at the provided row and column.\n *\n * @param {number} row The zero-based index of the row.\n * @param {number} column The zero-based index of the column.\n * @returns {number} The index of the element at the provided row and column.\n *\n * @exception {DeveloperError} row must be 0, 1, 2, or 3.\n * @exception {DeveloperError} column must be 0, 1, 2, or 3.\n *\n * @example\n * const myMatrix = new Cesium.Matrix4();\n * const column1Row0Index = Cesium.Matrix4.getElementIndex(1, 0);\n * const column1Row0 = myMatrix[column1Row0Index];\n * myMatrix[column1Row0Index] = 10.0;\n */\nMatrix4.getElementIndex = function (column, row) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThanOrEquals(\"row\", row, 0);\n Check.typeOf.number.lessThanOrEquals(\"row\", row, 3);\n\n Check.typeOf.number.greaterThanOrEquals(\"column\", column, 0);\n Check.typeOf.number.lessThanOrEquals(\"column\", column, 3);\n //>>includeEnd('debug');\n\n return column * 4 + row;\n};\n\n/**\n * Retrieves a copy of the matrix column at the provided index as a Cartesian4 instance.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {number} index The zero-based index of the column to retrieve.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, 2, or 3.\n *\n * @example\n * //returns a Cartesian4 instance with values from the specified column\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * //Example 1: Creates an instance of Cartesian\n * const a = Cesium.Matrix4.getColumn(m, 2, new Cesium.Cartesian4());\n *\n * @example\n * //Example 2: Sets values for Cartesian instance\n * const a = new Cesium.Cartesian4();\n * Cesium.Matrix4.getColumn(m, 2, a);\n *\n * // a.x = 12.0; a.y = 16.0; a.z = 20.0; a.w = 24.0;\n */\nMatrix4.getColumn = function (matrix, index, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 3);\n\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const startIndex = index * 4;\n const x = matrix[startIndex];\n const y = matrix[startIndex + 1];\n const z = matrix[startIndex + 2];\n const w = matrix[startIndex + 3];\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian4 instance.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {number} index The zero-based index of the column to set.\n * @param {Cartesian4} cartesian The Cartesian whose values will be assigned to the specified column.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, 2, or 3.\n *\n * @example\n * //creates a new Matrix4 instance with new column values from the Cartesian4 instance\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * const a = Cesium.Matrix4.setColumn(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());\n *\n * // m remains the same\n * // a = [10.0, 11.0, 99.0, 13.0]\n * // [14.0, 15.0, 98.0, 17.0]\n * // [18.0, 19.0, 97.0, 21.0]\n * // [22.0, 23.0, 96.0, 25.0]\n */\nMatrix4.setColumn = function (matrix, index, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 3);\n\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result = Matrix4.clone(matrix, result);\n const startIndex = index * 4;\n result[startIndex] = cartesian.x;\n result[startIndex + 1] = cartesian.y;\n result[startIndex + 2] = cartesian.z;\n result[startIndex + 3] = cartesian.w;\n return result;\n};\n\n/**\n * Retrieves a copy of the matrix row at the provided index as a Cartesian4 instance.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {number} index The zero-based index of the row to retrieve.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, 2, or 3.\n *\n * @example\n * //returns a Cartesian4 instance with values from the specified column\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * //Example 1: Returns an instance of Cartesian\n * const a = Cesium.Matrix4.getRow(m, 2, new Cesium.Cartesian4());\n *\n * @example\n * //Example 2: Sets values for a Cartesian instance\n * const a = new Cesium.Cartesian4();\n * Cesium.Matrix4.getRow(m, 2, a);\n *\n * // a.x = 18.0; a.y = 19.0; a.z = 20.0; a.w = 21.0;\n */\nMatrix4.getRow = function (matrix, index, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 3);\n\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = matrix[index];\n const y = matrix[index + 4];\n const z = matrix[index + 8];\n const w = matrix[index + 12];\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian4 instance.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {number} index The zero-based index of the row to set.\n * @param {Cartesian4} cartesian The Cartesian whose values will be assigned to the specified row.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0, 1, 2, or 3.\n *\n * @example\n * //create a new Matrix4 instance with new row values from the Cartesian4 instance\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * const a = Cesium.Matrix4.setRow(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());\n *\n * // m remains the same\n * // a = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [99.0, 98.0, 97.0, 96.0]\n * // [22.0, 23.0, 24.0, 25.0]\n */\nMatrix4.setRow = function (matrix, index, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 3);\n\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result = Matrix4.clone(matrix, result);\n result[index] = cartesian.x;\n result[index + 4] = cartesian.y;\n result[index + 8] = cartesian.z;\n result[index + 12] = cartesian.w;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the translation in the rightmost column of the provided\n * matrix with the provided translation. This assumes the matrix is an affine transformation.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {Cartesian3} translation The translation that replaces the translation of the provided matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.setTranslation = function (matrix, translation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"translation\", translation);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n\n result[4] = matrix[4];\n result[5] = matrix[5];\n result[6] = matrix[6];\n result[7] = matrix[7];\n\n result[8] = matrix[8];\n result[9] = matrix[9];\n result[10] = matrix[10];\n result[11] = matrix[11];\n\n result[12] = translation.x;\n result[13] = translation.y;\n result[14] = translation.z;\n result[15] = matrix[15];\n\n return result;\n};\n\nconst scaleScratch1 = new Cartesian3();\n\n/**\n * Computes a new matrix that replaces the scale with the provided scale.\n * This assumes the matrix is an affine transformation.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {Cartesian3} scale The scale that replaces the scale of the provided matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @see Matrix4.setUniformScale\n * @see Matrix4.fromScale\n * @see Matrix4.fromUniformScale\n * @see Matrix4.multiplyByScale\n * @see Matrix4.multiplyByUniformScale\n * @see Matrix4.getScale\n */\nMatrix4.setScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const existingScale = Matrix4.getScale(matrix, scaleScratch1);\n const scaleRatioX = scale.x / existingScale.x;\n const scaleRatioY = scale.y / existingScale.y;\n const scaleRatioZ = scale.z / existingScale.z;\n\n result[0] = matrix[0] * scaleRatioX;\n result[1] = matrix[1] * scaleRatioX;\n result[2] = matrix[2] * scaleRatioX;\n result[3] = matrix[3];\n\n result[4] = matrix[4] * scaleRatioY;\n result[5] = matrix[5] * scaleRatioY;\n result[6] = matrix[6] * scaleRatioY;\n result[7] = matrix[7];\n\n result[8] = matrix[8] * scaleRatioZ;\n result[9] = matrix[9] * scaleRatioZ;\n result[10] = matrix[10] * scaleRatioZ;\n result[11] = matrix[11];\n\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n\n return result;\n};\n\nconst scaleScratch2 = new Cartesian3();\n\n/**\n * Computes a new matrix that replaces the scale with the provided uniform scale.\n * This assumes the matrix is an affine transformation.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {number} scale The uniform scale that replaces the scale of the provided matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @see Matrix4.setScale\n * @see Matrix4.fromScale\n * @see Matrix4.fromUniformScale\n * @see Matrix4.multiplyByScale\n * @see Matrix4.multiplyByUniformScale\n * @see Matrix4.getScale\n */\nMatrix4.setUniformScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const existingScale = Matrix4.getScale(matrix, scaleScratch2);\n const scaleRatioX = scale / existingScale.x;\n const scaleRatioY = scale / existingScale.y;\n const scaleRatioZ = scale / existingScale.z;\n\n result[0] = matrix[0] * scaleRatioX;\n result[1] = matrix[1] * scaleRatioX;\n result[2] = matrix[2] * scaleRatioX;\n result[3] = matrix[3];\n\n result[4] = matrix[4] * scaleRatioY;\n result[5] = matrix[5] * scaleRatioY;\n result[6] = matrix[6] * scaleRatioY;\n result[7] = matrix[7];\n\n result[8] = matrix[8] * scaleRatioZ;\n result[9] = matrix[9] * scaleRatioZ;\n result[10] = matrix[10] * scaleRatioZ;\n result[11] = matrix[11];\n\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n\n return result;\n};\n\nconst scratchColumn = new Cartesian3();\n\n/**\n * Extracts the non-uniform scale assuming the matrix is an affine transformation.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter\n *\n * @see Matrix4.multiplyByScale\n * @see Matrix4.multiplyByUniformScale\n * @see Matrix4.fromScale\n * @see Matrix4.fromUniformScale\n * @see Matrix4.setScale\n * @see Matrix4.setUniformScale\n */\nMatrix4.getScale = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Cartesian3.magnitude(\n Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)\n );\n result.y = Cartesian3.magnitude(\n Cartesian3.fromElements(matrix[4], matrix[5], matrix[6], scratchColumn)\n );\n result.z = Cartesian3.magnitude(\n Cartesian3.fromElements(matrix[8], matrix[9], matrix[10], scratchColumn)\n );\n return result;\n};\n\nconst scaleScratch3 = new Cartesian3();\n\n/**\n * Computes the maximum scale assuming the matrix is an affine transformation.\n * The maximum scale is the maximum length of the column vectors in the upper-left\n * 3x3 matrix.\n *\n * @param {Matrix4} matrix The matrix.\n * @returns {number} The maximum scale.\n */\nMatrix4.getMaximumScale = function (matrix) {\n Matrix4.getScale(matrix, scaleScratch3);\n return Cartesian3.maximumComponent(scaleScratch3);\n};\n\nconst scaleScratch4 = new Cartesian3();\n\n/**\n * Sets the rotation assuming the matrix is an affine transformation.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {Matrix3} rotation The rotation matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @see Matrix4.fromRotation\n * @see Matrix4.getRotation\n */\nMatrix4.setRotation = function (matrix, rotation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scale = Matrix4.getScale(matrix, scaleScratch4);\n\n result[0] = rotation[0] * scale.x;\n result[1] = rotation[1] * scale.x;\n result[2] = rotation[2] * scale.x;\n result[3] = matrix[3];\n\n result[4] = rotation[3] * scale.y;\n result[5] = rotation[4] * scale.y;\n result[6] = rotation[5] * scale.y;\n result[7] = matrix[7];\n\n result[8] = rotation[6] * scale.z;\n result[9] = rotation[7] * scale.z;\n result[10] = rotation[8] * scale.z;\n result[11] = matrix[11];\n\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n\n return result;\n};\n\nconst scaleScratch5 = new Cartesian3();\n\n/**\n * Extracts the rotation matrix assuming the matrix is an affine transformation.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @see Matrix4.setRotation\n * @see Matrix4.fromRotation\n */\nMatrix4.getRotation = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scale = Matrix4.getScale(matrix, scaleScratch5);\n\n result[0] = matrix[0] / scale.x;\n result[1] = matrix[1] / scale.x;\n result[2] = matrix[2] / scale.x;\n\n result[3] = matrix[4] / scale.y;\n result[4] = matrix[5] / scale.y;\n result[5] = matrix[6] / scale.y;\n\n result[6] = matrix[8] / scale.z;\n result[7] = matrix[9] / scale.z;\n result[8] = matrix[10] / scale.z;\n\n return result;\n};\n\n/**\n * Computes the product of two matrices.\n *\n * @param {Matrix4} left The first matrix.\n * @param {Matrix4} right The second matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.multiply = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const left0 = left[0];\n const left1 = left[1];\n const left2 = left[2];\n const left3 = left[3];\n const left4 = left[4];\n const left5 = left[5];\n const left6 = left[6];\n const left7 = left[7];\n const left8 = left[8];\n const left9 = left[9];\n const left10 = left[10];\n const left11 = left[11];\n const left12 = left[12];\n const left13 = left[13];\n const left14 = left[14];\n const left15 = left[15];\n\n const right0 = right[0];\n const right1 = right[1];\n const right2 = right[2];\n const right3 = right[3];\n const right4 = right[4];\n const right5 = right[5];\n const right6 = right[6];\n const right7 = right[7];\n const right8 = right[8];\n const right9 = right[9];\n const right10 = right[10];\n const right11 = right[11];\n const right12 = right[12];\n const right13 = right[13];\n const right14 = right[14];\n const right15 = right[15];\n\n const column0Row0 =\n left0 * right0 + left4 * right1 + left8 * right2 + left12 * right3;\n const column0Row1 =\n left1 * right0 + left5 * right1 + left9 * right2 + left13 * right3;\n const column0Row2 =\n left2 * right0 + left6 * right1 + left10 * right2 + left14 * right3;\n const column0Row3 =\n left3 * right0 + left7 * right1 + left11 * right2 + left15 * right3;\n\n const column1Row0 =\n left0 * right4 + left4 * right5 + left8 * right6 + left12 * right7;\n const column1Row1 =\n left1 * right4 + left5 * right5 + left9 * right6 + left13 * right7;\n const column1Row2 =\n left2 * right4 + left6 * right5 + left10 * right6 + left14 * right7;\n const column1Row3 =\n left3 * right4 + left7 * right5 + left11 * right6 + left15 * right7;\n\n const column2Row0 =\n left0 * right8 + left4 * right9 + left8 * right10 + left12 * right11;\n const column2Row1 =\n left1 * right8 + left5 * right9 + left9 * right10 + left13 * right11;\n const column2Row2 =\n left2 * right8 + left6 * right9 + left10 * right10 + left14 * right11;\n const column2Row3 =\n left3 * right8 + left7 * right9 + left11 * right10 + left15 * right11;\n\n const column3Row0 =\n left0 * right12 + left4 * right13 + left8 * right14 + left12 * right15;\n const column3Row1 =\n left1 * right12 + left5 * right13 + left9 * right14 + left13 * right15;\n const column3Row2 =\n left2 * right12 + left6 * right13 + left10 * right14 + left14 * right15;\n const column3Row3 =\n left3 * right12 + left7 * right13 + left11 * right14 + left15 * right15;\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column0Row2;\n result[3] = column0Row3;\n result[4] = column1Row0;\n result[5] = column1Row1;\n result[6] = column1Row2;\n result[7] = column1Row3;\n result[8] = column2Row0;\n result[9] = column2Row1;\n result[10] = column2Row2;\n result[11] = column2Row3;\n result[12] = column3Row0;\n result[13] = column3Row1;\n result[14] = column3Row2;\n result[15] = column3Row3;\n return result;\n};\n\n/**\n * Computes the sum of two matrices.\n *\n * @param {Matrix4} left The first matrix.\n * @param {Matrix4} right The second matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = left[0] + right[0];\n result[1] = left[1] + right[1];\n result[2] = left[2] + right[2];\n result[3] = left[3] + right[3];\n result[4] = left[4] + right[4];\n result[5] = left[5] + right[5];\n result[6] = left[6] + right[6];\n result[7] = left[7] + right[7];\n result[8] = left[8] + right[8];\n result[9] = left[9] + right[9];\n result[10] = left[10] + right[10];\n result[11] = left[11] + right[11];\n result[12] = left[12] + right[12];\n result[13] = left[13] + right[13];\n result[14] = left[14] + right[14];\n result[15] = left[15] + right[15];\n return result;\n};\n\n/**\n * Computes the difference of two matrices.\n *\n * @param {Matrix4} left The first matrix.\n * @param {Matrix4} right The second matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = left[0] - right[0];\n result[1] = left[1] - right[1];\n result[2] = left[2] - right[2];\n result[3] = left[3] - right[3];\n result[4] = left[4] - right[4];\n result[5] = left[5] - right[5];\n result[6] = left[6] - right[6];\n result[7] = left[7] - right[7];\n result[8] = left[8] - right[8];\n result[9] = left[9] - right[9];\n result[10] = left[10] - right[10];\n result[11] = left[11] - right[11];\n result[12] = left[12] - right[12];\n result[13] = left[13] - right[13];\n result[14] = left[14] - right[14];\n result[15] = left[15] - right[15];\n return result;\n};\n\n/**\n * Computes the product of two matrices assuming the matrices are affine transformation matrices,\n * where the upper left 3x3 elements are any matrix, and\n * the upper three elements in the fourth column are the translation.\n * The bottom row is assumed to be [0, 0, 0, 1].\n * The matrix is not verified to be in the proper form.\n * This method is faster than computing the product for general 4x4\n * matrices using {@link Matrix4.multiply}.\n *\n * @param {Matrix4} left The first matrix.\n * @param {Matrix4} right The second matrix.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * const m1 = new Cesium.Matrix4(1.0, 6.0, 7.0, 0.0, 2.0, 5.0, 8.0, 0.0, 3.0, 4.0, 9.0, 0.0, 0.0, 0.0, 0.0, 1.0);\n * const m2 = Cesium.Transforms.eastNorthUpToFixedFrame(new Cesium.Cartesian3(1.0, 1.0, 1.0));\n * const m3 = Cesium.Matrix4.multiplyTransformation(m1, m2, new Cesium.Matrix4());\n */\nMatrix4.multiplyTransformation = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const left0 = left[0];\n const left1 = left[1];\n const left2 = left[2];\n const left4 = left[4];\n const left5 = left[5];\n const left6 = left[6];\n const left8 = left[8];\n const left9 = left[9];\n const left10 = left[10];\n const left12 = left[12];\n const left13 = left[13];\n const left14 = left[14];\n\n const right0 = right[0];\n const right1 = right[1];\n const right2 = right[2];\n const right4 = right[4];\n const right5 = right[5];\n const right6 = right[6];\n const right8 = right[8];\n const right9 = right[9];\n const right10 = right[10];\n const right12 = right[12];\n const right13 = right[13];\n const right14 = right[14];\n\n const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;\n const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;\n const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;\n\n const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;\n const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;\n const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;\n\n const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;\n const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;\n const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;\n\n const column3Row0 =\n left0 * right12 + left4 * right13 + left8 * right14 + left12;\n const column3Row1 =\n left1 * right12 + left5 * right13 + left9 * right14 + left13;\n const column3Row2 =\n left2 * right12 + left6 * right13 + left10 * right14 + left14;\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column0Row2;\n result[3] = 0.0;\n result[4] = column1Row0;\n result[5] = column1Row1;\n result[6] = column1Row2;\n result[7] = 0.0;\n result[8] = column2Row0;\n result[9] = column2Row1;\n result[10] = column2Row2;\n result[11] = 0.0;\n result[12] = column3Row0;\n result[13] = column3Row1;\n result[14] = column3Row2;\n result[15] = 1.0;\n return result;\n};\n\n/**\n * Multiplies a transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0])\n * by a 3x3 rotation matrix. This is an optimization\n * for Matrix4.multiply(m, Matrix4.fromRotationTranslation(rotation), m); with less allocations and arithmetic operations.\n *\n * @param {Matrix4} matrix The matrix on the left-hand side.\n * @param {Matrix3} rotation The 3x3 rotation matrix on the right-hand side.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromRotationTranslation(rotation), m);\n * Cesium.Matrix4.multiplyByMatrix3(m, rotation, m);\n */\nMatrix4.multiplyByMatrix3 = function (matrix, rotation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"rotation\", rotation);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const left0 = matrix[0];\n const left1 = matrix[1];\n const left2 = matrix[2];\n const left4 = matrix[4];\n const left5 = matrix[5];\n const left6 = matrix[6];\n const left8 = matrix[8];\n const left9 = matrix[9];\n const left10 = matrix[10];\n\n const right0 = rotation[0];\n const right1 = rotation[1];\n const right2 = rotation[2];\n const right4 = rotation[3];\n const right5 = rotation[4];\n const right6 = rotation[5];\n const right8 = rotation[6];\n const right9 = rotation[7];\n const right10 = rotation[8];\n\n const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;\n const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;\n const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;\n\n const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;\n const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;\n const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;\n\n const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;\n const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;\n const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column0Row2;\n result[3] = 0.0;\n result[4] = column1Row0;\n result[5] = column1Row1;\n result[6] = column1Row2;\n result[7] = 0.0;\n result[8] = column2Row0;\n result[9] = column2Row1;\n result[10] = column2Row2;\n result[11] = 0.0;\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n return result;\n};\n\n/**\n * Multiplies a transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0])\n * by an implicit translation matrix defined by a {@link Cartesian3}. This is an optimization\n * for Matrix4.multiply(m, Matrix4.fromTranslation(position), m); with less allocations and arithmetic operations.\n *\n * @param {Matrix4} matrix The matrix on the left-hand side.\n * @param {Cartesian3} translation The translation on the right-hand side.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromTranslation(position), m);\n * Cesium.Matrix4.multiplyByTranslation(m, position, m);\n */\nMatrix4.multiplyByTranslation = function (matrix, translation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"translation\", translation);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = translation.x;\n const y = translation.y;\n const z = translation.z;\n\n const tx = x * matrix[0] + y * matrix[4] + z * matrix[8] + matrix[12];\n const ty = x * matrix[1] + y * matrix[5] + z * matrix[9] + matrix[13];\n const tz = x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14];\n\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n result[4] = matrix[4];\n result[5] = matrix[5];\n result[6] = matrix[6];\n result[7] = matrix[7];\n result[8] = matrix[8];\n result[9] = matrix[9];\n result[10] = matrix[10];\n result[11] = matrix[11];\n result[12] = tx;\n result[13] = ty;\n result[14] = tz;\n result[15] = matrix[15];\n return result;\n};\n\n/**\n * Multiplies an affine transformation matrix (with a bottom row of [0.0, 0.0, 0.0, 1.0])\n * by an implicit non-uniform scale matrix. This is an optimization\n * for Matrix4.multiply(m, Matrix4.fromUniformScale(scale), m);, where\n * m must be an affine matrix.\n * This function performs fewer allocations and arithmetic operations.\n *\n * @param {Matrix4} matrix The affine matrix on the left-hand side.\n * @param {Cartesian3} scale The non-uniform scale on the right-hand side.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n *\n * @example\n * // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromScale(scale), m);\n * Cesium.Matrix4.multiplyByScale(m, scale, m);\n *\n * @see Matrix4.multiplyByUniformScale\n * @see Matrix4.fromScale\n * @see Matrix4.fromUniformScale\n * @see Matrix4.setScale\n * @see Matrix4.setUniformScale\n * @see Matrix4.getScale\n */\nMatrix4.multiplyByScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scaleX = scale.x;\n const scaleY = scale.y;\n const scaleZ = scale.z;\n\n // Faster than Cartesian3.equals\n if (scaleX === 1.0 && scaleY === 1.0 && scaleZ === 1.0) {\n return Matrix4.clone(matrix, result);\n }\n\n result[0] = scaleX * matrix[0];\n result[1] = scaleX * matrix[1];\n result[2] = scaleX * matrix[2];\n result[3] = matrix[3];\n\n result[4] = scaleY * matrix[4];\n result[5] = scaleY * matrix[5];\n result[6] = scaleY * matrix[6];\n result[7] = matrix[7];\n\n result[8] = scaleZ * matrix[8];\n result[9] = scaleZ * matrix[9];\n result[10] = scaleZ * matrix[10];\n result[11] = matrix[11];\n\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n\n return result;\n};\n\n/**\n * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.\n *\n * @param {Matrix4} matrix The matrix on the left-hand side.\n * @param {number} scale The uniform scale on the right-hand side.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * // Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromUniformScale(scale), m);\n * Cesium.Matrix4.multiplyByUniformScale(m, scale, m);\n *\n * @see Matrix4.multiplyByScale\n * @see Matrix4.fromScale\n * @see Matrix4.fromUniformScale\n * @see Matrix4.setScale\n * @see Matrix4.setUniformScale\n * @see Matrix4.getScale\n */\nMatrix4.multiplyByUniformScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scale;\n result[1] = matrix[1] * scale;\n result[2] = matrix[2] * scale;\n result[3] = matrix[3];\n\n result[4] = matrix[4] * scale;\n result[5] = matrix[5] * scale;\n result[6] = matrix[6] * scale;\n result[7] = matrix[7];\n\n result[8] = matrix[8] * scale;\n result[9] = matrix[9] * scale;\n result[10] = matrix[10] * scale;\n result[11] = matrix[11];\n\n result[12] = matrix[12];\n result[13] = matrix[13];\n result[14] = matrix[14];\n result[15] = matrix[15];\n\n return result;\n};\n\n/**\n * Computes the product of a matrix and a column vector.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {Cartesian4} cartesian The vector.\n * @param {Cartesian4} result The object onto which to store the result.\n * @returns {Cartesian4} The modified result parameter.\n */\nMatrix4.multiplyByVector = function (matrix, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const vX = cartesian.x;\n const vY = cartesian.y;\n const vZ = cartesian.z;\n const vW = cartesian.w;\n\n const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12] * vW;\n const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13] * vW;\n const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14] * vW;\n const w = matrix[3] * vX + matrix[7] * vY + matrix[11] * vZ + matrix[15] * vW;\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\n/**\n * Computes the product of a matrix and a {@link Cartesian3}. This is equivalent to calling {@link Matrix4.multiplyByVector}\n * with a {@link Cartesian4} with a w component of zero.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {Cartesian3} cartesian The point.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n *\n * @example\n * const p = new Cesium.Cartesian3(1.0, 2.0, 3.0);\n * const result = Cesium.Matrix4.multiplyByPointAsVector(matrix, p, new Cesium.Cartesian3());\n * // A shortcut for\n * // Cartesian3 p = ...\n * // Cesium.Matrix4.multiplyByVector(matrix, new Cesium.Cartesian4(p.x, p.y, p.z, 0.0), result);\n */\nMatrix4.multiplyByPointAsVector = function (matrix, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const vX = cartesian.x;\n const vY = cartesian.y;\n const vZ = cartesian.z;\n\n const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ;\n const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ;\n const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ;\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Computes the product of a matrix and a {@link Cartesian3}. This is equivalent to calling {@link Matrix4.multiplyByVector}\n * with a {@link Cartesian4} with a w component of 1, but returns a {@link Cartesian3} instead of a {@link Cartesian4}.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {Cartesian3} cartesian The point.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n *\n * @example\n * const p = new Cesium.Cartesian3(1.0, 2.0, 3.0);\n * const result = Cesium.Matrix4.multiplyByPoint(matrix, p, new Cesium.Cartesian3());\n */\nMatrix4.multiplyByPoint = function (matrix, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const vX = cartesian.x;\n const vY = cartesian.y;\n const vZ = cartesian.z;\n\n const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12];\n const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13];\n const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14];\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Computes the product of a matrix and a scalar.\n *\n * @param {Matrix4} matrix The matrix.\n * @param {number} scalar The number to multiply by.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * //create a Matrix4 instance which is a scaled version of the supplied Matrix4\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * const a = Cesium.Matrix4.multiplyByScalar(m, -2, new Cesium.Matrix4());\n *\n * // m remains the same\n * // a = [-20.0, -22.0, -24.0, -26.0]\n * // [-28.0, -30.0, -32.0, -34.0]\n * // [-36.0, -38.0, -40.0, -42.0]\n * // [-44.0, -46.0, -48.0, -50.0]\n */\nMatrix4.multiplyByScalar = function (matrix, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scalar;\n result[1] = matrix[1] * scalar;\n result[2] = matrix[2] * scalar;\n result[3] = matrix[3] * scalar;\n result[4] = matrix[4] * scalar;\n result[5] = matrix[5] * scalar;\n result[6] = matrix[6] * scalar;\n result[7] = matrix[7] * scalar;\n result[8] = matrix[8] * scalar;\n result[9] = matrix[9] * scalar;\n result[10] = matrix[10] * scalar;\n result[11] = matrix[11] * scalar;\n result[12] = matrix[12] * scalar;\n result[13] = matrix[13] * scalar;\n result[14] = matrix[14] * scalar;\n result[15] = matrix[15] * scalar;\n return result;\n};\n\n/**\n * Computes a negated copy of the provided matrix.\n *\n * @param {Matrix4} matrix The matrix to negate.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * //create a new Matrix4 instance which is a negation of a Matrix4\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * const a = Cesium.Matrix4.negate(m, new Cesium.Matrix4());\n *\n * // m remains the same\n * // a = [-10.0, -11.0, -12.0, -13.0]\n * // [-14.0, -15.0, -16.0, -17.0]\n * // [-18.0, -19.0, -20.0, -21.0]\n * // [-22.0, -23.0, -24.0, -25.0]\n */\nMatrix4.negate = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = -matrix[0];\n result[1] = -matrix[1];\n result[2] = -matrix[2];\n result[3] = -matrix[3];\n result[4] = -matrix[4];\n result[5] = -matrix[5];\n result[6] = -matrix[6];\n result[7] = -matrix[7];\n result[8] = -matrix[8];\n result[9] = -matrix[9];\n result[10] = -matrix[10];\n result[11] = -matrix[11];\n result[12] = -matrix[12];\n result[13] = -matrix[13];\n result[14] = -matrix[14];\n result[15] = -matrix[15];\n return result;\n};\n\n/**\n * Computes the transpose of the provided matrix.\n *\n * @param {Matrix4} matrix The matrix to transpose.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @example\n * //returns transpose of a Matrix4\n * // m = [10.0, 11.0, 12.0, 13.0]\n * // [14.0, 15.0, 16.0, 17.0]\n * // [18.0, 19.0, 20.0, 21.0]\n * // [22.0, 23.0, 24.0, 25.0]\n *\n * const a = Cesium.Matrix4.transpose(m, new Cesium.Matrix4());\n *\n * // m remains the same\n * // a = [10.0, 14.0, 18.0, 22.0]\n * // [11.0, 15.0, 19.0, 23.0]\n * // [12.0, 16.0, 20.0, 24.0]\n * // [13.0, 17.0, 21.0, 25.0]\n */\nMatrix4.transpose = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const matrix1 = matrix[1];\n const matrix2 = matrix[2];\n const matrix3 = matrix[3];\n const matrix6 = matrix[6];\n const matrix7 = matrix[7];\n const matrix11 = matrix[11];\n\n result[0] = matrix[0];\n result[1] = matrix[4];\n result[2] = matrix[8];\n result[3] = matrix[12];\n result[4] = matrix1;\n result[5] = matrix[5];\n result[6] = matrix[9];\n result[7] = matrix[13];\n result[8] = matrix2;\n result[9] = matrix6;\n result[10] = matrix[10];\n result[11] = matrix[14];\n result[12] = matrix3;\n result[13] = matrix7;\n result[14] = matrix11;\n result[15] = matrix[15];\n return result;\n};\n\n/**\n * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.\n *\n * @param {Matrix4} matrix The matrix with signed elements.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.abs = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = Math.abs(matrix[0]);\n result[1] = Math.abs(matrix[1]);\n result[2] = Math.abs(matrix[2]);\n result[3] = Math.abs(matrix[3]);\n result[4] = Math.abs(matrix[4]);\n result[5] = Math.abs(matrix[5]);\n result[6] = Math.abs(matrix[6]);\n result[7] = Math.abs(matrix[7]);\n result[8] = Math.abs(matrix[8]);\n result[9] = Math.abs(matrix[9]);\n result[10] = Math.abs(matrix[10]);\n result[11] = Math.abs(matrix[11]);\n result[12] = Math.abs(matrix[12]);\n result[13] = Math.abs(matrix[13]);\n result[14] = Math.abs(matrix[14]);\n result[15] = Math.abs(matrix[15]);\n\n return result;\n};\n\n/**\n * Compares the provided matrices componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Matrix4} [left] The first matrix.\n * @param {Matrix4} [right] The second matrix.\n * @returns {boolean} true if left and right are equal, false otherwise.\n *\n * @example\n * //compares two Matrix4 instances\n *\n * // a = [10.0, 14.0, 18.0, 22.0]\n * // [11.0, 15.0, 19.0, 23.0]\n * // [12.0, 16.0, 20.0, 24.0]\n * // [13.0, 17.0, 21.0, 25.0]\n *\n * // b = [10.0, 14.0, 18.0, 22.0]\n * // [11.0, 15.0, 19.0, 23.0]\n * // [12.0, 16.0, 20.0, 24.0]\n * // [13.0, 17.0, 21.0, 25.0]\n *\n * if(Cesium.Matrix4.equals(a,b)) {\n * console.log(\"Both matrices are equal\");\n * } else {\n * console.log(\"They are not equal\");\n * }\n *\n * //Prints \"Both matrices are equal\" on the console\n */\nMatrix4.equals = function (left, right) {\n // Given that most matrices will be transformation matrices, the elements\n // are tested in order such that the test is likely to fail as early\n // as possible. I _think_ this is just as friendly to the L1 cache\n // as testing in index order. It is certainty faster in practice.\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n // Translation\n left[12] === right[12] &&\n left[13] === right[13] &&\n left[14] === right[14] &&\n // Rotation/scale\n left[0] === right[0] &&\n left[1] === right[1] &&\n left[2] === right[2] &&\n left[4] === right[4] &&\n left[5] === right[5] &&\n left[6] === right[6] &&\n left[8] === right[8] &&\n left[9] === right[9] &&\n left[10] === right[10] &&\n // Bottom row\n left[3] === right[3] &&\n left[7] === right[7] &&\n left[11] === right[11] &&\n left[15] === right[15])\n );\n};\n\n/**\n * Compares the provided matrices componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Matrix4} [left] The first matrix.\n * @param {Matrix4} [right] The second matrix.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n *\n * @example\n * //compares two Matrix4 instances\n *\n * // a = [10.5, 14.5, 18.5, 22.5]\n * // [11.5, 15.5, 19.5, 23.5]\n * // [12.5, 16.5, 20.5, 24.5]\n * // [13.5, 17.5, 21.5, 25.5]\n *\n * // b = [10.0, 14.0, 18.0, 22.0]\n * // [11.0, 15.0, 19.0, 23.0]\n * // [12.0, 16.0, 20.0, 24.0]\n * // [13.0, 17.0, 21.0, 25.0]\n *\n * if(Cesium.Matrix4.equalsEpsilon(a,b,0.1)){\n * console.log(\"Difference between both the matrices is less than 0.1\");\n * } else {\n * console.log(\"Difference between both the matrices is not less than 0.1\");\n * }\n *\n * //Prints \"Difference between both the matrices is not less than 0.1\" on the console\n */\nMatrix4.equalsEpsilon = function (left, right, epsilon) {\n epsilon = defaultValue(epsilon, 0);\n\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(left[0] - right[0]) <= epsilon &&\n Math.abs(left[1] - right[1]) <= epsilon &&\n Math.abs(left[2] - right[2]) <= epsilon &&\n Math.abs(left[3] - right[3]) <= epsilon &&\n Math.abs(left[4] - right[4]) <= epsilon &&\n Math.abs(left[5] - right[5]) <= epsilon &&\n Math.abs(left[6] - right[6]) <= epsilon &&\n Math.abs(left[7] - right[7]) <= epsilon &&\n Math.abs(left[8] - right[8]) <= epsilon &&\n Math.abs(left[9] - right[9]) <= epsilon &&\n Math.abs(left[10] - right[10]) <= epsilon &&\n Math.abs(left[11] - right[11]) <= epsilon &&\n Math.abs(left[12] - right[12]) <= epsilon &&\n Math.abs(left[13] - right[13]) <= epsilon &&\n Math.abs(left[14] - right[14]) <= epsilon &&\n Math.abs(left[15] - right[15]) <= epsilon)\n );\n};\n\n/**\n * Gets the translation portion of the provided matrix, assuming the matrix is an affine transformation matrix.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nMatrix4.getTranslation = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = matrix[12];\n result.y = matrix[13];\n result.z = matrix[14];\n return result;\n};\n\n/**\n * Gets the upper left 3x3 matrix of the provided matrix.\n *\n * @param {Matrix4} matrix The matrix to use.\n * @param {Matrix3} result The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter.\n *\n * @example\n * // returns a Matrix3 instance from a Matrix4 instance\n *\n * // m = [10.0, 14.0, 18.0, 22.0]\n * // [11.0, 15.0, 19.0, 23.0]\n * // [12.0, 16.0, 20.0, 24.0]\n * // [13.0, 17.0, 21.0, 25.0]\n *\n * const b = new Cesium.Matrix3();\n * Cesium.Matrix4.getMatrix3(m,b);\n *\n * // b = [10.0, 14.0, 18.0]\n * // [11.0, 15.0, 19.0]\n * // [12.0, 16.0, 20.0]\n */\nMatrix4.getMatrix3 = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[4];\n result[4] = matrix[5];\n result[5] = matrix[6];\n result[6] = matrix[8];\n result[7] = matrix[9];\n result[8] = matrix[10];\n return result;\n};\n\nconst scratchInverseRotation = new Matrix3();\nconst scratchMatrix3Zero = new Matrix3();\nconst scratchBottomRow = new Cartesian4();\nconst scratchExpectedBottomRow = new Cartesian4(0.0, 0.0, 0.0, 1.0);\n\n/**\n * Computes the inverse of the provided matrix using Cramers Rule.\n * If the determinant is zero, the matrix can not be inverted, and an exception is thrown.\n * If the matrix is a proper rigid transformation, it is more efficient\n * to invert it with {@link Matrix4.inverseTransformation}.\n *\n * @param {Matrix4} matrix The matrix to invert.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n *\n * @exception {RuntimeError} matrix is not invertible because its determinate is zero.\n */\nMatrix4.inverse = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n //\n // Ported from:\n // ftp://download.intel.com/design/PentiumIII/sml/24504301.pdf\n //\n const src0 = matrix[0];\n const src1 = matrix[4];\n const src2 = matrix[8];\n const src3 = matrix[12];\n const src4 = matrix[1];\n const src5 = matrix[5];\n const src6 = matrix[9];\n const src7 = matrix[13];\n const src8 = matrix[2];\n const src9 = matrix[6];\n const src10 = matrix[10];\n const src11 = matrix[14];\n const src12 = matrix[3];\n const src13 = matrix[7];\n const src14 = matrix[11];\n const src15 = matrix[15];\n\n // calculate pairs for first 8 elements (cofactors)\n let tmp0 = src10 * src15;\n let tmp1 = src11 * src14;\n let tmp2 = src9 * src15;\n let tmp3 = src11 * src13;\n let tmp4 = src9 * src14;\n let tmp5 = src10 * src13;\n let tmp6 = src8 * src15;\n let tmp7 = src11 * src12;\n let tmp8 = src8 * src14;\n let tmp9 = src10 * src12;\n let tmp10 = src8 * src13;\n let tmp11 = src9 * src12;\n\n // calculate first 8 elements (cofactors)\n const dst0 =\n tmp0 * src5 +\n tmp3 * src6 +\n tmp4 * src7 -\n (tmp1 * src5 + tmp2 * src6 + tmp5 * src7);\n const dst1 =\n tmp1 * src4 +\n tmp6 * src6 +\n tmp9 * src7 -\n (tmp0 * src4 + tmp7 * src6 + tmp8 * src7);\n const dst2 =\n tmp2 * src4 +\n tmp7 * src5 +\n tmp10 * src7 -\n (tmp3 * src4 + tmp6 * src5 + tmp11 * src7);\n const dst3 =\n tmp5 * src4 +\n tmp8 * src5 +\n tmp11 * src6 -\n (tmp4 * src4 + tmp9 * src5 + tmp10 * src6);\n const dst4 =\n tmp1 * src1 +\n tmp2 * src2 +\n tmp5 * src3 -\n (tmp0 * src1 + tmp3 * src2 + tmp4 * src3);\n const dst5 =\n tmp0 * src0 +\n tmp7 * src2 +\n tmp8 * src3 -\n (tmp1 * src0 + tmp6 * src2 + tmp9 * src3);\n const dst6 =\n tmp3 * src0 +\n tmp6 * src1 +\n tmp11 * src3 -\n (tmp2 * src0 + tmp7 * src1 + tmp10 * src3);\n const dst7 =\n tmp4 * src0 +\n tmp9 * src1 +\n tmp10 * src2 -\n (tmp5 * src0 + tmp8 * src1 + tmp11 * src2);\n\n // calculate pairs for second 8 elements (cofactors)\n tmp0 = src2 * src7;\n tmp1 = src3 * src6;\n tmp2 = src1 * src7;\n tmp3 = src3 * src5;\n tmp4 = src1 * src6;\n tmp5 = src2 * src5;\n tmp6 = src0 * src7;\n tmp7 = src3 * src4;\n tmp8 = src0 * src6;\n tmp9 = src2 * src4;\n tmp10 = src0 * src5;\n tmp11 = src1 * src4;\n\n // calculate second 8 elements (cofactors)\n const dst8 =\n tmp0 * src13 +\n tmp3 * src14 +\n tmp4 * src15 -\n (tmp1 * src13 + tmp2 * src14 + tmp5 * src15);\n const dst9 =\n tmp1 * src12 +\n tmp6 * src14 +\n tmp9 * src15 -\n (tmp0 * src12 + tmp7 * src14 + tmp8 * src15);\n const dst10 =\n tmp2 * src12 +\n tmp7 * src13 +\n tmp10 * src15 -\n (tmp3 * src12 + tmp6 * src13 + tmp11 * src15);\n const dst11 =\n tmp5 * src12 +\n tmp8 * src13 +\n tmp11 * src14 -\n (tmp4 * src12 + tmp9 * src13 + tmp10 * src14);\n const dst12 =\n tmp2 * src10 +\n tmp5 * src11 +\n tmp1 * src9 -\n (tmp4 * src11 + tmp0 * src9 + tmp3 * src10);\n const dst13 =\n tmp8 * src11 +\n tmp0 * src8 +\n tmp7 * src10 -\n (tmp6 * src10 + tmp9 * src11 + tmp1 * src8);\n const dst14 =\n tmp6 * src9 +\n tmp11 * src11 +\n tmp3 * src8 -\n (tmp10 * src11 + tmp2 * src8 + tmp7 * src9);\n const dst15 =\n tmp10 * src10 +\n tmp4 * src8 +\n tmp9 * src9 -\n (tmp8 * src9 + tmp11 * src10 + tmp5 * src8);\n\n // calculate determinant\n let det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;\n\n if (Math.abs(det) < CesiumMath.EPSILON21) {\n // Special case for a zero scale matrix that can occur, for example,\n // when a model's node has a [0, 0, 0] scale.\n if (\n Matrix3.equalsEpsilon(\n Matrix4.getMatrix3(matrix, scratchInverseRotation),\n scratchMatrix3Zero,\n CesiumMath.EPSILON7\n ) &&\n Cartesian4.equals(\n Matrix4.getRow(matrix, 3, scratchBottomRow),\n scratchExpectedBottomRow\n )\n ) {\n result[0] = 0.0;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = 0.0;\n result[4] = 0.0;\n result[5] = 0.0;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 0.0;\n result[9] = 0.0;\n result[10] = 0.0;\n result[11] = 0.0;\n result[12] = -matrix[12];\n result[13] = -matrix[13];\n result[14] = -matrix[14];\n result[15] = 1.0;\n return result;\n }\n\n throw new RuntimeError(\n \"matrix is not invertible because its determinate is zero.\"\n );\n }\n\n // calculate matrix inverse\n det = 1.0 / det;\n\n result[0] = dst0 * det;\n result[1] = dst1 * det;\n result[2] = dst2 * det;\n result[3] = dst3 * det;\n result[4] = dst4 * det;\n result[5] = dst5 * det;\n result[6] = dst6 * det;\n result[7] = dst7 * det;\n result[8] = dst8 * det;\n result[9] = dst9 * det;\n result[10] = dst10 * det;\n result[11] = dst11 * det;\n result[12] = dst12 * det;\n result[13] = dst13 * det;\n result[14] = dst14 * det;\n result[15] = dst15 * det;\n return result;\n};\n\n/**\n * Computes the inverse of the provided matrix assuming it is a proper rigid matrix,\n * where the upper left 3x3 elements are a rotation matrix,\n * and the upper three elements in the fourth column are the translation.\n * The bottom row is assumed to be [0, 0, 0, 1].\n * The matrix is not verified to be in the proper form.\n * This method is faster than computing the inverse for a general 4x4\n * matrix using {@link Matrix4.inverse}.\n *\n * @param {Matrix4} matrix The matrix to invert.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.inverseTransformation = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n //This function is an optimized version of the below 4 lines.\n //const rT = Matrix3.transpose(Matrix4.getMatrix3(matrix));\n //const rTN = Matrix3.negate(rT);\n //const rTT = Matrix3.multiplyByVector(rTN, Matrix4.getTranslation(matrix));\n //return Matrix4.fromRotationTranslation(rT, rTT, result);\n\n const matrix0 = matrix[0];\n const matrix1 = matrix[1];\n const matrix2 = matrix[2];\n const matrix4 = matrix[4];\n const matrix5 = matrix[5];\n const matrix6 = matrix[6];\n const matrix8 = matrix[8];\n const matrix9 = matrix[9];\n const matrix10 = matrix[10];\n\n const vX = matrix[12];\n const vY = matrix[13];\n const vZ = matrix[14];\n\n const x = -matrix0 * vX - matrix1 * vY - matrix2 * vZ;\n const y = -matrix4 * vX - matrix5 * vY - matrix6 * vZ;\n const z = -matrix8 * vX - matrix9 * vY - matrix10 * vZ;\n\n result[0] = matrix0;\n result[1] = matrix4;\n result[2] = matrix8;\n result[3] = 0.0;\n result[4] = matrix1;\n result[5] = matrix5;\n result[6] = matrix9;\n result[7] = 0.0;\n result[8] = matrix2;\n result[9] = matrix6;\n result[10] = matrix10;\n result[11] = 0.0;\n result[12] = x;\n result[13] = y;\n result[14] = z;\n result[15] = 1.0;\n return result;\n};\n\nconst scratchTransposeMatrix = new Matrix4();\n\n/**\n * Computes the inverse transpose of a matrix.\n *\n * @param {Matrix4} matrix The matrix to transpose and invert.\n * @param {Matrix4} result The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter.\n */\nMatrix4.inverseTranspose = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n return Matrix4.inverse(\n Matrix4.transpose(matrix, scratchTransposeMatrix),\n result\n );\n};\n\n/**\n * An immutable Matrix4 instance initialized to the identity matrix.\n *\n * @type {Matrix4}\n * @constant\n */\nMatrix4.IDENTITY = Object.freeze(\n new Matrix4(\n 1.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n )\n);\n\n/**\n * An immutable Matrix4 instance initialized to the zero matrix.\n *\n * @type {Matrix4}\n * @constant\n */\nMatrix4.ZERO = Object.freeze(\n new Matrix4(\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0\n )\n);\n\n/**\n * The index into Matrix4 for column 0, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN0ROW0 = 0;\n\n/**\n * The index into Matrix4 for column 0, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN0ROW1 = 1;\n\n/**\n * The index into Matrix4 for column 0, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN0ROW2 = 2;\n\n/**\n * The index into Matrix4 for column 0, row 3.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN0ROW3 = 3;\n\n/**\n * The index into Matrix4 for column 1, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN1ROW0 = 4;\n\n/**\n * The index into Matrix4 for column 1, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN1ROW1 = 5;\n\n/**\n * The index into Matrix4 for column 1, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN1ROW2 = 6;\n\n/**\n * The index into Matrix4 for column 1, row 3.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN1ROW3 = 7;\n\n/**\n * The index into Matrix4 for column 2, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN2ROW0 = 8;\n\n/**\n * The index into Matrix4 for column 2, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN2ROW1 = 9;\n\n/**\n * The index into Matrix4 for column 2, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN2ROW2 = 10;\n\n/**\n * The index into Matrix4 for column 2, row 3.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN2ROW3 = 11;\n\n/**\n * The index into Matrix4 for column 3, row 0.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN3ROW0 = 12;\n\n/**\n * The index into Matrix4 for column 3, row 1.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN3ROW1 = 13;\n\n/**\n * The index into Matrix4 for column 3, row 2.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN3ROW2 = 14;\n\n/**\n * The index into Matrix4 for column 3, row 3.\n *\n * @type {number}\n * @constant\n */\nMatrix4.COLUMN3ROW3 = 15;\n\nObject.defineProperties(Matrix4.prototype, {\n /**\n * Gets the number of items in the collection.\n * @memberof Matrix4.prototype\n *\n * @type {number}\n */\n length: {\n get: function () {\n return Matrix4.packedLength;\n },\n },\n});\n\n/**\n * Duplicates the provided Matrix4 instance.\n *\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.\n */\nMatrix4.prototype.clone = function (result) {\n return Matrix4.clone(this, result);\n};\n\n/**\n * Compares this matrix to the provided matrix componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Matrix4} [right] The right hand side matrix.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nMatrix4.prototype.equals = function (right) {\n return Matrix4.equals(this, right);\n};\n\n/**\n * @private\n */\nMatrix4.equalsArray = function (matrix, array, offset) {\n return (\n matrix[0] === array[offset] &&\n matrix[1] === array[offset + 1] &&\n matrix[2] === array[offset + 2] &&\n matrix[3] === array[offset + 3] &&\n matrix[4] === array[offset + 4] &&\n matrix[5] === array[offset + 5] &&\n matrix[6] === array[offset + 6] &&\n matrix[7] === array[offset + 7] &&\n matrix[8] === array[offset + 8] &&\n matrix[9] === array[offset + 9] &&\n matrix[10] === array[offset + 10] &&\n matrix[11] === array[offset + 11] &&\n matrix[12] === array[offset + 12] &&\n matrix[13] === array[offset + 13] &&\n matrix[14] === array[offset + 14] &&\n matrix[15] === array[offset + 15]\n );\n};\n\n/**\n * Compares this matrix to the provided matrix componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Matrix4} [right] The right hand side matrix.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nMatrix4.prototype.equalsEpsilon = function (right, epsilon) {\n return Matrix4.equalsEpsilon(this, right, epsilon);\n};\n\n/**\n * Computes a string representing this Matrix with each row being\n * on a separate line and in the format '(column0, column1, column2, column3)'.\n *\n * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2, column3)'.\n */\nMatrix4.prototype.toString = function () {\n return (\n `(${this[0]}, ${this[4]}, ${this[8]}, ${this[12]})\\n` +\n `(${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})\\n` +\n `(${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})\\n` +\n `(${this[3]}, ${this[7]}, ${this[11]}, ${this[15]})`\n );\n};\nexport default Matrix4;\n", "/**\n * Enum containing WebGL Constant values by name.\n * for use without an active WebGL context, or in cases where certain constants are unavailable using the WebGL context\n * (For example, in [Safari 9]{@link https://github.com/CesiumGS/cesium/issues/2989}).\n *\n * These match the constants from the [WebGL 1.0]{@link https://www.khronos.org/registry/webgl/specs/latest/1.0/}\n * and [WebGL 2.0]{@link https://www.khronos.org/registry/webgl/specs/latest/2.0/}\n * specifications.\n *\n * @enum {number}\n */\nconst WebGLConstants = {\n DEPTH_BUFFER_BIT: 0x00000100,\n STENCIL_BUFFER_BIT: 0x00000400,\n COLOR_BUFFER_BIT: 0x00004000,\n POINTS: 0x0000,\n LINES: 0x0001,\n LINE_LOOP: 0x0002,\n LINE_STRIP: 0x0003,\n TRIANGLES: 0x0004,\n TRIANGLE_STRIP: 0x0005,\n TRIANGLE_FAN: 0x0006,\n ZERO: 0,\n ONE: 1,\n SRC_COLOR: 0x0300,\n ONE_MINUS_SRC_COLOR: 0x0301,\n SRC_ALPHA: 0x0302,\n ONE_MINUS_SRC_ALPHA: 0x0303,\n DST_ALPHA: 0x0304,\n ONE_MINUS_DST_ALPHA: 0x0305,\n DST_COLOR: 0x0306,\n ONE_MINUS_DST_COLOR: 0x0307,\n SRC_ALPHA_SATURATE: 0x0308,\n FUNC_ADD: 0x8006,\n BLEND_EQUATION: 0x8009,\n BLEND_EQUATION_RGB: 0x8009, // same as BLEND_EQUATION\n BLEND_EQUATION_ALPHA: 0x883d,\n FUNC_SUBTRACT: 0x800a,\n FUNC_REVERSE_SUBTRACT: 0x800b,\n BLEND_DST_RGB: 0x80c8,\n BLEND_SRC_RGB: 0x80c9,\n BLEND_DST_ALPHA: 0x80ca,\n BLEND_SRC_ALPHA: 0x80cb,\n CONSTANT_COLOR: 0x8001,\n ONE_MINUS_CONSTANT_COLOR: 0x8002,\n CONSTANT_ALPHA: 0x8003,\n ONE_MINUS_CONSTANT_ALPHA: 0x8004,\n BLEND_COLOR: 0x8005,\n ARRAY_BUFFER: 0x8892,\n ELEMENT_ARRAY_BUFFER: 0x8893,\n ARRAY_BUFFER_BINDING: 0x8894,\n ELEMENT_ARRAY_BUFFER_BINDING: 0x8895,\n STREAM_DRAW: 0x88e0,\n STATIC_DRAW: 0x88e4,\n DYNAMIC_DRAW: 0x88e8,\n BUFFER_SIZE: 0x8764,\n BUFFER_USAGE: 0x8765,\n CURRENT_VERTEX_ATTRIB: 0x8626,\n FRONT: 0x0404,\n BACK: 0x0405,\n FRONT_AND_BACK: 0x0408,\n CULL_FACE: 0x0b44,\n BLEND: 0x0be2,\n DITHER: 0x0bd0,\n STENCIL_TEST: 0x0b90,\n DEPTH_TEST: 0x0b71,\n SCISSOR_TEST: 0x0c11,\n POLYGON_OFFSET_FILL: 0x8037,\n SAMPLE_ALPHA_TO_COVERAGE: 0x809e,\n SAMPLE_COVERAGE: 0x80a0,\n NO_ERROR: 0,\n INVALID_ENUM: 0x0500,\n INVALID_VALUE: 0x0501,\n INVALID_OPERATION: 0x0502,\n OUT_OF_MEMORY: 0x0505,\n CW: 0x0900,\n CCW: 0x0901,\n LINE_WIDTH: 0x0b21,\n ALIASED_POINT_SIZE_RANGE: 0x846d,\n ALIASED_LINE_WIDTH_RANGE: 0x846e,\n CULL_FACE_MODE: 0x0b45,\n FRONT_FACE: 0x0b46,\n DEPTH_RANGE: 0x0b70,\n DEPTH_WRITEMASK: 0x0b72,\n DEPTH_CLEAR_VALUE: 0x0b73,\n DEPTH_FUNC: 0x0b74,\n STENCIL_CLEAR_VALUE: 0x0b91,\n STENCIL_FUNC: 0x0b92,\n STENCIL_FAIL: 0x0b94,\n STENCIL_PASS_DEPTH_FAIL: 0x0b95,\n STENCIL_PASS_DEPTH_PASS: 0x0b96,\n STENCIL_REF: 0x0b97,\n STENCIL_VALUE_MASK: 0x0b93,\n STENCIL_WRITEMASK: 0x0b98,\n STENCIL_BACK_FUNC: 0x8800,\n STENCIL_BACK_FAIL: 0x8801,\n STENCIL_BACK_PASS_DEPTH_FAIL: 0x8802,\n STENCIL_BACK_PASS_DEPTH_PASS: 0x8803,\n STENCIL_BACK_REF: 0x8ca3,\n STENCIL_BACK_VALUE_MASK: 0x8ca4,\n STENCIL_BACK_WRITEMASK: 0x8ca5,\n VIEWPORT: 0x0ba2,\n SCISSOR_BOX: 0x0c10,\n COLOR_CLEAR_VALUE: 0x0c22,\n COLOR_WRITEMASK: 0x0c23,\n UNPACK_ALIGNMENT: 0x0cf5,\n PACK_ALIGNMENT: 0x0d05,\n MAX_TEXTURE_SIZE: 0x0d33,\n MAX_VIEWPORT_DIMS: 0x0d3a,\n SUBPIXEL_BITS: 0x0d50,\n RED_BITS: 0x0d52,\n GREEN_BITS: 0x0d53,\n BLUE_BITS: 0x0d54,\n ALPHA_BITS: 0x0d55,\n DEPTH_BITS: 0x0d56,\n STENCIL_BITS: 0x0d57,\n POLYGON_OFFSET_UNITS: 0x2a00,\n POLYGON_OFFSET_FACTOR: 0x8038,\n TEXTURE_BINDING_2D: 0x8069,\n SAMPLE_BUFFERS: 0x80a8,\n SAMPLES: 0x80a9,\n SAMPLE_COVERAGE_VALUE: 0x80aa,\n SAMPLE_COVERAGE_INVERT: 0x80ab,\n COMPRESSED_TEXTURE_FORMATS: 0x86a3,\n DONT_CARE: 0x1100,\n FASTEST: 0x1101,\n NICEST: 0x1102,\n GENERATE_MIPMAP_HINT: 0x8192,\n BYTE: 0x1400,\n UNSIGNED_BYTE: 0x1401,\n SHORT: 0x1402,\n UNSIGNED_SHORT: 0x1403,\n INT: 0x1404,\n UNSIGNED_INT: 0x1405,\n FLOAT: 0x1406,\n DEPTH_COMPONENT: 0x1902,\n ALPHA: 0x1906,\n RGB: 0x1907,\n RGBA: 0x1908,\n LUMINANCE: 0x1909,\n LUMINANCE_ALPHA: 0x190a,\n UNSIGNED_SHORT_4_4_4_4: 0x8033,\n UNSIGNED_SHORT_5_5_5_1: 0x8034,\n UNSIGNED_SHORT_5_6_5: 0x8363,\n FRAGMENT_SHADER: 0x8b30,\n VERTEX_SHADER: 0x8b31,\n MAX_VERTEX_ATTRIBS: 0x8869,\n MAX_VERTEX_UNIFORM_VECTORS: 0x8dfb,\n MAX_VARYING_VECTORS: 0x8dfc,\n MAX_COMBINED_TEXTURE_IMAGE_UNITS: 0x8b4d,\n MAX_VERTEX_TEXTURE_IMAGE_UNITS: 0x8b4c,\n MAX_TEXTURE_IMAGE_UNITS: 0x8872,\n MAX_FRAGMENT_UNIFORM_VECTORS: 0x8dfd,\n SHADER_TYPE: 0x8b4f,\n DELETE_STATUS: 0x8b80,\n LINK_STATUS: 0x8b82,\n VALIDATE_STATUS: 0x8b83,\n ATTACHED_SHADERS: 0x8b85,\n ACTIVE_UNIFORMS: 0x8b86,\n ACTIVE_ATTRIBUTES: 0x8b89,\n SHADING_LANGUAGE_VERSION: 0x8b8c,\n CURRENT_PROGRAM: 0x8b8d,\n NEVER: 0x0200,\n LESS: 0x0201,\n EQUAL: 0x0202,\n LEQUAL: 0x0203,\n GREATER: 0x0204,\n NOTEQUAL: 0x0205,\n GEQUAL: 0x0206,\n ALWAYS: 0x0207,\n KEEP: 0x1e00,\n REPLACE: 0x1e01,\n INCR: 0x1e02,\n DECR: 0x1e03,\n INVERT: 0x150a,\n INCR_WRAP: 0x8507,\n DECR_WRAP: 0x8508,\n VENDOR: 0x1f00,\n RENDERER: 0x1f01,\n VERSION: 0x1f02,\n NEAREST: 0x2600,\n LINEAR: 0x2601,\n NEAREST_MIPMAP_NEAREST: 0x2700,\n LINEAR_MIPMAP_NEAREST: 0x2701,\n NEAREST_MIPMAP_LINEAR: 0x2702,\n LINEAR_MIPMAP_LINEAR: 0x2703,\n TEXTURE_MAG_FILTER: 0x2800,\n TEXTURE_MIN_FILTER: 0x2801,\n TEXTURE_WRAP_S: 0x2802,\n TEXTURE_WRAP_T: 0x2803,\n TEXTURE_2D: 0x0de1,\n TEXTURE: 0x1702,\n TEXTURE_CUBE_MAP: 0x8513,\n TEXTURE_BINDING_CUBE_MAP: 0x8514,\n TEXTURE_CUBE_MAP_POSITIVE_X: 0x8515,\n TEXTURE_CUBE_MAP_NEGATIVE_X: 0x8516,\n TEXTURE_CUBE_MAP_POSITIVE_Y: 0x8517,\n TEXTURE_CUBE_MAP_NEGATIVE_Y: 0x8518,\n TEXTURE_CUBE_MAP_POSITIVE_Z: 0x8519,\n TEXTURE_CUBE_MAP_NEGATIVE_Z: 0x851a,\n MAX_CUBE_MAP_TEXTURE_SIZE: 0x851c,\n TEXTURE0: 0x84c0,\n TEXTURE1: 0x84c1,\n TEXTURE2: 0x84c2,\n TEXTURE3: 0x84c3,\n TEXTURE4: 0x84c4,\n TEXTURE5: 0x84c5,\n TEXTURE6: 0x84c6,\n TEXTURE7: 0x84c7,\n TEXTURE8: 0x84c8,\n TEXTURE9: 0x84c9,\n TEXTURE10: 0x84ca,\n TEXTURE11: 0x84cb,\n TEXTURE12: 0x84cc,\n TEXTURE13: 0x84cd,\n TEXTURE14: 0x84ce,\n TEXTURE15: 0x84cf,\n TEXTURE16: 0x84d0,\n TEXTURE17: 0x84d1,\n TEXTURE18: 0x84d2,\n TEXTURE19: 0x84d3,\n TEXTURE20: 0x84d4,\n TEXTURE21: 0x84d5,\n TEXTURE22: 0x84d6,\n TEXTURE23: 0x84d7,\n TEXTURE24: 0x84d8,\n TEXTURE25: 0x84d9,\n TEXTURE26: 0x84da,\n TEXTURE27: 0x84db,\n TEXTURE28: 0x84dc,\n TEXTURE29: 0x84dd,\n TEXTURE30: 0x84de,\n TEXTURE31: 0x84df,\n ACTIVE_TEXTURE: 0x84e0,\n REPEAT: 0x2901,\n CLAMP_TO_EDGE: 0x812f,\n MIRRORED_REPEAT: 0x8370,\n FLOAT_VEC2: 0x8b50,\n FLOAT_VEC3: 0x8b51,\n FLOAT_VEC4: 0x8b52,\n INT_VEC2: 0x8b53,\n INT_VEC3: 0x8b54,\n INT_VEC4: 0x8b55,\n BOOL: 0x8b56,\n BOOL_VEC2: 0x8b57,\n BOOL_VEC3: 0x8b58,\n BOOL_VEC4: 0x8b59,\n FLOAT_MAT2: 0x8b5a,\n FLOAT_MAT3: 0x8b5b,\n FLOAT_MAT4: 0x8b5c,\n SAMPLER_2D: 0x8b5e,\n SAMPLER_CUBE: 0x8b60,\n VERTEX_ATTRIB_ARRAY_ENABLED: 0x8622,\n VERTEX_ATTRIB_ARRAY_SIZE: 0x8623,\n VERTEX_ATTRIB_ARRAY_STRIDE: 0x8624,\n VERTEX_ATTRIB_ARRAY_TYPE: 0x8625,\n VERTEX_ATTRIB_ARRAY_NORMALIZED: 0x886a,\n VERTEX_ATTRIB_ARRAY_POINTER: 0x8645,\n VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 0x889f,\n IMPLEMENTATION_COLOR_READ_TYPE: 0x8b9a,\n IMPLEMENTATION_COLOR_READ_FORMAT: 0x8b9b,\n COMPILE_STATUS: 0x8b81,\n LOW_FLOAT: 0x8df0,\n MEDIUM_FLOAT: 0x8df1,\n HIGH_FLOAT: 0x8df2,\n LOW_INT: 0x8df3,\n MEDIUM_INT: 0x8df4,\n HIGH_INT: 0x8df5,\n FRAMEBUFFER: 0x8d40,\n RENDERBUFFER: 0x8d41,\n RGBA4: 0x8056,\n RGB5_A1: 0x8057,\n RGB565: 0x8d62,\n DEPTH_COMPONENT16: 0x81a5,\n STENCIL_INDEX: 0x1901,\n STENCIL_INDEX8: 0x8d48,\n DEPTH_STENCIL: 0x84f9,\n RENDERBUFFER_WIDTH: 0x8d42,\n RENDERBUFFER_HEIGHT: 0x8d43,\n RENDERBUFFER_INTERNAL_FORMAT: 0x8d44,\n RENDERBUFFER_RED_SIZE: 0x8d50,\n RENDERBUFFER_GREEN_SIZE: 0x8d51,\n RENDERBUFFER_BLUE_SIZE: 0x8d52,\n RENDERBUFFER_ALPHA_SIZE: 0x8d53,\n RENDERBUFFER_DEPTH_SIZE: 0x8d54,\n RENDERBUFFER_STENCIL_SIZE: 0x8d55,\n FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 0x8cd0,\n FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 0x8cd1,\n FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 0x8cd2,\n FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 0x8cd3,\n COLOR_ATTACHMENT0: 0x8ce0,\n DEPTH_ATTACHMENT: 0x8d00,\n STENCIL_ATTACHMENT: 0x8d20,\n DEPTH_STENCIL_ATTACHMENT: 0x821a,\n NONE: 0,\n FRAMEBUFFER_COMPLETE: 0x8cd5,\n FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 0x8cd6,\n FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 0x8cd7,\n FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 0x8cd9,\n FRAMEBUFFER_UNSUPPORTED: 0x8cdd,\n FRAMEBUFFER_BINDING: 0x8ca6,\n RENDERBUFFER_BINDING: 0x8ca7,\n MAX_RENDERBUFFER_SIZE: 0x84e8,\n INVALID_FRAMEBUFFER_OPERATION: 0x0506,\n UNPACK_FLIP_Y_WEBGL: 0x9240,\n UNPACK_PREMULTIPLY_ALPHA_WEBGL: 0x9241,\n CONTEXT_LOST_WEBGL: 0x9242,\n UNPACK_COLORSPACE_CONVERSION_WEBGL: 0x9243,\n BROWSER_DEFAULT_WEBGL: 0x9244,\n\n // WEBGL_compressed_texture_s3tc\n COMPRESSED_RGB_S3TC_DXT1_EXT: 0x83f0,\n COMPRESSED_RGBA_S3TC_DXT1_EXT: 0x83f1,\n COMPRESSED_RGBA_S3TC_DXT3_EXT: 0x83f2,\n COMPRESSED_RGBA_S3TC_DXT5_EXT: 0x83f3,\n\n // WEBGL_compressed_texture_pvrtc\n COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 0x8c00,\n COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 0x8c01,\n COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 0x8c02,\n COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 0x8c03,\n\n // WEBGL_compressed_texture_astc\n COMPRESSED_RGBA_ASTC_4x4_WEBGL: 0x93b0,\n\n // WEBGL_compressed_texture_etc1\n COMPRESSED_RGB_ETC1_WEBGL: 0x8d64,\n\n // EXT_texture_compression_bptc\n COMPRESSED_RGBA_BPTC_UNORM: 0x8e8c,\n\n // EXT_color_buffer_half_float\n HALF_FLOAT_OES: 0x8d61,\n\n // Desktop OpenGL\n DOUBLE: 0x140a,\n\n // WebGL 2\n READ_BUFFER: 0x0c02,\n UNPACK_ROW_LENGTH: 0x0cf2,\n UNPACK_SKIP_ROWS: 0x0cf3,\n UNPACK_SKIP_PIXELS: 0x0cf4,\n PACK_ROW_LENGTH: 0x0d02,\n PACK_SKIP_ROWS: 0x0d03,\n PACK_SKIP_PIXELS: 0x0d04,\n COLOR: 0x1800,\n DEPTH: 0x1801,\n STENCIL: 0x1802,\n RED: 0x1903,\n RGB8: 0x8051,\n RGBA8: 0x8058,\n RGB10_A2: 0x8059,\n TEXTURE_BINDING_3D: 0x806a,\n UNPACK_SKIP_IMAGES: 0x806d,\n UNPACK_IMAGE_HEIGHT: 0x806e,\n TEXTURE_3D: 0x806f,\n TEXTURE_WRAP_R: 0x8072,\n MAX_3D_TEXTURE_SIZE: 0x8073,\n UNSIGNED_INT_2_10_10_10_REV: 0x8368,\n MAX_ELEMENTS_VERTICES: 0x80e8,\n MAX_ELEMENTS_INDICES: 0x80e9,\n TEXTURE_MIN_LOD: 0x813a,\n TEXTURE_MAX_LOD: 0x813b,\n TEXTURE_BASE_LEVEL: 0x813c,\n TEXTURE_MAX_LEVEL: 0x813d,\n MIN: 0x8007,\n MAX: 0x8008,\n DEPTH_COMPONENT24: 0x81a6,\n MAX_TEXTURE_LOD_BIAS: 0x84fd,\n TEXTURE_COMPARE_MODE: 0x884c,\n TEXTURE_COMPARE_FUNC: 0x884d,\n CURRENT_QUERY: 0x8865,\n QUERY_RESULT: 0x8866,\n QUERY_RESULT_AVAILABLE: 0x8867,\n STREAM_READ: 0x88e1,\n STREAM_COPY: 0x88e2,\n STATIC_READ: 0x88e5,\n STATIC_COPY: 0x88e6,\n DYNAMIC_READ: 0x88e9,\n DYNAMIC_COPY: 0x88ea,\n MAX_DRAW_BUFFERS: 0x8824,\n DRAW_BUFFER0: 0x8825,\n DRAW_BUFFER1: 0x8826,\n DRAW_BUFFER2: 0x8827,\n DRAW_BUFFER3: 0x8828,\n DRAW_BUFFER4: 0x8829,\n DRAW_BUFFER5: 0x882a,\n DRAW_BUFFER6: 0x882b,\n DRAW_BUFFER7: 0x882c,\n DRAW_BUFFER8: 0x882d,\n DRAW_BUFFER9: 0x882e,\n DRAW_BUFFER10: 0x882f,\n DRAW_BUFFER11: 0x8830,\n DRAW_BUFFER12: 0x8831,\n DRAW_BUFFER13: 0x8832,\n DRAW_BUFFER14: 0x8833,\n DRAW_BUFFER15: 0x8834,\n MAX_FRAGMENT_UNIFORM_COMPONENTS: 0x8b49,\n MAX_VERTEX_UNIFORM_COMPONENTS: 0x8b4a,\n SAMPLER_3D: 0x8b5f,\n SAMPLER_2D_SHADOW: 0x8b62,\n FRAGMENT_SHADER_DERIVATIVE_HINT: 0x8b8b,\n PIXEL_PACK_BUFFER: 0x88eb,\n PIXEL_UNPACK_BUFFER: 0x88ec,\n PIXEL_PACK_BUFFER_BINDING: 0x88ed,\n PIXEL_UNPACK_BUFFER_BINDING: 0x88ef,\n FLOAT_MAT2x3: 0x8b65,\n FLOAT_MAT2x4: 0x8b66,\n FLOAT_MAT3x2: 0x8b67,\n FLOAT_MAT3x4: 0x8b68,\n FLOAT_MAT4x2: 0x8b69,\n FLOAT_MAT4x3: 0x8b6a,\n SRGB: 0x8c40,\n SRGB8: 0x8c41,\n SRGB8_ALPHA8: 0x8c43,\n COMPARE_REF_TO_TEXTURE: 0x884e,\n RGBA32F: 0x8814,\n RGB32F: 0x8815,\n RGBA16F: 0x881a,\n RGB16F: 0x881b,\n VERTEX_ATTRIB_ARRAY_INTEGER: 0x88fd,\n MAX_ARRAY_TEXTURE_LAYERS: 0x88ff,\n MIN_PROGRAM_TEXEL_OFFSET: 0x8904,\n MAX_PROGRAM_TEXEL_OFFSET: 0x8905,\n MAX_VARYING_COMPONENTS: 0x8b4b,\n TEXTURE_2D_ARRAY: 0x8c1a,\n TEXTURE_BINDING_2D_ARRAY: 0x8c1d,\n R11F_G11F_B10F: 0x8c3a,\n UNSIGNED_INT_10F_11F_11F_REV: 0x8c3b,\n RGB9_E5: 0x8c3d,\n UNSIGNED_INT_5_9_9_9_REV: 0x8c3e,\n TRANSFORM_FEEDBACK_BUFFER_MODE: 0x8c7f,\n MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 0x8c80,\n TRANSFORM_FEEDBACK_VARYINGS: 0x8c83,\n TRANSFORM_FEEDBACK_BUFFER_START: 0x8c84,\n TRANSFORM_FEEDBACK_BUFFER_SIZE: 0x8c85,\n TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 0x8c88,\n RASTERIZER_DISCARD: 0x8c89,\n MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 0x8c8a,\n MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 0x8c8b,\n INTERLEAVED_ATTRIBS: 0x8c8c,\n SEPARATE_ATTRIBS: 0x8c8d,\n TRANSFORM_FEEDBACK_BUFFER: 0x8c8e,\n TRANSFORM_FEEDBACK_BUFFER_BINDING: 0x8c8f,\n RGBA32UI: 0x8d70,\n RGB32UI: 0x8d71,\n RGBA16UI: 0x8d76,\n RGB16UI: 0x8d77,\n RGBA8UI: 0x8d7c,\n RGB8UI: 0x8d7d,\n RGBA32I: 0x8d82,\n RGB32I: 0x8d83,\n RGBA16I: 0x8d88,\n RGB16I: 0x8d89,\n RGBA8I: 0x8d8e,\n RGB8I: 0x8d8f,\n RED_INTEGER: 0x8d94,\n RGB_INTEGER: 0x8d98,\n RGBA_INTEGER: 0x8d99,\n SAMPLER_2D_ARRAY: 0x8dc1,\n SAMPLER_2D_ARRAY_SHADOW: 0x8dc4,\n SAMPLER_CUBE_SHADOW: 0x8dc5,\n UNSIGNED_INT_VEC2: 0x8dc6,\n UNSIGNED_INT_VEC3: 0x8dc7,\n UNSIGNED_INT_VEC4: 0x8dc8,\n INT_SAMPLER_2D: 0x8dca,\n INT_SAMPLER_3D: 0x8dcb,\n INT_SAMPLER_CUBE: 0x8dcc,\n INT_SAMPLER_2D_ARRAY: 0x8dcf,\n UNSIGNED_INT_SAMPLER_2D: 0x8dd2,\n UNSIGNED_INT_SAMPLER_3D: 0x8dd3,\n UNSIGNED_INT_SAMPLER_CUBE: 0x8dd4,\n UNSIGNED_INT_SAMPLER_2D_ARRAY: 0x8dd7,\n DEPTH_COMPONENT32F: 0x8cac,\n DEPTH32F_STENCIL8: 0x8cad,\n FLOAT_32_UNSIGNED_INT_24_8_REV: 0x8dad,\n FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 0x8210,\n FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 0x8211,\n FRAMEBUFFER_ATTACHMENT_RED_SIZE: 0x8212,\n FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 0x8213,\n FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 0x8214,\n FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 0x8215,\n FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 0x8216,\n FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 0x8217,\n FRAMEBUFFER_DEFAULT: 0x8218,\n UNSIGNED_INT_24_8: 0x84fa,\n DEPTH24_STENCIL8: 0x88f0,\n UNSIGNED_NORMALIZED: 0x8c17,\n DRAW_FRAMEBUFFER_BINDING: 0x8ca6, // Same as FRAMEBUFFER_BINDING\n READ_FRAMEBUFFER: 0x8ca8,\n DRAW_FRAMEBUFFER: 0x8ca9,\n READ_FRAMEBUFFER_BINDING: 0x8caa,\n RENDERBUFFER_SAMPLES: 0x8cab,\n FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 0x8cd4,\n MAX_COLOR_ATTACHMENTS: 0x8cdf,\n COLOR_ATTACHMENT1: 0x8ce1,\n COLOR_ATTACHMENT2: 0x8ce2,\n COLOR_ATTACHMENT3: 0x8ce3,\n COLOR_ATTACHMENT4: 0x8ce4,\n COLOR_ATTACHMENT5: 0x8ce5,\n COLOR_ATTACHMENT6: 0x8ce6,\n COLOR_ATTACHMENT7: 0x8ce7,\n COLOR_ATTACHMENT8: 0x8ce8,\n COLOR_ATTACHMENT9: 0x8ce9,\n COLOR_ATTACHMENT10: 0x8cea,\n COLOR_ATTACHMENT11: 0x8ceb,\n COLOR_ATTACHMENT12: 0x8cec,\n COLOR_ATTACHMENT13: 0x8ced,\n COLOR_ATTACHMENT14: 0x8cee,\n COLOR_ATTACHMENT15: 0x8cef,\n FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 0x8d56,\n MAX_SAMPLES: 0x8d57,\n HALF_FLOAT: 0x140b,\n RG: 0x8227,\n RG_INTEGER: 0x8228,\n R8: 0x8229,\n RG8: 0x822b,\n R16F: 0x822d,\n R32F: 0x822e,\n RG16F: 0x822f,\n RG32F: 0x8230,\n R8I: 0x8231,\n R8UI: 0x8232,\n R16I: 0x8233,\n R16UI: 0x8234,\n R32I: 0x8235,\n R32UI: 0x8236,\n RG8I: 0x8237,\n RG8UI: 0x8238,\n RG16I: 0x8239,\n RG16UI: 0x823a,\n RG32I: 0x823b,\n RG32UI: 0x823c,\n VERTEX_ARRAY_BINDING: 0x85b5,\n R8_SNORM: 0x8f94,\n RG8_SNORM: 0x8f95,\n RGB8_SNORM: 0x8f96,\n RGBA8_SNORM: 0x8f97,\n SIGNED_NORMALIZED: 0x8f9c,\n COPY_READ_BUFFER: 0x8f36,\n COPY_WRITE_BUFFER: 0x8f37,\n COPY_READ_BUFFER_BINDING: 0x8f36, // Same as COPY_READ_BUFFER\n COPY_WRITE_BUFFER_BINDING: 0x8f37, // Same as COPY_WRITE_BUFFER\n UNIFORM_BUFFER: 0x8a11,\n UNIFORM_BUFFER_BINDING: 0x8a28,\n UNIFORM_BUFFER_START: 0x8a29,\n UNIFORM_BUFFER_SIZE: 0x8a2a,\n MAX_VERTEX_UNIFORM_BLOCKS: 0x8a2b,\n MAX_FRAGMENT_UNIFORM_BLOCKS: 0x8a2d,\n MAX_COMBINED_UNIFORM_BLOCKS: 0x8a2e,\n MAX_UNIFORM_BUFFER_BINDINGS: 0x8a2f,\n MAX_UNIFORM_BLOCK_SIZE: 0x8a30,\n MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 0x8a31,\n MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 0x8a33,\n UNIFORM_BUFFER_OFFSET_ALIGNMENT: 0x8a34,\n ACTIVE_UNIFORM_BLOCKS: 0x8a36,\n UNIFORM_TYPE: 0x8a37,\n UNIFORM_SIZE: 0x8a38,\n UNIFORM_BLOCK_INDEX: 0x8a3a,\n UNIFORM_OFFSET: 0x8a3b,\n UNIFORM_ARRAY_STRIDE: 0x8a3c,\n UNIFORM_MATRIX_STRIDE: 0x8a3d,\n UNIFORM_IS_ROW_MAJOR: 0x8a3e,\n UNIFORM_BLOCK_BINDING: 0x8a3f,\n UNIFORM_BLOCK_DATA_SIZE: 0x8a40,\n UNIFORM_BLOCK_ACTIVE_UNIFORMS: 0x8a42,\n UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 0x8a43,\n UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 0x8a44,\n UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 0x8a46,\n INVALID_INDEX: 0xffffffff,\n MAX_VERTEX_OUTPUT_COMPONENTS: 0x9122,\n MAX_FRAGMENT_INPUT_COMPONENTS: 0x9125,\n MAX_SERVER_WAIT_TIMEOUT: 0x9111,\n OBJECT_TYPE: 0x9112,\n SYNC_CONDITION: 0x9113,\n SYNC_STATUS: 0x9114,\n SYNC_FLAGS: 0x9115,\n SYNC_FENCE: 0x9116,\n SYNC_GPU_COMMANDS_COMPLETE: 0x9117,\n UNSIGNALED: 0x9118,\n SIGNALED: 0x9119,\n ALREADY_SIGNALED: 0x911a,\n TIMEOUT_EXPIRED: 0x911b,\n CONDITION_SATISFIED: 0x911c,\n WAIT_FAILED: 0x911d,\n SYNC_FLUSH_COMMANDS_BIT: 0x00000001,\n VERTEX_ATTRIB_ARRAY_DIVISOR: 0x88fe,\n ANY_SAMPLES_PASSED: 0x8c2f,\n ANY_SAMPLES_PASSED_CONSERVATIVE: 0x8d6a,\n SAMPLER_BINDING: 0x8919,\n RGB10_A2UI: 0x906f,\n INT_2_10_10_10_REV: 0x8d9f,\n TRANSFORM_FEEDBACK: 0x8e22,\n TRANSFORM_FEEDBACK_PAUSED: 0x8e23,\n TRANSFORM_FEEDBACK_ACTIVE: 0x8e24,\n TRANSFORM_FEEDBACK_BINDING: 0x8e25,\n COMPRESSED_R11_EAC: 0x9270,\n COMPRESSED_SIGNED_R11_EAC: 0x9271,\n COMPRESSED_RG11_EAC: 0x9272,\n COMPRESSED_SIGNED_RG11_EAC: 0x9273,\n COMPRESSED_RGB8_ETC2: 0x9274,\n COMPRESSED_SRGB8_ETC2: 0x9275,\n COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 0x9276,\n COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 0x9277,\n COMPRESSED_RGBA8_ETC2_EAC: 0x9278,\n COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 0x9279,\n TEXTURE_IMMUTABLE_FORMAT: 0x912f,\n MAX_ELEMENT_INDEX: 0x8d6b,\n TEXTURE_IMMUTABLE_LEVELS: 0x82df,\n\n // Extensions\n MAX_TEXTURE_MAX_ANISOTROPY_EXT: 0x84ff,\n};\nexport default Object.freeze(WebGLConstants);\n", "import Cartesian3 from \"../Core/Cartesian3.js\";\nimport Matrix4 from \"../Core/Matrix4.js\";\nimport WebGLConstants from \"../Core/WebGLConstants.js\";\n\nconst viewerPositionWCScratch = new Cartesian3();\n\nfunction AutomaticUniform(options) {\n this._size = options.size;\n this._datatype = options.datatype;\n this.getValue = options.getValue;\n}\n\nconst datatypeToGlsl = {};\ndatatypeToGlsl[WebGLConstants.FLOAT] = \"float\";\ndatatypeToGlsl[WebGLConstants.FLOAT_VEC2] = \"vec2\";\ndatatypeToGlsl[WebGLConstants.FLOAT_VEC3] = \"vec3\";\ndatatypeToGlsl[WebGLConstants.FLOAT_VEC4] = \"vec4\";\ndatatypeToGlsl[WebGLConstants.INT] = \"int\";\ndatatypeToGlsl[WebGLConstants.INT_VEC2] = \"ivec2\";\ndatatypeToGlsl[WebGLConstants.INT_VEC3] = \"ivec3\";\ndatatypeToGlsl[WebGLConstants.INT_VEC4] = \"ivec4\";\ndatatypeToGlsl[WebGLConstants.BOOL] = \"bool\";\ndatatypeToGlsl[WebGLConstants.BOOL_VEC2] = \"bvec2\";\ndatatypeToGlsl[WebGLConstants.BOOL_VEC3] = \"bvec3\";\ndatatypeToGlsl[WebGLConstants.BOOL_VEC4] = \"bvec4\";\ndatatypeToGlsl[WebGLConstants.FLOAT_MAT2] = \"mat2\";\ndatatypeToGlsl[WebGLConstants.FLOAT_MAT3] = \"mat3\";\ndatatypeToGlsl[WebGLConstants.FLOAT_MAT4] = \"mat4\";\ndatatypeToGlsl[WebGLConstants.SAMPLER_2D] = \"sampler2D\";\ndatatypeToGlsl[WebGLConstants.SAMPLER_CUBE] = \"samplerCube\";\n\nAutomaticUniform.prototype.getDeclaration = function (name) {\n let declaration = `uniform ${datatypeToGlsl[this._datatype]} ${name}`;\n\n const size = this._size;\n if (size === 1) {\n declaration += \";\";\n } else {\n declaration += `[${size.toString()}];`;\n }\n\n return declaration;\n};\n\n/**\n * @private\n */\nconst AutomaticUniforms = {\n /**\n * An automatic GLSL uniform containing the viewport's x, y, width,\n * and height properties in an vec4's x, y, z,\n * and w components, respectively.\n *\n * @example\n * // GLSL declaration\n * uniform vec4 czm_viewport;\n *\n * // Scale the window coordinate components to [0, 1] by dividing\n * // by the viewport's width and height.\n * vec2 v = gl_FragCoord.xy / czm_viewport.zw;\n *\n * @see Context#getViewport\n */\n czm_viewport: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC4,\n getValue: function (uniformState) {\n return uniformState.viewportCartesian4;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 orthographic projection matrix that\n * transforms window coordinates to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *
\n * This transform is useful when a vertex shader inputs or manipulates window coordinates\n * as done by {@link BillboardCollection}.\n *
\n * Do not confuse {@link czm_viewportTransformation} with czm_viewportOrthographic.\n * The former transforms from normalized device coordinates to window coordinates; the later transforms\n * from window coordinates to clip coordinates, and is often used to assign to gl_Position.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_viewportOrthographic;\n *\n * // Example\n * gl_Position = czm_viewportOrthographic * vec4(windowPosition, 0.0, 1.0);\n *\n * @see UniformState#viewportOrthographic\n * @see czm_viewport\n * @see czm_viewportTransformation\n * @see BillboardCollection\n */\n czm_viewportOrthographic: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.viewportOrthographic;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 transformation matrix that\n * transforms normalized device coordinates to window coordinates. The context's\n * full viewport is used, and the depth range is assumed to be near = 0\n * and far = 1.\n *
\n * This transform is useful when there is a need to manipulate window coordinates\n * in a vertex shader as done by {@link BillboardCollection}. In many cases,\n * this matrix will not be used directly; instead, {@link czm_modelToWindowCoordinates}\n * will be used to transform directly from model to window coordinates.\n *
\n * Do not confuse czm_viewportTransformation with {@link czm_viewportOrthographic}.\n * The former transforms from normalized device coordinates to window coordinates; the later transforms\n * from window coordinates to clip coordinates, and is often used to assign to gl_Position.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_viewportTransformation;\n *\n * // Use czm_viewportTransformation as part of the\n * // transform from model to window coordinates.\n * vec4 q = czm_modelViewProjection * positionMC; // model to clip coordinates\n * q.xyz /= q.w; // clip to normalized device coordinates (ndc)\n * q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // ndc to window coordinates\n *\n * @see UniformState#viewportTransformation\n * @see czm_viewport\n * @see czm_viewportOrthographic\n * @see czm_modelToWindowCoordinates\n * @see BillboardCollection\n */\n czm_viewportTransformation: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.viewportTransformation;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the depth of the scene\n * after the globe pass and then updated after the 3D Tiles pass.\n * The depth is packed into an RGBA texture.\n *\n * @example\n * // GLSL declaration\n * uniform sampler2D czm_globeDepthTexture;\n *\n * // Get the depth at the current fragment\n * vec2 coords = gl_FragCoord.xy / czm_viewport.zw;\n * float depth = czm_unpackDepth(texture(czm_globeDepthTexture, coords));\n */\n czm_globeDepthTexture: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.SAMPLER_2D,\n getValue: function (uniformState) {\n return uniformState.globeDepthTexture;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model transformation matrix that\n * transforms model coordinates to world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_model;\n *\n * // Example\n * vec4 worldPosition = czm_model * modelPosition;\n *\n * @see UniformState#model\n * @see czm_inverseModel\n * @see czm_modelView\n * @see czm_modelViewProjection\n */\n czm_model: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.model;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model transformation matrix that\n * transforms world coordinates to model coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseModel;\n *\n * // Example\n * vec4 modelPosition = czm_inverseModel * worldPosition;\n *\n * @see UniformState#inverseModel\n * @see czm_model\n * @see czm_inverseModelView\n */\n czm_inverseModel: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseModel;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 view transformation matrix that\n * transforms world coordinates to eye coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_view;\n *\n * // Example\n * vec4 eyePosition = czm_view * worldPosition;\n *\n * @see UniformState#view\n * @see czm_viewRotation\n * @see czm_modelView\n * @see czm_viewProjection\n * @see czm_modelViewProjection\n * @see czm_inverseView\n */\n czm_view: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.view;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 view transformation matrix that\n * transforms 3D world coordinates to eye coordinates. In 3D mode, this is identical to\n * {@link czm_view}, but in 2D and Columbus View it represents the view matrix\n * as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_view3D;\n *\n * // Example\n * vec4 eyePosition3D = czm_view3D * worldPosition3D;\n *\n * @see UniformState#view3D\n * @see czm_view\n */\n czm_view3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.view3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 view rotation matrix that\n * transforms vectors in world coordinates to eye coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_viewRotation;\n *\n * // Example\n * vec3 eyeVector = czm_viewRotation * worldVector;\n *\n * @see UniformState#viewRotation\n * @see czm_view\n * @see czm_inverseView\n * @see czm_inverseViewRotation\n */\n czm_viewRotation: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.viewRotation;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 view rotation matrix that\n * transforms vectors in 3D world coordinates to eye coordinates. In 3D mode, this is identical to\n * {@link czm_viewRotation}, but in 2D and Columbus View it represents the view matrix\n * as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_viewRotation3D;\n *\n * // Example\n * vec3 eyeVector = czm_viewRotation3D * worldVector;\n *\n * @see UniformState#viewRotation3D\n * @see czm_viewRotation\n */\n czm_viewRotation3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.viewRotation3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 transformation matrix that\n * transforms from eye coordinates to world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseView;\n *\n * // Example\n * vec4 worldPosition = czm_inverseView * eyePosition;\n *\n * @see UniformState#inverseView\n * @see czm_view\n * @see czm_inverseNormal\n */\n czm_inverseView: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseView;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 transformation matrix that\n * transforms from 3D eye coordinates to world coordinates. In 3D mode, this is identical to\n * {@link czm_inverseView}, but in 2D and Columbus View it represents the inverse view matrix\n * as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseView3D;\n *\n * // Example\n * vec4 worldPosition = czm_inverseView3D * eyePosition;\n *\n * @see UniformState#inverseView3D\n * @see czm_inverseView\n */\n czm_inverseView3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseView3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 rotation matrix that\n * transforms vectors from eye coordinates to world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_inverseViewRotation;\n *\n * // Example\n * vec4 worldVector = czm_inverseViewRotation * eyeVector;\n *\n * @see UniformState#inverseView\n * @see czm_view\n * @see czm_viewRotation\n * @see czm_inverseViewRotation\n */\n czm_inverseViewRotation: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.inverseViewRotation;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 rotation matrix that\n * transforms vectors from 3D eye coordinates to world coordinates. In 3D mode, this is identical to\n * {@link czm_inverseViewRotation}, but in 2D and Columbus View it represents the inverse view matrix\n * as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_inverseViewRotation3D;\n *\n * // Example\n * vec4 worldVector = czm_inverseViewRotation3D * eyeVector;\n *\n * @see UniformState#inverseView3D\n * @see czm_inverseViewRotation\n */\n czm_inverseViewRotation3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.inverseViewRotation3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 projection transformation matrix that\n * transforms eye coordinates to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_projection;\n *\n * // Example\n * gl_Position = czm_projection * eyePosition;\n *\n * @see UniformState#projection\n * @see czm_viewProjection\n * @see czm_modelViewProjection\n * @see czm_infiniteProjection\n */\n czm_projection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.projection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 inverse projection transformation matrix that\n * transforms from clip coordinates to eye coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseProjection;\n *\n * // Example\n * vec4 eyePosition = czm_inverseProjection * clipPosition;\n *\n * @see UniformState#inverseProjection\n * @see czm_projection\n */\n czm_inverseProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 projection transformation matrix with the far plane at infinity,\n * that transforms eye coordinates to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output. An infinite far plane is used\n * in algorithms like shadow volumes and GPU ray casting with proxy geometry to ensure that triangles\n * are not clipped by the far plane.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_infiniteProjection;\n *\n * // Example\n * gl_Position = czm_infiniteProjection * eyePosition;\n *\n * @see UniformState#infiniteProjection\n * @see czm_projection\n * @see czm_modelViewInfiniteProjection\n */\n czm_infiniteProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.infiniteProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model-view transformation matrix that\n * transforms model coordinates to eye coordinates.\n *
\n * Positions should be transformed to eye coordinates using czm_modelView and\n * normals should be transformed using {@link czm_normal}.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_modelView;\n *\n * // Example\n * vec4 eyePosition = czm_modelView * modelPosition;\n *\n * // The above is equivalent to, but more efficient than:\n * vec4 eyePosition = czm_view * czm_model * modelPosition;\n *\n * @see UniformState#modelView\n * @see czm_model\n * @see czm_view\n * @see czm_modelViewProjection\n * @see czm_normal\n */\n czm_modelView: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.modelView;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model-view transformation matrix that\n * transforms 3D model coordinates to eye coordinates. In 3D mode, this is identical to\n * {@link czm_modelView}, but in 2D and Columbus View it represents the model-view matrix\n * as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *
\n * Positions should be transformed to eye coordinates using czm_modelView3D and\n * normals should be transformed using {@link czm_normal3D}.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_modelView3D;\n *\n * // Example\n * vec4 eyePosition = czm_modelView3D * modelPosition;\n *\n * // The above is equivalent to, but more efficient than:\n * vec4 eyePosition = czm_view3D * czm_model * modelPosition;\n *\n * @see UniformState#modelView3D\n * @see czm_modelView\n */\n czm_modelView3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.modelView3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model-view transformation matrix that\n * transforms model coordinates, relative to the eye, to eye coordinates. This is used\n * in conjunction with {@link czm_translateRelativeToEye}.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_modelViewRelativeToEye;\n *\n * // Example\n * attribute vec3 positionHigh;\n * attribute vec3 positionLow;\n *\n * void main()\n * {\n * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n * gl_Position = czm_projection * (czm_modelViewRelativeToEye * p);\n * }\n *\n * @see czm_modelViewProjectionRelativeToEye\n * @see czm_translateRelativeToEye\n * @see EncodedCartesian3\n */\n czm_modelViewRelativeToEye: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.modelViewRelativeToEye;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 transformation matrix that\n * transforms from eye coordinates to model coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseModelView;\n *\n * // Example\n * vec4 modelPosition = czm_inverseModelView * eyePosition;\n *\n * @see UniformState#inverseModelView\n * @see czm_modelView\n */\n czm_inverseModelView: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseModelView;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 transformation matrix that\n * transforms from eye coordinates to 3D model coordinates. In 3D mode, this is identical to\n * {@link czm_inverseModelView}, but in 2D and Columbus View it represents the inverse model-view matrix\n * as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseModelView3D;\n *\n * // Example\n * vec4 modelPosition = czm_inverseModelView3D * eyePosition;\n *\n * @see UniformState#inverseModelView\n * @see czm_inverseModelView\n * @see czm_modelView3D\n */\n czm_inverseModelView3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseModelView3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 view-projection transformation matrix that\n * transforms world coordinates to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_viewProjection;\n *\n * // Example\n * vec4 gl_Position = czm_viewProjection * czm_model * modelPosition;\n *\n * // The above is equivalent to, but more efficient than:\n * gl_Position = czm_projection * czm_view * czm_model * modelPosition;\n *\n * @see UniformState#viewProjection\n * @see czm_view\n * @see czm_projection\n * @see czm_modelViewProjection\n * @see czm_inverseViewProjection\n */\n czm_viewProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.viewProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 view-projection transformation matrix that\n * transforms clip coordinates to world coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseViewProjection;\n *\n * // Example\n * vec4 worldPosition = czm_inverseViewProjection * clipPosition;\n *\n * @see UniformState#inverseViewProjection\n * @see czm_viewProjection\n */\n czm_inverseViewProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseViewProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model-view-projection transformation matrix that\n * transforms model coordinates to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_modelViewProjection;\n *\n * // Example\n * vec4 gl_Position = czm_modelViewProjection * modelPosition;\n *\n * // The above is equivalent to, but more efficient than:\n * gl_Position = czm_projection * czm_view * czm_model * modelPosition;\n *\n * @see UniformState#modelViewProjection\n * @see czm_model\n * @see czm_view\n * @see czm_projection\n * @see czm_modelView\n * @see czm_viewProjection\n * @see czm_modelViewInfiniteProjection\n * @see czm_inverseModelViewProjection\n */\n czm_modelViewProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.modelViewProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 inverse model-view-projection transformation matrix that\n * transforms clip coordinates to model coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_inverseModelViewProjection;\n *\n * // Example\n * vec4 modelPosition = czm_inverseModelViewProjection * clipPosition;\n *\n * @see UniformState#modelViewProjection\n * @see czm_modelViewProjection\n */\n czm_inverseModelViewProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.inverseModelViewProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model-view-projection transformation matrix that\n * transforms model coordinates, relative to the eye, to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output. This is used in\n * conjunction with {@link czm_translateRelativeToEye}.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_modelViewProjectionRelativeToEye;\n *\n * // Example\n * attribute vec3 positionHigh;\n * attribute vec3 positionLow;\n *\n * void main()\n * {\n * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n * gl_Position = czm_modelViewProjectionRelativeToEye * p;\n * }\n *\n * @see czm_modelViewRelativeToEye\n * @see czm_translateRelativeToEye\n * @see EncodedCartesian3\n */\n czm_modelViewProjectionRelativeToEye: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.modelViewProjectionRelativeToEye;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 4x4 model-view-projection transformation matrix that\n * transforms model coordinates to clip coordinates. Clip coordinates is the\n * coordinate system for a vertex shader's gl_Position output. The projection matrix places\n * the far plane at infinity. This is useful in algorithms like shadow volumes and GPU ray casting with\n * proxy geometry to ensure that triangles are not clipped by the far plane.\n *\n * @example\n * // GLSL declaration\n * uniform mat4 czm_modelViewInfiniteProjection;\n *\n * // Example\n * vec4 gl_Position = czm_modelViewInfiniteProjection * modelPosition;\n *\n * // The above is equivalent to, but more efficient than:\n * gl_Position = czm_infiniteProjection * czm_view * czm_model * modelPosition;\n *\n * @see UniformState#modelViewInfiniteProjection\n * @see czm_model\n * @see czm_view\n * @see czm_infiniteProjection\n * @see czm_modelViewProjection\n */\n czm_modelViewInfiniteProjection: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT4,\n getValue: function (uniformState) {\n return uniformState.modelViewInfiniteProjection;\n },\n }),\n\n /**\n * An automatic GLSL uniform that indicates if the current camera is orthographic in 3D.\n *\n * @see UniformState#orthographicIn3D\n */\n czm_orthographicIn3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.orthographicIn3D ? 1 : 0;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 normal transformation matrix that\n * transforms normal vectors in model coordinates to eye coordinates.\n *
\n * Positions should be transformed to eye coordinates using {@link czm_modelView} and\n * normals should be transformed using czm_normal.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_normal;\n *\n * // Example\n * vec3 eyeNormal = czm_normal * normal;\n *\n * @see UniformState#normal\n * @see czm_inverseNormal\n * @see czm_modelView\n */\n czm_normal: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.normal;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 normal transformation matrix that\n * transforms normal vectors in 3D model coordinates to eye coordinates.\n * In 3D mode, this is identical to\n * {@link czm_normal}, but in 2D and Columbus View it represents the normal transformation\n * matrix as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *
\n * Positions should be transformed to eye coordinates using {@link czm_modelView3D} and\n * normals should be transformed using czm_normal3D.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_normal3D;\n *\n * // Example\n * vec3 eyeNormal = czm_normal3D * normal;\n *\n * @see UniformState#normal3D\n * @see czm_normal\n */\n czm_normal3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.normal3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 normal transformation matrix that\n * transforms normal vectors in eye coordinates to model coordinates. This is\n * the opposite of the transform provided by {@link czm_normal}.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_inverseNormal;\n *\n * // Example\n * vec3 normalMC = czm_inverseNormal * normalEC;\n *\n * @see UniformState#inverseNormal\n * @see czm_normal\n * @see czm_modelView\n * @see czm_inverseView\n */\n czm_inverseNormal: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.inverseNormal;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 normal transformation matrix that\n * transforms normal vectors in eye coordinates to 3D model coordinates. This is\n * the opposite of the transform provided by {@link czm_normal}.\n * In 3D mode, this is identical to\n * {@link czm_inverseNormal}, but in 2D and Columbus View it represents the inverse normal transformation\n * matrix as if the camera were at an equivalent location in 3D mode. This is useful for lighting\n * 2D and Columbus View in the same way that 3D is lit.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_inverseNormal3D;\n *\n * // Example\n * vec3 normalMC = czm_inverseNormal3D * normalEC;\n *\n * @see UniformState#inverseNormal3D\n * @see czm_inverseNormal\n */\n czm_inverseNormal3D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.inverseNormal3D;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the height in meters of the\n * eye (camera) above or below the ellipsoid.\n *\n * @see UniformState#eyeHeight\n */\n czm_eyeHeight: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.eyeHeight;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing height (x) and height squared (y)\n * in meters of the eye (camera) above the 2D world plane. This uniform is only valid\n * when the {@link SceneMode} is SCENE2D.\n *\n * @see UniformState#eyeHeight2D\n */\n czm_eyeHeight2D: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC2,\n getValue: function (uniformState) {\n return uniformState.eyeHeight2D;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the near distance (x) and the far distance (y)\n * of the frustum defined by the camera. This is the largest possible frustum, not an individual\n * frustum used for multi-frustum rendering.\n *\n * @example\n * // GLSL declaration\n * uniform vec2 czm_entireFrustum;\n *\n * // Example\n * float frustumLength = czm_entireFrustum.y - czm_entireFrustum.x;\n *\n * @see UniformState#entireFrustum\n * @see czm_currentFrustum\n */\n czm_entireFrustum: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC2,\n getValue: function (uniformState) {\n return uniformState.entireFrustum;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the near distance (x) and the far distance (y)\n * of the frustum defined by the camera. This is the individual\n * frustum used for multi-frustum rendering.\n *\n * @example\n * // GLSL declaration\n * uniform vec2 czm_currentFrustum;\n *\n * // Example\n * float frustumLength = czm_currentFrustum.y - czm_currentFrustum.x;\n *\n * @see UniformState#currentFrustum\n * @see czm_entireFrustum\n */\n czm_currentFrustum: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC2,\n getValue: function (uniformState) {\n return uniformState.currentFrustum;\n },\n }),\n\n /**\n * The distances to the frustum planes. The top, bottom, left and right distances are\n * the x, y, z, and w components, respectively.\n */\n czm_frustumPlanes: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC4,\n getValue: function (uniformState) {\n return uniformState.frustumPlanes;\n },\n }),\n\n /**\n * Gets the far plane's distance from the near plane, plus 1.0.\n */\n czm_farDepthFromNearPlusOne: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.farDepthFromNearPlusOne;\n },\n }),\n\n /**\n * Gets the log2 of {@link AutomaticUniforms#czm_farDepthFromNearPlusOne}.\n */\n czm_log2FarDepthFromNearPlusOne: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.log2FarDepthFromNearPlusOne;\n },\n }),\n\n /**\n * Gets 1.0 divided by {@link AutomaticUniforms#czm_log2FarDepthFromNearPlusOne}.\n */\n czm_oneOverLog2FarDepthFromNearPlusOne: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.oneOverLog2FarDepthFromNearPlusOne;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the sun position in world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_sunPositionWC;\n *\n * @see UniformState#sunPositionWC\n * @see czm_sunPositionColumbusView\n * @see czm_sunDirectionWC\n */\n czm_sunPositionWC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.sunPositionWC;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the sun position in Columbus view world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_sunPositionColumbusView;\n *\n * @see UniformState#sunPositionColumbusView\n * @see czm_sunPositionWC\n */\n czm_sunPositionColumbusView: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.sunPositionColumbusView;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the normalized direction to the sun in eye coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_sunDirectionEC;\n *\n * // Example\n * float diffuse = max(dot(czm_sunDirectionEC, normalEC), 0.0);\n *\n * @see UniformState#sunDirectionEC\n * @see czm_moonDirectionEC\n * @see czm_sunDirectionWC\n */\n czm_sunDirectionEC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.sunDirectionEC;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the normalized direction to the sun in world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_sunDirectionWC;\n *\n * // Example\n * float diffuse = max(dot(czm_sunDirectionWC, normalWC), 0.0);\n *\n * @see UniformState#sunDirectionWC\n * @see czm_sunPositionWC\n * @see czm_sunDirectionEC\n */\n czm_sunDirectionWC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.sunDirectionWC;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the normalized direction to the moon in eye coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_moonDirectionEC;\n *\n * // Example\n * float diffuse = max(dot(czm_moonDirectionEC, normalEC), 0.0);\n *\n * @see UniformState#moonDirectionEC\n * @see czm_sunDirectionEC\n */\n czm_moonDirectionEC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.moonDirectionEC;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the normalized direction to the scene's light source in eye coordinates.\n * This is commonly used for directional lighting computations.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_lightDirectionEC;\n *\n * // Example\n * float diffuse = max(dot(czm_lightDirectionEC, normalEC), 0.0);\n *\n * @see UniformState#lightDirectionEC\n * @see czm_lightDirectionWC\n */\n czm_lightDirectionEC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.lightDirectionEC;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the normalized direction to the scene's light source in world coordinates.\n * This is commonly used for directional lighting computations.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_lightDirectionWC;\n *\n * // Example\n * float diffuse = max(dot(czm_lightDirectionWC, normalWC), 0.0);\n *\n * @see UniformState#lightDirectionWC\n * @see czm_lightDirectionEC\n */\n czm_lightDirectionWC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.lightDirectionWC;\n },\n }),\n\n /**\n * An automatic GLSL uniform that represents the color of light emitted by the scene's light source. This\n * is equivalent to the light color multiplied by the light intensity limited to a maximum luminance of 1.0\n * suitable for non-HDR lighting.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_lightColor;\n *\n * // Example\n * vec3 diffuseColor = czm_lightColor * max(dot(czm_lightDirectionWC, normalWC), 0.0);\n *\n * @see UniformState#lightColor\n * @see czm_lightColorHdr\n */\n czm_lightColor: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.lightColor;\n },\n }),\n\n /**\n * An automatic GLSL uniform that represents the high dynamic range color of light emitted by the scene's light\n * source. This is equivalent to the light color multiplied by the light intensity suitable for HDR lighting.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_lightColorHdr;\n *\n * // Example\n * vec3 diffuseColor = czm_lightColorHdr * max(dot(czm_lightDirectionWC, normalWC), 0.0);\n *\n * @see UniformState#lightColorHdr\n * @see czm_lightColor\n */\n czm_lightColorHdr: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.lightColorHdr;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the high bits of the camera position in model\n * coordinates. This is used for GPU RTE to eliminate jittering artifacts when rendering\n * as described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_encodedCameraPositionMCHigh;\n *\n * @see czm_encodedCameraPositionMCLow\n * @see czm_modelViewRelativeToEye\n * @see czm_modelViewProjectionRelativeToEye\n */\n czm_encodedCameraPositionMCHigh: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.encodedCameraPositionMCHigh;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the low bits of the camera position in model\n * coordinates. This is used for GPU RTE to eliminate jittering artifacts when rendering\n * as described in {@linkhttp://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_encodedCameraPositionMCLow;\n *\n * @see czm_encodedCameraPositionMCHigh\n * @see czm_modelViewRelativeToEye\n * @see czm_modelViewProjectionRelativeToEye\n */\n czm_encodedCameraPositionMCLow: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.encodedCameraPositionMCLow;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the position of the viewer (camera) in world coordinates.\n *\n * @example\n * // GLSL declaration\n * uniform vec3 czm_viewerPositionWC;\n */\n czm_viewerPositionWC: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return Matrix4.getTranslation(\n uniformState.inverseView,\n viewerPositionWCScratch\n );\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the frame number. This uniform is automatically incremented\n * every frame.\n *\n * @example\n * // GLSL declaration\n * uniform float czm_frameNumber;\n */\n czm_frameNumber: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.frameState.frameNumber;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the current morph transition time between\n * 2D/Columbus View and 3D, with 0.0 being 2D or Columbus View and 1.0 being 3D.\n *\n * @example\n * // GLSL declaration\n * uniform float czm_morphTime;\n *\n * // Example\n * vec4 p = czm_columbusViewMorph(position2D, position3D, czm_morphTime);\n */\n czm_morphTime: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.frameState.morphTime;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the current {@link SceneMode}, expressed\n * as a float.\n *\n * @example\n * // GLSL declaration\n * uniform float czm_sceneMode;\n *\n * // Example\n * if (czm_sceneMode == czm_sceneMode2D)\n * {\n * eyeHeightSq = czm_eyeHeight2D.y;\n * }\n *\n * @see czm_sceneMode2D\n * @see czm_sceneModeColumbusView\n * @see czm_sceneMode3D\n * @see czm_sceneModeMorphing\n */\n czm_sceneMode: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.frameState.mode;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the current rendering pass.\n *\n * @example\n * // GLSL declaration\n * uniform float czm_pass;\n *\n * // Example\n * if ((czm_pass == czm_passTranslucent) && isOpaque())\n * {\n * gl_Position *= 0.0; // Cull opaque geometry in the translucent pass\n * }\n */\n czm_pass: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.pass;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the current scene background color.\n *\n * @example\n * // GLSL declaration\n * uniform vec4 czm_backgroundColor;\n *\n * // Example: If the given color's RGB matches the background color, invert it.\n * vec4 adjustColorForContrast(vec4 color)\n * {\n * if (czm_backgroundColor.rgb == color.rgb)\n * {\n * color.rgb = vec3(1.0) - color.rgb;\n * }\n *\n * return color;\n * }\n */\n czm_backgroundColor: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC4,\n getValue: function (uniformState) {\n return uniformState.backgroundColor;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the BRDF look up texture used for image-based lighting computations.\n *\n * @example\n * // GLSL declaration\n * uniform sampler2D czm_brdfLut;\n *\n * // Example: For a given roughness and NdotV value, find the material's BRDF information in the red and green channels\n * float roughness = 0.5;\n * float NdotV = dot(normal, view);\n * vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, 1.0 - roughness)).rg;\n */\n czm_brdfLut: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.SAMPLER_2D,\n getValue: function (uniformState) {\n return uniformState.brdfLut;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the environment map used within the scene.\n *\n * @example\n * // GLSL declaration\n * uniform samplerCube czm_environmentMap;\n *\n * // Example: Create a perfect reflection of the environment map on a model\n * float reflected = reflect(view, normal);\n * vec4 reflectedColor = texture(czm_environmentMap, reflected);\n */\n czm_environmentMap: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.SAMPLER_CUBE,\n getValue: function (uniformState) {\n return uniformState.environmentMap;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the specular environment map atlas used within the scene.\n *\n * @example\n * // GLSL declaration\n * uniform sampler2D czm_specularEnvironmentMaps;\n */\n czm_specularEnvironmentMaps: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.SAMPLER_2D,\n getValue: function (uniformState) {\n return uniformState.specularEnvironmentMaps;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the size of the specular environment map atlas used within the scene.\n *\n * @example\n * // GLSL declaration\n * uniform vec2 czm_specularEnvironmentMapSize;\n */\n czm_specularEnvironmentMapSize: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC2,\n getValue: function (uniformState) {\n return uniformState.specularEnvironmentMapsDimensions;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the maximum level-of-detail of the specular environment map atlas used within the scene.\n *\n * @example\n * // GLSL declaration\n * uniform float czm_specularEnvironmentMapsMaximumLOD;\n */\n czm_specularEnvironmentMapsMaximumLOD: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.specularEnvironmentMapsMaximumLOD;\n },\n }),\n\n /**\n * An automatic GLSL uniform containing the spherical harmonic coefficients used within the scene.\n *\n * @example\n * // GLSL declaration\n * uniform vec3[9] czm_sphericalHarmonicCoefficients;\n */\n czm_sphericalHarmonicCoefficients: new AutomaticUniform({\n size: 9,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.sphericalHarmonicCoefficients;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing a 3x3 rotation matrix that transforms\n * from True Equator Mean Equinox (TEME) axes to the pseudo-fixed axes at the current scene time.\n *\n * @example\n * // GLSL declaration\n * uniform mat3 czm_temeToPseudoFixed;\n *\n * // Example\n * vec3 pseudoFixed = czm_temeToPseudoFixed * teme;\n *\n * @see UniformState#temeToPseudoFixedMatrix\n * @see Transforms.computeTemeToPseudoFixedMatrix\n */\n czm_temeToPseudoFixed: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_MAT3,\n getValue: function (uniformState) {\n return uniformState.temeToPseudoFixedMatrix;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the ratio of canvas coordinate space to canvas pixel space.\n *\n * @example\n * uniform float czm_pixelRatio;\n */\n czm_pixelRatio: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.pixelRatio;\n },\n }),\n\n /**\n * An automatic GLSL uniform scalar used to mix a color with the fog color based on the distance to the camera.\n *\n * @see czm_fog\n */\n czm_fogDensity: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.fogDensity;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the splitter position to use when rendering with a splitter.\n * This will be in pixel coordinates relative to the canvas.\n *\n * @example\n * // GLSL declaration\n * uniform float czm_splitPosition;\n */\n czm_splitPosition: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.splitPosition;\n },\n }),\n\n /**\n * An automatic GLSL uniform scalar representing the geometric tolerance per meter\n */\n czm_geometricToleranceOverMeter: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.geometricToleranceOverMeter;\n },\n }),\n\n /**\n * An automatic GLSL uniform representing the distance from the camera at which to disable the depth test of billboards, labels and points\n * to, for example, prevent clipping against terrain. When set to zero, the depth test should always be applied. When less than zero,\n * the depth test should never be applied.\n */\n czm_minimumDisableDepthTestDistance: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.minimumDisableDepthTestDistance;\n },\n }),\n\n /**\n * An automatic GLSL uniform that will be the highlight color of unclassified 3D Tiles.\n */\n czm_invertClassificationColor: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC4,\n getValue: function (uniformState) {\n return uniformState.invertClassificationColor;\n },\n }),\n\n /**\n * An automatic GLSL uniform that is used for gamma correction.\n */\n czm_gamma: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT,\n getValue: function (uniformState) {\n return uniformState.gamma;\n },\n }),\n\n /**\n * An automatic GLSL uniform that stores the ellipsoid radii.\n */\n czm_ellipsoidRadii: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.ellipsoid.radii;\n },\n }),\n\n /**\n * An automatic GLSL uniform that stores the ellipsoid inverse radii.\n */\n czm_ellipsoidInverseRadii: new AutomaticUniform({\n size: 1,\n datatype: WebGLConstants.FLOAT_VEC3,\n getValue: function (uniformState) {\n return uniformState.ellipsoid.oneOverRadii;\n },\n }),\n};\nexport default AutomaticUniforms;\n", "/**\n * Creates a Globally unique identifier (GUID) string. A GUID is 128 bits long, and can guarantee uniqueness across space and time.\n *\n * @function\n *\n * @returns {string}\n *\n *\n * @example\n * this.guid = Cesium.createGuid();\n *\n * @see {@link http://www.ietf.org/rfc/rfc4122.txt|RFC 4122 A Universally Unique IDentifier (UUID) URN Namespace}\n */\nfunction createGuid() {\n // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function (c) {\n const r = (Math.random() * 16) | 0;\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nexport default createGuid;\n", "import defaultValue from \"./defaultValue.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\nfunction returnTrue() {\n return true;\n}\n\n/**\n * Destroys an object. Each of the object's functions, including functions in its prototype,\n * is replaced with a function that throws a {@link DeveloperError}, except for the object's\n * isDestroyed function, which is set to a function that returns true.\n * The object's properties are removed with delete.\n *
\n * This function is used by objects that hold native resources, e.g., WebGL resources, which\n * need to be explicitly released. Client code calls an object's destroy function,\n * which then releases the native resource and calls destroyObject to put itself\n * in a destroyed state.\n *\n * @function\n *\n * @param {object} object The object to destroy.\n * @param {string} [message] The message to include in the exception that is thrown if\n * a destroyed object's function is called.\n *\n *\n * @example\n * // How a texture would destroy itself.\n * this.destroy = function () {\n * _gl.deleteTexture(_texture);\n * return Cesium.destroyObject(this);\n * };\n *\n * @see DeveloperError\n */\nfunction destroyObject(object, message) {\n message = defaultValue(\n message,\n \"This object was destroyed, i.e., destroy() was called.\"\n );\n\n function throwOnDestroyed() {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(message);\n //>>includeEnd('debug');\n }\n\n for (const key in object) {\n if (typeof object[key] === \"function\") {\n object[key] = throwOnDestroyed;\n }\n }\n\n object.isDestroyed = returnTrue;\n\n return undefined;\n}\nexport default destroyObject;\n", "import defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\nimport WebGLConstants from \"./WebGLConstants.js\";\n\n/**\n * Constants for WebGL index datatypes. These corresponds to the\n * type parameter of {@link http://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml|drawElements}.\n *\n * @enum {number}\n */\nconst IndexDatatype = {\n /**\n * 8-bit unsigned byte corresponding to UNSIGNED_BYTE and the type\n * of an element in Uint8Array.\n *\n * @type {number}\n * @constant\n */\n UNSIGNED_BYTE: WebGLConstants.UNSIGNED_BYTE,\n\n /**\n * 16-bit unsigned short corresponding to UNSIGNED_SHORT and the type\n * of an element in Uint16Array.\n *\n * @type {number}\n * @constant\n */\n UNSIGNED_SHORT: WebGLConstants.UNSIGNED_SHORT,\n\n /**\n * 32-bit unsigned int corresponding to UNSIGNED_INT and the type\n * of an element in Uint32Array.\n *\n * @type {number}\n * @constant\n */\n UNSIGNED_INT: WebGLConstants.UNSIGNED_INT,\n};\n\n/**\n * Returns the size, in bytes, of the corresponding datatype.\n *\n * @param {IndexDatatype} indexDatatype The index datatype to get the size of.\n * @returns {number} The size in bytes.\n *\n * @example\n * // Returns 2\n * const size = Cesium.IndexDatatype.getSizeInBytes(Cesium.IndexDatatype.UNSIGNED_SHORT);\n */\nIndexDatatype.getSizeInBytes = function (indexDatatype) {\n switch (indexDatatype) {\n case IndexDatatype.UNSIGNED_BYTE:\n return Uint8Array.BYTES_PER_ELEMENT;\n case IndexDatatype.UNSIGNED_SHORT:\n return Uint16Array.BYTES_PER_ELEMENT;\n case IndexDatatype.UNSIGNED_INT:\n return Uint32Array.BYTES_PER_ELEMENT;\n }\n\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"indexDatatype is required and must be a valid IndexDatatype constant.\"\n );\n //>>includeEnd('debug');\n};\n\n/**\n * Gets the datatype with a given size in bytes.\n *\n * @param {number} sizeInBytes The size of a single index in bytes.\n * @returns {IndexDatatype} The index datatype with the given size.\n */\nIndexDatatype.fromSizeInBytes = function (sizeInBytes) {\n switch (sizeInBytes) {\n case 2:\n return IndexDatatype.UNSIGNED_SHORT;\n case 4:\n return IndexDatatype.UNSIGNED_INT;\n case 1:\n return IndexDatatype.UNSIGNED_BYTE;\n //>>includeStart('debug', pragmas.debug);\n default:\n throw new DeveloperError(\n \"Size in bytes cannot be mapped to an IndexDatatype\"\n );\n //>>includeEnd('debug');\n }\n};\n\n/**\n * Validates that the provided index datatype is a valid {@link IndexDatatype}.\n *\n * @param {IndexDatatype} indexDatatype The index datatype to validate.\n * @returns {boolean} true if the provided index datatype is a valid value; otherwise, false.\n *\n * @example\n * if (!Cesium.IndexDatatype.validate(indexDatatype)) {\n * throw new Cesium.DeveloperError('indexDatatype must be a valid value.');\n * }\n */\nIndexDatatype.validate = function (indexDatatype) {\n return (\n defined(indexDatatype) &&\n (indexDatatype === IndexDatatype.UNSIGNED_BYTE ||\n indexDatatype === IndexDatatype.UNSIGNED_SHORT ||\n indexDatatype === IndexDatatype.UNSIGNED_INT)\n );\n};\n\n/**\n * Creates a typed array that will store indices, using either \n * or Uint32Array depending on the number of vertices.\n *\n * @param {number} numberOfVertices Number of vertices that the indices will reference.\n * @param {number|Array} indicesLengthOrArray Passed through to the typed array constructor.\n * @returns {Uint16Array|Uint32Array} A Uint16Array or Uint32Array constructed with indicesLengthOrArray.\n *\n * @example\n * this.indices = Cesium.IndexDatatype.createTypedArray(positions.length / 3, numberOfIndices);\n */\nIndexDatatype.createTypedArray = function (\n numberOfVertices,\n indicesLengthOrArray\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(numberOfVertices)) {\n throw new DeveloperError(\"numberOfVertices is required.\");\n }\n //>>includeEnd('debug');\n\n if (numberOfVertices >= CesiumMath.SIXTY_FOUR_KILOBYTES) {\n return new Uint32Array(indicesLengthOrArray);\n }\n\n return new Uint16Array(indicesLengthOrArray);\n};\n\n/**\n * Creates a typed array from a source array buffer. The resulting typed array will store indices, using either \n * or Uint32Array depending on the number of vertices.\n *\n * @param {number} numberOfVertices Number of vertices that the indices will reference.\n * @param {ArrayBuffer} sourceArray Passed through to the typed array constructor.\n * @param {number} byteOffset Passed through to the typed array constructor.\n * @param {number} length Passed through to the typed array constructor.\n * @returns {Uint16Array|Uint32Array} A Uint16Array or Uint32Array constructed with sourceArray, byteOffset, and length.\n *\n */\nIndexDatatype.createTypedArrayFromArrayBuffer = function (\n numberOfVertices,\n sourceArray,\n byteOffset,\n length\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(numberOfVertices)) {\n throw new DeveloperError(\"numberOfVertices is required.\");\n }\n if (!defined(sourceArray)) {\n throw new DeveloperError(\"sourceArray is required.\");\n }\n if (!defined(byteOffset)) {\n throw new DeveloperError(\"byteOffset is required.\");\n }\n //>>includeEnd('debug');\n\n if (numberOfVertices >= CesiumMath.SIXTY_FOUR_KILOBYTES) {\n return new Uint32Array(sourceArray, byteOffset, length);\n }\n\n return new Uint16Array(sourceArray, byteOffset, length);\n};\n\n/**\n * Gets the {@link IndexDatatype} for the provided TypedArray instance.\n *\n * @param {Uint8Array|Uint16Array|Uint32Array} array The typed array.\n * @returns {IndexDatatype} The IndexDatatype for the provided array, or undefined if the array is not a Uint8Array, Uint16Array, or Uint32Array.\n */\nIndexDatatype.fromTypedArray = function (array) {\n if (array instanceof Uint8Array) {\n return IndexDatatype.UNSIGNED_BYTE;\n }\n if (array instanceof Uint16Array) {\n return IndexDatatype.UNSIGNED_SHORT;\n }\n if (array instanceof Uint32Array) {\n return IndexDatatype.UNSIGNED_INT;\n }\n\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"array must be a Uint8Array, Uint16Array, or Uint32Array.\"\n );\n //>>includeEnd('debug');\n};\n\nexport default Object.freeze(IndexDatatype);\n", "import WebGLConstants from \"../Core/WebGLConstants.js\";\n\n/**\n * @private\n */\nconst BufferUsage = {\n STREAM_DRAW: WebGLConstants.STREAM_DRAW,\n STATIC_DRAW: WebGLConstants.STATIC_DRAW,\n DYNAMIC_DRAW: WebGLConstants.DYNAMIC_DRAW,\n\n validate: function (bufferUsage) {\n return (\n bufferUsage === BufferUsage.STREAM_DRAW ||\n bufferUsage === BufferUsage.STATIC_DRAW ||\n bufferUsage === BufferUsage.DYNAMIC_DRAW\n );\n },\n};\nexport default Object.freeze(BufferUsage);\n", "import Check from \"../Core/Check.js\";\nimport createGuid from \"../Core/createGuid.js\";\nimport defaultValue from \"../Core/defaultValue.js\";\nimport defined from \"../Core/defined.js\";\nimport destroyObject from \"../Core/destroyObject.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport IndexDatatype from \"../Core/IndexDatatype.js\";\nimport WebGLConstants from \"../Core/WebGLConstants.js\";\nimport BufferUsage from \"./BufferUsage.js\";\n\n/**\n * @private\n */\nfunction Buffer(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.context\", options.context);\n\n if (!defined(options.typedArray) && !defined(options.sizeInBytes)) {\n throw new DeveloperError(\n \"Either options.sizeInBytes or options.typedArray is required.\"\n );\n }\n\n if (defined(options.typedArray) && defined(options.sizeInBytes)) {\n throw new DeveloperError(\n \"Cannot pass in both options.sizeInBytes and options.typedArray.\"\n );\n }\n\n if (defined(options.typedArray)) {\n Check.typeOf.object(\"options.typedArray\", options.typedArray);\n Check.typeOf.number(\n \"options.typedArray.byteLength\",\n options.typedArray.byteLength\n );\n }\n\n if (!BufferUsage.validate(options.usage)) {\n throw new DeveloperError(\"usage is invalid.\");\n }\n //>>includeEnd('debug');\n\n const gl = options.context._gl;\n const bufferTarget = options.bufferTarget;\n const typedArray = options.typedArray;\n let sizeInBytes = options.sizeInBytes;\n const usage = options.usage;\n const hasArray = defined(typedArray);\n\n if (hasArray) {\n sizeInBytes = typedArray.byteLength;\n }\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThan(\"sizeInBytes\", sizeInBytes, 0);\n //>>includeEnd('debug');\n\n const buffer = gl.createBuffer();\n gl.bindBuffer(bufferTarget, buffer);\n gl.bufferData(bufferTarget, hasArray ? typedArray : sizeInBytes, usage);\n gl.bindBuffer(bufferTarget, null);\n\n this._id = createGuid();\n this._gl = gl;\n this._webgl2 = options.context._webgl2;\n this._bufferTarget = bufferTarget;\n this._sizeInBytes = sizeInBytes;\n this._usage = usage;\n this._buffer = buffer;\n this.vertexArrayDestroyable = true;\n}\n\n/**\n * Creates a vertex buffer, which contains untyped vertex data in GPU-controlled memory.\n *
\n * A vertex array defines the actual makeup of a vertex, e.g., positions, normals, texture coordinates,\n * etc., by interpreting the raw data in one or more vertex buffers.\n *\n * @param {object} options An object containing the following properties:\n * @param {Context} options.context The context in which to create the buffer\n * @param {ArrayBufferView} [options.typedArray] A typed array containing the data to copy to the buffer.\n * @param {number} [options.sizeInBytes] A Number defining the size of the buffer in bytes. Required if options.typedArray is not given.\n * @param {BufferUsage} options.usage Specifies the expected usage pattern of the buffer. On some GL implementations, this can significantly affect performance. See {@link BufferUsage}.\n * @returns {VertexBuffer} The vertex buffer, ready to be attached to a vertex array.\n *\n * @exception {DeveloperError} Must specify either or , but not both.\n * @exception {DeveloperError} The buffer size must be greater than zero.\n * @exception {DeveloperError} Invalid usage.\n *\n *\n * @example\n * // Example 1. Create a dynamic vertex buffer 16 bytes in size.\n * const buffer = Buffer.createVertexBuffer({\n * context : context,\n * sizeInBytes : 16,\n * usage : BufferUsage.DYNAMIC_DRAW\n * });\n *\n * @example\n * // Example 2. Create a dynamic vertex buffer from three floating-point values.\n * // The data copied to the vertex buffer is considered raw bytes until it is\n * // interpreted as vertices using a vertex array.\n * const positionBuffer = buffer.createVertexBuffer({\n * context : context,\n * typedArray : new Float32Array([0, 0, 0]),\n * usage : BufferUsage.STATIC_DRAW\n * });\n *\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenBuffer.xml|glGenBuffer}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindBuffer.xml|glBindBuffer} with ARRAY_BUFFER\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBufferData.xml|glBufferData} with ARRAY_BUFFER\n */\nBuffer.createVertexBuffer = function (options) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.context\", options.context);\n //>>includeEnd('debug');\n\n return new Buffer({\n context: options.context,\n bufferTarget: WebGLConstants.ARRAY_BUFFER,\n typedArray: options.typedArray,\n sizeInBytes: options.sizeInBytes,\n usage: options.usage,\n });\n};\n\n/**\n * Creates an index buffer, which contains typed indices in GPU-controlled memory.\n *
\n * An index buffer can be attached to a vertex array to select vertices for rendering.\n * Context.draw can render using the entire index buffer or a subset\n * of the index buffer defined by an offset and count.\n *\n * @param {object} options An object containing the following properties:\n * @param {Context} options.context The context in which to create the buffer\n * @param {ArrayBufferView} [options.typedArray] A typed array containing the data to copy to the buffer.\n * @param {number} [options.sizeInBytes] A Number defining the size of the buffer in bytes. Required if options.typedArray is not given.\n * @param {BufferUsage} options.usage Specifies the expected usage pattern of the buffer. On some GL implementations, this can significantly affect performance. See {@link BufferUsage}.\n * @param {IndexDatatype} options.indexDatatype The datatype of indices in the buffer.\n * @returns {IndexBuffer} The index buffer, ready to be attached to a vertex array.\n *\n * @exception {DeveloperError} Must specify either or , but not both.\n * @exception {DeveloperError} IndexDatatype.UNSIGNED_INT requires OES_element_index_uint, which is not supported on this system. Check context.elementIndexUint.\n * @exception {DeveloperError} The size in bytes must be greater than zero.\n * @exception {DeveloperError} Invalid usage.\n * @exception {DeveloperError} Invalid indexDatatype.\n *\n *\n * @example\n * // Example 1. Create a stream index buffer of unsigned shorts that is\n * // 16 bytes in size.\n * const buffer = Buffer.createIndexBuffer({\n * context : context,\n * sizeInBytes : 16,\n * usage : BufferUsage.STREAM_DRAW,\n * indexDatatype : IndexDatatype.UNSIGNED_SHORT\n * });\n *\n * @example\n * // Example 2. Create a static index buffer containing three unsigned shorts.\n * const buffer = Buffer.createIndexBuffer({\n * context : context,\n * typedArray : new Uint16Array([0, 1, 2]),\n * usage : BufferUsage.STATIC_DRAW,\n * indexDatatype : IndexDatatype.UNSIGNED_SHORT\n * });\n *\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenBuffer.xml|glGenBuffer}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindBuffer.xml|glBindBuffer} with ELEMENT_ARRAY_BUFFER\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBufferData.xml|glBufferData} with ELEMENT_ARRAY_BUFFER\n */\nBuffer.createIndexBuffer = function (options) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.context\", options.context);\n\n if (!IndexDatatype.validate(options.indexDatatype)) {\n throw new DeveloperError(\"Invalid indexDatatype.\");\n }\n\n if (\n options.indexDatatype === IndexDatatype.UNSIGNED_INT &&\n !options.context.elementIndexUint\n ) {\n throw new DeveloperError(\n \"IndexDatatype.UNSIGNED_INT requires OES_element_index_uint, which is not supported on this system. Check context.elementIndexUint.\"\n );\n }\n //>>includeEnd('debug');\n\n const context = options.context;\n const indexDatatype = options.indexDatatype;\n\n const bytesPerIndex = IndexDatatype.getSizeInBytes(indexDatatype);\n const buffer = new Buffer({\n context: context,\n bufferTarget: WebGLConstants.ELEMENT_ARRAY_BUFFER,\n typedArray: options.typedArray,\n sizeInBytes: options.sizeInBytes,\n usage: options.usage,\n });\n\n const numberOfIndices = buffer.sizeInBytes / bytesPerIndex;\n\n Object.defineProperties(buffer, {\n indexDatatype: {\n get: function () {\n return indexDatatype;\n },\n },\n bytesPerIndex: {\n get: function () {\n return bytesPerIndex;\n },\n },\n numberOfIndices: {\n get: function () {\n return numberOfIndices;\n },\n },\n });\n\n return buffer;\n};\n\nObject.defineProperties(Buffer.prototype, {\n sizeInBytes: {\n get: function () {\n return this._sizeInBytes;\n },\n },\n\n usage: {\n get: function () {\n return this._usage;\n },\n },\n});\n\nBuffer.prototype._getBuffer = function () {\n return this._buffer;\n};\n\nBuffer.prototype.copyFromArrayView = function (arrayView, offsetInBytes) {\n offsetInBytes = defaultValue(offsetInBytes, 0);\n\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"arrayView\", arrayView);\n Check.typeOf.number.lessThanOrEquals(\n \"offsetInBytes + arrayView.byteLength\",\n offsetInBytes + arrayView.byteLength,\n this._sizeInBytes\n );\n //>>includeEnd('debug');\n\n const gl = this._gl;\n const target = this._bufferTarget;\n gl.bindBuffer(target, this._buffer);\n gl.bufferSubData(target, offsetInBytes, arrayView);\n gl.bindBuffer(target, null);\n};\n\nBuffer.prototype.copyFromBuffer = function (\n readBuffer,\n readOffset,\n writeOffset,\n sizeInBytes\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!this._webgl2) {\n throw new DeveloperError(\"A WebGL 2 context is required.\");\n }\n if (!defined(readBuffer)) {\n throw new DeveloperError(\"readBuffer must be defined.\");\n }\n if (!defined(sizeInBytes) || sizeInBytes <= 0) {\n throw new DeveloperError(\n \"sizeInBytes must be defined and be greater than zero.\"\n );\n }\n if (\n !defined(readOffset) ||\n readOffset < 0 ||\n readOffset + sizeInBytes > readBuffer._sizeInBytes\n ) {\n throw new DeveloperError(\n \"readOffset must be greater than or equal to zero and readOffset + sizeInBytes must be less than of equal to readBuffer.sizeInBytes.\"\n );\n }\n if (\n !defined(writeOffset) ||\n writeOffset < 0 ||\n writeOffset + sizeInBytes > this._sizeInBytes\n ) {\n throw new DeveloperError(\n \"writeOffset must be greater than or equal to zero and writeOffset + sizeInBytes must be less than of equal to this.sizeInBytes.\"\n );\n }\n if (\n this._buffer === readBuffer._buffer &&\n ((writeOffset >= readOffset && writeOffset < readOffset + sizeInBytes) ||\n (readOffset > writeOffset && readOffset < writeOffset + sizeInBytes))\n ) {\n throw new DeveloperError(\n \"When readBuffer is equal to this, the ranges [readOffset + sizeInBytes) and [writeOffset, writeOffset + sizeInBytes) must not overlap.\"\n );\n }\n if (\n (this._bufferTarget === WebGLConstants.ELEMENT_ARRAY_BUFFER &&\n readBuffer._bufferTarget !== WebGLConstants.ELEMENT_ARRAY_BUFFER) ||\n (this._bufferTarget !== WebGLConstants.ELEMENT_ARRAY_BUFFER &&\n readBuffer._bufferTarget === WebGLConstants.ELEMENT_ARRAY_BUFFER)\n ) {\n throw new DeveloperError(\n \"Can not copy an index buffer into another buffer type.\"\n );\n }\n //>>includeEnd('debug');\n\n const readTarget = WebGLConstants.COPY_READ_BUFFER;\n const writeTarget = WebGLConstants.COPY_WRITE_BUFFER;\n\n const gl = this._gl;\n gl.bindBuffer(writeTarget, this._buffer);\n gl.bindBuffer(readTarget, readBuffer._buffer);\n gl.copyBufferSubData(\n readTarget,\n writeTarget,\n readOffset,\n writeOffset,\n sizeInBytes\n );\n gl.bindBuffer(writeTarget, null);\n gl.bindBuffer(readTarget, null);\n};\n\nBuffer.prototype.getBufferData = function (\n arrayView,\n sourceOffset,\n destinationOffset,\n length\n) {\n sourceOffset = defaultValue(sourceOffset, 0);\n destinationOffset = defaultValue(destinationOffset, 0);\n\n //>>includeStart('debug', pragmas.debug);\n if (!this._webgl2) {\n throw new DeveloperError(\"A WebGL 2 context is required.\");\n }\n if (!defined(arrayView)) {\n throw new DeveloperError(\"arrayView is required.\");\n }\n\n let copyLength;\n let elementSize;\n let arrayLength = arrayView.byteLength;\n if (!defined(length)) {\n if (defined(arrayLength)) {\n copyLength = arrayLength - destinationOffset;\n elementSize = 1;\n } else {\n arrayLength = arrayView.length;\n copyLength = arrayLength - destinationOffset;\n elementSize = arrayView.BYTES_PER_ELEMENT;\n }\n } else {\n copyLength = length;\n if (defined(arrayLength)) {\n elementSize = 1;\n } else {\n arrayLength = arrayView.length;\n elementSize = arrayView.BYTES_PER_ELEMENT;\n }\n }\n\n if (destinationOffset < 0 || destinationOffset > arrayLength) {\n throw new DeveloperError(\n \"destinationOffset must be greater than zero and less than the arrayView length.\"\n );\n }\n if (destinationOffset + copyLength > arrayLength) {\n throw new DeveloperError(\n \"destinationOffset + length must be less than or equal to the arrayViewLength.\"\n );\n }\n if (sourceOffset < 0 || sourceOffset > this._sizeInBytes) {\n throw new DeveloperError(\n \"sourceOffset must be greater than zero and less than the buffers size.\"\n );\n }\n if (sourceOffset + copyLength * elementSize > this._sizeInBytes) {\n throw new DeveloperError(\n \"sourceOffset + length must be less than the buffers size.\"\n );\n }\n //>>includeEnd('debug');\n\n const gl = this._gl;\n const target = WebGLConstants.COPY_READ_BUFFER;\n gl.bindBuffer(target, this._buffer);\n gl.getBufferSubData(\n target,\n sourceOffset,\n arrayView,\n destinationOffset,\n length\n );\n gl.bindBuffer(target, null);\n};\n\nBuffer.prototype.isDestroyed = function () {\n return false;\n};\n\nBuffer.prototype.destroy = function () {\n this._gl.deleteBuffer(this._buffer);\n return destroyObject(this);\n};\nexport default Buffer;\n", "import defined from \"./defined.js\";\n\nlet _supportsFullscreen;\nconst _names = {\n requestFullscreen: undefined,\n exitFullscreen: undefined,\n fullscreenEnabled: undefined,\n fullscreenElement: undefined,\n fullscreenchange: undefined,\n fullscreenerror: undefined,\n};\n\n/**\n * Browser-independent functions for working with the standard fullscreen API.\n *\n * @namespace Fullscreen\n *\n * @see {@link http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html|W3C Fullscreen Living Specification}\n */\nconst Fullscreen = {};\n\nObject.defineProperties(Fullscreen, {\n /**\n * The element that is currently fullscreen, if any. To simply check if the\n * browser is in fullscreen mode or not, use {@link Fullscreen#fullscreen}.\n * @memberof Fullscreen\n * @type {object}\n * @readonly\n */\n element: {\n get: function () {\n if (!Fullscreen.supportsFullscreen()) {\n return undefined;\n }\n\n return document[_names.fullscreenElement];\n },\n },\n\n /**\n * The name of the event on the document that is fired when fullscreen is\n * entered or exited. This event name is intended for use with addEventListener.\n * In your event handler, to determine if the browser is in fullscreen mode or not,\n * use {@link Fullscreen#fullscreen}.\n * @memberof Fullscreen\n * @type {string}\n * @readonly\n */\n changeEventName: {\n get: function () {\n if (!Fullscreen.supportsFullscreen()) {\n return undefined;\n }\n\n return _names.fullscreenchange;\n },\n },\n\n /**\n * The name of the event that is fired when a fullscreen error\n * occurs. This event name is intended for use with addEventListener.\n * @memberof Fullscreen\n * @type {string}\n * @readonly\n */\n errorEventName: {\n get: function () {\n if (!Fullscreen.supportsFullscreen()) {\n return undefined;\n }\n\n return _names.fullscreenerror;\n },\n },\n\n /**\n * Determine whether the browser will allow an element to be made fullscreen, or not.\n * For example, by default, iframes cannot go fullscreen unless the containing page\n * adds an \"allowfullscreen\" attribute (or prefixed equivalent).\n * @memberof Fullscreen\n * @type {boolean}\n * @readonly\n */\n enabled: {\n get: function () {\n if (!Fullscreen.supportsFullscreen()) {\n return undefined;\n }\n\n return document[_names.fullscreenEnabled];\n },\n },\n\n /**\n * Determines if the browser is currently in fullscreen mode.\n * @memberof Fullscreen\n * @type {boolean}\n * @readonly\n */\n fullscreen: {\n get: function () {\n if (!Fullscreen.supportsFullscreen()) {\n return undefined;\n }\n\n return Fullscreen.element !== null;\n },\n },\n});\n\n/**\n * Detects whether the browser supports the standard fullscreen API.\n *\n * @returns {boolean} true if the browser supports the standard fullscreen API,\n * false otherwise.\n */\nFullscreen.supportsFullscreen = function () {\n if (defined(_supportsFullscreen)) {\n return _supportsFullscreen;\n }\n\n _supportsFullscreen = false;\n\n const body = document.body;\n if (typeof body.requestFullscreen === \"function\") {\n // go with the unprefixed, standard set of names\n _names.requestFullscreen = \"requestFullscreen\";\n _names.exitFullscreen = \"exitFullscreen\";\n _names.fullscreenEnabled = \"fullscreenEnabled\";\n _names.fullscreenElement = \"fullscreenElement\";\n _names.fullscreenchange = \"fullscreenchange\";\n _names.fullscreenerror = \"fullscreenerror\";\n _supportsFullscreen = true;\n return _supportsFullscreen;\n }\n\n //check for the correct combination of prefix plus the various names that browsers use\n const prefixes = [\"webkit\", \"moz\", \"o\", \"ms\", \"khtml\"];\n let name;\n for (let i = 0, len = prefixes.length; i < len; ++i) {\n const prefix = prefixes[i];\n\n // casing of Fullscreen differs across browsers\n name = `${prefix}RequestFullscreen`;\n if (typeof body[name] === \"function\") {\n _names.requestFullscreen = name;\n _supportsFullscreen = true;\n } else {\n name = `${prefix}RequestFullScreen`;\n if (typeof body[name] === \"function\") {\n _names.requestFullscreen = name;\n _supportsFullscreen = true;\n }\n }\n\n // disagreement about whether it's \"exit\" as per spec, or \"cancel\"\n name = `${prefix}ExitFullscreen`;\n if (typeof document[name] === \"function\") {\n _names.exitFullscreen = name;\n } else {\n name = `${prefix}CancelFullScreen`;\n if (typeof document[name] === \"function\") {\n _names.exitFullscreen = name;\n }\n }\n\n // casing of Fullscreen differs across browsers\n name = `${prefix}FullscreenEnabled`;\n if (document[name] !== undefined) {\n _names.fullscreenEnabled = name;\n } else {\n name = `${prefix}FullScreenEnabled`;\n if (document[name] !== undefined) {\n _names.fullscreenEnabled = name;\n }\n }\n\n // casing of Fullscreen differs across browsers\n name = `${prefix}FullscreenElement`;\n if (document[name] !== undefined) {\n _names.fullscreenElement = name;\n } else {\n name = `${prefix}FullScreenElement`;\n if (document[name] !== undefined) {\n _names.fullscreenElement = name;\n }\n }\n\n // thankfully, event names are all lowercase per spec\n name = `${prefix}fullscreenchange`;\n // event names do not have 'on' in the front, but the property on the document does\n if (document[`on${name}`] !== undefined) {\n //except on IE\n if (prefix === \"ms\") {\n name = \"MSFullscreenChange\";\n }\n _names.fullscreenchange = name;\n }\n\n name = `${prefix}fullscreenerror`;\n if (document[`on${name}`] !== undefined) {\n //except on IE\n if (prefix === \"ms\") {\n name = \"MSFullscreenError\";\n }\n _names.fullscreenerror = name;\n }\n }\n\n return _supportsFullscreen;\n};\n\n/**\n * Asynchronously requests the browser to enter fullscreen mode on the given element.\n * If fullscreen mode is not supported by the browser, does nothing.\n *\n * @param {object} element The HTML element which will be placed into fullscreen mode.\n * @param {object} [vrDevice] The HMDVRDevice device.\n *\n * @example\n * // Put the entire page into fullscreen.\n * Cesium.Fullscreen.requestFullscreen(document.body)\n *\n * // Place only the Cesium canvas into fullscreen.\n * Cesium.Fullscreen.requestFullscreen(scene.canvas)\n */\nFullscreen.requestFullscreen = function (element, vrDevice) {\n if (!Fullscreen.supportsFullscreen()) {\n return;\n }\n\n element[_names.requestFullscreen]({ vrDisplay: vrDevice });\n};\n\n/**\n * Asynchronously exits fullscreen mode. If the browser is not currently\n * in fullscreen, or if fullscreen mode is not supported by the browser, does nothing.\n */\nFullscreen.exitFullscreen = function () {\n if (!Fullscreen.supportsFullscreen()) {\n return;\n }\n\n document[_names.exitFullscreen]();\n};\n\n//For unit tests\nFullscreen._names = _names;\nexport default Fullscreen;\n", "import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport Fullscreen from \"./Fullscreen.js\";\n\nlet theNavigator;\nif (typeof navigator !== \"undefined\") {\n theNavigator = navigator;\n} else {\n theNavigator = {};\n}\n\nfunction extractVersion(versionString) {\n const parts = versionString.split(\".\");\n for (let i = 0, len = parts.length; i < len; ++i) {\n parts[i] = parseInt(parts[i], 10);\n }\n return parts;\n}\n\nlet isChromeResult;\nlet chromeVersionResult;\nfunction isChrome() {\n if (!defined(isChromeResult)) {\n isChromeResult = false;\n // Edge contains Chrome in the user agent too\n if (!isEdge()) {\n const fields = / Chrome\\/([\\.0-9]+)/.exec(theNavigator.userAgent);\n if (fields !== null) {\n isChromeResult = true;\n chromeVersionResult = extractVersion(fields[1]);\n }\n }\n }\n\n return isChromeResult;\n}\n\nfunction chromeVersion() {\n return isChrome() && chromeVersionResult;\n}\n\nlet isSafariResult;\nlet safariVersionResult;\nfunction isSafari() {\n if (!defined(isSafariResult)) {\n isSafariResult = false;\n\n // Chrome and Edge contain Safari in the user agent too\n if (\n !isChrome() &&\n !isEdge() &&\n / Safari\\/[\\.0-9]+/.test(theNavigator.userAgent)\n ) {\n const fields = / Version\\/([\\.0-9]+)/.exec(theNavigator.userAgent);\n if (fields !== null) {\n isSafariResult = true;\n safariVersionResult = extractVersion(fields[1]);\n }\n }\n }\n\n return isSafariResult;\n}\n\nfunction safariVersion() {\n return isSafari() && safariVersionResult;\n}\n\nlet isWebkitResult;\nlet webkitVersionResult;\nfunction isWebkit() {\n if (!defined(isWebkitResult)) {\n isWebkitResult = false;\n\n const fields = / AppleWebKit\\/([\\.0-9]+)(\\+?)/.exec(theNavigator.userAgent);\n if (fields !== null) {\n isWebkitResult = true;\n webkitVersionResult = extractVersion(fields[1]);\n webkitVersionResult.isNightly = !!fields[2];\n }\n }\n\n return isWebkitResult;\n}\n\nfunction webkitVersion() {\n return isWebkit() && webkitVersionResult;\n}\n\nlet isInternetExplorerResult;\nlet internetExplorerVersionResult;\nfunction isInternetExplorer() {\n if (!defined(isInternetExplorerResult)) {\n isInternetExplorerResult = false;\n\n let fields;\n if (theNavigator.appName === \"Microsoft Internet Explorer\") {\n fields = /MSIE ([0-9]{1,}[\\.0-9]{0,})/.exec(theNavigator.userAgent);\n if (fields !== null) {\n isInternetExplorerResult = true;\n internetExplorerVersionResult = extractVersion(fields[1]);\n }\n } else if (theNavigator.appName === \"Netscape\") {\n fields = /Trident\\/.*rv:([0-9]{1,}[\\.0-9]{0,})/.exec(\n theNavigator.userAgent\n );\n if (fields !== null) {\n isInternetExplorerResult = true;\n internetExplorerVersionResult = extractVersion(fields[1]);\n }\n }\n }\n return isInternetExplorerResult;\n}\n\nfunction internetExplorerVersion() {\n return isInternetExplorer() && internetExplorerVersionResult;\n}\n\nlet isEdgeResult;\nlet edgeVersionResult;\nfunction isEdge() {\n if (!defined(isEdgeResult)) {\n isEdgeResult = false;\n const fields = / Edg\\/([\\.0-9]+)/.exec(theNavigator.userAgent);\n if (fields !== null) {\n isEdgeResult = true;\n edgeVersionResult = extractVersion(fields[1]);\n }\n }\n return isEdgeResult;\n}\n\nfunction edgeVersion() {\n return isEdge() && edgeVersionResult;\n}\n\nlet isFirefoxResult;\nlet firefoxVersionResult;\nfunction isFirefox() {\n if (!defined(isFirefoxResult)) {\n isFirefoxResult = false;\n\n const fields = /Firefox\\/([\\.0-9]+)/.exec(theNavigator.userAgent);\n if (fields !== null) {\n isFirefoxResult = true;\n firefoxVersionResult = extractVersion(fields[1]);\n }\n }\n return isFirefoxResult;\n}\n\nlet isWindowsResult;\nfunction isWindows() {\n if (!defined(isWindowsResult)) {\n isWindowsResult = /Windows/i.test(theNavigator.appVersion);\n }\n return isWindowsResult;\n}\n\nlet isIPadOrIOSResult;\nfunction isIPadOrIOS() {\n if (!defined(isIPadOrIOSResult)) {\n isIPadOrIOSResult =\n navigator.platform === \"iPhone\" ||\n navigator.platform === \"iPod\" ||\n navigator.platform === \"iPad\";\n }\n\n return isIPadOrIOSResult;\n}\n\nfunction firefoxVersion() {\n return isFirefox() && firefoxVersionResult;\n}\n\nlet hasPointerEvents;\nfunction supportsPointerEvents() {\n if (!defined(hasPointerEvents)) {\n //While navigator.pointerEnabled is deprecated in the W3C specification\n //we still need to use it if it exists in order to support browsers\n //that rely on it, such as the Windows WebBrowser control which defines\n //PointerEvent but sets navigator.pointerEnabled to false.\n\n //Firefox disabled because of https://github.com/CesiumGS/cesium/issues/6372\n hasPointerEvents =\n !isFirefox() &&\n typeof PointerEvent !== \"undefined\" &&\n (!defined(theNavigator.pointerEnabled) || theNavigator.pointerEnabled);\n }\n return hasPointerEvents;\n}\n\nlet imageRenderingValueResult;\nlet supportsImageRenderingPixelatedResult;\nfunction supportsImageRenderingPixelated() {\n if (!defined(supportsImageRenderingPixelatedResult)) {\n const canvas = document.createElement(\"canvas\");\n canvas.setAttribute(\n \"style\",\n \"image-rendering: -moz-crisp-edges;\" + \"image-rendering: pixelated;\"\n );\n //canvas.style.imageRendering will be undefined, null or an empty string on unsupported browsers.\n const tmp = canvas.style.imageRendering;\n supportsImageRenderingPixelatedResult = defined(tmp) && tmp !== \"\";\n if (supportsImageRenderingPixelatedResult) {\n imageRenderingValueResult = tmp;\n }\n }\n return supportsImageRenderingPixelatedResult;\n}\n\nfunction imageRenderingValue() {\n return supportsImageRenderingPixelated()\n ? imageRenderingValueResult\n : undefined;\n}\n\nfunction supportsWebP() {\n //>>includeStart('debug', pragmas.debug);\n if (!supportsWebP.initialized) {\n throw new DeveloperError(\n \"You must call FeatureDetection.supportsWebP.initialize and wait for the promise to resolve before calling FeatureDetection.supportsWebP\"\n );\n }\n //>>includeEnd('debug');\n return supportsWebP._result;\n}\nsupportsWebP._promise = undefined;\nsupportsWebP._result = undefined;\nsupportsWebP.initialize = function () {\n // From https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp\n if (defined(supportsWebP._promise)) {\n return supportsWebP._promise;\n }\n\n supportsWebP._promise = new Promise((resolve) => {\n const image = new Image();\n image.onload = function () {\n supportsWebP._result = image.width > 0 && image.height > 0;\n resolve(supportsWebP._result);\n };\n\n image.onerror = function () {\n supportsWebP._result = false;\n resolve(supportsWebP._result);\n };\n image.src =\n \"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA\";\n });\n\n return supportsWebP._promise;\n};\nObject.defineProperties(supportsWebP, {\n initialized: {\n get: function () {\n return defined(supportsWebP._result);\n },\n },\n});\n\nconst typedArrayTypes = [];\nif (typeof ArrayBuffer !== \"undefined\") {\n typedArrayTypes.push(\n Int8Array,\n Uint8Array,\n Int16Array,\n Uint16Array,\n Int32Array,\n Uint32Array,\n Float32Array,\n Float64Array\n );\n\n if (typeof Uint8ClampedArray !== \"undefined\") {\n typedArrayTypes.push(Uint8ClampedArray);\n }\n\n if (typeof Uint8ClampedArray !== \"undefined\") {\n typedArrayTypes.push(Uint8ClampedArray);\n }\n\n if (typeof BigInt64Array !== \"undefined\") {\n // eslint-disable-next-line no-undef\n typedArrayTypes.push(BigInt64Array);\n }\n\n if (typeof BigUint64Array !== \"undefined\") {\n // eslint-disable-next-line no-undef\n typedArrayTypes.push(BigUint64Array);\n }\n}\n\n/**\n * A set of functions to detect whether the current browser supports\n * various features.\n *\n * @namespace FeatureDetection\n */\nconst FeatureDetection = {\n isChrome: isChrome,\n chromeVersion: chromeVersion,\n isSafari: isSafari,\n safariVersion: safariVersion,\n isWebkit: isWebkit,\n webkitVersion: webkitVersion,\n isInternetExplorer: isInternetExplorer,\n internetExplorerVersion: internetExplorerVersion,\n isEdge: isEdge,\n edgeVersion: edgeVersion,\n isFirefox: isFirefox,\n firefoxVersion: firefoxVersion,\n isWindows: isWindows,\n isIPadOrIOS: isIPadOrIOS,\n hardwareConcurrency: defaultValue(theNavigator.hardwareConcurrency, 3),\n supportsPointerEvents: supportsPointerEvents,\n supportsImageRenderingPixelated: supportsImageRenderingPixelated,\n supportsWebP: supportsWebP,\n imageRenderingValue: imageRenderingValue,\n typedArrayTypes: typedArrayTypes,\n};\n\n/**\n * Detects whether the current browser supports Basis Universal textures and the web assembly modules needed to transcode them.\n *\n * @param {Scene} scene\n * @returns {boolean} true if the browser supports web assembly modules and the scene supports Basis Universal textures, false if not.\n */\nFeatureDetection.supportsBasis = function (scene) {\n return FeatureDetection.supportsWebAssembly() && scene.context.supportsBasis;\n};\n\n/**\n * Detects whether the current browser supports the full screen standard.\n *\n * @returns {boolean} true if the browser supports the full screen standard, false if not.\n *\n * @see Fullscreen\n * @see {@link http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html|W3C Fullscreen Living Specification}\n */\nFeatureDetection.supportsFullscreen = function () {\n return Fullscreen.supportsFullscreen();\n};\n\n/**\n * Detects whether the current browser supports typed arrays.\n *\n * @returns {boolean} true if the browser supports typed arrays, false if not.\n *\n * @see {@link https://tc39.es/ecma262/#sec-typedarray-objects|Typed Array Specification}\n */\nFeatureDetection.supportsTypedArrays = function () {\n return typeof ArrayBuffer !== \"undefined\";\n};\n\n/**\n * Detects whether the current browser supports BigInt64Array typed arrays.\n *\n * @returns {boolean} true if the browser supports BigInt64Array typed arrays, false if not.\n *\n * @see {@link https://tc39.es/ecma262/#sec-typedarray-objects|Typed Array Specification}\n */\nFeatureDetection.supportsBigInt64Array = function () {\n return typeof BigInt64Array !== \"undefined\";\n};\n\n/**\n * Detects whether the current browser supports BigUint64Array typed arrays.\n *\n * @returns {boolean} true if the browser supports BigUint64Array typed arrays, false if not.\n *\n * @see {@link https://tc39.es/ecma262/#sec-typedarray-objects|Typed Array Specification}\n */\nFeatureDetection.supportsBigUint64Array = function () {\n return typeof BigUint64Array !== \"undefined\";\n};\n\n/**\n * Detects whether the current browser supports BigInt.\n *\n * @returns {boolean} true if the browser supports BigInt, false if not.\n *\n * @see {@link https://tc39.es/ecma262/#sec-bigint-objects|BigInt Specification}\n */\nFeatureDetection.supportsBigInt = function () {\n return typeof BigInt !== \"undefined\";\n};\n\n/**\n * Detects whether the current browser supports Web Workers.\n *\n * @returns {boolean} true if the browsers supports Web Workers, false if not.\n *\n * @see {@link http://www.w3.org/TR/workers/}\n */\nFeatureDetection.supportsWebWorkers = function () {\n return typeof Worker !== \"undefined\";\n};\n\n/**\n * Detects whether the current browser supports Web Assembly.\n *\n * @returns {boolean} true if the browsers supports Web Assembly, false if not.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/WebAssembly}\n */\nFeatureDetection.supportsWebAssembly = function () {\n return typeof WebAssembly !== \"undefined\";\n};\n\n/**\n * Detects whether the current browser supports a WebGL2 rendering context for the specified scene.\n *\n * @param {Scene} scene the Cesium scene specifying the rendering context\n * @returns {boolean} true if the browser supports a WebGL2 rendering context, false if not.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext|WebGL2RenderingContext}\n */\nFeatureDetection.supportsWebgl2 = function (scene) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"scene\", scene);\n //>>includeEnd('debug');\n\n return scene.context.webgl2;\n};\n\nexport default FeatureDetection;\n", "import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport FeatureDetection from \"./FeatureDetection.js\";\nimport CesiumMath from \"./Math.js\";\n\nfunction hue2rgb(m1, m2, h) {\n if (h < 0) {\n h += 1;\n }\n if (h > 1) {\n h -= 1;\n }\n if (h * 6 < 1) {\n return m1 + (m2 - m1) * 6 * h;\n }\n if (h * 2 < 1) {\n return m2;\n }\n if (h * 3 < 2) {\n return m1 + (m2 - m1) * (2 / 3 - h) * 6;\n }\n return m1;\n}\n\n/**\n * A color, specified using red, green, blue, and alpha values,\n * which range from 0 (no intensity) to 1.0 (full intensity).\n * @param {number} [red=1.0] The red component.\n * @param {number} [green=1.0] The green component.\n * @param {number} [blue=1.0] The blue component.\n * @param {number} [alpha=1.0] The alpha component.\n *\n * @constructor\n * @alias Color\n *\n * @see Packable\n */\nfunction Color(red, green, blue, alpha) {\n /**\n * The red component.\n * @type {number}\n * @default 1.0\n */\n this.red = defaultValue(red, 1.0);\n /**\n * The green component.\n * @type {number}\n * @default 1.0\n */\n this.green = defaultValue(green, 1.0);\n /**\n * The blue component.\n * @type {number}\n * @default 1.0\n */\n this.blue = defaultValue(blue, 1.0);\n /**\n * The alpha component.\n * @type {number}\n * @default 1.0\n */\n this.alpha = defaultValue(alpha, 1.0);\n}\n\n/**\n * Creates a Color instance from a {@link Cartesian4}. x, y, z,\n * and w map to red, green, blue, and alpha, respectively.\n *\n * @param {Cartesian4} cartesian The source cartesian.\n * @param {Color} [result] The object onto which to store the result.\n * @returns {Color} The modified result parameter or a new Color instance if one was not provided.\n */\nColor.fromCartesian4 = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Color(cartesian.x, cartesian.y, cartesian.z, cartesian.w);\n }\n\n result.red = cartesian.x;\n result.green = cartesian.y;\n result.blue = cartesian.z;\n result.alpha = cartesian.w;\n return result;\n};\n\n/**\n * Creates a new Color specified using red, green, blue, and alpha values\n * that are in the range of 0 to 255, converting them internally to a range of 0.0 to 1.0.\n *\n * @param {number} [red=255] The red component.\n * @param {number} [green=255] The green component.\n * @param {number} [blue=255] The blue component.\n * @param {number} [alpha=255] The alpha component.\n * @param {Color} [result] The object onto which to store the result.\n * @returns {Color} The modified result parameter or a new Color instance if one was not provided.\n */\nColor.fromBytes = function (red, green, blue, alpha, result) {\n red = Color.byteToFloat(defaultValue(red, 255.0));\n green = Color.byteToFloat(defaultValue(green, 255.0));\n blue = Color.byteToFloat(defaultValue(blue, 255.0));\n alpha = Color.byteToFloat(defaultValue(alpha, 255.0));\n\n if (!defined(result)) {\n return new Color(red, green, blue, alpha);\n }\n\n result.red = red;\n result.green = green;\n result.blue = blue;\n result.alpha = alpha;\n return result;\n};\n\n/**\n * Creates a new Color that has the same red, green, and blue components\n * of the specified color, but with the specified alpha value.\n *\n * @param {Color} color The base color\n * @param {number} alpha The new alpha component.\n * @param {Color} [result] The object onto which to store the result.\n * @returns {Color} The modified result parameter or a new Color instance if one was not provided.\n *\n * @example const translucentRed = Cesium.Color.fromAlpha(Cesium.Color.RED, 0.9);\n */\nColor.fromAlpha = function (color, alpha, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"color\", color);\n Check.typeOf.number(\"alpha\", alpha);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Color(color.red, color.green, color.blue, alpha);\n }\n\n result.red = color.red;\n result.green = color.green;\n result.blue = color.blue;\n result.alpha = alpha;\n return result;\n};\n\nlet scratchArrayBuffer;\nlet scratchUint32Array;\nlet scratchUint8Array;\nif (FeatureDetection.supportsTypedArrays()) {\n scratchArrayBuffer = new ArrayBuffer(4);\n scratchUint32Array = new Uint32Array(scratchArrayBuffer);\n scratchUint8Array = new Uint8Array(scratchArrayBuffer);\n}\n\n/**\n * Creates a new Color from a single numeric unsigned 32-bit RGBA value, using the endianness\n * of the system.\n *\n * @param {number} rgba A single numeric unsigned 32-bit RGBA value.\n * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.\n * @returns {Color} The color object.\n *\n * @example\n * const color = Cesium.Color.fromRgba(0x67ADDFFF);\n *\n * @see Color#toRgba\n */\nColor.fromRgba = function (rgba, result) {\n // scratchUint32Array and scratchUint8Array share an underlying array buffer\n scratchUint32Array[0] = rgba;\n return Color.fromBytes(\n scratchUint8Array[0],\n scratchUint8Array[1],\n scratchUint8Array[2],\n scratchUint8Array[3],\n result\n );\n};\n\n/**\n * Creates a Color instance from hue, saturation, and lightness.\n *\n * @param {number} [hue=0] The hue angle 0...1\n * @param {number} [saturation=0] The saturation value 0...1\n * @param {number} [lightness=0] The lightness value 0...1\n * @param {number} [alpha=1.0] The alpha component 0...1\n * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.\n * @returns {Color} The color object.\n *\n * @see {@link http://www.w3.org/TR/css3-color/#hsl-color|CSS color values}\n */\nColor.fromHsl = function (hue, saturation, lightness, alpha, result) {\n hue = defaultValue(hue, 0.0) % 1.0;\n saturation = defaultValue(saturation, 0.0);\n lightness = defaultValue(lightness, 0.0);\n alpha = defaultValue(alpha, 1.0);\n\n let red = lightness;\n let green = lightness;\n let blue = lightness;\n\n if (saturation !== 0) {\n let m2;\n if (lightness < 0.5) {\n m2 = lightness * (1 + saturation);\n } else {\n m2 = lightness + saturation - lightness * saturation;\n }\n\n const m1 = 2.0 * lightness - m2;\n red = hue2rgb(m1, m2, hue + 1 / 3);\n green = hue2rgb(m1, m2, hue);\n blue = hue2rgb(m1, m2, hue - 1 / 3);\n }\n\n if (!defined(result)) {\n return new Color(red, green, blue, alpha);\n }\n\n result.red = red;\n result.green = green;\n result.blue = blue;\n result.alpha = alpha;\n return result;\n};\n\n/**\n * Creates a random color using the provided options. For reproducible random colors, you should\n * call {@link CesiumMath#setRandomNumberSeed} once at the beginning of your application.\n *\n * @param {object} [options] Object with the following properties:\n * @param {number} [options.red] If specified, the red component to use instead of a randomized value.\n * @param {number} [options.minimumRed=0.0] The maximum red value to generate if none was specified.\n * @param {number} [options.maximumRed=1.0] The minimum red value to generate if none was specified.\n * @param {number} [options.green] If specified, the green component to use instead of a randomized value.\n * @param {number} [options.minimumGreen=0.0] The maximum green value to generate if none was specified.\n * @param {number} [options.maximumGreen=1.0] The minimum green value to generate if none was specified.\n * @param {number} [options.blue] If specified, the blue component to use instead of a randomized value.\n * @param {number} [options.minimumBlue=0.0] The maximum blue value to generate if none was specified.\n * @param {number} [options.maximumBlue=1.0] The minimum blue value to generate if none was specified.\n * @param {number} [options.alpha] If specified, the alpha component to use instead of a randomized value.\n * @param {number} [options.minimumAlpha=0.0] The maximum alpha value to generate if none was specified.\n * @param {number} [options.maximumAlpha=1.0] The minimum alpha value to generate if none was specified.\n * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.\n * @returns {Color} The modified result parameter or a new instance if result was undefined.\n *\n * @exception {DeveloperError} minimumRed must be less than or equal to maximumRed.\n * @exception {DeveloperError} minimumGreen must be less than or equal to maximumGreen.\n * @exception {DeveloperError} minimumBlue must be less than or equal to maximumBlue.\n * @exception {DeveloperError} minimumAlpha must be less than or equal to maximumAlpha.\n *\n * @example\n * //Create a completely random color\n * const color = Cesium.Color.fromRandom();\n *\n * //Create a random shade of yellow.\n * const color1 = Cesium.Color.fromRandom({\n * red : 1.0,\n * green : 1.0,\n * alpha : 1.0\n * });\n *\n * //Create a random bright color.\n * const color2 = Cesium.Color.fromRandom({\n * minimumRed : 0.75,\n * minimumGreen : 0.75,\n * minimumBlue : 0.75,\n * alpha : 1.0\n * });\n */\nColor.fromRandom = function (options, result) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n let red = options.red;\n if (!defined(red)) {\n const minimumRed = defaultValue(options.minimumRed, 0);\n const maximumRed = defaultValue(options.maximumRed, 1.0);\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.lessThanOrEquals(\"minimumRed\", minimumRed, maximumRed);\n //>>includeEnd('debug');\n\n red =\n minimumRed + CesiumMath.nextRandomNumber() * (maximumRed - minimumRed);\n }\n\n let green = options.green;\n if (!defined(green)) {\n const minimumGreen = defaultValue(options.minimumGreen, 0);\n const maximumGreen = defaultValue(options.maximumGreen, 1.0);\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.lessThanOrEquals(\n \"minimumGreen\",\n minimumGreen,\n maximumGreen\n );\n //>>includeEnd('debug');\n green =\n minimumGreen +\n CesiumMath.nextRandomNumber() * (maximumGreen - minimumGreen);\n }\n\n let blue = options.blue;\n if (!defined(blue)) {\n const minimumBlue = defaultValue(options.minimumBlue, 0);\n const maximumBlue = defaultValue(options.maximumBlue, 1.0);\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.lessThanOrEquals(\n \"minimumBlue\",\n minimumBlue,\n maximumBlue\n );\n //>>includeEnd('debug');\n\n blue =\n minimumBlue + CesiumMath.nextRandomNumber() * (maximumBlue - minimumBlue);\n }\n\n let alpha = options.alpha;\n if (!defined(alpha)) {\n const minimumAlpha = defaultValue(options.minimumAlpha, 0);\n const maximumAlpha = defaultValue(options.maximumAlpha, 1.0);\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.lessThanOrEquals(\n \"minumumAlpha\",\n minimumAlpha,\n maximumAlpha\n );\n //>>includeEnd('debug');\n\n alpha =\n minimumAlpha +\n CesiumMath.nextRandomNumber() * (maximumAlpha - minimumAlpha);\n }\n\n if (!defined(result)) {\n return new Color(red, green, blue, alpha);\n }\n\n result.red = red;\n result.green = green;\n result.blue = blue;\n result.alpha = alpha;\n return result;\n};\n\n//#rgba\nconst rgbaMatcher = /^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i;\n//#rrggbbaa\nconst rrggbbaaMatcher = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;\n//rgb(), rgba(), or rgb%()\nconst rgbParenthesesMatcher = /^rgba?\\s*\\(\\s*([0-9.]+%?)\\s*[,\\s]+\\s*([0-9.]+%?)\\s*[,\\s]+\\s*([0-9.]+%?)(?:\\s*[,\\s/]+\\s*([0-9.]+))?\\s*\\)$/i;\n//hsl() or hsla()\nconst hslParenthesesMatcher = /^hsla?\\s*\\(\\s*([0-9.]+)\\s*[,\\s]+\\s*([0-9.]+%)\\s*[,\\s]+\\s*([0-9.]+%)(?:\\s*[,\\s/]+\\s*([0-9.]+))?\\s*\\)$/i;\n\n/**\n * Creates a Color instance from a CSS color value.\n *\n * @param {string} color The CSS color value in #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), or hsla() format.\n * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.\n * @returns {Color} The color object, or undefined if the string was not a valid CSS color.\n *\n *\n * @example\n * const cesiumBlue = Cesium.Color.fromCssColorString('#67ADDF');\n * const green = Cesium.Color.fromCssColorString('green');\n *\n * @see {@link http://www.w3.org/TR/css3-color|CSS color values}\n */\nColor.fromCssColorString = function (color, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.string(\"color\", color);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Color();\n }\n\n // Remove all surrounding whitespaces from the color string\n color = color.trim();\n\n const namedColor = Color[color.toUpperCase()];\n if (defined(namedColor)) {\n Color.clone(namedColor, result);\n return result;\n }\n\n let matches = rgbaMatcher.exec(color);\n if (matches !== null) {\n result.red = parseInt(matches[1], 16) / 15;\n result.green = parseInt(matches[2], 16) / 15.0;\n result.blue = parseInt(matches[3], 16) / 15.0;\n result.alpha = parseInt(defaultValue(matches[4], \"f\"), 16) / 15.0;\n return result;\n }\n\n matches = rrggbbaaMatcher.exec(color);\n if (matches !== null) {\n result.red = parseInt(matches[1], 16) / 255.0;\n result.green = parseInt(matches[2], 16) / 255.0;\n result.blue = parseInt(matches[3], 16) / 255.0;\n result.alpha = parseInt(defaultValue(matches[4], \"ff\"), 16) / 255.0;\n return result;\n }\n\n matches = rgbParenthesesMatcher.exec(color);\n if (matches !== null) {\n result.red =\n parseFloat(matches[1]) / (\"%\" === matches[1].substr(-1) ? 100.0 : 255.0);\n result.green =\n parseFloat(matches[2]) / (\"%\" === matches[2].substr(-1) ? 100.0 : 255.0);\n result.blue =\n parseFloat(matches[3]) / (\"%\" === matches[3].substr(-1) ? 100.0 : 255.0);\n result.alpha = parseFloat(defaultValue(matches[4], \"1.0\"));\n return result;\n }\n\n matches = hslParenthesesMatcher.exec(color);\n if (matches !== null) {\n return Color.fromHsl(\n parseFloat(matches[1]) / 360.0,\n parseFloat(matches[2]) / 100.0,\n parseFloat(matches[3]) / 100.0,\n parseFloat(defaultValue(matches[4], \"1.0\")),\n result\n );\n }\n\n result = undefined;\n return result;\n};\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nColor.packedLength = 4;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Color} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nColor.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n array[startingIndex++] = value.red;\n array[startingIndex++] = value.green;\n array[startingIndex++] = value.blue;\n array[startingIndex] = value.alpha;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Color} [result] The object into which to store the result.\n * @returns {Color} The modified result parameter or a new Color instance if one was not provided.\n */\nColor.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n if (!defined(result)) {\n result = new Color();\n }\n result.red = array[startingIndex++];\n result.green = array[startingIndex++];\n result.blue = array[startingIndex++];\n result.alpha = array[startingIndex];\n return result;\n};\n\n/**\n * Converts a 'byte' color component in the range of 0 to 255 into\n * a 'float' color component in the range of 0 to 1.0.\n *\n * @param {number} number The number to be converted.\n * @returns {number} The converted number.\n */\nColor.byteToFloat = function (number) {\n return number / 255.0;\n};\n\n/**\n * Converts a 'float' color component in the range of 0 to 1.0 into\n * a 'byte' color component in the range of 0 to 255.\n *\n * @param {number} number The number to be converted.\n * @returns {number} The converted number.\n */\nColor.floatToByte = function (number) {\n return number === 1.0 ? 255.0 : (number * 256.0) | 0;\n};\n\n/**\n * Duplicates a Color.\n *\n * @param {Color} color The Color to duplicate.\n * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.\n * @returns {Color} The modified result parameter or a new instance if result was undefined. (Returns undefined if color is undefined)\n */\nColor.clone = function (color, result) {\n if (!defined(color)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Color(color.red, color.green, color.blue, color.alpha);\n }\n result.red = color.red;\n result.green = color.green;\n result.blue = color.blue;\n result.alpha = color.alpha;\n return result;\n};\n\n/**\n * Returns true if the first Color equals the second color.\n *\n * @param {Color} left The first Color to compare for equality.\n * @param {Color} right The second Color to compare for equality.\n * @returns {boolean} true if the Colors are equal; otherwise, false.\n */\nColor.equals = function (left, right) {\n return (\n left === right || //\n (defined(left) && //\n defined(right) && //\n left.red === right.red && //\n left.green === right.green && //\n left.blue === right.blue && //\n left.alpha === right.alpha)\n );\n};\n\n/**\n * @private\n */\nColor.equalsArray = function (color, array, offset) {\n return (\n color.red === array[offset] &&\n color.green === array[offset + 1] &&\n color.blue === array[offset + 2] &&\n color.alpha === array[offset + 3]\n );\n};\n\n/**\n * Returns a duplicate of a Color instance.\n *\n * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.\n * @returns {Color} The modified result parameter or a new instance if result was undefined.\n */\nColor.prototype.clone = function (result) {\n return Color.clone(this, result);\n};\n\n/**\n * Returns true if this Color equals other.\n *\n * @param {Color} other The Color to compare for equality.\n * @returns {boolean} true if the Colors are equal; otherwise, false.\n */\nColor.prototype.equals = function (other) {\n return Color.equals(this, other);\n};\n\n/**\n * Returns true if this Color equals other componentwise within the specified epsilon.\n *\n * @param {Color} other The Color to compare for equality.\n * @param {number} [epsilon=0.0] The epsilon to use for equality testing.\n * @returns {boolean} true if the Colors are equal within the specified epsilon; otherwise, false.\n */\nColor.prototype.equalsEpsilon = function (other, epsilon) {\n return (\n this === other || //\n (defined(other) && //\n Math.abs(this.red - other.red) <= epsilon && //\n Math.abs(this.green - other.green) <= epsilon && //\n Math.abs(this.blue - other.blue) <= epsilon && //\n Math.abs(this.alpha - other.alpha) <= epsilon)\n );\n};\n\n/**\n * Creates a string representing this Color in the format '(red, green, blue, alpha)'.\n *\n * @returns {string} A string representing this Color in the format '(red, green, blue, alpha)'.\n */\nColor.prototype.toString = function () {\n return `(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;\n};\n\n/**\n * Creates a string containing the CSS color value for this color.\n *\n * @returns {string} The CSS equivalent of this color.\n *\n * @see {@link http://www.w3.org/TR/css3-color/#rgba-color|CSS RGB or RGBA color values}\n */\nColor.prototype.toCssColorString = function () {\n const red = Color.floatToByte(this.red);\n const green = Color.floatToByte(this.green);\n const blue = Color.floatToByte(this.blue);\n if (this.alpha === 1) {\n return `rgb(${red},${green},${blue})`;\n }\n return `rgba(${red},${green},${blue},${this.alpha})`;\n};\n\n/**\n * Creates a string containing CSS hex string color value for this color.\n *\n * @returns {string} The CSS hex string equivalent of this color.\n */\nColor.prototype.toCssHexString = function () {\n let r = Color.floatToByte(this.red).toString(16);\n if (r.length < 2) {\n r = `0${r}`;\n }\n let g = Color.floatToByte(this.green).toString(16);\n if (g.length < 2) {\n g = `0${g}`;\n }\n let b = Color.floatToByte(this.blue).toString(16);\n if (b.length < 2) {\n b = `0${b}`;\n }\n if (this.alpha < 1) {\n let hexAlpha = Color.floatToByte(this.alpha).toString(16);\n if (hexAlpha.length < 2) {\n hexAlpha = `0${hexAlpha}`;\n }\n return `#${r}${g}${b}${hexAlpha}`;\n }\n return `#${r}${g}${b}`;\n};\n\n/**\n * Converts this color to an array of red, green, blue, and alpha values\n * that are in the range of 0 to 255.\n *\n * @param {number[]} [result] The array to store the result in, if undefined a new instance will be created.\n * @returns {number[]} The modified result parameter or a new instance if result was undefined.\n */\nColor.prototype.toBytes = function (result) {\n const red = Color.floatToByte(this.red);\n const green = Color.floatToByte(this.green);\n const blue = Color.floatToByte(this.blue);\n const alpha = Color.floatToByte(this.alpha);\n\n if (!defined(result)) {\n return [red, green, blue, alpha];\n }\n result[0] = red;\n result[1] = green;\n result[2] = blue;\n result[3] = alpha;\n return result;\n};\n\n/**\n * Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness\n * of the system.\n *\n * @returns {number} A single numeric unsigned 32-bit RGBA value.\n *\n *\n * @example\n * const rgba = Cesium.Color.BLUE.toRgba();\n *\n * @see Color.fromRgba\n */\nColor.prototype.toRgba = function () {\n // scratchUint32Array and scratchUint8Array share an underlying array buffer\n scratchUint8Array[0] = Color.floatToByte(this.red);\n scratchUint8Array[1] = Color.floatToByte(this.green);\n scratchUint8Array[2] = Color.floatToByte(this.blue);\n scratchUint8Array[3] = Color.floatToByte(this.alpha);\n return scratchUint32Array[0];\n};\n\n/**\n * Brightens this color by the provided magnitude.\n *\n * @param {number} magnitude A positive number indicating the amount to brighten.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n *\n * @example\n * const brightBlue = Cesium.Color.BLUE.brighten(0.5, new Cesium.Color());\n */\nColor.prototype.brighten = function (magnitude, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"magnitude\", magnitude);\n Check.typeOf.number.greaterThanOrEquals(\"magnitude\", magnitude, 0.0);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n magnitude = 1.0 - magnitude;\n result.red = 1.0 - (1.0 - this.red) * magnitude;\n result.green = 1.0 - (1.0 - this.green) * magnitude;\n result.blue = 1.0 - (1.0 - this.blue) * magnitude;\n result.alpha = this.alpha;\n return result;\n};\n\n/**\n * Darkens this color by the provided magnitude.\n *\n * @param {number} magnitude A positive number indicating the amount to darken.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n *\n * @example\n * const darkBlue = Cesium.Color.BLUE.darken(0.5, new Cesium.Color());\n */\nColor.prototype.darken = function (magnitude, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"magnitude\", magnitude);\n Check.typeOf.number.greaterThanOrEquals(\"magnitude\", magnitude, 0.0);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n magnitude = 1.0 - magnitude;\n result.red = this.red * magnitude;\n result.green = this.green * magnitude;\n result.blue = this.blue * magnitude;\n result.alpha = this.alpha;\n return result;\n};\n\n/**\n * Creates a new Color that has the same red, green, and blue components\n * as this Color, but with the specified alpha value.\n *\n * @param {number} alpha The new alpha component.\n * @param {Color} [result] The object onto which to store the result.\n * @returns {Color} The modified result parameter or a new Color instance if one was not provided.\n *\n * @example const translucentRed = Cesium.Color.RED.withAlpha(0.9);\n */\nColor.prototype.withAlpha = function (alpha, result) {\n return Color.fromAlpha(this, alpha, result);\n};\n\n/**\n * Computes the componentwise sum of two Colors.\n *\n * @param {Color} left The first Color.\n * @param {Color} right The second Color.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = left.red + right.red;\n result.green = left.green + right.green;\n result.blue = left.blue + right.blue;\n result.alpha = left.alpha + right.alpha;\n return result;\n};\n\n/**\n * Computes the componentwise difference of two Colors.\n *\n * @param {Color} left The first Color.\n * @param {Color} right The second Color.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = left.red - right.red;\n result.green = left.green - right.green;\n result.blue = left.blue - right.blue;\n result.alpha = left.alpha - right.alpha;\n return result;\n};\n\n/**\n * Computes the componentwise product of two Colors.\n *\n * @param {Color} left The first Color.\n * @param {Color} right The second Color.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.multiply = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = left.red * right.red;\n result.green = left.green * right.green;\n result.blue = left.blue * right.blue;\n result.alpha = left.alpha * right.alpha;\n return result;\n};\n\n/**\n * Computes the componentwise quotient of two Colors.\n *\n * @param {Color} left The first Color.\n * @param {Color} right The second Color.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.divide = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = left.red / right.red;\n result.green = left.green / right.green;\n result.blue = left.blue / right.blue;\n result.alpha = left.alpha / right.alpha;\n return result;\n};\n\n/**\n * Computes the componentwise modulus of two Colors.\n *\n * @param {Color} left The first Color.\n * @param {Color} right The second Color.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.mod = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = left.red % right.red;\n result.green = left.green % right.green;\n result.blue = left.blue % right.blue;\n result.alpha = left.alpha % right.alpha;\n return result;\n};\n\n/**\n * Computes the linear interpolation or extrapolation at t between the provided colors.\n *\n * @param {Color} start The color corresponding to t at 0.0.\n * @param {Color} end The color corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.lerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = CesiumMath.lerp(start.red, end.red, t);\n result.green = CesiumMath.lerp(start.green, end.green, t);\n result.blue = CesiumMath.lerp(start.blue, end.blue, t);\n result.alpha = CesiumMath.lerp(start.alpha, end.alpha, t);\n return result;\n};\n\n/**\n * Multiplies the provided Color componentwise by the provided scalar.\n *\n * @param {Color} color The Color to be scaled.\n * @param {number} scalar The scalar to multiply with.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.multiplyByScalar = function (color, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"color\", color);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = color.red * scalar;\n result.green = color.green * scalar;\n result.blue = color.blue * scalar;\n result.alpha = color.alpha * scalar;\n return result;\n};\n\n/**\n * Divides the provided Color componentwise by the provided scalar.\n *\n * @param {Color} color The Color to be divided.\n * @param {number} scalar The scalar to divide with.\n * @param {Color} result The object onto which to store the result.\n * @returns {Color} The modified result parameter.\n */\nColor.divideByScalar = function (color, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"color\", color);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.red = color.red / scalar;\n result.green = color.green / scalar;\n result.blue = color.blue / scalar;\n result.alpha = color.alpha / scalar;\n return result;\n};\n\n/**\n * An immutable Color instance initialized to CSS color #F0F8FF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ALICEBLUE = Object.freeze(Color.fromCssColorString(\"#F0F8FF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FAEBD7\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ANTIQUEWHITE = Object.freeze(Color.fromCssColorString(\"#FAEBD7\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00FFFF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.AQUA = Object.freeze(Color.fromCssColorString(\"#00FFFF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #7FFFD4\n * \n *\n * @constant\n * @type {Color}\n */\nColor.AQUAMARINE = Object.freeze(Color.fromCssColorString(\"#7FFFD4\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F0FFFF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.AZURE = Object.freeze(Color.fromCssColorString(\"#F0FFFF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F5F5DC\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BEIGE = Object.freeze(Color.fromCssColorString(\"#F5F5DC\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFE4C4\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BISQUE = Object.freeze(Color.fromCssColorString(\"#FFE4C4\"));\n\n/**\n * An immutable Color instance initialized to CSS color #000000\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BLACK = Object.freeze(Color.fromCssColorString(\"#000000\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFEBCD\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BLANCHEDALMOND = Object.freeze(Color.fromCssColorString(\"#FFEBCD\"));\n\n/**\n * An immutable Color instance initialized to CSS color #0000FF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BLUE = Object.freeze(Color.fromCssColorString(\"#0000FF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #8A2BE2\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BLUEVIOLET = Object.freeze(Color.fromCssColorString(\"#8A2BE2\"));\n\n/**\n * An immutable Color instance initialized to CSS color #A52A2A\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BROWN = Object.freeze(Color.fromCssColorString(\"#A52A2A\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DEB887\n * \n *\n * @constant\n * @type {Color}\n */\nColor.BURLYWOOD = Object.freeze(Color.fromCssColorString(\"#DEB887\"));\n\n/**\n * An immutable Color instance initialized to CSS color #5F9EA0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CADETBLUE = Object.freeze(Color.fromCssColorString(\"#5F9EA0\"));\n/**\n * An immutable Color instance initialized to CSS color #7FFF00\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CHARTREUSE = Object.freeze(Color.fromCssColorString(\"#7FFF00\"));\n\n/**\n * An immutable Color instance initialized to CSS color #D2691E\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CHOCOLATE = Object.freeze(Color.fromCssColorString(\"#D2691E\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF7F50\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CORAL = Object.freeze(Color.fromCssColorString(\"#FF7F50\"));\n\n/**\n * An immutable Color instance initialized to CSS color #6495ED\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CORNFLOWERBLUE = Object.freeze(Color.fromCssColorString(\"#6495ED\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFF8DC\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CORNSILK = Object.freeze(Color.fromCssColorString(\"#FFF8DC\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DC143C\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CRIMSON = Object.freeze(Color.fromCssColorString(\"#DC143C\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00FFFF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.CYAN = Object.freeze(Color.fromCssColorString(\"#00FFFF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00008B\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKBLUE = Object.freeze(Color.fromCssColorString(\"#00008B\"));\n\n/**\n * An immutable Color instance initialized to CSS color #008B8B\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKCYAN = Object.freeze(Color.fromCssColorString(\"#008B8B\"));\n\n/**\n * An immutable Color instance initialized to CSS color #B8860B\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKGOLDENROD = Object.freeze(Color.fromCssColorString(\"#B8860B\"));\n\n/**\n * An immutable Color instance initialized to CSS color #A9A9A9\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKGRAY = Object.freeze(Color.fromCssColorString(\"#A9A9A9\"));\n\n/**\n * An immutable Color instance initialized to CSS color #006400\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKGREEN = Object.freeze(Color.fromCssColorString(\"#006400\"));\n\n/**\n * An immutable Color instance initialized to CSS color #A9A9A9\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKGREY = Color.DARKGRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #BDB76B\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKKHAKI = Object.freeze(Color.fromCssColorString(\"#BDB76B\"));\n\n/**\n * An immutable Color instance initialized to CSS color #8B008B\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKMAGENTA = Object.freeze(Color.fromCssColorString(\"#8B008B\"));\n\n/**\n * An immutable Color instance initialized to CSS color #556B2F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKOLIVEGREEN = Object.freeze(Color.fromCssColorString(\"#556B2F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF8C00\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKORANGE = Object.freeze(Color.fromCssColorString(\"#FF8C00\"));\n\n/**\n * An immutable Color instance initialized to CSS color #9932CC\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKORCHID = Object.freeze(Color.fromCssColorString(\"#9932CC\"));\n\n/**\n * An immutable Color instance initialized to CSS color #8B0000\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKRED = Object.freeze(Color.fromCssColorString(\"#8B0000\"));\n\n/**\n * An immutable Color instance initialized to CSS color #E9967A\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKSALMON = Object.freeze(Color.fromCssColorString(\"#E9967A\"));\n\n/**\n * An immutable Color instance initialized to CSS color #8FBC8F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKSEAGREEN = Object.freeze(Color.fromCssColorString(\"#8FBC8F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #483D8B\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKSLATEBLUE = Object.freeze(Color.fromCssColorString(\"#483D8B\"));\n\n/**\n * An immutable Color instance initialized to CSS color #2F4F4F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKSLATEGRAY = Object.freeze(Color.fromCssColorString(\"#2F4F4F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #2F4F4F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKSLATEGREY = Color.DARKSLATEGRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #00CED1\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKTURQUOISE = Object.freeze(Color.fromCssColorString(\"#00CED1\"));\n\n/**\n * An immutable Color instance initialized to CSS color #9400D3\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DARKVIOLET = Object.freeze(Color.fromCssColorString(\"#9400D3\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF1493\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DEEPPINK = Object.freeze(Color.fromCssColorString(\"#FF1493\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00BFFF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DEEPSKYBLUE = Object.freeze(Color.fromCssColorString(\"#00BFFF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #696969\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DIMGRAY = Object.freeze(Color.fromCssColorString(\"#696969\"));\n\n/**\n * An immutable Color instance initialized to CSS color #696969\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DIMGREY = Color.DIMGRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #1E90FF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.DODGERBLUE = Object.freeze(Color.fromCssColorString(\"#1E90FF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #B22222\n * \n *\n * @constant\n * @type {Color}\n */\nColor.FIREBRICK = Object.freeze(Color.fromCssColorString(\"#B22222\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFFAF0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.FLORALWHITE = Object.freeze(Color.fromCssColorString(\"#FFFAF0\"));\n\n/**\n * An immutable Color instance initialized to CSS color #228B22\n * \n *\n * @constant\n * @type {Color}\n */\nColor.FORESTGREEN = Object.freeze(Color.fromCssColorString(\"#228B22\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF00FF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.FUCHSIA = Object.freeze(Color.fromCssColorString(\"#FF00FF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DCDCDC\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GAINSBORO = Object.freeze(Color.fromCssColorString(\"#DCDCDC\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F8F8FF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GHOSTWHITE = Object.freeze(Color.fromCssColorString(\"#F8F8FF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFD700\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GOLD = Object.freeze(Color.fromCssColorString(\"#FFD700\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DAA520\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GOLDENROD = Object.freeze(Color.fromCssColorString(\"#DAA520\"));\n\n/**\n * An immutable Color instance initialized to CSS color #808080\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GRAY = Object.freeze(Color.fromCssColorString(\"#808080\"));\n\n/**\n * An immutable Color instance initialized to CSS color #008000\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GREEN = Object.freeze(Color.fromCssColorString(\"#008000\"));\n\n/**\n * An immutable Color instance initialized to CSS color #ADFF2F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GREENYELLOW = Object.freeze(Color.fromCssColorString(\"#ADFF2F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #808080\n * \n *\n * @constant\n * @type {Color}\n */\nColor.GREY = Color.GRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #F0FFF0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.HONEYDEW = Object.freeze(Color.fromCssColorString(\"#F0FFF0\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF69B4\n * \n *\n * @constant\n * @type {Color}\n */\nColor.HOTPINK = Object.freeze(Color.fromCssColorString(\"#FF69B4\"));\n\n/**\n * An immutable Color instance initialized to CSS color #CD5C5C\n * \n *\n * @constant\n * @type {Color}\n */\nColor.INDIANRED = Object.freeze(Color.fromCssColorString(\"#CD5C5C\"));\n\n/**\n * An immutable Color instance initialized to CSS color #4B0082\n * \n *\n * @constant\n * @type {Color}\n */\nColor.INDIGO = Object.freeze(Color.fromCssColorString(\"#4B0082\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFFFF0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.IVORY = Object.freeze(Color.fromCssColorString(\"#FFFFF0\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F0E68C\n * \n *\n * @constant\n * @type {Color}\n */\nColor.KHAKI = Object.freeze(Color.fromCssColorString(\"#F0E68C\"));\n\n/**\n * An immutable Color instance initialized to CSS color #E6E6FA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LAVENDER = Object.freeze(Color.fromCssColorString(\"#E6E6FA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFF0F5\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LAVENDAR_BLUSH = Object.freeze(Color.fromCssColorString(\"#FFF0F5\"));\n\n/**\n * An immutable Color instance initialized to CSS color #7CFC00\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LAWNGREEN = Object.freeze(Color.fromCssColorString(\"#7CFC00\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFFACD\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LEMONCHIFFON = Object.freeze(Color.fromCssColorString(\"#FFFACD\"));\n\n/**\n * An immutable Color instance initialized to CSS color #ADD8E6\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTBLUE = Object.freeze(Color.fromCssColorString(\"#ADD8E6\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F08080\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTCORAL = Object.freeze(Color.fromCssColorString(\"#F08080\"));\n\n/**\n * An immutable Color instance initialized to CSS color #E0FFFF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTCYAN = Object.freeze(Color.fromCssColorString(\"#E0FFFF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FAFAD2\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTGOLDENRODYELLOW = Object.freeze(Color.fromCssColorString(\"#FAFAD2\"));\n\n/**\n * An immutable Color instance initialized to CSS color #D3D3D3\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTGRAY = Object.freeze(Color.fromCssColorString(\"#D3D3D3\"));\n\n/**\n * An immutable Color instance initialized to CSS color #90EE90\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTGREEN = Object.freeze(Color.fromCssColorString(\"#90EE90\"));\n\n/**\n * An immutable Color instance initialized to CSS color #D3D3D3\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTGREY = Color.LIGHTGRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #FFB6C1\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTPINK = Object.freeze(Color.fromCssColorString(\"#FFB6C1\"));\n\n/**\n * An immutable Color instance initialized to CSS color #20B2AA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTSEAGREEN = Object.freeze(Color.fromCssColorString(\"#20B2AA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #87CEFA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTSKYBLUE = Object.freeze(Color.fromCssColorString(\"#87CEFA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #778899\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTSLATEGRAY = Object.freeze(Color.fromCssColorString(\"#778899\"));\n\n/**\n * An immutable Color instance initialized to CSS color #778899\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTSLATEGREY = Color.LIGHTSLATEGRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #B0C4DE\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTSTEELBLUE = Object.freeze(Color.fromCssColorString(\"#B0C4DE\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFFFE0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIGHTYELLOW = Object.freeze(Color.fromCssColorString(\"#FFFFE0\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00FF00\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIME = Object.freeze(Color.fromCssColorString(\"#00FF00\"));\n\n/**\n * An immutable Color instance initialized to CSS color #32CD32\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LIMEGREEN = Object.freeze(Color.fromCssColorString(\"#32CD32\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FAF0E6\n * \n *\n * @constant\n * @type {Color}\n */\nColor.LINEN = Object.freeze(Color.fromCssColorString(\"#FAF0E6\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF00FF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MAGENTA = Object.freeze(Color.fromCssColorString(\"#FF00FF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #800000\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MAROON = Object.freeze(Color.fromCssColorString(\"#800000\"));\n\n/**\n * An immutable Color instance initialized to CSS color #66CDAA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMAQUAMARINE = Object.freeze(Color.fromCssColorString(\"#66CDAA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #0000CD\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMBLUE = Object.freeze(Color.fromCssColorString(\"#0000CD\"));\n\n/**\n * An immutable Color instance initialized to CSS color #BA55D3\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMORCHID = Object.freeze(Color.fromCssColorString(\"#BA55D3\"));\n\n/**\n * An immutable Color instance initialized to CSS color #9370DB\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMPURPLE = Object.freeze(Color.fromCssColorString(\"#9370DB\"));\n\n/**\n * An immutable Color instance initialized to CSS color #3CB371\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMSEAGREEN = Object.freeze(Color.fromCssColorString(\"#3CB371\"));\n\n/**\n * An immutable Color instance initialized to CSS color #7B68EE\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMSLATEBLUE = Object.freeze(Color.fromCssColorString(\"#7B68EE\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00FA9A\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMSPRINGGREEN = Object.freeze(Color.fromCssColorString(\"#00FA9A\"));\n\n/**\n * An immutable Color instance initialized to CSS color #48D1CC\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMTURQUOISE = Object.freeze(Color.fromCssColorString(\"#48D1CC\"));\n\n/**\n * An immutable Color instance initialized to CSS color #C71585\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MEDIUMVIOLETRED = Object.freeze(Color.fromCssColorString(\"#C71585\"));\n\n/**\n * An immutable Color instance initialized to CSS color #191970\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MIDNIGHTBLUE = Object.freeze(Color.fromCssColorString(\"#191970\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F5FFFA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MINTCREAM = Object.freeze(Color.fromCssColorString(\"#F5FFFA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFE4E1\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MISTYROSE = Object.freeze(Color.fromCssColorString(\"#FFE4E1\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFE4B5\n * \n *\n * @constant\n * @type {Color}\n */\nColor.MOCCASIN = Object.freeze(Color.fromCssColorString(\"#FFE4B5\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFDEAD\n * \n *\n * @constant\n * @type {Color}\n */\nColor.NAVAJOWHITE = Object.freeze(Color.fromCssColorString(\"#FFDEAD\"));\n\n/**\n * An immutable Color instance initialized to CSS color #000080\n * \n *\n * @constant\n * @type {Color}\n */\nColor.NAVY = Object.freeze(Color.fromCssColorString(\"#000080\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FDF5E6\n * \n *\n * @constant\n * @type {Color}\n */\nColor.OLDLACE = Object.freeze(Color.fromCssColorString(\"#FDF5E6\"));\n\n/**\n * An immutable Color instance initialized to CSS color #808000\n * \n *\n * @constant\n * @type {Color}\n */\nColor.OLIVE = Object.freeze(Color.fromCssColorString(\"#808000\"));\n\n/**\n * An immutable Color instance initialized to CSS color #6B8E23\n * \n *\n * @constant\n * @type {Color}\n */\nColor.OLIVEDRAB = Object.freeze(Color.fromCssColorString(\"#6B8E23\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFA500\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ORANGE = Object.freeze(Color.fromCssColorString(\"#FFA500\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF4500\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ORANGERED = Object.freeze(Color.fromCssColorString(\"#FF4500\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DA70D6\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ORCHID = Object.freeze(Color.fromCssColorString(\"#DA70D6\"));\n\n/**\n * An immutable Color instance initialized to CSS color #EEE8AA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PALEGOLDENROD = Object.freeze(Color.fromCssColorString(\"#EEE8AA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #98FB98\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PALEGREEN = Object.freeze(Color.fromCssColorString(\"#98FB98\"));\n\n/**\n * An immutable Color instance initialized to CSS color #AFEEEE\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PALETURQUOISE = Object.freeze(Color.fromCssColorString(\"#AFEEEE\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DB7093\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PALEVIOLETRED = Object.freeze(Color.fromCssColorString(\"#DB7093\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFEFD5\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PAPAYAWHIP = Object.freeze(Color.fromCssColorString(\"#FFEFD5\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFDAB9\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PEACHPUFF = Object.freeze(Color.fromCssColorString(\"#FFDAB9\"));\n\n/**\n * An immutable Color instance initialized to CSS color #CD853F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PERU = Object.freeze(Color.fromCssColorString(\"#CD853F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFC0CB\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PINK = Object.freeze(Color.fromCssColorString(\"#FFC0CB\"));\n\n/**\n * An immutable Color instance initialized to CSS color #DDA0DD\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PLUM = Object.freeze(Color.fromCssColorString(\"#DDA0DD\"));\n\n/**\n * An immutable Color instance initialized to CSS color #B0E0E6\n * \n *\n * @constant\n * @type {Color}\n */\nColor.POWDERBLUE = Object.freeze(Color.fromCssColorString(\"#B0E0E6\"));\n\n/**\n * An immutable Color instance initialized to CSS color #800080\n * \n *\n * @constant\n * @type {Color}\n */\nColor.PURPLE = Object.freeze(Color.fromCssColorString(\"#800080\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF0000\n * \n *\n * @constant\n * @type {Color}\n */\nColor.RED = Object.freeze(Color.fromCssColorString(\"#FF0000\"));\n\n/**\n * An immutable Color instance initialized to CSS color #BC8F8F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ROSYBROWN = Object.freeze(Color.fromCssColorString(\"#BC8F8F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #4169E1\n * \n *\n * @constant\n * @type {Color}\n */\nColor.ROYALBLUE = Object.freeze(Color.fromCssColorString(\"#4169E1\"));\n\n/**\n * An immutable Color instance initialized to CSS color #8B4513\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SADDLEBROWN = Object.freeze(Color.fromCssColorString(\"#8B4513\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FA8072\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SALMON = Object.freeze(Color.fromCssColorString(\"#FA8072\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F4A460\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SANDYBROWN = Object.freeze(Color.fromCssColorString(\"#F4A460\"));\n\n/**\n * An immutable Color instance initialized to CSS color #2E8B57\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SEAGREEN = Object.freeze(Color.fromCssColorString(\"#2E8B57\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFF5EE\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SEASHELL = Object.freeze(Color.fromCssColorString(\"#FFF5EE\"));\n\n/**\n * An immutable Color instance initialized to CSS color #A0522D\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SIENNA = Object.freeze(Color.fromCssColorString(\"#A0522D\"));\n\n/**\n * An immutable Color instance initialized to CSS color #C0C0C0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SILVER = Object.freeze(Color.fromCssColorString(\"#C0C0C0\"));\n\n/**\n * An immutable Color instance initialized to CSS color #87CEEB\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SKYBLUE = Object.freeze(Color.fromCssColorString(\"#87CEEB\"));\n\n/**\n * An immutable Color instance initialized to CSS color #6A5ACD\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SLATEBLUE = Object.freeze(Color.fromCssColorString(\"#6A5ACD\"));\n\n/**\n * An immutable Color instance initialized to CSS color #708090\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SLATEGRAY = Object.freeze(Color.fromCssColorString(\"#708090\"));\n\n/**\n * An immutable Color instance initialized to CSS color #708090\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SLATEGREY = Color.SLATEGRAY;\n\n/**\n * An immutable Color instance initialized to CSS color #FFFAFA\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SNOW = Object.freeze(Color.fromCssColorString(\"#FFFAFA\"));\n\n/**\n * An immutable Color instance initialized to CSS color #00FF7F\n * \n *\n * @constant\n * @type {Color}\n */\nColor.SPRINGGREEN = Object.freeze(Color.fromCssColorString(\"#00FF7F\"));\n\n/**\n * An immutable Color instance initialized to CSS color #4682B4\n * \n *\n * @constant\n * @type {Color}\n */\nColor.STEELBLUE = Object.freeze(Color.fromCssColorString(\"#4682B4\"));\n\n/**\n * An immutable Color instance initialized to CSS color #D2B48C\n * \n *\n * @constant\n * @type {Color}\n */\nColor.TAN = Object.freeze(Color.fromCssColorString(\"#D2B48C\"));\n\n/**\n * An immutable Color instance initialized to CSS color #008080\n * \n *\n * @constant\n * @type {Color}\n */\nColor.TEAL = Object.freeze(Color.fromCssColorString(\"#008080\"));\n\n/**\n * An immutable Color instance initialized to CSS color #D8BFD8\n * \n *\n * @constant\n * @type {Color}\n */\nColor.THISTLE = Object.freeze(Color.fromCssColorString(\"#D8BFD8\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FF6347\n * \n *\n * @constant\n * @type {Color}\n */\nColor.TOMATO = Object.freeze(Color.fromCssColorString(\"#FF6347\"));\n\n/**\n * An immutable Color instance initialized to CSS color #40E0D0\n * \n *\n * @constant\n * @type {Color}\n */\nColor.TURQUOISE = Object.freeze(Color.fromCssColorString(\"#40E0D0\"));\n\n/**\n * An immutable Color instance initialized to CSS color #EE82EE\n * \n *\n * @constant\n * @type {Color}\n */\nColor.VIOLET = Object.freeze(Color.fromCssColorString(\"#EE82EE\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F5DEB3\n * \n *\n * @constant\n * @type {Color}\n */\nColor.WHEAT = Object.freeze(Color.fromCssColorString(\"#F5DEB3\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFFFFF\n * \n *\n * @constant\n * @type {Color}\n */\nColor.WHITE = Object.freeze(Color.fromCssColorString(\"#FFFFFF\"));\n\n/**\n * An immutable Color instance initialized to CSS color #F5F5F5\n * \n *\n * @constant\n * @type {Color}\n */\nColor.WHITESMOKE = Object.freeze(Color.fromCssColorString(\"#F5F5F5\"));\n\n/**\n * An immutable Color instance initialized to CSS color #FFFF00\n * \n *\n * @constant\n * @type {Color}\n */\nColor.YELLOW = Object.freeze(Color.fromCssColorString(\"#FFFF00\"));\n\n/**\n * An immutable Color instance initialized to CSS color #9ACD32\n * \n *\n * @constant\n * @type {Color}\n */\nColor.YELLOWGREEN = Object.freeze(Color.fromCssColorString(\"#9ACD32\"));\n\n/**\n * An immutable Color instance initialized to CSS transparent.\n * \n *\n * @constant\n * @type {Color}\n */\nColor.TRANSPARENT = Object.freeze(new Color(0, 0, 0, 0));\nexport default Color;\n", "import Color from \"../Core/Color.js\";\nimport defaultValue from \"../Core/defaultValue.js\";\n\n/**\n * Represents a command to the renderer for clearing a framebuffer.\n *\n * @private\n * @constructor\n */\nfunction ClearCommand(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n /**\n * The value to clear the color buffer to. When undefined, the color buffer is not cleared.\n *\n * @type {Color}\n *\n * @default undefined\n */\n this.color = options.color;\n\n /**\n * The value to clear the depth buffer to. When undefined, the depth buffer is not cleared.\n *\n * @type {number}\n *\n * @default undefined\n */\n this.depth = options.depth;\n\n /**\n * The value to clear the stencil buffer to. When undefined, the stencil buffer is not cleared.\n *\n * @type {number}\n *\n * @default undefined\n */\n this.stencil = options.stencil;\n\n /**\n * The render state to apply when executing the clear command. The following states affect clearing:\n * scissor test, color mask, depth mask, and stencil mask. When the render state is\n * undefined, the default render state is used.\n *\n * @type {RenderState}\n *\n * @default undefined\n */\n this.renderState = options.renderState;\n\n /**\n * The framebuffer to clear.\n *\n * @type {Framebuffer}\n *\n * @default undefined\n */\n this.framebuffer = options.framebuffer;\n\n /**\n * The object who created this command. This is useful for debugging command\n * execution; it allows you to see who created a command when you only have a\n * reference to the command, and can be used to selectively execute commands\n * with {@link Scene#debugCommandFilter}.\n *\n * @type {object}\n *\n * @default undefined\n *\n * @see Scene#debugCommandFilter\n */\n this.owner = options.owner;\n\n /**\n * The pass in which to run this command.\n *\n * @type {Pass}\n *\n * @default undefined\n */\n this.pass = options.pass;\n}\n\n/**\n * Clears color to (0.0, 0.0, 0.0, 0.0); depth to 1.0; and stencil to 0.\n *\n * @type {ClearCommand}\n *\n * @constant\n */\nClearCommand.ALL = Object.freeze(\n new ClearCommand({\n color: new Color(0.0, 0.0, 0.0, 0.0),\n depth: 1.0,\n stencil: 0.0,\n })\n);\n\nClearCommand.prototype.execute = function (context, passState) {\n context.clear(this, passState);\n};\nexport default ClearCommand;\n", "/**\n * The render pass for a command.\n *\n * @private\n */\nconst Pass = {\n // If you add/modify/remove Pass constants, also change the automatic GLSL constants\n // that start with 'czm_pass'\n //\n // Commands are executed in order by pass up to the translucent pass.\n // Translucent geometry needs special handling (sorting/OIT). The compute pass\n // is executed first and the overlay pass is executed last. Both are not sorted\n // by frustum.\n ENVIRONMENT: 0,\n COMPUTE: 1,\n GLOBE: 2,\n TERRAIN_CLASSIFICATION: 3,\n CESIUM_3D_TILE: 4,\n CESIUM_3D_TILE_CLASSIFICATION: 5,\n CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW: 6,\n OPAQUE: 7,\n TRANSLUCENT: 8,\n VOXELS: 9,\n OVERLAY: 10,\n NUMBER_OF_PASSES: 11,\n};\nexport default Object.freeze(Pass);\n", "import defaultValue from \"../Core/defaultValue.js\";\nimport Pass from \"./Pass.js\";\n\n/**\n * Represents a command to the renderer for GPU Compute (using old-school GPGPU).\n *\n * @private\n * @constructor\n */\nfunction ComputeCommand(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n /**\n * The vertex array. If none is provided, a viewport quad will be used.\n *\n * @type {VertexArray}\n * @default undefined\n */\n this.vertexArray = options.vertexArray;\n\n /**\n * The fragment shader source. The default vertex shader is ViewportQuadVS.\n *\n * @type {ShaderSource}\n * @default undefined\n */\n this.fragmentShaderSource = options.fragmentShaderSource;\n\n /**\n * The shader program to apply.\n *\n * @type {ShaderProgram}\n * @default undefined\n */\n this.shaderProgram = options.shaderProgram;\n\n /**\n * An object with functions whose names match the uniforms in the shader program\n * and return values to set those uniforms.\n *\n * @type {object}\n * @default undefined\n */\n this.uniformMap = options.uniformMap;\n\n /**\n * Texture to use for offscreen rendering.\n *\n * @type {Texture}\n * @default undefined\n */\n this.outputTexture = options.outputTexture;\n\n /**\n * Function that is called immediately before the ComputeCommand is executed. Used to\n * update any renderer resources. Takes the ComputeCommand as its single argument.\n *\n * @type {Function}\n * @default undefined\n */\n this.preExecute = options.preExecute;\n\n /**\n * Function that is called after the ComputeCommand is executed. Takes the output\n * texture as its single argument.\n *\n * @type {Function}\n * @default undefined\n */\n this.postExecute = options.postExecute;\n\n /**\n * Function that is called when the command is canceled\n *\n * @type {Function}\n * @default undefined\n */\n this.canceled = options.canceled;\n\n /**\n * Whether the renderer resources will persist beyond this call. If not, they\n * will be destroyed after completion.\n *\n * @type {boolean}\n * @default false\n */\n this.persists = defaultValue(options.persists, false);\n\n /**\n * The pass when to render. Always compute pass.\n *\n * @type {Pass}\n * @default Pass.COMPUTE;\n */\n this.pass = Pass.COMPUTE;\n\n /**\n * The object who created this command. This is useful for debugging command\n * execution; it allows us to see who created a command when we only have a\n * reference to the command, and can be used to selectively execute commands\n * with {@link Scene#debugCommandFilter}.\n *\n * @type {object}\n * @default undefined\n *\n * @see Scene#debugCommandFilter\n */\n this.owner = options.owner;\n}\n\n/**\n * Executes the compute command.\n *\n * @param {ComputeEngine} computeEngine The context that processes the compute command.\n */\nComputeCommand.prototype.execute = function (computeEngine) {\n computeEngine.execute(this);\n};\nexport default ComputeCommand;\n", "import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\n\n/**\n * A 2D Cartesian point.\n * @alias Cartesian2\n * @constructor\n *\n * @param {number} [x=0.0] The X component.\n * @param {number} [y=0.0] The Y component.\n *\n * @see Cartesian3\n * @see Cartesian4\n * @see Packable\n */\nfunction Cartesian2(x, y) {\n /**\n * The X component.\n * @type {number}\n * @default 0.0\n */\n this.x = defaultValue(x, 0.0);\n\n /**\n * The Y component.\n * @type {number}\n * @default 0.0\n */\n this.y = defaultValue(y, 0.0);\n}\n\n/**\n * Creates a Cartesian2 instance from x and y coordinates.\n *\n * @param {number} x The x coordinate.\n * @param {number} y The y coordinate.\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.\n */\nCartesian2.fromElements = function (x, y, result) {\n if (!defined(result)) {\n return new Cartesian2(x, y);\n }\n\n result.x = x;\n result.y = y;\n return result;\n};\n\n/**\n * Duplicates a Cartesian2 instance.\n *\n * @param {Cartesian2} cartesian The Cartesian to duplicate.\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. (Returns undefined if cartesian is undefined)\n */\nCartesian2.clone = function (cartesian, result) {\n if (!defined(cartesian)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Cartesian2(cartesian.x, cartesian.y);\n }\n\n result.x = cartesian.x;\n result.y = cartesian.y;\n return result;\n};\n\n/**\n * Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the\n * x and y properties of the Cartesian3 and drops z.\n * @function\n *\n * @param {Cartesian3} cartesian The Cartesian3 instance to create a Cartesian2 instance from.\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.\n */\nCartesian2.fromCartesian3 = Cartesian2.clone;\n\n/**\n * Creates a Cartesian2 instance from an existing Cartesian4. This simply takes the\n * x and y properties of the Cartesian4 and drops z and w.\n * @function\n *\n * @param {Cartesian4} cartesian The Cartesian4 instance to create a Cartesian2 instance from.\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.\n */\nCartesian2.fromCartesian4 = Cartesian2.clone;\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nCartesian2.packedLength = 2;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Cartesian2} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nCartesian2.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value.x;\n array[startingIndex] = value.y;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Cartesian2} [result] The object into which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.\n */\nCartesian2.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Cartesian2();\n }\n result.x = array[startingIndex++];\n result.y = array[startingIndex];\n return result;\n};\n\n/**\n * Flattens an array of Cartesian2s into an array of components.\n *\n * @param {Cartesian2[]} array The array of cartesians to pack.\n * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 2 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.\n * @returns {number[]} The packed array.\n */\nCartesian2.packArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n const length = array.length;\n const resultLength = length * 2;\n if (!defined(result)) {\n result = new Array(resultLength);\n } else if (!Array.isArray(result) && result.length !== resultLength) {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"If result is a typed array, it must have exactly array.length * 2 elements\"\n );\n //>>includeEnd('debug');\n } else if (result.length !== resultLength) {\n result.length = resultLength;\n }\n\n for (let i = 0; i < length; ++i) {\n Cartesian2.pack(array[i], result, i * 2);\n }\n return result;\n};\n\n/**\n * Unpacks an array of cartesian components into an array of Cartesian2s.\n *\n * @param {number[]} array The array of components to unpack.\n * @param {Cartesian2[]} [result] The array onto which to store the result.\n * @returns {Cartesian2[]} The unpacked array.\n */\nCartesian2.unpackArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.typeOf.number.greaterThanOrEquals(\"array.length\", array.length, 2);\n if (array.length % 2 !== 0) {\n throw new DeveloperError(\"array length must be a multiple of 2.\");\n }\n //>>includeEnd('debug');\n\n const length = array.length;\n if (!defined(result)) {\n result = new Array(length / 2);\n } else {\n result.length = length / 2;\n }\n\n for (let i = 0; i < length; i += 2) {\n const index = i / 2;\n result[index] = Cartesian2.unpack(array, i, result[index]);\n }\n return result;\n};\n\n/**\n * Creates a Cartesian2 from two consecutive elements in an array.\n * @function\n *\n * @param {number[]} array The array whose two consecutive elements correspond to the x and y components, respectively.\n * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.\n *\n * @example\n * // Create a Cartesian2 with (1.0, 2.0)\n * const v = [1.0, 2.0];\n * const p = Cesium.Cartesian2.fromArray(v);\n *\n * // Create a Cartesian2 with (1.0, 2.0) using an offset into an array\n * const v2 = [0.0, 0.0, 1.0, 2.0];\n * const p2 = Cesium.Cartesian2.fromArray(v2, 2);\n */\nCartesian2.fromArray = Cartesian2.unpack;\n\n/**\n * Computes the value of the maximum component for the supplied Cartesian.\n *\n * @param {Cartesian2} cartesian The cartesian to use.\n * @returns {number} The value of the maximum component.\n */\nCartesian2.maximumComponent = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return Math.max(cartesian.x, cartesian.y);\n};\n\n/**\n * Computes the value of the minimum component for the supplied Cartesian.\n *\n * @param {Cartesian2} cartesian The cartesian to use.\n * @returns {number} The value of the minimum component.\n */\nCartesian2.minimumComponent = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return Math.min(cartesian.x, cartesian.y);\n};\n\n/**\n * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.\n *\n * @param {Cartesian2} first A cartesian to compare.\n * @param {Cartesian2} second A cartesian to compare.\n * @param {Cartesian2} result The object into which to store the result.\n * @returns {Cartesian2} A cartesian with the minimum components.\n */\nCartesian2.minimumByComponent = function (first, second, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"first\", first);\n Check.typeOf.object(\"second\", second);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.min(first.x, second.x);\n result.y = Math.min(first.y, second.y);\n\n return result;\n};\n\n/**\n * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.\n *\n * @param {Cartesian2} first A cartesian to compare.\n * @param {Cartesian2} second A cartesian to compare.\n * @param {Cartesian2} result The object into which to store the result.\n * @returns {Cartesian2} A cartesian with the maximum components.\n */\nCartesian2.maximumByComponent = function (first, second, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"first\", first);\n Check.typeOf.object(\"second\", second);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.max(first.x, second.x);\n result.y = Math.max(first.y, second.y);\n return result;\n};\n\n/**\n * Constrain a value to lie between two values.\n *\n * @param {Cartesian2} value The value to clamp.\n * @param {Cartesian2} min The minimum bound.\n * @param {Cartesian2} max The maximum bound.\n * @param {Cartesian2} result The object into which to store the result.\n * @returns {Cartesian2} The clamped value such that min <= result <= max.\n */\nCartesian2.clamp = function (value, min, max, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.typeOf.object(\"min\", min);\n Check.typeOf.object(\"max\", max);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = CesiumMath.clamp(value.x, min.x, max.x);\n const y = CesiumMath.clamp(value.y, min.y, max.y);\n\n result.x = x;\n result.y = y;\n\n return result;\n};\n\n/**\n * Computes the provided Cartesian's squared magnitude.\n *\n * @param {Cartesian2} cartesian The Cartesian instance whose squared magnitude is to be computed.\n * @returns {number} The squared magnitude.\n */\nCartesian2.magnitudeSquared = function (cartesian) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n return cartesian.x * cartesian.x + cartesian.y * cartesian.y;\n};\n\n/**\n * Computes the Cartesian's magnitude (length).\n *\n * @param {Cartesian2} cartesian The Cartesian instance whose magnitude is to be computed.\n * @returns {number} The magnitude.\n */\nCartesian2.magnitude = function (cartesian) {\n return Math.sqrt(Cartesian2.magnitudeSquared(cartesian));\n};\n\nconst distanceScratch = new Cartesian2();\n\n/**\n * Computes the distance between two points.\n *\n * @param {Cartesian2} left The first point to compute the distance from.\n * @param {Cartesian2} right The second point to compute the distance to.\n * @returns {number} The distance between two points.\n *\n * @example\n * // Returns 1.0\n * const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(2.0, 0.0));\n */\nCartesian2.distance = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian2.subtract(left, right, distanceScratch);\n return Cartesian2.magnitude(distanceScratch);\n};\n\n/**\n * Computes the squared distance between two points. Comparing squared distances\n * using this function is more efficient than comparing distances using {@link Cartesian2#distance}.\n *\n * @param {Cartesian2} left The first point to compute the distance from.\n * @param {Cartesian2} right The second point to compute the distance to.\n * @returns {number} The distance between two points.\n *\n * @example\n * // Returns 4.0, not 2.0\n * const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(3.0, 0.0));\n */\nCartesian2.distanceSquared = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian2.subtract(left, right, distanceScratch);\n return Cartesian2.magnitudeSquared(distanceScratch);\n};\n\n/**\n * Computes the normalized form of the supplied Cartesian.\n *\n * @param {Cartesian2} cartesian The Cartesian to be normalized.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.normalize = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const magnitude = Cartesian2.magnitude(cartesian);\n\n result.x = cartesian.x / magnitude;\n result.y = cartesian.y / magnitude;\n\n //>>includeStart('debug', pragmas.debug);\n if (isNaN(result.x) || isNaN(result.y)) {\n throw new DeveloperError(\"normalized result is not a number\");\n }\n //>>includeEnd('debug');\n\n return result;\n};\n\n/**\n * Computes the dot (scalar) product of two Cartesians.\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @returns {number} The dot product.\n */\nCartesian2.dot = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n return left.x * right.x + left.y * right.y;\n};\n\n/**\n * Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @returns {number} The cross product.\n */\nCartesian2.cross = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n return left.x * right.y - left.y * right.x;\n};\n\n/**\n * Computes the componentwise product of two Cartesians.\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.multiplyComponents = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x * right.x;\n result.y = left.y * right.y;\n return result;\n};\n\n/**\n * Computes the componentwise quotient of two Cartesians.\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.divideComponents = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x / right.x;\n result.y = left.y / right.y;\n return result;\n};\n\n/**\n * Computes the componentwise sum of two Cartesians.\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x + right.x;\n result.y = left.y + right.y;\n return result;\n};\n\n/**\n * Computes the componentwise difference of two Cartesians.\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x - right.x;\n result.y = left.y - right.y;\n return result;\n};\n\n/**\n * Multiplies the provided Cartesian componentwise by the provided scalar.\n *\n * @param {Cartesian2} cartesian The Cartesian to be scaled.\n * @param {number} scalar The scalar to multiply with.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.multiplyByScalar = function (cartesian, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = cartesian.x * scalar;\n result.y = cartesian.y * scalar;\n return result;\n};\n\n/**\n * Divides the provided Cartesian componentwise by the provided scalar.\n *\n * @param {Cartesian2} cartesian The Cartesian to be divided.\n * @param {number} scalar The scalar to divide by.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.divideByScalar = function (cartesian, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = cartesian.x / scalar;\n result.y = cartesian.y / scalar;\n return result;\n};\n\n/**\n * Negates the provided Cartesian.\n *\n * @param {Cartesian2} cartesian The Cartesian to be negated.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.negate = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = -cartesian.x;\n result.y = -cartesian.y;\n return result;\n};\n\n/**\n * Computes the absolute value of the provided Cartesian.\n *\n * @param {Cartesian2} cartesian The Cartesian whose absolute value is to be computed.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.abs = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Math.abs(cartesian.x);\n result.y = Math.abs(cartesian.y);\n return result;\n};\n\nconst lerpScratch = new Cartesian2();\n/**\n * Computes the linear interpolation or extrapolation at t using the provided cartesians.\n *\n * @param {Cartesian2} start The value corresponding to t at 0.0.\n * @param {Cartesian2} end The value corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nCartesian2.lerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n Cartesian2.multiplyByScalar(end, t, lerpScratch);\n result = Cartesian2.multiplyByScalar(start, 1.0 - t, result);\n return Cartesian2.add(lerpScratch, result, result);\n};\n\nconst angleBetweenScratch = new Cartesian2();\nconst angleBetweenScratch2 = new Cartesian2();\n/**\n * Returns the angle, in radians, between the provided Cartesians.\n *\n * @param {Cartesian2} left The first Cartesian.\n * @param {Cartesian2} right The second Cartesian.\n * @returns {number} The angle between the Cartesians.\n */\nCartesian2.angleBetween = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n Cartesian2.normalize(left, angleBetweenScratch);\n Cartesian2.normalize(right, angleBetweenScratch2);\n return CesiumMath.acosClamped(\n Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2)\n );\n};\n\nconst mostOrthogonalAxisScratch = new Cartesian2();\n/**\n * Returns the axis that is most orthogonal to the provided Cartesian.\n *\n * @param {Cartesian2} cartesian The Cartesian on which to find the most orthogonal axis.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The most orthogonal axis.\n */\nCartesian2.mostOrthogonalAxis = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);\n Cartesian2.abs(f, f);\n\n if (f.x <= f.y) {\n result = Cartesian2.clone(Cartesian2.UNIT_X, result);\n } else {\n result = Cartesian2.clone(Cartesian2.UNIT_Y, result);\n }\n\n return result;\n};\n\n/**\n * Compares the provided Cartesians componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartesian2} [left] The first Cartesian.\n * @param {Cartesian2} [right] The second Cartesian.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nCartesian2.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.x === right.x &&\n left.y === right.y)\n );\n};\n\n/**\n * @private\n */\nCartesian2.equalsArray = function (cartesian, array, offset) {\n return cartesian.x === array[offset] && cartesian.y === array[offset + 1];\n};\n\n/**\n * Compares the provided Cartesians componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Cartesian2} [left] The first Cartesian.\n * @param {Cartesian2} [right] The second Cartesian.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nCartesian2.equalsEpsilon = function (\n left,\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n CesiumMath.equalsEpsilon(\n left.x,\n right.x,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.y,\n right.y,\n relativeEpsilon,\n absoluteEpsilon\n ))\n );\n};\n\n/**\n * An immutable Cartesian2 instance initialized to (0.0, 0.0).\n *\n * @type {Cartesian2}\n * @constant\n */\nCartesian2.ZERO = Object.freeze(new Cartesian2(0.0, 0.0));\n\n/**\n * An immutable Cartesian2 instance initialized to (1.0, 1.0).\n *\n * @type {Cartesian2}\n * @constant\n */\nCartesian2.ONE = Object.freeze(new Cartesian2(1.0, 1.0));\n\n/**\n * An immutable Cartesian2 instance initialized to (1.0, 0.0).\n *\n * @type {Cartesian2}\n * @constant\n */\nCartesian2.UNIT_X = Object.freeze(new Cartesian2(1.0, 0.0));\n\n/**\n * An immutable Cartesian2 instance initialized to (0.0, 1.0).\n *\n * @type {Cartesian2}\n * @constant\n */\nCartesian2.UNIT_Y = Object.freeze(new Cartesian2(0.0, 1.0));\n\n/**\n * Duplicates this Cartesian2 instance.\n *\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.\n */\nCartesian2.prototype.clone = function (result) {\n return Cartesian2.clone(this, result);\n};\n\n/**\n * Compares this Cartesian against the provided Cartesian componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartesian2} [right] The right hand side Cartesian.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nCartesian2.prototype.equals = function (right) {\n return Cartesian2.equals(this, right);\n};\n\n/**\n * Compares this Cartesian against the provided Cartesian componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Cartesian2} [right] The right hand side Cartesian.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nCartesian2.prototype.equalsEpsilon = function (\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return Cartesian2.equalsEpsilon(\n this,\n right,\n relativeEpsilon,\n absoluteEpsilon\n );\n};\n\n/**\n * Creates a string representing this Cartesian in the format '(x, y)'.\n *\n * @returns {string} A string representing the provided Cartesian in the format '(x, y)'.\n */\nCartesian2.prototype.toString = function () {\n return `(${this.x}, ${this.y})`;\n};\nexport default Cartesian2;\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\n\nconst scaleToGeodeticSurfaceIntersection = new Cartesian3();\nconst scaleToGeodeticSurfaceGradient = new Cartesian3();\n\n/**\n * Scales the provided Cartesian position along the geodetic surface normal\n * so that it is on the surface of this ellipsoid. If the position is\n * at the center of the ellipsoid, this function returns undefined.\n *\n * @param {Cartesian3} cartesian The Cartesian position to scale.\n * @param {Cartesian3} oneOverRadii One over radii of the ellipsoid.\n * @param {Cartesian3} oneOverRadiiSquared One over radii squared of the ellipsoid.\n * @param {number} centerToleranceSquared Tolerance for closeness to the center.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter, a new Cartesian3 instance if none was provided, or undefined if the position is at the center.\n *\n * @function scaleToGeodeticSurface\n *\n * @private\n */\nfunction scaleToGeodeticSurface(\n cartesian,\n oneOverRadii,\n oneOverRadiiSquared,\n centerToleranceSquared,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(cartesian)) {\n throw new DeveloperError(\"cartesian is required.\");\n }\n if (!defined(oneOverRadii)) {\n throw new DeveloperError(\"oneOverRadii is required.\");\n }\n if (!defined(oneOverRadiiSquared)) {\n throw new DeveloperError(\"oneOverRadiiSquared is required.\");\n }\n if (!defined(centerToleranceSquared)) {\n throw new DeveloperError(\"centerToleranceSquared is required.\");\n }\n //>>includeEnd('debug');\n\n const positionX = cartesian.x;\n const positionY = cartesian.y;\n const positionZ = cartesian.z;\n\n const oneOverRadiiX = oneOverRadii.x;\n const oneOverRadiiY = oneOverRadii.y;\n const oneOverRadiiZ = oneOverRadii.z;\n\n const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;\n const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;\n const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;\n\n // Compute the squared ellipsoid norm.\n const squaredNorm = x2 + y2 + z2;\n const ratio = Math.sqrt(1.0 / squaredNorm);\n\n // As an initial approximation, assume that the radial intersection is the projection point.\n const intersection = Cartesian3.multiplyByScalar(\n cartesian,\n ratio,\n scaleToGeodeticSurfaceIntersection\n );\n\n // If the position is near the center, the iteration will not converge.\n if (squaredNorm < centerToleranceSquared) {\n return !isFinite(ratio)\n ? undefined\n : Cartesian3.clone(intersection, result);\n }\n\n const oneOverRadiiSquaredX = oneOverRadiiSquared.x;\n const oneOverRadiiSquaredY = oneOverRadiiSquared.y;\n const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;\n\n // Use the gradient at the intersection point in place of the true unit normal.\n // The difference in magnitude will be absorbed in the multiplier.\n const gradient = scaleToGeodeticSurfaceGradient;\n gradient.x = intersection.x * oneOverRadiiSquaredX * 2.0;\n gradient.y = intersection.y * oneOverRadiiSquaredY * 2.0;\n gradient.z = intersection.z * oneOverRadiiSquaredZ * 2.0;\n\n // Compute the initial guess at the normal vector multiplier, lambda.\n let lambda =\n ((1.0 - ratio) * Cartesian3.magnitude(cartesian)) /\n (0.5 * Cartesian3.magnitude(gradient));\n let correction = 0.0;\n\n let func;\n let denominator;\n let xMultiplier;\n let yMultiplier;\n let zMultiplier;\n let xMultiplier2;\n let yMultiplier2;\n let zMultiplier2;\n let xMultiplier3;\n let yMultiplier3;\n let zMultiplier3;\n\n do {\n lambda -= correction;\n\n xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);\n yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY);\n zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ);\n\n xMultiplier2 = xMultiplier * xMultiplier;\n yMultiplier2 = yMultiplier * yMultiplier;\n zMultiplier2 = zMultiplier * zMultiplier;\n\n xMultiplier3 = xMultiplier2 * xMultiplier;\n yMultiplier3 = yMultiplier2 * yMultiplier;\n zMultiplier3 = zMultiplier2 * zMultiplier;\n\n func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;\n\n // \"denominator\" here refers to the use of this expression in the velocity and acceleration\n // computations in the sections to follow.\n denominator =\n x2 * xMultiplier3 * oneOverRadiiSquaredX +\n y2 * yMultiplier3 * oneOverRadiiSquaredY +\n z2 * zMultiplier3 * oneOverRadiiSquaredZ;\n\n const derivative = -2.0 * denominator;\n\n correction = func / derivative;\n } while (Math.abs(func) > CesiumMath.EPSILON12);\n\n if (!defined(result)) {\n return new Cartesian3(\n positionX * xMultiplier,\n positionY * yMultiplier,\n positionZ * zMultiplier\n );\n }\n result.x = positionX * xMultiplier;\n result.y = positionY * yMultiplier;\n result.z = positionZ * zMultiplier;\n return result;\n}\nexport default scaleToGeodeticSurface;\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport CesiumMath from \"./Math.js\";\nimport scaleToGeodeticSurface from \"./scaleToGeodeticSurface.js\";\n\n/**\n * A position defined by longitude, latitude, and height.\n * @alias Cartographic\n * @constructor\n *\n * @param {number} [longitude=0.0] The longitude, in radians.\n * @param {number} [latitude=0.0] The latitude, in radians.\n * @param {number} [height=0.0] The height, in meters, above the ellipsoid.\n *\n * @see Ellipsoid\n */\nfunction Cartographic(longitude, latitude, height) {\n /**\n * The longitude, in radians.\n * @type {number}\n * @default 0.0\n */\n this.longitude = defaultValue(longitude, 0.0);\n\n /**\n * The latitude, in radians.\n * @type {number}\n * @default 0.0\n */\n this.latitude = defaultValue(latitude, 0.0);\n\n /**\n * The height, in meters, above the ellipsoid.\n * @type {number}\n * @default 0.0\n */\n this.height = defaultValue(height, 0.0);\n}\n\n/**\n * Creates a new Cartographic instance from longitude and latitude\n * specified in radians.\n *\n * @param {number} longitude The longitude, in radians.\n * @param {number} latitude The latitude, in radians.\n * @param {number} [height=0.0] The height, in meters, above the ellipsoid.\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided.\n */\nCartographic.fromRadians = function (longitude, latitude, height, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"longitude\", longitude);\n Check.typeOf.number(\"latitude\", latitude);\n //>>includeEnd('debug');\n\n height = defaultValue(height, 0.0);\n\n if (!defined(result)) {\n return new Cartographic(longitude, latitude, height);\n }\n\n result.longitude = longitude;\n result.latitude = latitude;\n result.height = height;\n return result;\n};\n\n/**\n * Creates a new Cartographic instance from longitude and latitude\n * specified in degrees. The values in the resulting object will\n * be in radians.\n *\n * @param {number} longitude The longitude, in degrees.\n * @param {number} latitude The latitude, in degrees.\n * @param {number} [height=0.0] The height, in meters, above the ellipsoid.\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided.\n */\nCartographic.fromDegrees = function (longitude, latitude, height, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"longitude\", longitude);\n Check.typeOf.number(\"latitude\", latitude);\n //>>includeEnd('debug');\n longitude = CesiumMath.toRadians(longitude);\n latitude = CesiumMath.toRadians(latitude);\n\n return Cartographic.fromRadians(longitude, latitude, height, result);\n};\n\nconst cartesianToCartographicN = new Cartesian3();\nconst cartesianToCartographicP = new Cartesian3();\nconst cartesianToCartographicH = new Cartesian3();\nconst wgs84OneOverRadii = new Cartesian3(\n 1.0 / 6378137.0,\n 1.0 / 6378137.0,\n 1.0 / 6356752.3142451793\n);\nconst wgs84OneOverRadiiSquared = new Cartesian3(\n 1.0 / (6378137.0 * 6378137.0),\n 1.0 / (6378137.0 * 6378137.0),\n 1.0 / (6356752.3142451793 * 6356752.3142451793)\n);\nconst wgs84CenterToleranceSquared = CesiumMath.EPSILON1;\n\n/**\n * Creates a new Cartographic instance from a Cartesian position. The values in the\n * resulting object will be in radians.\n *\n * @param {Cartesian3} cartesian The Cartesian position to convert to cartographic representation.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter, new Cartographic instance if none was provided, or undefined if the cartesian is at the center of the ellipsoid.\n */\nCartographic.fromCartesian = function (cartesian, ellipsoid, result) {\n const oneOverRadii = defined(ellipsoid)\n ? ellipsoid.oneOverRadii\n : wgs84OneOverRadii;\n const oneOverRadiiSquared = defined(ellipsoid)\n ? ellipsoid.oneOverRadiiSquared\n : wgs84OneOverRadiiSquared;\n const centerToleranceSquared = defined(ellipsoid)\n ? ellipsoid._centerToleranceSquared\n : wgs84CenterToleranceSquared;\n\n //`cartesian is required.` is thrown from scaleToGeodeticSurface\n const p = scaleToGeodeticSurface(\n cartesian,\n oneOverRadii,\n oneOverRadiiSquared,\n centerToleranceSquared,\n cartesianToCartographicP\n );\n\n if (!defined(p)) {\n return undefined;\n }\n\n let n = Cartesian3.multiplyComponents(\n p,\n oneOverRadiiSquared,\n cartesianToCartographicN\n );\n n = Cartesian3.normalize(n, n);\n\n const h = Cartesian3.subtract(cartesian, p, cartesianToCartographicH);\n\n const longitude = Math.atan2(n.y, n.x);\n const latitude = Math.asin(n.z);\n const height =\n CesiumMath.sign(Cartesian3.dot(h, cartesian)) * Cartesian3.magnitude(h);\n\n if (!defined(result)) {\n return new Cartographic(longitude, latitude, height);\n }\n result.longitude = longitude;\n result.latitude = latitude;\n result.height = height;\n return result;\n};\n\n/**\n * Creates a new Cartesian3 instance from a Cartographic input. The values in the inputted\n * object should be in radians.\n *\n * @param {Cartographic} cartographic Input to be converted into a Cartesian3 output.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The position\n */\nCartographic.toCartesian = function (cartographic, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"cartographic\", cartographic);\n //>>includeEnd('debug');\n\n return Cartesian3.fromRadians(\n cartographic.longitude,\n cartographic.latitude,\n cartographic.height,\n ellipsoid,\n result\n );\n};\n\n/**\n * Duplicates a Cartographic instance.\n *\n * @param {Cartographic} cartographic The cartographic to duplicate.\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided. (Returns undefined if cartographic is undefined)\n */\nCartographic.clone = function (cartographic, result) {\n if (!defined(cartographic)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Cartographic(\n cartographic.longitude,\n cartographic.latitude,\n cartographic.height\n );\n }\n result.longitude = cartographic.longitude;\n result.latitude = cartographic.latitude;\n result.height = cartographic.height;\n return result;\n};\n\n/**\n * Compares the provided cartographics componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartographic} [left] The first cartographic.\n * @param {Cartographic} [right] The second cartographic.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nCartographic.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.longitude === right.longitude &&\n left.latitude === right.latitude &&\n left.height === right.height)\n );\n};\n\n/**\n * Compares the provided cartographics componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Cartographic} [left] The first cartographic.\n * @param {Cartographic} [right] The second cartographic.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nCartographic.equalsEpsilon = function (left, right, epsilon) {\n epsilon = defaultValue(epsilon, 0);\n\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(left.longitude - right.longitude) <= epsilon &&\n Math.abs(left.latitude - right.latitude) <= epsilon &&\n Math.abs(left.height - right.height) <= epsilon)\n );\n};\n\n/**\n * An immutable Cartographic instance initialized to (0.0, 0.0, 0.0).\n *\n * @type {Cartographic}\n * @constant\n */\nCartographic.ZERO = Object.freeze(new Cartographic(0.0, 0.0, 0.0));\n\n/**\n * Duplicates this instance.\n *\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided.\n */\nCartographic.prototype.clone = function (result) {\n return Cartographic.clone(this, result);\n};\n\n/**\n * Compares the provided against this cartographic componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Cartographic} [right] The second cartographic.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nCartographic.prototype.equals = function (right) {\n return Cartographic.equals(this, right);\n};\n\n/**\n * Compares the provided against this cartographic componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Cartographic} [right] The second cartographic.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nCartographic.prototype.equalsEpsilon = function (right, epsilon) {\n return Cartographic.equalsEpsilon(this, right, epsilon);\n};\n\n/**\n * Creates a string representing this cartographic in the format '(longitude, latitude, height)'.\n *\n * @returns {string} A string representing the provided cartographic in the format '(longitude, latitude, height)'.\n */\nCartographic.prototype.toString = function () {\n return `(${this.longitude}, ${this.latitude}, ${this.height})`;\n};\nexport default Cartographic;\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\nimport scaleToGeodeticSurface from \"./scaleToGeodeticSurface.js\";\n\nfunction initialize(ellipsoid, x, y, z) {\n x = defaultValue(x, 0.0);\n y = defaultValue(y, 0.0);\n z = defaultValue(z, 0.0);\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThanOrEquals(\"x\", x, 0.0);\n Check.typeOf.number.greaterThanOrEquals(\"y\", y, 0.0);\n Check.typeOf.number.greaterThanOrEquals(\"z\", z, 0.0);\n //>>includeEnd('debug');\n\n ellipsoid._radii = new Cartesian3(x, y, z);\n\n ellipsoid._radiiSquared = new Cartesian3(x * x, y * y, z * z);\n\n ellipsoid._radiiToTheFourth = new Cartesian3(\n x * x * x * x,\n y * y * y * y,\n z * z * z * z\n );\n\n ellipsoid._oneOverRadii = new Cartesian3(\n x === 0.0 ? 0.0 : 1.0 / x,\n y === 0.0 ? 0.0 : 1.0 / y,\n z === 0.0 ? 0.0 : 1.0 / z\n );\n\n ellipsoid._oneOverRadiiSquared = new Cartesian3(\n x === 0.0 ? 0.0 : 1.0 / (x * x),\n y === 0.0 ? 0.0 : 1.0 / (y * y),\n z === 0.0 ? 0.0 : 1.0 / (z * z)\n );\n\n ellipsoid._minimumRadius = Math.min(x, y, z);\n\n ellipsoid._maximumRadius = Math.max(x, y, z);\n\n ellipsoid._centerToleranceSquared = CesiumMath.EPSILON1;\n\n if (ellipsoid._radiiSquared.z !== 0) {\n ellipsoid._squaredXOverSquaredZ =\n ellipsoid._radiiSquared.x / ellipsoid._radiiSquared.z;\n }\n}\n\n/**\n * A quadratic surface defined in Cartesian coordinates by the equation\n * (x / a)^2 + (y / b)^2 + (z / c)^2 = 1. Primarily used\n * by Cesium to represent the shape of planetary bodies.\n *\n * Rather than constructing this object directly, one of the provided\n * constants is normally used.\n * @alias Ellipsoid\n * @constructor\n *\n * @param {number} [x=0] The radius in the x direction.\n * @param {number} [y=0] The radius in the y direction.\n * @param {number} [z=0] The radius in the z direction.\n *\n * @exception {DeveloperError} All radii components must be greater than or equal to zero.\n *\n * @see Ellipsoid.fromCartesian3\n * @see Ellipsoid.WGS84\n * @see Ellipsoid.UNIT_SPHERE\n */\nfunction Ellipsoid(x, y, z) {\n this._radii = undefined;\n this._radiiSquared = undefined;\n this._radiiToTheFourth = undefined;\n this._oneOverRadii = undefined;\n this._oneOverRadiiSquared = undefined;\n this._minimumRadius = undefined;\n this._maximumRadius = undefined;\n this._centerToleranceSquared = undefined;\n this._squaredXOverSquaredZ = undefined;\n\n initialize(this, x, y, z);\n}\n\nObject.defineProperties(Ellipsoid.prototype, {\n /**\n * Gets the radii of the ellipsoid.\n * @memberof Ellipsoid.prototype\n * @type {Cartesian3}\n * @readonly\n */\n radii: {\n get: function () {\n return this._radii;\n },\n },\n /**\n * Gets the squared radii of the ellipsoid.\n * @memberof Ellipsoid.prototype\n * @type {Cartesian3}\n * @readonly\n */\n radiiSquared: {\n get: function () {\n return this._radiiSquared;\n },\n },\n /**\n * Gets the radii of the ellipsoid raise to the fourth power.\n * @memberof Ellipsoid.prototype\n * @type {Cartesian3}\n * @readonly\n */\n radiiToTheFourth: {\n get: function () {\n return this._radiiToTheFourth;\n },\n },\n /**\n * Gets one over the radii of the ellipsoid.\n * @memberof Ellipsoid.prototype\n * @type {Cartesian3}\n * @readonly\n */\n oneOverRadii: {\n get: function () {\n return this._oneOverRadii;\n },\n },\n /**\n * Gets one over the squared radii of the ellipsoid.\n * @memberof Ellipsoid.prototype\n * @type {Cartesian3}\n * @readonly\n */\n oneOverRadiiSquared: {\n get: function () {\n return this._oneOverRadiiSquared;\n },\n },\n /**\n * Gets the minimum radius of the ellipsoid.\n * @memberof Ellipsoid.prototype\n * @type {number}\n * @readonly\n */\n minimumRadius: {\n get: function () {\n return this._minimumRadius;\n },\n },\n /**\n * Gets the maximum radius of the ellipsoid.\n * @memberof Ellipsoid.prototype\n * @type {number}\n * @readonly\n */\n maximumRadius: {\n get: function () {\n return this._maximumRadius;\n },\n },\n});\n\n/**\n * Duplicates an Ellipsoid instance.\n *\n * @param {Ellipsoid} ellipsoid The ellipsoid to duplicate.\n * @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new\n * instance should be created.\n * @returns {Ellipsoid} The cloned Ellipsoid. (Returns undefined if ellipsoid is undefined)\n */\nEllipsoid.clone = function (ellipsoid, result) {\n if (!defined(ellipsoid)) {\n return undefined;\n }\n const radii = ellipsoid._radii;\n\n if (!defined(result)) {\n return new Ellipsoid(radii.x, radii.y, radii.z);\n }\n\n Cartesian3.clone(radii, result._radii);\n Cartesian3.clone(ellipsoid._radiiSquared, result._radiiSquared);\n Cartesian3.clone(ellipsoid._radiiToTheFourth, result._radiiToTheFourth);\n Cartesian3.clone(ellipsoid._oneOverRadii, result._oneOverRadii);\n Cartesian3.clone(ellipsoid._oneOverRadiiSquared, result._oneOverRadiiSquared);\n result._minimumRadius = ellipsoid._minimumRadius;\n result._maximumRadius = ellipsoid._maximumRadius;\n result._centerToleranceSquared = ellipsoid._centerToleranceSquared;\n\n return result;\n};\n\n/**\n * Computes an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions.\n *\n * @param {Cartesian3} [cartesian=Cartesian3.ZERO] The ellipsoid's radius in the x, y, and z directions.\n * @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new\n * instance should be created.\n * @returns {Ellipsoid} A new Ellipsoid instance.\n *\n * @exception {DeveloperError} All radii components must be greater than or equal to zero.\n *\n * @see Ellipsoid.WGS84\n * @see Ellipsoid.UNIT_SPHERE\n */\nEllipsoid.fromCartesian3 = function (cartesian, result) {\n if (!defined(result)) {\n result = new Ellipsoid();\n }\n\n if (!defined(cartesian)) {\n return result;\n }\n\n initialize(result, cartesian.x, cartesian.y, cartesian.z);\n return result;\n};\n\n/**\n * An Ellipsoid instance initialized to the WGS84 standard.\n *\n * @type {Ellipsoid}\n * @constant\n */\nEllipsoid.WGS84 = Object.freeze(\n new Ellipsoid(6378137.0, 6378137.0, 6356752.3142451793)\n);\n\n/**\n * An Ellipsoid instance initialized to radii of (1.0, 1.0, 1.0).\n *\n * @type {Ellipsoid}\n * @constant\n */\nEllipsoid.UNIT_SPHERE = Object.freeze(new Ellipsoid(1.0, 1.0, 1.0));\n\n/**\n * An Ellipsoid instance initialized to a sphere with the lunar radius.\n *\n * @type {Ellipsoid}\n * @constant\n */\nEllipsoid.MOON = Object.freeze(\n new Ellipsoid(\n CesiumMath.LUNAR_RADIUS,\n CesiumMath.LUNAR_RADIUS,\n CesiumMath.LUNAR_RADIUS\n )\n);\n\n/**\n * Duplicates an Ellipsoid instance.\n *\n * @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new\n * instance should be created.\n * @returns {Ellipsoid} The cloned Ellipsoid.\n */\nEllipsoid.prototype.clone = function (result) {\n return Ellipsoid.clone(this, result);\n};\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nEllipsoid.packedLength = Cartesian3.packedLength;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Ellipsoid} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nEllipsoid.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n Cartesian3.pack(value._radii, array, startingIndex);\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Ellipsoid} [result] The object into which to store the result.\n * @returns {Ellipsoid} The modified result parameter or a new Ellipsoid instance if one was not provided.\n */\nEllipsoid.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n const radii = Cartesian3.unpack(array, startingIndex);\n return Ellipsoid.fromCartesian3(radii, result);\n};\n\n/**\n * Computes the unit vector directed from the center of this ellipsoid toward the provided Cartesian position.\n * @function\n *\n * @param {Cartesian3} cartesian The Cartesian for which to to determine the geocentric normal.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.\n */\nEllipsoid.prototype.geocentricSurfaceNormal = Cartesian3.normalize;\n\n/**\n * Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.\n *\n * @param {Cartographic} cartographic The cartographic position for which to to determine the geodetic normal.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.\n */\nEllipsoid.prototype.geodeticSurfaceNormalCartographic = function (\n cartographic,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartographic\", cartographic);\n //>>includeEnd('debug');\n\n const longitude = cartographic.longitude;\n const latitude = cartographic.latitude;\n const cosLatitude = Math.cos(latitude);\n\n const x = cosLatitude * Math.cos(longitude);\n const y = cosLatitude * Math.sin(longitude);\n const z = Math.sin(latitude);\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n result.x = x;\n result.y = y;\n result.z = z;\n return Cartesian3.normalize(result, result);\n};\n\n/**\n * Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.\n *\n * @param {Cartesian3} cartesian The Cartesian position for which to to determine the surface normal.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided, or undefined if a normal cannot be found.\n */\nEllipsoid.prototype.geodeticSurfaceNormal = function (cartesian, result) {\n if (\n Cartesian3.equalsEpsilon(cartesian, Cartesian3.ZERO, CesiumMath.EPSILON14)\n ) {\n return undefined;\n }\n if (!defined(result)) {\n result = new Cartesian3();\n }\n result = Cartesian3.multiplyComponents(\n cartesian,\n this._oneOverRadiiSquared,\n result\n );\n return Cartesian3.normalize(result, result);\n};\n\nconst cartographicToCartesianNormal = new Cartesian3();\nconst cartographicToCartesianK = new Cartesian3();\n\n/**\n * Converts the provided cartographic to Cartesian representation.\n *\n * @param {Cartographic} cartographic The cartographic position.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.\n *\n * @example\n * //Create a Cartographic and determine it's Cartesian representation on a WGS84 ellipsoid.\n * const position = new Cesium.Cartographic(Cesium.Math.toRadians(21), Cesium.Math.toRadians(78), 5000);\n * const cartesianPosition = Cesium.Ellipsoid.WGS84.cartographicToCartesian(position);\n */\nEllipsoid.prototype.cartographicToCartesian = function (cartographic, result) {\n //`cartographic is required` is thrown from geodeticSurfaceNormalCartographic.\n const n = cartographicToCartesianNormal;\n const k = cartographicToCartesianK;\n this.geodeticSurfaceNormalCartographic(cartographic, n);\n Cartesian3.multiplyComponents(this._radiiSquared, n, k);\n const gamma = Math.sqrt(Cartesian3.dot(n, k));\n Cartesian3.divideByScalar(k, gamma, k);\n Cartesian3.multiplyByScalar(n, cartographic.height, n);\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n return Cartesian3.add(k, n, result);\n};\n\n/**\n * Converts the provided array of cartographics to an array of Cartesians.\n *\n * @param {Cartographic[]} cartographics An array of cartographic positions.\n * @param {Cartesian3[]} [result] The object onto which to store the result.\n * @returns {Cartesian3[]} The modified result parameter or a new Array instance if none was provided.\n *\n * @example\n * //Convert an array of Cartographics and determine their Cartesian representation on a WGS84 ellipsoid.\n * const positions = [new Cesium.Cartographic(Cesium.Math.toRadians(21), Cesium.Math.toRadians(78), 0),\n * new Cesium.Cartographic(Cesium.Math.toRadians(21.321), Cesium.Math.toRadians(78.123), 100),\n * new Cesium.Cartographic(Cesium.Math.toRadians(21.645), Cesium.Math.toRadians(78.456), 250)];\n * const cartesianPositions = Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(positions);\n */\nEllipsoid.prototype.cartographicArrayToCartesianArray = function (\n cartographics,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"cartographics\", cartographics);\n //>>includeEnd('debug')\n\n const length = cartographics.length;\n if (!defined(result)) {\n result = new Array(length);\n } else {\n result.length = length;\n }\n for (let i = 0; i < length; i++) {\n result[i] = this.cartographicToCartesian(cartographics[i], result[i]);\n }\n return result;\n};\n\nconst cartesianToCartographicN = new Cartesian3();\nconst cartesianToCartographicP = new Cartesian3();\nconst cartesianToCartographicH = new Cartesian3();\n\n/**\n * Converts the provided cartesian to cartographic representation.\n * The cartesian is undefined at the center of the ellipsoid.\n *\n * @param {Cartesian3} cartesian The Cartesian position to convert to cartographic representation.\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter, new Cartographic instance if none was provided, or undefined if the cartesian is at the center of the ellipsoid.\n *\n * @example\n * //Create a Cartesian and determine it's Cartographic representation on a WGS84 ellipsoid.\n * const position = new Cesium.Cartesian3(17832.12, 83234.52, 952313.73);\n * const cartographicPosition = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);\n */\nEllipsoid.prototype.cartesianToCartographic = function (cartesian, result) {\n //`cartesian is required.` is thrown from scaleToGeodeticSurface\n const p = this.scaleToGeodeticSurface(cartesian, cartesianToCartographicP);\n\n if (!defined(p)) {\n return undefined;\n }\n\n const n = this.geodeticSurfaceNormal(p, cartesianToCartographicN);\n const h = Cartesian3.subtract(cartesian, p, cartesianToCartographicH);\n\n const longitude = Math.atan2(n.y, n.x);\n const latitude = Math.asin(n.z);\n const height =\n CesiumMath.sign(Cartesian3.dot(h, cartesian)) * Cartesian3.magnitude(h);\n\n if (!defined(result)) {\n return new Cartographic(longitude, latitude, height);\n }\n result.longitude = longitude;\n result.latitude = latitude;\n result.height = height;\n return result;\n};\n\n/**\n * Converts the provided array of cartesians to an array of cartographics.\n *\n * @param {Cartesian3[]} cartesians An array of Cartesian positions.\n * @param {Cartographic[]} [result] The object onto which to store the result.\n * @returns {Cartographic[]} The modified result parameter or a new Array instance if none was provided.\n *\n * @example\n * //Create an array of Cartesians and determine their Cartographic representation on a WGS84 ellipsoid.\n * const positions = [new Cesium.Cartesian3(17832.12, 83234.52, 952313.73),\n * new Cesium.Cartesian3(17832.13, 83234.53, 952313.73),\n * new Cesium.Cartesian3(17832.14, 83234.54, 952313.73)]\n * const cartographicPositions = Cesium.Ellipsoid.WGS84.cartesianArrayToCartographicArray(positions);\n */\nEllipsoid.prototype.cartesianArrayToCartographicArray = function (\n cartesians,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"cartesians\", cartesians);\n //>>includeEnd('debug');\n\n const length = cartesians.length;\n if (!defined(result)) {\n result = new Array(length);\n } else {\n result.length = length;\n }\n for (let i = 0; i < length; ++i) {\n result[i] = this.cartesianToCartographic(cartesians[i], result[i]);\n }\n return result;\n};\n\n/**\n * Scales the provided Cartesian position along the geodetic surface normal\n * so that it is on the surface of this ellipsoid. If the position is\n * at the center of the ellipsoid, this function returns undefined.\n *\n * @param {Cartesian3} cartesian The Cartesian position to scale.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter, a new Cartesian3 instance if none was provided, or undefined if the position is at the center.\n */\nEllipsoid.prototype.scaleToGeodeticSurface = function (cartesian, result) {\n return scaleToGeodeticSurface(\n cartesian,\n this._oneOverRadii,\n this._oneOverRadiiSquared,\n this._centerToleranceSquared,\n result\n );\n};\n\n/**\n * Scales the provided Cartesian position along the geocentric surface normal\n * so that it is on the surface of this ellipsoid.\n *\n * @param {Cartesian3} cartesian The Cartesian position to scale.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.\n */\nEllipsoid.prototype.scaleToGeocentricSurface = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n\n const positionX = cartesian.x;\n const positionY = cartesian.y;\n const positionZ = cartesian.z;\n const oneOverRadiiSquared = this._oneOverRadiiSquared;\n\n const beta =\n 1.0 /\n Math.sqrt(\n positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z\n );\n\n return Cartesian3.multiplyByScalar(cartesian, beta, result);\n};\n\n/**\n * Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying\n * its components by the result of {@link Ellipsoid#oneOverRadii}.\n *\n * @param {Cartesian3} position The position to transform.\n * @param {Cartesian3} [result] The position to which to copy the result, or undefined to create and\n * return a new instance.\n * @returns {Cartesian3} The position expressed in the scaled space. The returned instance is the\n * one passed as the result parameter if it is not undefined, or a new instance of it is.\n */\nEllipsoid.prototype.transformPositionToScaledSpace = function (\n position,\n result\n) {\n if (!defined(result)) {\n result = new Cartesian3();\n }\n\n return Cartesian3.multiplyComponents(position, this._oneOverRadii, result);\n};\n\n/**\n * Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying\n * its components by the result of {@link Ellipsoid#radii}.\n *\n * @param {Cartesian3} position The position to transform.\n * @param {Cartesian3} [result] The position to which to copy the result, or undefined to create and\n * return a new instance.\n * @returns {Cartesian3} The position expressed in the unscaled space. The returned instance is the\n * one passed as the result parameter if it is not undefined, or a new instance of it is.\n */\nEllipsoid.prototype.transformPositionFromScaledSpace = function (\n position,\n result\n) {\n if (!defined(result)) {\n result = new Cartesian3();\n }\n\n return Cartesian3.multiplyComponents(position, this._radii, result);\n};\n\n/**\n * Compares this Ellipsoid against the provided Ellipsoid componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Ellipsoid} [right] The other Ellipsoid.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nEllipsoid.prototype.equals = function (right) {\n return (\n this === right ||\n (defined(right) && Cartesian3.equals(this._radii, right._radii))\n );\n};\n\n/**\n * Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'.\n *\n * @returns {string} A string representing this ellipsoid in the format '(radii.x, radii.y, radii.z)'.\n */\nEllipsoid.prototype.toString = function () {\n return this._radii.toString();\n};\n\n/**\n * Computes a point which is the intersection of the surface normal with the z-axis.\n *\n * @param {Cartesian3} position the position. must be on the surface of the ellipsoid.\n * @param {number} [buffer = 0.0] A buffer to subtract from the ellipsoid size when checking if the point is inside the ellipsoid.\n * In earth case, with common earth datums, there is no need for this buffer since the intersection point is always (relatively) very close to the center.\n * In WGS84 datum, intersection point is at max z = +-42841.31151331382 (0.673% of z-axis).\n * Intersection point could be outside the ellipsoid if the ratio of MajorAxis / AxisOfRotation is bigger than the square root of 2\n * @param {Cartesian3} [result] The cartesian to which to copy the result, or undefined to create and\n * return a new instance.\n * @returns {Cartesian3 | undefined} the intersection point if it's inside the ellipsoid, undefined otherwise\n *\n * @exception {DeveloperError} position is required.\n * @exception {DeveloperError} Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y).\n * @exception {DeveloperError} Ellipsoid.radii.z must be greater than 0.\n */\nEllipsoid.prototype.getSurfaceNormalIntersectionWithZAxis = function (\n position,\n buffer,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"position\", position);\n\n if (\n !CesiumMath.equalsEpsilon(\n this._radii.x,\n this._radii.y,\n CesiumMath.EPSILON15\n )\n ) {\n throw new DeveloperError(\n \"Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)\"\n );\n }\n\n Check.typeOf.number.greaterThan(\"Ellipsoid.radii.z\", this._radii.z, 0);\n //>>includeEnd('debug');\n\n buffer = defaultValue(buffer, 0.0);\n\n const squaredXOverSquaredZ = this._squaredXOverSquaredZ;\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n\n result.x = 0.0;\n result.y = 0.0;\n result.z = position.z * (1 - squaredXOverSquaredZ);\n\n if (Math.abs(result.z) >= this._radii.z - buffer) {\n return undefined;\n }\n\n return result;\n};\n\nconst abscissas = [\n 0.14887433898163,\n 0.43339539412925,\n 0.67940956829902,\n 0.86506336668898,\n 0.97390652851717,\n 0.0,\n];\nconst weights = [\n 0.29552422471475,\n 0.26926671930999,\n 0.21908636251598,\n 0.14945134915058,\n 0.066671344308684,\n 0.0,\n];\n\n/**\n * Compute the 10th order Gauss-Legendre Quadrature of the given definite integral.\n *\n * @param {number} a The lower bound for the integration.\n * @param {number} b The upper bound for the integration.\n * @param {Ellipsoid~RealValuedScalarFunction} func The function to integrate.\n * @returns {number} The value of the integral of the given function over the given domain.\n *\n * @private\n */\nfunction gaussLegendreQuadrature(a, b, func) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"a\", a);\n Check.typeOf.number(\"b\", b);\n Check.typeOf.func(\"func\", func);\n //>>includeEnd('debug');\n\n // The range is half of the normal range since the five weights add to one (ten weights add to two).\n // The values of the abscissas are multiplied by two to account for this.\n const xMean = 0.5 * (b + a);\n const xRange = 0.5 * (b - a);\n\n let sum = 0.0;\n for (let i = 0; i < 5; i++) {\n const dx = xRange * abscissas[i];\n sum += weights[i] * (func(xMean + dx) + func(xMean - dx));\n }\n\n // Scale the sum to the range of x.\n sum *= xRange;\n return sum;\n}\n\n/**\n * A real valued scalar function.\n * @callback Ellipsoid~RealValuedScalarFunction\n *\n * @param {number} x The value used to evaluate the function.\n * @returns {number} The value of the function at x.\n *\n * @private\n */\n\n/**\n * Computes an approximation of the surface area of a rectangle on the surface of an ellipsoid using\n * Gauss-Legendre 10th order quadrature.\n *\n * @param {Rectangle} rectangle The rectangle used for computing the surface area.\n * @returns {number} The approximate area of the rectangle on the surface of this ellipsoid.\n */\nEllipsoid.prototype.surfaceArea = function (rectangle) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n const minLongitude = rectangle.west;\n let maxLongitude = rectangle.east;\n const minLatitude = rectangle.south;\n const maxLatitude = rectangle.north;\n\n while (maxLongitude < minLongitude) {\n maxLongitude += CesiumMath.TWO_PI;\n }\n\n const radiiSquared = this._radiiSquared;\n const a2 = radiiSquared.x;\n const b2 = radiiSquared.y;\n const c2 = radiiSquared.z;\n const a2b2 = a2 * b2;\n return gaussLegendreQuadrature(minLatitude, maxLatitude, function (lat) {\n // phi represents the angle measured from the north pole\n // sin(phi) = sin(pi / 2 - lat) = cos(lat), cos(phi) is similar\n const sinPhi = Math.cos(lat);\n const cosPhi = Math.sin(lat);\n return (\n Math.cos(lat) *\n gaussLegendreQuadrature(minLongitude, maxLongitude, function (lon) {\n const cosTheta = Math.cos(lon);\n const sinTheta = Math.sin(lon);\n return Math.sqrt(\n a2b2 * cosPhi * cosPhi +\n c2 *\n (b2 * cosTheta * cosTheta + a2 * sinTheta * sinTheta) *\n sinPhi *\n sinPhi\n );\n })\n );\n });\n};\n\nexport default Ellipsoid;\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport Ellipsoid from \"./Ellipsoid.js\";\n\n/**\n * A simple map projection where longitude and latitude are linearly mapped to X and Y by multiplying\n * them by the {@link Ellipsoid#maximumRadius}. This projection\n * is commonly known as geographic, equirectangular, equidistant cylindrical, or plate carr\u00E9e. It\n * is also known as EPSG:4326.\n *\n * @alias GeographicProjection\n * @constructor\n *\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid.\n *\n * @see WebMercatorProjection\n */\nfunction GeographicProjection(ellipsoid) {\n this._ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);\n this._semimajorAxis = this._ellipsoid.maximumRadius;\n this._oneOverSemimajorAxis = 1.0 / this._semimajorAxis;\n}\n\nObject.defineProperties(GeographicProjection.prototype, {\n /**\n * Gets the {@link Ellipsoid}.\n *\n * @memberof GeographicProjection.prototype\n *\n * @type {Ellipsoid}\n * @readonly\n */\n ellipsoid: {\n get: function () {\n return this._ellipsoid;\n },\n },\n});\n\n/**\n * Projects a set of {@link Cartographic} coordinates, in radians, to map coordinates, in meters.\n * X and Y are the longitude and latitude, respectively, multiplied by the maximum radius of the\n * ellipsoid. Z is the unmodified height.\n *\n * @param {Cartographic} cartographic The coordinates to project.\n * @param {Cartesian3} [result] An instance into which to copy the result. If this parameter is\n * undefined, a new instance is created and returned.\n * @returns {Cartesian3} The projected coordinates. If the result parameter is not undefined, the\n * coordinates are copied there and that instance is returned. Otherwise, a new instance is\n * created and returned.\n */\nGeographicProjection.prototype.project = function (cartographic, result) {\n // Actually this is the special case of equidistant cylindrical called the plate carree\n const semimajorAxis = this._semimajorAxis;\n const x = cartographic.longitude * semimajorAxis;\n const y = cartographic.latitude * semimajorAxis;\n const z = cartographic.height;\n\n if (!defined(result)) {\n return new Cartesian3(x, y, z);\n }\n\n result.x = x;\n result.y = y;\n result.z = z;\n return result;\n};\n\n/**\n * Unprojects a set of projected {@link Cartesian3} coordinates, in meters, to {@link Cartographic}\n * coordinates, in radians. Longitude and Latitude are the X and Y coordinates, respectively,\n * divided by the maximum radius of the ellipsoid. Height is the unmodified Z coordinate.\n *\n * @param {Cartesian3} cartesian The Cartesian position to unproject with height (z) in meters.\n * @param {Cartographic} [result] An instance into which to copy the result. If this parameter is\n * undefined, a new instance is created and returned.\n * @returns {Cartographic} The unprojected coordinates. If the result parameter is not undefined, the\n * coordinates are copied there and that instance is returned. Otherwise, a new instance is\n * created and returned.\n */\nGeographicProjection.prototype.unproject = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(cartesian)) {\n throw new DeveloperError(\"cartesian is required\");\n }\n //>>includeEnd('debug');\n\n const oneOverEarthSemimajorAxis = this._oneOverSemimajorAxis;\n const longitude = cartesian.x * oneOverEarthSemimajorAxis;\n const latitude = cartesian.y * oneOverEarthSemimajorAxis;\n const height = cartesian.z;\n\n if (!defined(result)) {\n return new Cartographic(longitude, latitude, height);\n }\n\n result.longitude = longitude;\n result.latitude = latitude;\n result.height = height;\n return result;\n};\nexport default GeographicProjection;\n", "/**\n * This enumerated type is used in determining where, relative to the frustum, an\n * object is located. The object can either be fully contained within the frustum (INSIDE),\n * partially inside the frustum and partially outside (INTERSECTING), or somewhere entirely\n * outside of the frustum's 6 planes (OUTSIDE).\n *\n * @enum {number}\n */\nconst Intersect = {\n /**\n * Represents that an object is not contained within the frustum.\n *\n * @type {number}\n * @constant\n */\n OUTSIDE: -1,\n\n /**\n * Represents that an object intersects one of the frustum's planes.\n *\n * @type {number}\n * @constant\n */\n INTERSECTING: 0,\n\n /**\n * Represents that an object is fully within the frustum.\n *\n * @type {number}\n * @constant\n */\n INSIDE: 1,\n};\nexport default Object.freeze(Intersect);\n", "import Cartographic from \"./Cartographic.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport Ellipsoid from \"./Ellipsoid.js\";\nimport CesiumMath from \"./Math.js\";\n\n/**\n * A two dimensional region specified as longitude and latitude coordinates.\n *\n * @alias Rectangle\n * @constructor\n *\n * @param {number} [west=0.0] The westernmost longitude, in radians, in the range [-Pi, Pi].\n * @param {number} [south=0.0] The southernmost latitude, in radians, in the range [-Pi/2, Pi/2].\n * @param {number} [east=0.0] The easternmost longitude, in radians, in the range [-Pi, Pi].\n * @param {number} [north=0.0] The northernmost latitude, in radians, in the range [-Pi/2, Pi/2].\n *\n * @see Packable\n */\nfunction Rectangle(west, south, east, north) {\n /**\n * The westernmost longitude in radians in the range [-Pi, Pi].\n *\n * @type {number}\n * @default 0.0\n */\n this.west = defaultValue(west, 0.0);\n\n /**\n * The southernmost latitude in radians in the range [-Pi/2, Pi/2].\n *\n * @type {number}\n * @default 0.0\n */\n this.south = defaultValue(south, 0.0);\n\n /**\n * The easternmost longitude in radians in the range [-Pi, Pi].\n *\n * @type {number}\n * @default 0.0\n */\n this.east = defaultValue(east, 0.0);\n\n /**\n * The northernmost latitude in radians in the range [-Pi/2, Pi/2].\n *\n * @type {number}\n * @default 0.0\n */\n this.north = defaultValue(north, 0.0);\n}\n\nObject.defineProperties(Rectangle.prototype, {\n /**\n * Gets the width of the rectangle in radians.\n * @memberof Rectangle.prototype\n * @type {number}\n * @readonly\n */\n width: {\n get: function () {\n return Rectangle.computeWidth(this);\n },\n },\n\n /**\n * Gets the height of the rectangle in radians.\n * @memberof Rectangle.prototype\n * @type {number}\n * @readonly\n */\n height: {\n get: function () {\n return Rectangle.computeHeight(this);\n },\n },\n});\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nRectangle.packedLength = 4;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Rectangle} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nRectangle.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value.west;\n array[startingIndex++] = value.south;\n array[startingIndex++] = value.east;\n array[startingIndex] = value.north;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Rectangle} [result] The object into which to store the result.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided.\n */\nRectangle.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Rectangle();\n }\n\n result.west = array[startingIndex++];\n result.south = array[startingIndex++];\n result.east = array[startingIndex++];\n result.north = array[startingIndex];\n return result;\n};\n\n/**\n * Computes the width of a rectangle in radians.\n * @param {Rectangle} rectangle The rectangle to compute the width of.\n * @returns {number} The width.\n */\nRectangle.computeWidth = function (rectangle) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n let east = rectangle.east;\n const west = rectangle.west;\n if (east < west) {\n east += CesiumMath.TWO_PI;\n }\n return east - west;\n};\n\n/**\n * Computes the height of a rectangle in radians.\n * @param {Rectangle} rectangle The rectangle to compute the height of.\n * @returns {number} The height.\n */\nRectangle.computeHeight = function (rectangle) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n return rectangle.north - rectangle.south;\n};\n\n/**\n * Creates a rectangle given the boundary longitude and latitude in degrees.\n *\n * @param {number} [west=0.0] The westernmost longitude in degrees in the range [-180.0, 180.0].\n * @param {number} [south=0.0] The southernmost latitude in degrees in the range [-90.0, 90.0].\n * @param {number} [east=0.0] The easternmost longitude in degrees in the range [-180.0, 180.0].\n * @param {number} [north=0.0] The northernmost latitude in degrees in the range [-90.0, 90.0].\n * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n *\n * @example\n * const rectangle = Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0);\n */\nRectangle.fromDegrees = function (west, south, east, north, result) {\n west = CesiumMath.toRadians(defaultValue(west, 0.0));\n south = CesiumMath.toRadians(defaultValue(south, 0.0));\n east = CesiumMath.toRadians(defaultValue(east, 0.0));\n north = CesiumMath.toRadians(defaultValue(north, 0.0));\n\n if (!defined(result)) {\n return new Rectangle(west, south, east, north);\n }\n\n result.west = west;\n result.south = south;\n result.east = east;\n result.north = north;\n\n return result;\n};\n\n/**\n * Creates a rectangle given the boundary longitude and latitude in radians.\n *\n * @param {number} [west=0.0] The westernmost longitude in radians in the range [-Math.PI, Math.PI].\n * @param {number} [south=0.0] The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].\n * @param {number} [east=0.0] The easternmost longitude in radians in the range [-Math.PI, Math.PI].\n * @param {number} [north=0.0] The northernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].\n * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n *\n * @example\n * const rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);\n */\nRectangle.fromRadians = function (west, south, east, north, result) {\n if (!defined(result)) {\n return new Rectangle(west, south, east, north);\n }\n\n result.west = defaultValue(west, 0.0);\n result.south = defaultValue(south, 0.0);\n result.east = defaultValue(east, 0.0);\n result.north = defaultValue(north, 0.0);\n\n return result;\n};\n\n/**\n * Creates the smallest possible Rectangle that encloses all positions in the provided array.\n *\n * @param {Cartographic[]} cartographics The list of Cartographic instances.\n * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n */\nRectangle.fromCartographicArray = function (cartographics, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"cartographics\", cartographics);\n //>>includeEnd('debug');\n\n let west = Number.MAX_VALUE;\n let east = -Number.MAX_VALUE;\n let westOverIDL = Number.MAX_VALUE;\n let eastOverIDL = -Number.MAX_VALUE;\n let south = Number.MAX_VALUE;\n let north = -Number.MAX_VALUE;\n\n for (let i = 0, len = cartographics.length; i < len; i++) {\n const position = cartographics[i];\n west = Math.min(west, position.longitude);\n east = Math.max(east, position.longitude);\n south = Math.min(south, position.latitude);\n north = Math.max(north, position.latitude);\n\n const lonAdjusted =\n position.longitude >= 0\n ? position.longitude\n : position.longitude + CesiumMath.TWO_PI;\n westOverIDL = Math.min(westOverIDL, lonAdjusted);\n eastOverIDL = Math.max(eastOverIDL, lonAdjusted);\n }\n\n if (east - west > eastOverIDL - westOverIDL) {\n west = westOverIDL;\n east = eastOverIDL;\n\n if (east > CesiumMath.PI) {\n east = east - CesiumMath.TWO_PI;\n }\n if (west > CesiumMath.PI) {\n west = west - CesiumMath.TWO_PI;\n }\n }\n\n if (!defined(result)) {\n return new Rectangle(west, south, east, north);\n }\n\n result.west = west;\n result.south = south;\n result.east = east;\n result.north = north;\n return result;\n};\n\n/**\n * Creates the smallest possible Rectangle that encloses all positions in the provided array.\n *\n * @param {Cartesian3[]} cartesians The list of Cartesian instances.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid the cartesians are on.\n * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n */\nRectangle.fromCartesianArray = function (cartesians, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"cartesians\", cartesians);\n //>>includeEnd('debug');\n ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);\n\n let west = Number.MAX_VALUE;\n let east = -Number.MAX_VALUE;\n let westOverIDL = Number.MAX_VALUE;\n let eastOverIDL = -Number.MAX_VALUE;\n let south = Number.MAX_VALUE;\n let north = -Number.MAX_VALUE;\n\n for (let i = 0, len = cartesians.length; i < len; i++) {\n const position = ellipsoid.cartesianToCartographic(cartesians[i]);\n west = Math.min(west, position.longitude);\n east = Math.max(east, position.longitude);\n south = Math.min(south, position.latitude);\n north = Math.max(north, position.latitude);\n\n const lonAdjusted =\n position.longitude >= 0\n ? position.longitude\n : position.longitude + CesiumMath.TWO_PI;\n westOverIDL = Math.min(westOverIDL, lonAdjusted);\n eastOverIDL = Math.max(eastOverIDL, lonAdjusted);\n }\n\n if (east - west > eastOverIDL - westOverIDL) {\n west = westOverIDL;\n east = eastOverIDL;\n\n if (east > CesiumMath.PI) {\n east = east - CesiumMath.TWO_PI;\n }\n if (west > CesiumMath.PI) {\n west = west - CesiumMath.TWO_PI;\n }\n }\n\n if (!defined(result)) {\n return new Rectangle(west, south, east, north);\n }\n\n result.west = west;\n result.south = south;\n result.east = east;\n result.north = north;\n return result;\n};\n\n/**\n * Duplicates a Rectangle.\n *\n * @param {Rectangle} rectangle The rectangle to clone.\n * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. (Returns undefined if rectangle is undefined)\n */\nRectangle.clone = function (rectangle, result) {\n if (!defined(rectangle)) {\n return undefined;\n }\n\n if (!defined(result)) {\n return new Rectangle(\n rectangle.west,\n rectangle.south,\n rectangle.east,\n rectangle.north\n );\n }\n\n result.west = rectangle.west;\n result.south = rectangle.south;\n result.east = rectangle.east;\n result.north = rectangle.north;\n return result;\n};\n\n/**\n * Compares the provided Rectangles componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {Rectangle} [left] The first Rectangle.\n * @param {Rectangle} [right] The second Rectangle.\n * @param {number} [absoluteEpsilon=0] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nRectangle.equalsEpsilon = function (left, right, absoluteEpsilon) {\n absoluteEpsilon = defaultValue(absoluteEpsilon, 0);\n\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(left.west - right.west) <= absoluteEpsilon &&\n Math.abs(left.south - right.south) <= absoluteEpsilon &&\n Math.abs(left.east - right.east) <= absoluteEpsilon &&\n Math.abs(left.north - right.north) <= absoluteEpsilon)\n );\n};\n\n/**\n * Duplicates this Rectangle.\n *\n * @param {Rectangle} [result] The object onto which to store the result.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n */\nRectangle.prototype.clone = function (result) {\n return Rectangle.clone(this, result);\n};\n\n/**\n * Compares the provided Rectangle with this Rectangle componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Rectangle} [other] The Rectangle to compare.\n * @returns {boolean} true if the Rectangles are equal, false otherwise.\n */\nRectangle.prototype.equals = function (other) {\n return Rectangle.equals(this, other);\n};\n\n/**\n * Compares the provided rectangles and returns true if they are equal,\n * false otherwise.\n *\n * @param {Rectangle} [left] The first Rectangle.\n * @param {Rectangle} [right] The second Rectangle.\n * @returns {boolean} true if left and right are equal; otherwise false.\n */\nRectangle.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.west === right.west &&\n left.south === right.south &&\n left.east === right.east &&\n left.north === right.north)\n );\n};\n\n/**\n * Compares the provided Rectangle with this Rectangle componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Rectangle} [other] The Rectangle to compare.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if the Rectangles are within the provided epsilon, false otherwise.\n */\nRectangle.prototype.equalsEpsilon = function (other, epsilon) {\n return Rectangle.equalsEpsilon(this, other, epsilon);\n};\n\n/**\n * Checks a Rectangle's properties and throws if they are not in valid ranges.\n *\n * @param {Rectangle} rectangle The rectangle to validate\n *\n * @exception {DeveloperError} north must be in the interval [-Pi/2, Pi/2].\n * @exception {DeveloperError} south must be in the interval [-Pi/2, Pi/2].\n * @exception {DeveloperError} east must be in the interval [-Pi, Pi].\n * @exception {DeveloperError} west must be in the interval [-Pi, Pi].\n */\nRectangle.validate = function (rectangle) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n\n const north = rectangle.north;\n Check.typeOf.number.greaterThanOrEquals(\n \"north\",\n north,\n -CesiumMath.PI_OVER_TWO\n );\n Check.typeOf.number.lessThanOrEquals(\"north\", north, CesiumMath.PI_OVER_TWO);\n\n const south = rectangle.south;\n Check.typeOf.number.greaterThanOrEquals(\n \"south\",\n south,\n -CesiumMath.PI_OVER_TWO\n );\n Check.typeOf.number.lessThanOrEquals(\"south\", south, CesiumMath.PI_OVER_TWO);\n\n const west = rectangle.west;\n Check.typeOf.number.greaterThanOrEquals(\"west\", west, -Math.PI);\n Check.typeOf.number.lessThanOrEquals(\"west\", west, Math.PI);\n\n const east = rectangle.east;\n Check.typeOf.number.greaterThanOrEquals(\"east\", east, -Math.PI);\n Check.typeOf.number.lessThanOrEquals(\"east\", east, Math.PI);\n //>>includeEnd('debug');\n};\n\n/**\n * Computes the southwest corner of a rectangle.\n *\n * @param {Rectangle} rectangle The rectangle for which to find the corner\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.\n */\nRectangle.southwest = function (rectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Cartographic(rectangle.west, rectangle.south);\n }\n result.longitude = rectangle.west;\n result.latitude = rectangle.south;\n result.height = 0.0;\n return result;\n};\n\n/**\n * Computes the northwest corner of a rectangle.\n *\n * @param {Rectangle} rectangle The rectangle for which to find the corner\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.\n */\nRectangle.northwest = function (rectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Cartographic(rectangle.west, rectangle.north);\n }\n result.longitude = rectangle.west;\n result.latitude = rectangle.north;\n result.height = 0.0;\n return result;\n};\n\n/**\n * Computes the northeast corner of a rectangle.\n *\n * @param {Rectangle} rectangle The rectangle for which to find the corner\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.\n */\nRectangle.northeast = function (rectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Cartographic(rectangle.east, rectangle.north);\n }\n result.longitude = rectangle.east;\n result.latitude = rectangle.north;\n result.height = 0.0;\n return result;\n};\n\n/**\n * Computes the southeast corner of a rectangle.\n *\n * @param {Rectangle} rectangle The rectangle for which to find the corner\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.\n */\nRectangle.southeast = function (rectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Cartographic(rectangle.east, rectangle.south);\n }\n result.longitude = rectangle.east;\n result.latitude = rectangle.south;\n result.height = 0.0;\n return result;\n};\n\n/**\n * Computes the center of a rectangle.\n *\n * @param {Rectangle} rectangle The rectangle for which to find the center\n * @param {Cartographic} [result] The object onto which to store the result.\n * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.\n */\nRectangle.center = function (rectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n\n let east = rectangle.east;\n const west = rectangle.west;\n\n if (east < west) {\n east += CesiumMath.TWO_PI;\n }\n\n const longitude = CesiumMath.negativePiToPi((west + east) * 0.5);\n const latitude = (rectangle.south + rectangle.north) * 0.5;\n\n if (!defined(result)) {\n return new Cartographic(longitude, latitude);\n }\n\n result.longitude = longitude;\n result.latitude = latitude;\n result.height = 0.0;\n return result;\n};\n\n/**\n * Computes the intersection of two rectangles. This function assumes that the rectangle's coordinates are\n * latitude and longitude in radians and produces a correct intersection, taking into account the fact that\n * the same angle can be represented with multiple values as well as the wrapping of longitude at the\n * anti-meridian. For a simple intersection that ignores these factors and can be used with projected\n * coordinates, see {@link Rectangle.simpleIntersection}.\n *\n * @param {Rectangle} rectangle On rectangle to find an intersection\n * @param {Rectangle} otherRectangle Another rectangle to find an intersection\n * @param {Rectangle} [result] The object onto which to store the result.\n * @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.\n */\nRectangle.intersection = function (rectangle, otherRectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.object(\"otherRectangle\", otherRectangle);\n //>>includeEnd('debug');\n\n let rectangleEast = rectangle.east;\n let rectangleWest = rectangle.west;\n\n let otherRectangleEast = otherRectangle.east;\n let otherRectangleWest = otherRectangle.west;\n\n if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {\n rectangleEast += CesiumMath.TWO_PI;\n } else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {\n otherRectangleEast += CesiumMath.TWO_PI;\n }\n\n if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) {\n otherRectangleWest += CesiumMath.TWO_PI;\n } else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) {\n rectangleWest += CesiumMath.TWO_PI;\n }\n\n const west = CesiumMath.negativePiToPi(\n Math.max(rectangleWest, otherRectangleWest)\n );\n const east = CesiumMath.negativePiToPi(\n Math.min(rectangleEast, otherRectangleEast)\n );\n\n if (\n (rectangle.west < rectangle.east ||\n otherRectangle.west < otherRectangle.east) &&\n east <= west\n ) {\n return undefined;\n }\n\n const south = Math.max(rectangle.south, otherRectangle.south);\n const north = Math.min(rectangle.north, otherRectangle.north);\n\n if (south >= north) {\n return undefined;\n }\n\n if (!defined(result)) {\n return new Rectangle(west, south, east, north);\n }\n result.west = west;\n result.south = south;\n result.east = east;\n result.north = north;\n return result;\n};\n\n/**\n * Computes a simple intersection of two rectangles. Unlike {@link Rectangle.intersection}, this function\n * does not attempt to put the angular coordinates into a consistent range or to account for crossing the\n * anti-meridian. As such, it can be used for rectangles where the coordinates are not simply latitude\n * and longitude (i.e. projected coordinates).\n *\n * @param {Rectangle} rectangle On rectangle to find an intersection\n * @param {Rectangle} otherRectangle Another rectangle to find an intersection\n * @param {Rectangle} [result] The object onto which to store the result.\n * @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.\n */\nRectangle.simpleIntersection = function (rectangle, otherRectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.object(\"otherRectangle\", otherRectangle);\n //>>includeEnd('debug');\n\n const west = Math.max(rectangle.west, otherRectangle.west);\n const south = Math.max(rectangle.south, otherRectangle.south);\n const east = Math.min(rectangle.east, otherRectangle.east);\n const north = Math.min(rectangle.north, otherRectangle.north);\n\n if (south >= north || west >= east) {\n return undefined;\n }\n\n if (!defined(result)) {\n return new Rectangle(west, south, east, north);\n }\n\n result.west = west;\n result.south = south;\n result.east = east;\n result.north = north;\n return result;\n};\n\n/**\n * Computes a rectangle that is the union of two rectangles.\n *\n * @param {Rectangle} rectangle A rectangle to enclose in rectangle.\n * @param {Rectangle} otherRectangle A rectangle to enclose in a rectangle.\n * @param {Rectangle} [result] The object onto which to store the result.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n */\nRectangle.union = function (rectangle, otherRectangle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.object(\"otherRectangle\", otherRectangle);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Rectangle();\n }\n\n let rectangleEast = rectangle.east;\n let rectangleWest = rectangle.west;\n\n let otherRectangleEast = otherRectangle.east;\n let otherRectangleWest = otherRectangle.west;\n\n if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {\n rectangleEast += CesiumMath.TWO_PI;\n } else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {\n otherRectangleEast += CesiumMath.TWO_PI;\n }\n\n if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) {\n otherRectangleWest += CesiumMath.TWO_PI;\n } else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) {\n rectangleWest += CesiumMath.TWO_PI;\n }\n\n const west = CesiumMath.negativePiToPi(\n Math.min(rectangleWest, otherRectangleWest)\n );\n const east = CesiumMath.negativePiToPi(\n Math.max(rectangleEast, otherRectangleEast)\n );\n\n result.west = west;\n result.south = Math.min(rectangle.south, otherRectangle.south);\n result.east = east;\n result.north = Math.max(rectangle.north, otherRectangle.north);\n\n return result;\n};\n\n/**\n * Computes a rectangle by enlarging the provided rectangle until it contains the provided cartographic.\n *\n * @param {Rectangle} rectangle A rectangle to expand.\n * @param {Cartographic} cartographic A cartographic to enclose in a rectangle.\n * @param {Rectangle} [result] The object onto which to store the result.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided.\n */\nRectangle.expand = function (rectangle, cartographic, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.object(\"cartographic\", cartographic);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Rectangle();\n }\n\n result.west = Math.min(rectangle.west, cartographic.longitude);\n result.south = Math.min(rectangle.south, cartographic.latitude);\n result.east = Math.max(rectangle.east, cartographic.longitude);\n result.north = Math.max(rectangle.north, cartographic.latitude);\n\n return result;\n};\n\n/**\n * Returns true if the cartographic is on or inside the rectangle, false otherwise.\n *\n * @param {Rectangle} rectangle The rectangle\n * @param {Cartographic} cartographic The cartographic to test.\n * @returns {boolean} true if the provided cartographic is inside the rectangle, false otherwise.\n */\nRectangle.contains = function (rectangle, cartographic) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.object(\"cartographic\", cartographic);\n //>>includeEnd('debug');\n\n let longitude = cartographic.longitude;\n const latitude = cartographic.latitude;\n\n const west = rectangle.west;\n let east = rectangle.east;\n\n if (east < west) {\n east += CesiumMath.TWO_PI;\n if (longitude < 0.0) {\n longitude += CesiumMath.TWO_PI;\n }\n }\n return (\n (longitude > west ||\n CesiumMath.equalsEpsilon(longitude, west, CesiumMath.EPSILON14)) &&\n (longitude < east ||\n CesiumMath.equalsEpsilon(longitude, east, CesiumMath.EPSILON14)) &&\n latitude >= rectangle.south &&\n latitude <= rectangle.north\n );\n};\n\nconst subsampleLlaScratch = new Cartographic();\n/**\n * Samples a rectangle so that it includes a list of Cartesian points suitable for passing to\n * {@link BoundingSphere#fromPoints}. Sampling is necessary to account\n * for rectangles that cover the poles or cross the equator.\n *\n * @param {Rectangle} rectangle The rectangle to subsample.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to use.\n * @param {number} [surfaceHeight=0.0] The height of the rectangle above the ellipsoid.\n * @param {Cartesian3[]} [result] The array of Cartesians onto which to store the result.\n * @returns {Cartesian3[]} The modified result parameter or a new Array of Cartesians instances if none was provided.\n */\nRectangle.subsample = function (rectangle, ellipsoid, surfaceHeight, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n //>>includeEnd('debug');\n\n ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);\n surfaceHeight = defaultValue(surfaceHeight, 0.0);\n\n if (!defined(result)) {\n result = [];\n }\n let length = 0;\n\n const north = rectangle.north;\n const south = rectangle.south;\n const east = rectangle.east;\n const west = rectangle.west;\n\n const lla = subsampleLlaScratch;\n lla.height = surfaceHeight;\n\n lla.longitude = west;\n lla.latitude = north;\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n\n lla.longitude = east;\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n\n lla.latitude = south;\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n\n lla.longitude = west;\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n\n if (north < 0.0) {\n lla.latitude = north;\n } else if (south > 0.0) {\n lla.latitude = south;\n } else {\n lla.latitude = 0.0;\n }\n\n for (let i = 1; i < 8; ++i) {\n lla.longitude = -Math.PI + i * CesiumMath.PI_OVER_TWO;\n if (Rectangle.contains(rectangle, lla)) {\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n }\n }\n\n if (lla.latitude === 0.0) {\n lla.longitude = west;\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n lla.longitude = east;\n result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);\n length++;\n }\n result.length = length;\n return result;\n};\n\n/**\n * Computes a subsection of a rectangle from normalized coordinates in the range [0.0, 1.0].\n *\n * @param {Rectangle} rectangle The rectangle to subsection.\n * @param {number} westLerp The west interpolation factor in the range [0.0, 1.0]. Must be less than or equal to eastLerp.\n * @param {number} southLerp The south interpolation factor in the range [0.0, 1.0]. Must be less than or equal to northLerp.\n * @param {number} eastLerp The east interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to westLerp.\n * @param {number} northLerp The north interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to southLerp.\n * @param {Rectangle} [result] The object onto which to store the result.\n * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.\n */\nRectangle.subsection = function (\n rectangle,\n westLerp,\n southLerp,\n eastLerp,\n northLerp,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.number.greaterThanOrEquals(\"westLerp\", westLerp, 0.0);\n Check.typeOf.number.lessThanOrEquals(\"westLerp\", westLerp, 1.0);\n Check.typeOf.number.greaterThanOrEquals(\"southLerp\", southLerp, 0.0);\n Check.typeOf.number.lessThanOrEquals(\"southLerp\", southLerp, 1.0);\n Check.typeOf.number.greaterThanOrEquals(\"eastLerp\", eastLerp, 0.0);\n Check.typeOf.number.lessThanOrEquals(\"eastLerp\", eastLerp, 1.0);\n Check.typeOf.number.greaterThanOrEquals(\"northLerp\", northLerp, 0.0);\n Check.typeOf.number.lessThanOrEquals(\"northLerp\", northLerp, 1.0);\n\n Check.typeOf.number.lessThanOrEquals(\"westLerp\", westLerp, eastLerp);\n Check.typeOf.number.lessThanOrEquals(\"southLerp\", southLerp, northLerp);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Rectangle();\n }\n\n // This function doesn't use CesiumMath.lerp because it has floating point precision problems\n // when the start and end values are the same but the t changes.\n\n if (rectangle.west <= rectangle.east) {\n const width = rectangle.east - rectangle.west;\n result.west = rectangle.west + westLerp * width;\n result.east = rectangle.west + eastLerp * width;\n } else {\n const width = CesiumMath.TWO_PI + rectangle.east - rectangle.west;\n result.west = CesiumMath.negativePiToPi(rectangle.west + westLerp * width);\n result.east = CesiumMath.negativePiToPi(rectangle.west + eastLerp * width);\n }\n const height = rectangle.north - rectangle.south;\n result.south = rectangle.south + southLerp * height;\n result.north = rectangle.south + northLerp * height;\n\n // Fix floating point precision problems when t = 1\n if (westLerp === 1.0) {\n result.west = rectangle.east;\n }\n if (eastLerp === 1.0) {\n result.east = rectangle.east;\n }\n if (southLerp === 1.0) {\n result.south = rectangle.north;\n }\n if (northLerp === 1.0) {\n result.north = rectangle.north;\n }\n\n return result;\n};\n\n/**\n * The largest possible rectangle.\n *\n * @type {Rectangle}\n * @constant\n */\nRectangle.MAX_VALUE = Object.freeze(\n new Rectangle(\n -Math.PI,\n -CesiumMath.PI_OVER_TWO,\n Math.PI,\n CesiumMath.PI_OVER_TWO\n )\n);\nexport default Rectangle;\n", "import Cartesian2 from \"./Cartesian2.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport GeographicProjection from \"./GeographicProjection.js\";\nimport Intersect from \"./Intersect.js\";\nimport Rectangle from \"./Rectangle.js\";\n\n/**\n * A bounding rectangle given by a corner, width and height.\n * @alias BoundingRectangle\n * @constructor\n *\n * @param {number} [x=0.0] The x coordinate of the rectangle.\n * @param {number} [y=0.0] The y coordinate of the rectangle.\n * @param {number} [width=0.0] The width of the rectangle.\n * @param {number} [height=0.0] The height of the rectangle.\n *\n * @see BoundingSphere\n * @see Packable\n */\nfunction BoundingRectangle(x, y, width, height) {\n /**\n * The x coordinate of the rectangle.\n * @type {number}\n * @default 0.0\n */\n this.x = defaultValue(x, 0.0);\n\n /**\n * The y coordinate of the rectangle.\n * @type {number}\n * @default 0.0\n */\n this.y = defaultValue(y, 0.0);\n\n /**\n * The width of the rectangle.\n * @type {number}\n * @default 0.0\n */\n this.width = defaultValue(width, 0.0);\n\n /**\n * The height of the rectangle.\n * @type {number}\n * @default 0.0\n */\n this.height = defaultValue(height, 0.0);\n}\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nBoundingRectangle.packedLength = 4;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {BoundingRectangle} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nBoundingRectangle.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value.x;\n array[startingIndex++] = value.y;\n array[startingIndex++] = value.width;\n array[startingIndex] = value.height;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {BoundingRectangle} [result] The object into which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.\n */\nBoundingRectangle.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new BoundingRectangle();\n }\n result.x = array[startingIndex++];\n result.y = array[startingIndex++];\n result.width = array[startingIndex++];\n result.height = array[startingIndex];\n return result;\n};\n\n/**\n * Computes a bounding rectangle enclosing the list of 2D points.\n * The rectangle is oriented with the corner at the bottom left.\n *\n * @param {Cartesian2[]} positions List of points that the bounding rectangle will enclose. Each point must have x and y properties.\n * @param {BoundingRectangle} [result] The object onto which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.\n */\nBoundingRectangle.fromPoints = function (positions, result) {\n if (!defined(result)) {\n result = new BoundingRectangle();\n }\n\n if (!defined(positions) || positions.length === 0) {\n result.x = 0;\n result.y = 0;\n result.width = 0;\n result.height = 0;\n return result;\n }\n\n const length = positions.length;\n\n let minimumX = positions[0].x;\n let minimumY = positions[0].y;\n\n let maximumX = positions[0].x;\n let maximumY = positions[0].y;\n\n for (let i = 1; i < length; i++) {\n const p = positions[i];\n const x = p.x;\n const y = p.y;\n\n minimumX = Math.min(x, minimumX);\n maximumX = Math.max(x, maximumX);\n minimumY = Math.min(y, minimumY);\n maximumY = Math.max(y, maximumY);\n }\n\n result.x = minimumX;\n result.y = minimumY;\n result.width = maximumX - minimumX;\n result.height = maximumY - minimumY;\n return result;\n};\n\nconst defaultProjection = new GeographicProjection();\nconst fromRectangleLowerLeft = new Cartographic();\nconst fromRectangleUpperRight = new Cartographic();\n/**\n * Computes a bounding rectangle from a rectangle.\n *\n * @param {Rectangle} rectangle The valid rectangle used to create a bounding rectangle.\n * @param {object} [projection=GeographicProjection] The projection used to project the rectangle into 2D.\n * @param {BoundingRectangle} [result] The object onto which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.\n */\nBoundingRectangle.fromRectangle = function (rectangle, projection, result) {\n if (!defined(result)) {\n result = new BoundingRectangle();\n }\n\n if (!defined(rectangle)) {\n result.x = 0;\n result.y = 0;\n result.width = 0;\n result.height = 0;\n return result;\n }\n\n projection = defaultValue(projection, defaultProjection);\n\n const lowerLeft = projection.project(\n Rectangle.southwest(rectangle, fromRectangleLowerLeft)\n );\n const upperRight = projection.project(\n Rectangle.northeast(rectangle, fromRectangleUpperRight)\n );\n\n Cartesian2.subtract(upperRight, lowerLeft, upperRight);\n\n result.x = lowerLeft.x;\n result.y = lowerLeft.y;\n result.width = upperRight.x;\n result.height = upperRight.y;\n return result;\n};\n\n/**\n * Duplicates a BoundingRectangle instance.\n *\n * @param {BoundingRectangle} rectangle The bounding rectangle to duplicate.\n * @param {BoundingRectangle} [result] The object onto which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided. (Returns undefined if rectangle is undefined)\n */\nBoundingRectangle.clone = function (rectangle, result) {\n if (!defined(rectangle)) {\n return undefined;\n }\n\n if (!defined(result)) {\n return new BoundingRectangle(\n rectangle.x,\n rectangle.y,\n rectangle.width,\n rectangle.height\n );\n }\n\n result.x = rectangle.x;\n result.y = rectangle.y;\n result.width = rectangle.width;\n result.height = rectangle.height;\n return result;\n};\n\n/**\n * Computes a bounding rectangle that is the union of the left and right bounding rectangles.\n *\n * @param {BoundingRectangle} left A rectangle to enclose in bounding rectangle.\n * @param {BoundingRectangle} right A rectangle to enclose in a bounding rectangle.\n * @param {BoundingRectangle} [result] The object onto which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.\n */\nBoundingRectangle.union = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new BoundingRectangle();\n }\n\n const lowerLeftX = Math.min(left.x, right.x);\n const lowerLeftY = Math.min(left.y, right.y);\n const upperRightX = Math.max(left.x + left.width, right.x + right.width);\n const upperRightY = Math.max(left.y + left.height, right.y + right.height);\n\n result.x = lowerLeftX;\n result.y = lowerLeftY;\n result.width = upperRightX - lowerLeftX;\n result.height = upperRightY - lowerLeftY;\n return result;\n};\n\n/**\n * Computes a bounding rectangle by enlarging the provided rectangle until it contains the provided point.\n *\n * @param {BoundingRectangle} rectangle A rectangle to expand.\n * @param {Cartesian2} point A point to enclose in a bounding rectangle.\n * @param {BoundingRectangle} [result] The object onto which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.\n */\nBoundingRectangle.expand = function (rectangle, point, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"rectangle\", rectangle);\n Check.typeOf.object(\"point\", point);\n //>>includeEnd('debug');\n\n result = BoundingRectangle.clone(rectangle, result);\n\n const width = point.x - result.x;\n const height = point.y - result.y;\n\n if (width > result.width) {\n result.width = width;\n } else if (width < 0) {\n result.width -= width;\n result.x = point.x;\n }\n\n if (height > result.height) {\n result.height = height;\n } else if (height < 0) {\n result.height -= height;\n result.y = point.y;\n }\n\n return result;\n};\n\n/**\n * Determines if two rectangles intersect.\n *\n * @param {BoundingRectangle} left A rectangle to check for intersection.\n * @param {BoundingRectangle} right The other rectangle to check for intersection.\n * @returns {Intersect} Intersect.INTERSECTING if the rectangles intersect, Intersect.OUTSIDE otherwise.\n */\nBoundingRectangle.intersect = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n const leftX = left.x;\n const leftY = left.y;\n const rightX = right.x;\n const rightY = right.y;\n if (\n !(\n leftX > rightX + right.width ||\n leftX + left.width < rightX ||\n leftY + left.height < rightY ||\n leftY > rightY + right.height\n )\n ) {\n return Intersect.INTERSECTING;\n }\n\n return Intersect.OUTSIDE;\n};\n\n/**\n * Compares the provided BoundingRectangles componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {BoundingRectangle} [left] The first BoundingRectangle.\n * @param {BoundingRectangle} [right] The second BoundingRectangle.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nBoundingRectangle.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.x === right.x &&\n left.y === right.y &&\n left.width === right.width &&\n left.height === right.height)\n );\n};\n\n/**\n * Duplicates this BoundingRectangle instance.\n *\n * @param {BoundingRectangle} [result] The object onto which to store the result.\n * @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.\n */\nBoundingRectangle.prototype.clone = function (result) {\n return BoundingRectangle.clone(this, result);\n};\n\n/**\n * Determines if this rectangle intersects with another.\n *\n * @param {BoundingRectangle} right A rectangle to check for intersection.\n * @returns {Intersect} Intersect.INTERSECTING if the rectangles intersect, Intersect.OUTSIDE otherwise.\n */\nBoundingRectangle.prototype.intersect = function (right) {\n return BoundingRectangle.intersect(this, right);\n};\n\n/**\n * Compares this BoundingRectangle against the provided BoundingRectangle componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {BoundingRectangle} [right] The right hand side BoundingRectangle.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nBoundingRectangle.prototype.equals = function (right) {\n return BoundingRectangle.equals(this, right);\n};\nexport default BoundingRectangle;\n", "import WebGLConstants from \"./WebGLConstants.js\";\n\n/**\n * The type of a geometric primitive, i.e., points, lines, and triangles.\n *\n * @enum {number}\n */\nconst PrimitiveType = {\n /**\n * Points primitive where each vertex (or index) is a separate point.\n *\n * @type {number}\n * @constant\n */\n POINTS: WebGLConstants.POINTS,\n\n /**\n * Lines primitive where each two vertices (or indices) is a line segment. Line segments are not necessarily connected.\n *\n * @type {number}\n * @constant\n */\n LINES: WebGLConstants.LINES,\n\n /**\n * Line loop primitive where each vertex (or index) after the first connects a line to\n * the previous vertex, and the last vertex implicitly connects to the first.\n *\n * @type {number}\n * @constant\n */\n LINE_LOOP: WebGLConstants.LINE_LOOP,\n\n /**\n * Line strip primitive where each vertex (or index) after the first connects a line to the previous vertex.\n *\n * @type {number}\n * @constant\n */\n LINE_STRIP: WebGLConstants.LINE_STRIP,\n\n /**\n * Triangles primitive where each three vertices (or indices) is a triangle. Triangles do not necessarily share edges.\n *\n * @type {number}\n * @constant\n */\n TRIANGLES: WebGLConstants.TRIANGLES,\n\n /**\n * Triangle strip primitive where each vertex (or index) after the first two connect to\n * the previous two vertices forming a triangle. For example, this can be used to model a wall.\n *\n * @type {number}\n * @constant\n */\n TRIANGLE_STRIP: WebGLConstants.TRIANGLE_STRIP,\n\n /**\n * Triangle fan primitive where each vertex (or index) after the first two connect to\n * the previous vertex and the first vertex forming a triangle. For example, this can be used\n * to model a cone or circle.\n *\n * @type {number}\n * @constant\n */\n TRIANGLE_FAN: WebGLConstants.TRIANGLE_FAN,\n};\n\n/**\n * @private\n */\nPrimitiveType.isLines = function (primitiveType) {\n return (\n primitiveType === PrimitiveType.LINES ||\n primitiveType === PrimitiveType.LINE_LOOP ||\n primitiveType === PrimitiveType.LINE_STRIP\n );\n};\n\n/**\n * @private\n */\nPrimitiveType.isTriangles = function (primitiveType) {\n return (\n primitiveType === PrimitiveType.TRIANGLES ||\n primitiveType === PrimitiveType.TRIANGLE_STRIP ||\n primitiveType === PrimitiveType.TRIANGLE_FAN\n );\n};\n\n/**\n * @private\n */\nPrimitiveType.validate = function (primitiveType) {\n return (\n primitiveType === PrimitiveType.POINTS ||\n primitiveType === PrimitiveType.LINES ||\n primitiveType === PrimitiveType.LINE_LOOP ||\n primitiveType === PrimitiveType.LINE_STRIP ||\n primitiveType === PrimitiveType.TRIANGLES ||\n primitiveType === PrimitiveType.TRIANGLE_STRIP ||\n primitiveType === PrimitiveType.TRIANGLE_FAN\n );\n};\n\nexport default Object.freeze(PrimitiveType);\n", "//This file is automatically rebuilt by the Cesium build process.\nexport default \"in vec4 position;\\n\\\nin vec2 textureCoordinates;\\n\\\n\\n\\\nout vec2 v_textureCoordinates;\\n\\\n\\n\\\nvoid main() \\n\\\n{\\n\\\n gl_Position = position;\\n\\\n v_textureCoordinates = textureCoordinates;\\n\\\n}\\n\\\n\";\n", "import defaultValue from \"../Core/defaultValue.js\";\nimport defined from \"../Core/defined.js\";\nimport PrimitiveType from \"../Core/PrimitiveType.js\";\n\nconst Flags = {\n CULL: 1,\n OCCLUDE: 2,\n EXECUTE_IN_CLOSEST_FRUSTUM: 4,\n DEBUG_SHOW_BOUNDING_VOLUME: 8,\n CAST_SHADOWS: 16,\n RECEIVE_SHADOWS: 32,\n PICK_ONLY: 64,\n DEPTH_FOR_TRANSLUCENT_CLASSIFICATION: 128,\n};\n\n/**\n * Represents a command to the renderer for drawing.\n *\n * @private\n */\nfunction DrawCommand(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n this._boundingVolume = options.boundingVolume;\n this._orientedBoundingBox = options.orientedBoundingBox;\n this._modelMatrix = options.modelMatrix;\n this._primitiveType = defaultValue(\n options.primitiveType,\n PrimitiveType.TRIANGLES\n );\n this._vertexArray = options.vertexArray;\n this._count = options.count;\n this._offset = defaultValue(options.offset, 0);\n this._instanceCount = defaultValue(options.instanceCount, 0);\n this._shaderProgram = options.shaderProgram;\n this._uniformMap = options.uniformMap;\n this._renderState = options.renderState;\n this._framebuffer = options.framebuffer;\n this._pass = options.pass;\n this._owner = options.owner;\n this._debugOverlappingFrustums = 0;\n this._pickId = options.pickId;\n\n // Set initial flags.\n this._flags = 0;\n this.cull = defaultValue(options.cull, true);\n this.occlude = defaultValue(options.occlude, true);\n this.executeInClosestFrustum = defaultValue(\n options.executeInClosestFrustum,\n false\n );\n this.debugShowBoundingVolume = defaultValue(\n options.debugShowBoundingVolume,\n false\n );\n this.castShadows = defaultValue(options.castShadows, false);\n this.receiveShadows = defaultValue(options.receiveShadows, false);\n this.pickOnly = defaultValue(options.pickOnly, false);\n this.depthForTranslucentClassification = defaultValue(\n options.depthForTranslucentClassification,\n false\n );\n\n this.dirty = true;\n this.lastDirtyTime = 0;\n\n /**\n * @private\n */\n this.derivedCommands = {};\n}\n\nfunction hasFlag(command, flag) {\n return (command._flags & flag) === flag;\n}\n\nfunction setFlag(command, flag, value) {\n if (value) {\n command._flags |= flag;\n } else {\n command._flags &= ~flag;\n }\n}\n\nObject.defineProperties(DrawCommand.prototype, {\n /**\n * The bounding volume of the geometry in world space. This is used for culling and frustum selection.\n *
\n * For best rendering performance, use the tightest possible bounding volume. Although\n * undefined is allowed, always try to provide a bounding volume to\n * allow the tightest possible near and far planes to be computed for the scene, and\n * minimize the number of frustums needed.\n *
\n *\n * @memberof DrawCommand.prototype\n * @type {object}\n * @default undefined\n *\n * @see DrawCommand#debugShowBoundingVolume\n */\n boundingVolume: {\n get: function () {\n return this._boundingVolume;\n },\n set: function (value) {\n if (this._boundingVolume !== value) {\n this._boundingVolume = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The oriented bounding box of the geometry in world space. If this is defined, it is used instead of\n * {@link DrawCommand#boundingVolume} for plane intersection testing.\n *\n * @memberof DrawCommand.prototype\n * @type {OrientedBoundingBox}\n * @default undefined\n *\n * @see DrawCommand#debugShowBoundingVolume\n */\n orientedBoundingBox: {\n get: function () {\n return this._orientedBoundingBox;\n },\n set: function (value) {\n if (this._orientedBoundingBox !== value) {\n this._orientedBoundingBox = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * When true, the renderer frustum and horizon culls the command based on its {@link DrawCommand#boundingVolume}.\n * If the command was already culled, set this to false for a performance improvement.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default true\n */\n cull: {\n get: function () {\n return hasFlag(this, Flags.CULL);\n },\n set: function (value) {\n if (hasFlag(this, Flags.CULL) !== value) {\n setFlag(this, Flags.CULL, value);\n this.dirty = true;\n }\n },\n },\n\n /**\n * When true, the horizon culls the command based on its {@link DrawCommand#boundingVolume}.\n * {@link DrawCommand#cull} must also be true in order for the command to be culled.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default true\n */\n occlude: {\n get: function () {\n return hasFlag(this, Flags.OCCLUDE);\n },\n set: function (value) {\n if (hasFlag(this, Flags.OCCLUDE) !== value) {\n setFlag(this, Flags.OCCLUDE, value);\n this.dirty = true;\n }\n },\n },\n\n /**\n * The transformation from the geometry in model space to world space.\n *
\n * When undefined, the geometry is assumed to be defined in world space.\n *
\n *\n * @memberof DrawCommand.prototype\n * @type {Matrix4}\n * @default undefined\n */\n modelMatrix: {\n get: function () {\n return this._modelMatrix;\n },\n set: function (value) {\n if (this._modelMatrix !== value) {\n this._modelMatrix = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The type of geometry in the vertex array.\n *\n * @memberof DrawCommand.prototype\n * @type {PrimitiveType}\n * @default PrimitiveType.TRIANGLES\n */\n primitiveType: {\n get: function () {\n return this._primitiveType;\n },\n set: function (value) {\n if (this._primitiveType !== value) {\n this._primitiveType = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The vertex array.\n *\n * @memberof DrawCommand.prototype\n * @type {VertexArray}\n * @default undefined\n */\n vertexArray: {\n get: function () {\n return this._vertexArray;\n },\n set: function (value) {\n if (this._vertexArray !== value) {\n this._vertexArray = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The number of vertices to draw in the vertex array.\n *\n * @memberof DrawCommand.prototype\n * @type {number}\n * @default undefined\n */\n count: {\n get: function () {\n return this._count;\n },\n set: function (value) {\n if (this._count !== value) {\n this._count = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The offset to start drawing in the vertex array.\n *\n * @memberof DrawCommand.prototype\n * @type {number}\n * @default 0\n */\n offset: {\n get: function () {\n return this._offset;\n },\n set: function (value) {\n if (this._offset !== value) {\n this._offset = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The number of instances to draw.\n *\n * @memberof DrawCommand.prototype\n * @type {number}\n * @default 0\n */\n instanceCount: {\n get: function () {\n return this._instanceCount;\n },\n set: function (value) {\n if (this._instanceCount !== value) {\n this._instanceCount = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The shader program to apply.\n *\n * @memberof DrawCommand.prototype\n * @type {ShaderProgram}\n * @default undefined\n */\n shaderProgram: {\n get: function () {\n return this._shaderProgram;\n },\n set: function (value) {\n if (this._shaderProgram !== value) {\n this._shaderProgram = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * Whether this command should cast shadows when shadowing is enabled.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default false\n */\n castShadows: {\n get: function () {\n return hasFlag(this, Flags.CAST_SHADOWS);\n },\n set: function (value) {\n if (hasFlag(this, Flags.CAST_SHADOWS) !== value) {\n setFlag(this, Flags.CAST_SHADOWS, value);\n this.dirty = true;\n }\n },\n },\n\n /**\n * Whether this command should receive shadows when shadowing is enabled.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default false\n */\n receiveShadows: {\n get: function () {\n return hasFlag(this, Flags.RECEIVE_SHADOWS);\n },\n set: function (value) {\n if (hasFlag(this, Flags.RECEIVE_SHADOWS) !== value) {\n setFlag(this, Flags.RECEIVE_SHADOWS, value);\n this.dirty = true;\n }\n },\n },\n\n /**\n * An object with functions whose names match the uniforms in the shader program\n * and return values to set those uniforms.\n *\n * @memberof DrawCommand.prototype\n * @type {object}\n * @default undefined\n */\n uniformMap: {\n get: function () {\n return this._uniformMap;\n },\n set: function (value) {\n if (this._uniformMap !== value) {\n this._uniformMap = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The render state.\n *\n * @memberof DrawCommand.prototype\n * @type {RenderState}\n * @default undefined\n */\n renderState: {\n get: function () {\n return this._renderState;\n },\n set: function (value) {\n if (this._renderState !== value) {\n this._renderState = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The framebuffer to draw to.\n *\n * @memberof DrawCommand.prototype\n * @type {Framebuffer}\n * @default undefined\n */\n framebuffer: {\n get: function () {\n return this._framebuffer;\n },\n set: function (value) {\n if (this._framebuffer !== value) {\n this._framebuffer = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * The pass when to render.\n *\n * @memberof DrawCommand.prototype\n * @type {Pass}\n * @default undefined\n */\n pass: {\n get: function () {\n return this._pass;\n },\n set: function (value) {\n if (this._pass !== value) {\n this._pass = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * Specifies if this command is only to be executed in the frustum closest\n * to the eye containing the bounding volume. Defaults to false.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default false\n */\n executeInClosestFrustum: {\n get: function () {\n return hasFlag(this, Flags.EXECUTE_IN_CLOSEST_FRUSTUM);\n },\n set: function (value) {\n if (hasFlag(this, Flags.EXECUTE_IN_CLOSEST_FRUSTUM) !== value) {\n setFlag(this, Flags.EXECUTE_IN_CLOSEST_FRUSTUM, value);\n this.dirty = true;\n }\n },\n },\n\n /**\n * The object who created this command. This is useful for debugging command\n * execution; it allows us to see who created a command when we only have a\n * reference to the command, and can be used to selectively execute commands\n * with {@link Scene#debugCommandFilter}.\n *\n * @memberof DrawCommand.prototype\n * @type {object}\n * @default undefined\n *\n * @see Scene#debugCommandFilter\n */\n owner: {\n get: function () {\n return this._owner;\n },\n set: function (value) {\n if (this._owner !== value) {\n this._owner = value;\n this.dirty = true;\n }\n },\n },\n\n /**\n * This property is for debugging only; it is not for production use nor is it optimized.\n *
\n * Draws the {@link DrawCommand#boundingVolume} for this command, assuming it is a sphere, when the command executes.\n *
\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default false\n *\n * @see DrawCommand#boundingVolume\n */\n debugShowBoundingVolume: {\n get: function () {\n return hasFlag(this, Flags.DEBUG_SHOW_BOUNDING_VOLUME);\n },\n set: function (value) {\n if (hasFlag(this, Flags.DEBUG_SHOW_BOUNDING_VOLUME) !== value) {\n setFlag(this, Flags.DEBUG_SHOW_BOUNDING_VOLUME, value);\n this.dirty = true;\n }\n },\n },\n\n /**\n * Used to implement Scene.debugShowFrustums.\n * @private\n */\n debugOverlappingFrustums: {\n get: function () {\n return this._debugOverlappingFrustums;\n },\n set: function (value) {\n if (this._debugOverlappingFrustums !== value) {\n this._debugOverlappingFrustums = value;\n this.dirty = true;\n }\n },\n },\n /**\n * A GLSL string that will evaluate to a pick id. When undefined, the command will only draw depth\n * during the pick pass.\n *\n * @memberof DrawCommand.prototype\n * @type {string}\n * @default undefined\n */\n pickId: {\n get: function () {\n return this._pickId;\n },\n set: function (value) {\n if (this._pickId !== value) {\n this._pickId = value;\n this.dirty = true;\n }\n },\n },\n /**\n * Whether this command should be executed in the pick pass only.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default false\n */\n pickOnly: {\n get: function () {\n return hasFlag(this, Flags.PICK_ONLY);\n },\n set: function (value) {\n if (hasFlag(this, Flags.PICK_ONLY) !== value) {\n setFlag(this, Flags.PICK_ONLY, value);\n this.dirty = true;\n }\n },\n },\n /**\n * Whether this command should be derived to draw depth for classification of translucent primitives.\n *\n * @memberof DrawCommand.prototype\n * @type {boolean}\n * @default false\n */\n depthForTranslucentClassification: {\n get: function () {\n return hasFlag(this, Flags.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION);\n },\n set: function (value) {\n if (hasFlag(this, Flags.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION) !== value) {\n setFlag(this, Flags.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION, value);\n this.dirty = true;\n }\n },\n },\n});\n\n/**\n * @private\n */\nDrawCommand.shallowClone = function (command, result) {\n if (!defined(command)) {\n return undefined;\n }\n if (!defined(result)) {\n result = new DrawCommand();\n }\n\n result._boundingVolume = command._boundingVolume;\n result._orientedBoundingBox = command._orientedBoundingBox;\n result._modelMatrix = command._modelMatrix;\n result._primitiveType = command._primitiveType;\n result._vertexArray = command._vertexArray;\n result._count = command._count;\n result._offset = command._offset;\n result._instanceCount = command._instanceCount;\n result._shaderProgram = command._shaderProgram;\n result._uniformMap = command._uniformMap;\n result._renderState = command._renderState;\n result._framebuffer = command._framebuffer;\n result._pass = command._pass;\n result._owner = command._owner;\n result._debugOverlappingFrustums = command._debugOverlappingFrustums;\n result._pickId = command._pickId;\n result._flags = command._flags;\n\n result.dirty = true;\n result.lastDirtyTime = 0;\n\n return result;\n};\n\n/**\n * Executes the draw command.\n *\n * @param {Context} context The renderer context in which to draw.\n * @param {PassState} [passState] The state for the current render pass.\n */\nDrawCommand.prototype.execute = function (context, passState) {\n context.draw(this, passState);\n};\nexport default DrawCommand;\n", "import WebGLConstants from \"../Core/WebGLConstants.js\";\n\n/**\n * The data type of a pixel.\n *\n * @enum {number}\n * @see PostProcessStage\n */\nconst PixelDatatype = {\n UNSIGNED_BYTE: WebGLConstants.UNSIGNED_BYTE,\n UNSIGNED_SHORT: WebGLConstants.UNSIGNED_SHORT,\n UNSIGNED_INT: WebGLConstants.UNSIGNED_INT,\n FLOAT: WebGLConstants.FLOAT,\n HALF_FLOAT: WebGLConstants.HALF_FLOAT_OES,\n UNSIGNED_INT_24_8: WebGLConstants.UNSIGNED_INT_24_8,\n UNSIGNED_SHORT_4_4_4_4: WebGLConstants.UNSIGNED_SHORT_4_4_4_4,\n UNSIGNED_SHORT_5_5_5_1: WebGLConstants.UNSIGNED_SHORT_5_5_5_1,\n UNSIGNED_SHORT_5_6_5: WebGLConstants.UNSIGNED_SHORT_5_6_5,\n};\n\n/**\n @private\n*/\nPixelDatatype.toWebGLConstant = function (pixelDatatype, context) {\n switch (pixelDatatype) {\n case PixelDatatype.UNSIGNED_BYTE:\n return WebGLConstants.UNSIGNED_BYTE;\n case PixelDatatype.UNSIGNED_SHORT:\n return WebGLConstants.UNSIGNED_SHORT;\n case PixelDatatype.UNSIGNED_INT:\n return WebGLConstants.UNSIGNED_INT;\n case PixelDatatype.FLOAT:\n return WebGLConstants.FLOAT;\n case PixelDatatype.HALF_FLOAT:\n return context.webgl2\n ? WebGLConstants.HALF_FLOAT\n : WebGLConstants.HALF_FLOAT_OES;\n case PixelDatatype.UNSIGNED_INT_24_8:\n return WebGLConstants.UNSIGNED_INT_24_8;\n case PixelDatatype.UNSIGNED_SHORT_4_4_4_4:\n return WebGLConstants.UNSIGNED_SHORT_4_4_4_4;\n case PixelDatatype.UNSIGNED_SHORT_5_5_5_1:\n return WebGLConstants.UNSIGNED_SHORT_5_5_5_1;\n case PixelDatatype.UNSIGNED_SHORT_5_6_5:\n return PixelDatatype.UNSIGNED_SHORT_5_6_5;\n }\n};\n\n/**\n @private\n*/\nPixelDatatype.isPacked = function (pixelDatatype) {\n return (\n pixelDatatype === PixelDatatype.UNSIGNED_INT_24_8 ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT_4_4_4_4 ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_5_5_1 ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_6_5\n );\n};\n\n/**\n @private\n*/\nPixelDatatype.sizeInBytes = function (pixelDatatype) {\n switch (pixelDatatype) {\n case PixelDatatype.UNSIGNED_BYTE:\n return 1;\n case PixelDatatype.UNSIGNED_SHORT:\n case PixelDatatype.UNSIGNED_SHORT_4_4_4_4:\n case PixelDatatype.UNSIGNED_SHORT_5_5_5_1:\n case PixelDatatype.UNSIGNED_SHORT_5_6_5:\n case PixelDatatype.HALF_FLOAT:\n return 2;\n case PixelDatatype.UNSIGNED_INT:\n case PixelDatatype.FLOAT:\n case PixelDatatype.UNSIGNED_INT_24_8:\n return 4;\n }\n};\n\n/**\n @private\n*/\nPixelDatatype.validate = function (pixelDatatype) {\n return (\n pixelDatatype === PixelDatatype.UNSIGNED_BYTE ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT ||\n pixelDatatype === PixelDatatype.UNSIGNED_INT ||\n pixelDatatype === PixelDatatype.FLOAT ||\n pixelDatatype === PixelDatatype.HALF_FLOAT ||\n pixelDatatype === PixelDatatype.UNSIGNED_INT_24_8 ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT_4_4_4_4 ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_5_5_1 ||\n pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_6_5\n );\n};\n\nexport default Object.freeze(PixelDatatype);\n", "import PixelDatatype from \"../Renderer/PixelDatatype.js\";\nimport WebGLConstants from \"./WebGLConstants.js\";\n\n/**\n * The format of a pixel, i.e., the number of components it has and what they represent.\n *\n * @enum {number}\n */\nconst PixelFormat = {\n /**\n * A pixel format containing a depth value.\n *\n * @type {number}\n * @constant\n */\n DEPTH_COMPONENT: WebGLConstants.DEPTH_COMPONENT,\n\n /**\n * A pixel format containing a depth and stencil value, most often used with {@link PixelDatatype.UNSIGNED_INT_24_8}.\n *\n * @type {number}\n * @constant\n */\n DEPTH_STENCIL: WebGLConstants.DEPTH_STENCIL,\n\n /**\n * A pixel format containing an alpha channel.\n *\n * @type {number}\n * @constant\n */\n ALPHA: WebGLConstants.ALPHA,\n\n /**\n * A pixel format containing a red channel\n *\n * @type {number}\n * @constant\n */\n RED: WebGLConstants.RED,\n\n /**\n * A pixel format containing red and green channels.\n *\n * @type {number}\n * @constant\n */\n RG: WebGLConstants.RG,\n\n /**\n * A pixel format containing red, green, and blue channels.\n *\n * @type {number}\n * @constant\n */\n RGB: WebGLConstants.RGB,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels.\n *\n * @type {number}\n * @constant\n */\n RGBA: WebGLConstants.RGBA,\n\n /**\n * A pixel format containing a luminance (intensity) channel.\n *\n * @type {number}\n * @constant\n */\n LUMINANCE: WebGLConstants.LUMINANCE,\n\n /**\n * A pixel format containing luminance (intensity) and alpha channels.\n *\n * @type {number}\n * @constant\n */\n LUMINANCE_ALPHA: WebGLConstants.LUMINANCE_ALPHA,\n\n /**\n * A pixel format containing red, green, and blue channels that is DXT1 compressed.\n *\n * @type {number}\n * @constant\n */\n RGB_DXT1: WebGLConstants.COMPRESSED_RGB_S3TC_DXT1_EXT,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is DXT1 compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_DXT1: WebGLConstants.COMPRESSED_RGBA_S3TC_DXT1_EXT,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is DXT3 compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_DXT3: WebGLConstants.COMPRESSED_RGBA_S3TC_DXT3_EXT,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is DXT5 compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_DXT5: WebGLConstants.COMPRESSED_RGBA_S3TC_DXT5_EXT,\n\n /**\n * A pixel format containing red, green, and blue channels that is PVR 4bpp compressed.\n *\n * @type {number}\n * @constant\n */\n RGB_PVRTC_4BPPV1: WebGLConstants.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,\n\n /**\n * A pixel format containing red, green, and blue channels that is PVR 2bpp compressed.\n *\n * @type {number}\n * @constant\n */\n RGB_PVRTC_2BPPV1: WebGLConstants.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is PVR 4bpp compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_PVRTC_4BPPV1: WebGLConstants.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is PVR 2bpp compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_PVRTC_2BPPV1: WebGLConstants.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is ASTC compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_ASTC: WebGLConstants.COMPRESSED_RGBA_ASTC_4x4_WEBGL,\n\n /**\n * A pixel format containing red, green, and blue channels that is ETC1 compressed.\n *\n * @type {number}\n * @constant\n */\n RGB_ETC1: WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,\n\n /**\n * A pixel format containing red, green, and blue channels that is ETC2 compressed.\n *\n * @type {number}\n * @constant\n */\n RGB8_ETC2: WebGLConstants.COMPRESSED_RGB8_ETC2,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is ETC2 compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA8_ETC2_EAC: WebGLConstants.COMPRESSED_RGBA8_ETC2_EAC,\n\n /**\n * A pixel format containing red, green, blue, and alpha channels that is BC7 compressed.\n *\n * @type {number}\n * @constant\n */\n RGBA_BC7: WebGLConstants.COMPRESSED_RGBA_BPTC_UNORM,\n};\n\n/**\n * @private\n */\nPixelFormat.componentsLength = function (pixelFormat) {\n switch (pixelFormat) {\n case PixelFormat.RGB:\n return 3;\n case PixelFormat.RGBA:\n return 4;\n case PixelFormat.LUMINANCE_ALPHA:\n case PixelFormat.RG:\n return 2;\n case PixelFormat.ALPHA:\n case PixelFormat.RED:\n case PixelFormat.LUMINANCE:\n return 1;\n default:\n return 1;\n }\n};\n\n/**\n * @private\n */\nPixelFormat.validate = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.DEPTH_COMPONENT ||\n pixelFormat === PixelFormat.DEPTH_STENCIL ||\n pixelFormat === PixelFormat.ALPHA ||\n pixelFormat === PixelFormat.RED ||\n pixelFormat === PixelFormat.RG ||\n pixelFormat === PixelFormat.RGB ||\n pixelFormat === PixelFormat.RGBA ||\n pixelFormat === PixelFormat.LUMINANCE ||\n pixelFormat === PixelFormat.LUMINANCE_ALPHA ||\n pixelFormat === PixelFormat.RGB_DXT1 ||\n pixelFormat === PixelFormat.RGBA_DXT1 ||\n pixelFormat === PixelFormat.RGBA_DXT3 ||\n pixelFormat === PixelFormat.RGBA_DXT5 ||\n pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 ||\n pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 ||\n pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 ||\n pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1 ||\n pixelFormat === PixelFormat.RGBA_ASTC ||\n pixelFormat === PixelFormat.RGB_ETC1 ||\n pixelFormat === PixelFormat.RGB8_ETC2 ||\n pixelFormat === PixelFormat.RGBA8_ETC2_EAC ||\n pixelFormat === PixelFormat.RGBA_BC7\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isColorFormat = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.ALPHA ||\n pixelFormat === PixelFormat.RGB ||\n pixelFormat === PixelFormat.RGBA ||\n pixelFormat === PixelFormat.LUMINANCE ||\n pixelFormat === PixelFormat.LUMINANCE_ALPHA\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isDepthFormat = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.DEPTH_COMPONENT ||\n pixelFormat === PixelFormat.DEPTH_STENCIL\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isCompressedFormat = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.RGB_DXT1 ||\n pixelFormat === PixelFormat.RGBA_DXT1 ||\n pixelFormat === PixelFormat.RGBA_DXT3 ||\n pixelFormat === PixelFormat.RGBA_DXT5 ||\n pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 ||\n pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 ||\n pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 ||\n pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1 ||\n pixelFormat === PixelFormat.RGBA_ASTC ||\n pixelFormat === PixelFormat.RGB_ETC1 ||\n pixelFormat === PixelFormat.RGB8_ETC2 ||\n pixelFormat === PixelFormat.RGBA8_ETC2_EAC ||\n pixelFormat === PixelFormat.RGBA_BC7\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isDXTFormat = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.RGB_DXT1 ||\n pixelFormat === PixelFormat.RGBA_DXT1 ||\n pixelFormat === PixelFormat.RGBA_DXT3 ||\n pixelFormat === PixelFormat.RGBA_DXT5\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isPVRTCFormat = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 ||\n pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 ||\n pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 ||\n pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isASTCFormat = function (pixelFormat) {\n return pixelFormat === PixelFormat.RGBA_ASTC;\n};\n\n/**\n * @private\n */\nPixelFormat.isETC1Format = function (pixelFormat) {\n return pixelFormat === PixelFormat.RGB_ETC1;\n};\n\n/**\n * @private\n */\nPixelFormat.isETC2Format = function (pixelFormat) {\n return (\n pixelFormat === PixelFormat.RGB8_ETC2 ||\n pixelFormat === PixelFormat.RGBA8_ETC2_EAC\n );\n};\n\n/**\n * @private\n */\nPixelFormat.isBC7Format = function (pixelFormat) {\n return pixelFormat === PixelFormat.RGBA_BC7;\n};\n\n/**\n * @private\n */\nPixelFormat.compressedTextureSizeInBytes = function (\n pixelFormat,\n width,\n height\n) {\n switch (pixelFormat) {\n case PixelFormat.RGB_DXT1:\n case PixelFormat.RGBA_DXT1:\n case PixelFormat.RGB_ETC1:\n case PixelFormat.RGB8_ETC2:\n return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 8;\n\n case PixelFormat.RGBA_DXT3:\n case PixelFormat.RGBA_DXT5:\n case PixelFormat.RGBA_ASTC:\n case PixelFormat.RGBA8_ETC2_EAC:\n return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 16;\n\n case PixelFormat.RGB_PVRTC_4BPPV1:\n case PixelFormat.RGBA_PVRTC_4BPPV1:\n return Math.floor((Math.max(width, 8) * Math.max(height, 8) * 4 + 7) / 8);\n\n case PixelFormat.RGB_PVRTC_2BPPV1:\n case PixelFormat.RGBA_PVRTC_2BPPV1:\n return Math.floor(\n (Math.max(width, 16) * Math.max(height, 8) * 2 + 7) / 8\n );\n\n case PixelFormat.RGBA_BC7:\n return Math.ceil(width / 4) * Math.ceil(height / 4) * 16;\n\n default:\n return 0;\n }\n};\n\n/**\n * @private\n */\nPixelFormat.textureSizeInBytes = function (\n pixelFormat,\n pixelDatatype,\n width,\n height\n) {\n let componentsLength = PixelFormat.componentsLength(pixelFormat);\n if (PixelDatatype.isPacked(pixelDatatype)) {\n componentsLength = 1;\n }\n return (\n componentsLength * PixelDatatype.sizeInBytes(pixelDatatype) * width * height\n );\n};\n\n/**\n * @private\n */\nPixelFormat.alignmentInBytes = function (pixelFormat, pixelDatatype, width) {\n const mod =\n PixelFormat.textureSizeInBytes(pixelFormat, pixelDatatype, width, 1) % 4;\n return mod === 0 ? 4 : mod === 2 ? 2 : 1;\n};\n\n/**\n * @private\n */\nPixelFormat.createTypedArray = function (\n pixelFormat,\n pixelDatatype,\n width,\n height\n) {\n let constructor;\n const sizeInBytes = PixelDatatype.sizeInBytes(pixelDatatype);\n if (sizeInBytes === Uint8Array.BYTES_PER_ELEMENT) {\n constructor = Uint8Array;\n } else if (sizeInBytes === Uint16Array.BYTES_PER_ELEMENT) {\n constructor = Uint16Array;\n } else if (\n sizeInBytes === Float32Array.BYTES_PER_ELEMENT &&\n pixelDatatype === PixelDatatype.FLOAT\n ) {\n constructor = Float32Array;\n } else {\n constructor = Uint32Array;\n }\n\n const size = PixelFormat.componentsLength(pixelFormat) * width * height;\n return new constructor(size);\n};\n\n/**\n * @private\n */\nPixelFormat.flipY = function (\n bufferView,\n pixelFormat,\n pixelDatatype,\n width,\n height\n) {\n if (height === 1) {\n return bufferView;\n }\n const flipped = PixelFormat.createTypedArray(\n pixelFormat,\n pixelDatatype,\n width,\n height\n );\n const numberOfComponents = PixelFormat.componentsLength(pixelFormat);\n const textureWidth = width * numberOfComponents;\n for (let i = 0; i < height; ++i) {\n const row = i * width * numberOfComponents;\n const flippedRow = (height - i - 1) * width * numberOfComponents;\n for (let j = 0; j < textureWidth; ++j) {\n flipped[flippedRow + j] = bufferView[row + j];\n }\n }\n return flipped;\n};\n\n/**\n * @private\n */\nPixelFormat.toInternalFormat = function (pixelFormat, pixelDatatype, context) {\n // WebGL 1 require internalFormat to be the same as PixelFormat\n if (!context.webgl2) {\n return pixelFormat;\n }\n\n // Convert pixelFormat to correct internalFormat for WebGL 2\n if (pixelFormat === PixelFormat.DEPTH_STENCIL) {\n return WebGLConstants.DEPTH24_STENCIL8;\n }\n\n if (pixelFormat === PixelFormat.DEPTH_COMPONENT) {\n if (pixelDatatype === PixelDatatype.UNSIGNED_SHORT) {\n return WebGLConstants.DEPTH_COMPONENT16;\n } else if (pixelDatatype === PixelDatatype.UNSIGNED_INT) {\n return WebGLConstants.DEPTH_COMPONENT24;\n }\n }\n\n if (pixelDatatype === PixelDatatype.FLOAT) {\n switch (pixelFormat) {\n case PixelFormat.RGBA:\n return WebGLConstants.RGBA32F;\n case PixelFormat.RGB:\n return WebGLConstants.RGB32F;\n case PixelFormat.RG:\n return WebGLConstants.RG32F;\n case PixelFormat.RED:\n return WebGLConstants.R32F;\n }\n }\n\n if (pixelDatatype === PixelDatatype.HALF_FLOAT) {\n switch (pixelFormat) {\n case PixelFormat.RGBA:\n return WebGLConstants.RGBA16F;\n case PixelFormat.RGB:\n return WebGLConstants.RGB16F;\n case PixelFormat.RG:\n return WebGLConstants.RG16F;\n case PixelFormat.RED:\n return WebGLConstants.R16F;\n }\n }\n\n return pixelFormat;\n};\n\nexport default Object.freeze(PixelFormat);\n", "/**\n * @private\n */\nconst ContextLimits = {\n _maximumCombinedTextureImageUnits: 0,\n _maximumCubeMapSize: 0,\n _maximumFragmentUniformVectors: 0,\n _maximumTextureImageUnits: 0,\n _maximumRenderbufferSize: 0,\n _maximumTextureSize: 0,\n _maximumVaryingVectors: 0,\n _maximumVertexAttributes: 0,\n _maximumVertexTextureImageUnits: 0,\n _maximumVertexUniformVectors: 0,\n _minimumAliasedLineWidth: 0,\n _maximumAliasedLineWidth: 0,\n _minimumAliasedPointSize: 0,\n _maximumAliasedPointSize: 0,\n _maximumViewportWidth: 0,\n _maximumViewportHeight: 0,\n _maximumTextureFilterAnisotropy: 0,\n _maximumDrawBuffers: 0,\n _maximumColorAttachments: 0,\n _maximumSamples: 0,\n _highpFloatSupported: false,\n _highpIntSupported: false,\n};\n\nObject.defineProperties(ContextLimits, {\n /**\n * The maximum number of texture units that can be used from the vertex and fragment\n * shader with this WebGL implementation. The minimum is eight. If both shaders access the\n * same texture unit, this counts as two texture units.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_COMBINED_TEXTURE_IMAGE_UNITS.\n */\n maximumCombinedTextureImageUnits: {\n get: function () {\n return ContextLimits._maximumCombinedTextureImageUnits;\n },\n },\n\n /**\n * The approximate maximum cube mape width and height supported by this WebGL implementation.\n * The minimum is 16, but most desktop and laptop implementations will support much larger sizes like 8,192.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_CUBE_MAP_TEXTURE_SIZE.\n */\n maximumCubeMapSize: {\n get: function () {\n return ContextLimits._maximumCubeMapSize;\n },\n },\n\n /**\n * The maximum number of vec4, ivec4, and bvec4\n * uniforms that can be used by a fragment shader with this WebGL implementation. The minimum is 16.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_FRAGMENT_UNIFORM_VECTORS.\n */\n maximumFragmentUniformVectors: {\n get: function () {\n return ContextLimits._maximumFragmentUniformVectors;\n },\n },\n\n /**\n * The maximum number of texture units that can be used from the fragment shader with this WebGL implementation. The minimum is eight.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_TEXTURE_IMAGE_UNITS.\n */\n maximumTextureImageUnits: {\n get: function () {\n return ContextLimits._maximumTextureImageUnits;\n },\n },\n\n /**\n * The maximum renderbuffer width and height supported by this WebGL implementation.\n * The minimum is 16, but most desktop and laptop implementations will support much larger sizes like 8,192.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_RENDERBUFFER_SIZE.\n */\n maximumRenderbufferSize: {\n get: function () {\n return ContextLimits._maximumRenderbufferSize;\n },\n },\n\n /**\n * The approximate maximum texture width and height supported by this WebGL implementation.\n * The minimum is 64, but most desktop and laptop implementations will support much larger sizes like 8,192.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_TEXTURE_SIZE.\n */\n maximumTextureSize: {\n get: function () {\n return ContextLimits._maximumTextureSize;\n },\n },\n\n /**\n * The maximum number of vec4 varying variables supported by this WebGL implementation.\n * The minimum is eight. Matrices and arrays count as multiple vec4s.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_VARYING_VECTORS.\n */\n maximumVaryingVectors: {\n get: function () {\n return ContextLimits._maximumVaryingVectors;\n },\n },\n\n /**\n * The maximum number of vec4 vertex attributes supported by this WebGL implementation. The minimum is eight.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_VERTEX_ATTRIBS.\n */\n maximumVertexAttributes: {\n get: function () {\n return ContextLimits._maximumVertexAttributes;\n },\n },\n\n /**\n * The maximum number of texture units that can be used from the vertex shader with this WebGL implementation.\n * The minimum is zero, which means the GL does not support vertex texture fetch.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_VERTEX_TEXTURE_IMAGE_UNITS.\n */\n maximumVertexTextureImageUnits: {\n get: function () {\n return ContextLimits._maximumVertexTextureImageUnits;\n },\n },\n\n /**\n * The maximum number of vec4, ivec4, and bvec4\n * uniforms that can be used by a vertex shader with this WebGL implementation. The minimum is 16.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_VERTEX_UNIFORM_VECTORS.\n */\n maximumVertexUniformVectors: {\n get: function () {\n return ContextLimits._maximumVertexUniformVectors;\n },\n },\n\n /**\n * The minimum aliased line width, in pixels, supported by this WebGL implementation. It will be at most one.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with ALIASED_LINE_WIDTH_RANGE.\n */\n minimumAliasedLineWidth: {\n get: function () {\n return ContextLimits._minimumAliasedLineWidth;\n },\n },\n\n /**\n * The maximum aliased line width, in pixels, supported by this WebGL implementation. It will be at least one.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with ALIASED_LINE_WIDTH_RANGE.\n */\n maximumAliasedLineWidth: {\n get: function () {\n return ContextLimits._maximumAliasedLineWidth;\n },\n },\n\n /**\n * The minimum aliased point size, in pixels, supported by this WebGL implementation. It will be at most one.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with ALIASED_POINT_SIZE_RANGE.\n */\n minimumAliasedPointSize: {\n get: function () {\n return ContextLimits._minimumAliasedPointSize;\n },\n },\n\n /**\n * The maximum aliased point size, in pixels, supported by this WebGL implementation. It will be at least one.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with ALIASED_POINT_SIZE_RANGE.\n */\n maximumAliasedPointSize: {\n get: function () {\n return ContextLimits._maximumAliasedPointSize;\n },\n },\n\n /**\n * The maximum supported width of the viewport. It will be at least as large as the visible width of the associated canvas.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_VIEWPORT_DIMS.\n */\n maximumViewportWidth: {\n get: function () {\n return ContextLimits._maximumViewportWidth;\n },\n },\n\n /**\n * The maximum supported height of the viewport. It will be at least as large as the visible height of the associated canvas.\n * @memberof ContextLimits\n * @type {number}\n * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with MAX_VIEWPORT_DIMS.\n */\n maximumViewportHeight: {\n get: function () {\n return ContextLimits._maximumViewportHeight;\n },\n },\n\n /**\n * The maximum degree of anisotropy for texture filtering\n * @memberof ContextLimits\n * @type {number}\n */\n maximumTextureFilterAnisotropy: {\n get: function () {\n return ContextLimits._maximumTextureFilterAnisotropy;\n },\n },\n\n /**\n * The maximum number of simultaneous outputs that may be written in a fragment shader.\n * @memberof ContextLimits\n * @type {number}\n */\n maximumDrawBuffers: {\n get: function () {\n return ContextLimits._maximumDrawBuffers;\n },\n },\n\n /**\n * The maximum number of color attachments supported.\n * @memberof ContextLimits\n * @type {number}\n */\n maximumColorAttachments: {\n get: function () {\n return ContextLimits._maximumColorAttachments;\n },\n },\n\n /**\n * The maximum number of samples supported for multisampling.\n * @memberof ContextLimits\n * @type {number}\n */\n maximumSamples: {\n get: function () {\n return ContextLimits._maximumSamples;\n },\n },\n\n /**\n * High precision float supported (highp) in fragment shaders.\n * @memberof ContextLimits\n * @type {boolean}\n */\n highpFloatSupported: {\n get: function () {\n return ContextLimits._highpFloatSupported;\n },\n },\n\n /**\n * High precision int supported (highp) in fragment shaders.\n * @memberof ContextLimits\n * @type {boolean}\n */\n highpIntSupported: {\n get: function () {\n return ContextLimits._highpIntSupported;\n },\n },\n});\nexport default ContextLimits;\n", "import Check from \"../Core/Check.js\";\nimport defaultValue from \"../Core/defaultValue.js\";\nimport defined from \"../Core/defined.js\";\nimport destroyObject from \"../Core/destroyObject.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport PixelFormat from \"../Core/PixelFormat.js\";\nimport ContextLimits from \"./ContextLimits.js\";\nimport PixelDatatype from \"./PixelDatatype.js\";\n\nfunction attachTexture(framebuffer, attachment, texture) {\n const gl = framebuffer._gl;\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n attachment,\n texture._target,\n texture._texture,\n 0\n );\n}\n\nfunction attachRenderbuffer(framebuffer, attachment, renderbuffer) {\n const gl = framebuffer._gl;\n gl.framebufferRenderbuffer(\n gl.FRAMEBUFFER,\n attachment,\n gl.RENDERBUFFER,\n renderbuffer._getRenderbuffer()\n );\n}\n\n/**\n * Creates a framebuffer with optional initial color, depth, and stencil attachments.\n * Framebuffers are used for render-to-texture effects; they allow us to render to\n * textures in one pass, and read from it in a later pass.\n *\n * @param {object} options The initial framebuffer attachments as shown in the example below. context is required. The possible properties are colorTextures, colorRenderbuffers, depthTexture, depthRenderbuffer, stencilRenderbuffer, depthStencilTexture, depthStencilRenderbuffer, and destroyAttachments.\n *\n * @exception {DeveloperError} Cannot have both color texture and color renderbuffer attachments.\n * @exception {DeveloperError} Cannot have both a depth texture and depth renderbuffer attachment.\n * @exception {DeveloperError} Cannot have both a depth-stencil texture and depth-stencil renderbuffer attachment.\n * @exception {DeveloperError} Cannot have both a depth and depth-stencil renderbuffer.\n * @exception {DeveloperError} Cannot have both a stencil and depth-stencil renderbuffer.\n * @exception {DeveloperError} Cannot have both a depth and stencil renderbuffer.\n * @exception {DeveloperError} The color-texture pixel-format must be a color format.\n * @exception {DeveloperError} The depth-texture pixel-format must be DEPTH_COMPONENT.\n * @exception {DeveloperError} The depth-stencil-texture pixel-format must be DEPTH_STENCIL.\n * @exception {DeveloperError} The number of color attachments exceeds the number supported.\n * @exception {DeveloperError} The color-texture pixel datatype is HALF_FLOAT and the WebGL implementation does not support the EXT_color_buffer_half_float extension.\n * @exception {DeveloperError} The color-texture pixel datatype is FLOAT and the WebGL implementation does not support the EXT_color_buffer_float or WEBGL_color_buffer_float extensions.\n *\n * @example\n * // Create a framebuffer with color and depth texture attachments.\n * const width = context.canvas.clientWidth;\n * const height = context.canvas.clientHeight;\n * const framebuffer = new Framebuffer({\n * context : context,\n * colorTextures : [new Texture({\n * context : context,\n * width : width,\n * height : height,\n * pixelFormat : PixelFormat.RGBA\n * })],\n * depthTexture : new Texture({\n * context : context,\n * width : width,\n * height : height,\n * pixelFormat : PixelFormat.DEPTH_COMPONENT,\n * pixelDatatype : PixelDatatype.UNSIGNED_SHORT\n * })\n * });\n *\n * @private\n * @constructor\n */\nfunction Framebuffer(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n const context = options.context;\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.context\", context);\n //>>includeEnd('debug');\n\n const gl = context._gl;\n const maximumColorAttachments = ContextLimits.maximumColorAttachments;\n\n this._gl = gl;\n this._framebuffer = gl.createFramebuffer();\n\n this._colorTextures = [];\n this._colorRenderbuffers = [];\n this._activeColorAttachments = [];\n\n this._depthTexture = undefined;\n this._depthRenderbuffer = undefined;\n this._stencilRenderbuffer = undefined;\n this._depthStencilTexture = undefined;\n this._depthStencilRenderbuffer = undefined;\n\n /**\n * When true, the framebuffer owns its attachments so they will be destroyed when\n * {@link Framebuffer#destroy} is called or when a new attachment is assigned\n * to an attachment point.\n *\n * @type {boolean}\n * @default true\n *\n * @see Framebuffer#destroy\n */\n this.destroyAttachments = defaultValue(options.destroyAttachments, true);\n\n // Throw if a texture and renderbuffer are attached to the same point. This won't\n // cause a WebGL error (because only one will be attached), but is likely a developer error.\n\n //>>includeStart('debug', pragmas.debug);\n if (defined(options.colorTextures) && defined(options.colorRenderbuffers)) {\n throw new DeveloperError(\n \"Cannot have both color texture and color renderbuffer attachments.\"\n );\n }\n if (defined(options.depthTexture) && defined(options.depthRenderbuffer)) {\n throw new DeveloperError(\n \"Cannot have both a depth texture and depth renderbuffer attachment.\"\n );\n }\n if (\n defined(options.depthStencilTexture) &&\n defined(options.depthStencilRenderbuffer)\n ) {\n throw new DeveloperError(\n \"Cannot have both a depth-stencil texture and depth-stencil renderbuffer attachment.\"\n );\n }\n //>>includeEnd('debug');\n\n // Avoid errors defined in Section 6.5 of the WebGL spec\n const depthAttachment =\n defined(options.depthTexture) || defined(options.depthRenderbuffer);\n const depthStencilAttachment =\n defined(options.depthStencilTexture) ||\n defined(options.depthStencilRenderbuffer);\n\n //>>includeStart('debug', pragmas.debug);\n if (depthAttachment && depthStencilAttachment) {\n throw new DeveloperError(\n \"Cannot have both a depth and depth-stencil attachment.\"\n );\n }\n if (defined(options.stencilRenderbuffer) && depthStencilAttachment) {\n throw new DeveloperError(\n \"Cannot have both a stencil and depth-stencil attachment.\"\n );\n }\n if (depthAttachment && defined(options.stencilRenderbuffer)) {\n throw new DeveloperError(\n \"Cannot have both a depth and stencil attachment.\"\n );\n }\n //>>includeEnd('debug');\n\n ///////////////////////////////////////////////////////////////////\n\n this._bind();\n\n let texture;\n let renderbuffer;\n let i;\n let length;\n let attachmentEnum;\n\n if (defined(options.colorTextures)) {\n const textures = options.colorTextures;\n length = this._colorTextures.length = this._activeColorAttachments.length =\n textures.length;\n\n //>>includeStart('debug', pragmas.debug);\n if (length > maximumColorAttachments) {\n throw new DeveloperError(\n \"The number of color attachments exceeds the number supported.\"\n );\n }\n //>>includeEnd('debug');\n\n for (i = 0; i < length; ++i) {\n texture = textures[i];\n\n //>>includeStart('debug', pragmas.debug);\n if (!PixelFormat.isColorFormat(texture.pixelFormat)) {\n throw new DeveloperError(\n \"The color-texture pixel-format must be a color format.\"\n );\n }\n if (\n texture.pixelDatatype === PixelDatatype.FLOAT &&\n !context.colorBufferFloat\n ) {\n throw new DeveloperError(\n \"The color texture pixel datatype is FLOAT and the WebGL implementation does not support the EXT_color_buffer_float or WEBGL_color_buffer_float extensions. See Context.colorBufferFloat.\"\n );\n }\n if (\n texture.pixelDatatype === PixelDatatype.HALF_FLOAT &&\n !context.colorBufferHalfFloat\n ) {\n throw new DeveloperError(\n \"The color texture pixel datatype is HALF_FLOAT and the WebGL implementation does not support the EXT_color_buffer_half_float extension. See Context.colorBufferHalfFloat.\"\n );\n }\n //>>includeEnd('debug');\n\n attachmentEnum = this._gl.COLOR_ATTACHMENT0 + i;\n attachTexture(this, attachmentEnum, texture);\n this._activeColorAttachments[i] = attachmentEnum;\n this._colorTextures[i] = texture;\n }\n }\n\n if (defined(options.colorRenderbuffers)) {\n const renderbuffers = options.colorRenderbuffers;\n length = this._colorRenderbuffers.length = this._activeColorAttachments.length =\n renderbuffers.length;\n\n //>>includeStart('debug', pragmas.debug);\n if (length > maximumColorAttachments) {\n throw new DeveloperError(\n \"The number of color attachments exceeds the number supported.\"\n );\n }\n //>>includeEnd('debug');\n\n for (i = 0; i < length; ++i) {\n renderbuffer = renderbuffers[i];\n attachmentEnum = this._gl.COLOR_ATTACHMENT0 + i;\n attachRenderbuffer(this, attachmentEnum, renderbuffer);\n this._activeColorAttachments[i] = attachmentEnum;\n this._colorRenderbuffers[i] = renderbuffer;\n }\n }\n\n if (defined(options.depthTexture)) {\n texture = options.depthTexture;\n\n //>>includeStart('debug', pragmas.debug);\n if (texture.pixelFormat !== PixelFormat.DEPTH_COMPONENT) {\n throw new DeveloperError(\n \"The depth-texture pixel-format must be DEPTH_COMPONENT.\"\n );\n }\n //>>includeEnd('debug');\n\n attachTexture(this, this._gl.DEPTH_ATTACHMENT, texture);\n this._depthTexture = texture;\n }\n\n if (defined(options.depthRenderbuffer)) {\n renderbuffer = options.depthRenderbuffer;\n attachRenderbuffer(this, this._gl.DEPTH_ATTACHMENT, renderbuffer);\n this._depthRenderbuffer = renderbuffer;\n }\n\n if (defined(options.stencilRenderbuffer)) {\n renderbuffer = options.stencilRenderbuffer;\n attachRenderbuffer(this, this._gl.STENCIL_ATTACHMENT, renderbuffer);\n this._stencilRenderbuffer = renderbuffer;\n }\n\n if (defined(options.depthStencilTexture)) {\n texture = options.depthStencilTexture;\n\n //>>includeStart('debug', pragmas.debug);\n if (texture.pixelFormat !== PixelFormat.DEPTH_STENCIL) {\n throw new DeveloperError(\n \"The depth-stencil pixel-format must be DEPTH_STENCIL.\"\n );\n }\n //>>includeEnd('debug');\n\n attachTexture(this, this._gl.DEPTH_STENCIL_ATTACHMENT, texture);\n this._depthStencilTexture = texture;\n }\n\n if (defined(options.depthStencilRenderbuffer)) {\n renderbuffer = options.depthStencilRenderbuffer;\n attachRenderbuffer(this, this._gl.DEPTH_STENCIL_ATTACHMENT, renderbuffer);\n this._depthStencilRenderbuffer = renderbuffer;\n }\n\n this._unBind();\n}\n\nObject.defineProperties(Framebuffer.prototype, {\n /**\n * The status of the framebuffer. If the status is not WebGLConstants.FRAMEBUFFER_COMPLETE,\n * a {@link DeveloperError} will be thrown when attempting to render to the framebuffer.\n * @memberof Framebuffer.prototype\n * @type {number}\n */\n status: {\n get: function () {\n this._bind();\n const status = this._gl.checkFramebufferStatus(this._gl.FRAMEBUFFER);\n this._unBind();\n return status;\n },\n },\n numberOfColorAttachments: {\n get: function () {\n return this._activeColorAttachments.length;\n },\n },\n depthTexture: {\n get: function () {\n return this._depthTexture;\n },\n },\n depthRenderbuffer: {\n get: function () {\n return this._depthRenderbuffer;\n },\n },\n stencilRenderbuffer: {\n get: function () {\n return this._stencilRenderbuffer;\n },\n },\n depthStencilTexture: {\n get: function () {\n return this._depthStencilTexture;\n },\n },\n depthStencilRenderbuffer: {\n get: function () {\n return this._depthStencilRenderbuffer;\n },\n },\n\n /**\n * True if the framebuffer has a depth attachment. Depth attachments include\n * depth and depth-stencil textures, and depth and depth-stencil renderbuffers. When\n * rendering to a framebuffer, a depth attachment is required for the depth test to have effect.\n * @memberof Framebuffer.prototype\n * @type {boolean}\n */\n hasDepthAttachment: {\n get: function () {\n return !!(\n this.depthTexture ||\n this.depthRenderbuffer ||\n this.depthStencilTexture ||\n this.depthStencilRenderbuffer\n );\n },\n },\n});\n\nFramebuffer.prototype._bind = function () {\n const gl = this._gl;\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._framebuffer);\n};\n\nFramebuffer.prototype._unBind = function () {\n const gl = this._gl;\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n};\n\nFramebuffer.prototype.bindDraw = function () {\n const gl = this._gl;\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, this._framebuffer);\n};\n\nFramebuffer.prototype.bindRead = function () {\n const gl = this._gl;\n gl.bindFramebuffer(gl.READ_FRAMEBUFFER, this._framebuffer);\n};\n\nFramebuffer.prototype._getActiveColorAttachments = function () {\n return this._activeColorAttachments;\n};\n\nFramebuffer.prototype.getColorTexture = function (index) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(index) || index < 0 || index >= this._colorTextures.length) {\n throw new DeveloperError(\n \"index is required, must be greater than or equal to zero and must be less than the number of color attachments.\"\n );\n }\n //>>includeEnd('debug');\n\n return this._colorTextures[index];\n};\n\nFramebuffer.prototype.getColorRenderbuffer = function (index) {\n //>>includeStart('debug', pragmas.debug);\n if (\n !defined(index) ||\n index < 0 ||\n index >= this._colorRenderbuffers.length\n ) {\n throw new DeveloperError(\n \"index is required, must be greater than or equal to zero and must be less than the number of color attachments.\"\n );\n }\n //>>includeEnd('debug');\n\n return this._colorRenderbuffers[index];\n};\n\nFramebuffer.prototype.isDestroyed = function () {\n return false;\n};\n\nFramebuffer.prototype.destroy = function () {\n if (this.destroyAttachments) {\n // If the color texture is a cube map face, it is owned by the cube map, and will not be destroyed.\n let i = 0;\n const textures = this._colorTextures;\n let length = textures.length;\n for (; i < length; ++i) {\n const texture = textures[i];\n if (defined(texture)) {\n texture.destroy();\n }\n }\n\n const renderbuffers = this._colorRenderbuffers;\n length = renderbuffers.length;\n for (i = 0; i < length; ++i) {\n const renderbuffer = renderbuffers[i];\n if (defined(renderbuffer)) {\n renderbuffer.destroy();\n }\n }\n\n this._depthTexture = this._depthTexture && this._depthTexture.destroy();\n this._depthRenderbuffer =\n this._depthRenderbuffer && this._depthRenderbuffer.destroy();\n this._stencilRenderbuffer =\n this._stencilRenderbuffer && this._stencilRenderbuffer.destroy();\n this._depthStencilTexture =\n this._depthStencilTexture && this._depthStencilTexture.destroy();\n this._depthStencilRenderbuffer =\n this._depthStencilRenderbuffer &&\n this._depthStencilRenderbuffer.destroy();\n }\n\n this._gl.deleteFramebuffer(this._framebuffer);\n return destroyObject(this);\n};\nexport default Framebuffer;\n", "import WebGLConstants from \"./WebGLConstants.js\";\n\n/**\n * Winding order defines the order of vertices for a triangle to be considered front-facing.\n *\n * @enum {number}\n */\nconst WindingOrder = {\n /**\n * Vertices are in clockwise order.\n *\n * @type {number}\n * @constant\n */\n CLOCKWISE: WebGLConstants.CW,\n\n /**\n * Vertices are in counter-clockwise order.\n *\n * @type {number}\n * @constant\n */\n COUNTER_CLOCKWISE: WebGLConstants.CCW,\n};\n\n/**\n * @private\n */\nWindingOrder.validate = function (windingOrder) {\n return (\n windingOrder === WindingOrder.CLOCKWISE ||\n windingOrder === WindingOrder.COUNTER_CLOCKWISE\n );\n};\n\nexport default Object.freeze(WindingOrder);\n", "/**\n * Returns frozen renderState as well as all of the object literal properties. This function is deep object freeze\n * function ignoring properties named \"_applyFunctions\".\n *\n * @private\n *\n * @param {object} renderState\n * @returns {object} Returns frozen renderState.\n *\n */\nfunction freezeRenderState(renderState) {\n if (typeof renderState !== \"object\" || renderState === null) {\n return renderState;\n }\n\n let propName;\n const propNames = Object.keys(renderState);\n\n for (let i = 0; i < propNames.length; i++) {\n propName = propNames[i];\n if (\n renderState.hasOwnProperty(propName) &&\n propName !== \"_applyFunctions\"\n ) {\n renderState[propName] = freezeRenderState(renderState[propName]);\n }\n }\n return Object.freeze(renderState);\n}\nexport default freezeRenderState;\n", "import BoundingRectangle from \"../Core/BoundingRectangle.js\";\nimport Color from \"../Core/Color.js\";\nimport defaultValue from \"../Core/defaultValue.js\";\nimport defined from \"../Core/defined.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport WebGLConstants from \"../Core/WebGLConstants.js\";\nimport WindingOrder from \"../Core/WindingOrder.js\";\nimport ContextLimits from \"./ContextLimits.js\";\nimport freezeRenderState from \"./freezeRenderState.js\";\n\nfunction validateBlendEquation(blendEquation) {\n return (\n blendEquation === WebGLConstants.FUNC_ADD ||\n blendEquation === WebGLConstants.FUNC_SUBTRACT ||\n blendEquation === WebGLConstants.FUNC_REVERSE_SUBTRACT ||\n blendEquation === WebGLConstants.MIN ||\n blendEquation === WebGLConstants.MAX\n );\n}\n\nfunction validateBlendFunction(blendFunction) {\n return (\n blendFunction === WebGLConstants.ZERO ||\n blendFunction === WebGLConstants.ONE ||\n blendFunction === WebGLConstants.SRC_COLOR ||\n blendFunction === WebGLConstants.ONE_MINUS_SRC_COLOR ||\n blendFunction === WebGLConstants.DST_COLOR ||\n blendFunction === WebGLConstants.ONE_MINUS_DST_COLOR ||\n blendFunction === WebGLConstants.SRC_ALPHA ||\n blendFunction === WebGLConstants.ONE_MINUS_SRC_ALPHA ||\n blendFunction === WebGLConstants.DST_ALPHA ||\n blendFunction === WebGLConstants.ONE_MINUS_DST_ALPHA ||\n blendFunction === WebGLConstants.CONSTANT_COLOR ||\n blendFunction === WebGLConstants.ONE_MINUS_CONSTANT_COLOR ||\n blendFunction === WebGLConstants.CONSTANT_ALPHA ||\n blendFunction === WebGLConstants.ONE_MINUS_CONSTANT_ALPHA ||\n blendFunction === WebGLConstants.SRC_ALPHA_SATURATE\n );\n}\n\nfunction validateCullFace(cullFace) {\n return (\n cullFace === WebGLConstants.FRONT ||\n cullFace === WebGLConstants.BACK ||\n cullFace === WebGLConstants.FRONT_AND_BACK\n );\n}\n\nfunction validateDepthFunction(depthFunction) {\n return (\n depthFunction === WebGLConstants.NEVER ||\n depthFunction === WebGLConstants.LESS ||\n depthFunction === WebGLConstants.EQUAL ||\n depthFunction === WebGLConstants.LEQUAL ||\n depthFunction === WebGLConstants.GREATER ||\n depthFunction === WebGLConstants.NOTEQUAL ||\n depthFunction === WebGLConstants.GEQUAL ||\n depthFunction === WebGLConstants.ALWAYS\n );\n}\n\nfunction validateStencilFunction(stencilFunction) {\n return (\n stencilFunction === WebGLConstants.NEVER ||\n stencilFunction === WebGLConstants.LESS ||\n stencilFunction === WebGLConstants.EQUAL ||\n stencilFunction === WebGLConstants.LEQUAL ||\n stencilFunction === WebGLConstants.GREATER ||\n stencilFunction === WebGLConstants.NOTEQUAL ||\n stencilFunction === WebGLConstants.GEQUAL ||\n stencilFunction === WebGLConstants.ALWAYS\n );\n}\n\nfunction validateStencilOperation(stencilOperation) {\n return (\n stencilOperation === WebGLConstants.ZERO ||\n stencilOperation === WebGLConstants.KEEP ||\n stencilOperation === WebGLConstants.REPLACE ||\n stencilOperation === WebGLConstants.INCR ||\n stencilOperation === WebGLConstants.DECR ||\n stencilOperation === WebGLConstants.INVERT ||\n stencilOperation === WebGLConstants.INCR_WRAP ||\n stencilOperation === WebGLConstants.DECR_WRAP\n );\n}\n\n/**\n * @private\n */\nfunction RenderState(renderState) {\n const rs = defaultValue(renderState, defaultValue.EMPTY_OBJECT);\n const cull = defaultValue(rs.cull, defaultValue.EMPTY_OBJECT);\n const polygonOffset = defaultValue(\n rs.polygonOffset,\n defaultValue.EMPTY_OBJECT\n );\n const scissorTest = defaultValue(rs.scissorTest, defaultValue.EMPTY_OBJECT);\n const scissorTestRectangle = defaultValue(\n scissorTest.rectangle,\n defaultValue.EMPTY_OBJECT\n );\n const depthRange = defaultValue(rs.depthRange, defaultValue.EMPTY_OBJECT);\n const depthTest = defaultValue(rs.depthTest, defaultValue.EMPTY_OBJECT);\n const colorMask = defaultValue(rs.colorMask, defaultValue.EMPTY_OBJECT);\n const blending = defaultValue(rs.blending, defaultValue.EMPTY_OBJECT);\n const blendingColor = defaultValue(blending.color, defaultValue.EMPTY_OBJECT);\n const stencilTest = defaultValue(rs.stencilTest, defaultValue.EMPTY_OBJECT);\n const stencilTestFrontOperation = defaultValue(\n stencilTest.frontOperation,\n defaultValue.EMPTY_OBJECT\n );\n const stencilTestBackOperation = defaultValue(\n stencilTest.backOperation,\n defaultValue.EMPTY_OBJECT\n );\n const sampleCoverage = defaultValue(\n rs.sampleCoverage,\n defaultValue.EMPTY_OBJECT\n );\n const viewport = rs.viewport;\n\n this.frontFace = defaultValue(rs.frontFace, WindingOrder.COUNTER_CLOCKWISE);\n this.cull = {\n enabled: defaultValue(cull.enabled, false),\n face: defaultValue(cull.face, WebGLConstants.BACK),\n };\n this.lineWidth = defaultValue(rs.lineWidth, 1.0);\n this.polygonOffset = {\n enabled: defaultValue(polygonOffset.enabled, false),\n factor: defaultValue(polygonOffset.factor, 0),\n units: defaultValue(polygonOffset.units, 0),\n };\n this.scissorTest = {\n enabled: defaultValue(scissorTest.enabled, false),\n rectangle: BoundingRectangle.clone(scissorTestRectangle),\n };\n this.depthRange = {\n near: defaultValue(depthRange.near, 0),\n far: defaultValue(depthRange.far, 1),\n };\n this.depthTest = {\n enabled: defaultValue(depthTest.enabled, false),\n func: defaultValue(depthTest.func, WebGLConstants.LESS), // func, because function is a JavaScript keyword\n };\n this.colorMask = {\n red: defaultValue(colorMask.red, true),\n green: defaultValue(colorMask.green, true),\n blue: defaultValue(colorMask.blue, true),\n alpha: defaultValue(colorMask.alpha, true),\n };\n this.depthMask = defaultValue(rs.depthMask, true);\n this.stencilMask = defaultValue(rs.stencilMask, ~0);\n this.blending = {\n enabled: defaultValue(blending.enabled, false),\n color: new Color(\n defaultValue(blendingColor.red, 0.0),\n defaultValue(blendingColor.green, 0.0),\n defaultValue(blendingColor.blue, 0.0),\n defaultValue(blendingColor.alpha, 0.0)\n ),\n equationRgb: defaultValue(blending.equationRgb, WebGLConstants.FUNC_ADD),\n equationAlpha: defaultValue(\n blending.equationAlpha,\n WebGLConstants.FUNC_ADD\n ),\n functionSourceRgb: defaultValue(\n blending.functionSourceRgb,\n WebGLConstants.ONE\n ),\n functionSourceAlpha: defaultValue(\n blending.functionSourceAlpha,\n WebGLConstants.ONE\n ),\n functionDestinationRgb: defaultValue(\n blending.functionDestinationRgb,\n WebGLConstants.ZERO\n ),\n functionDestinationAlpha: defaultValue(\n blending.functionDestinationAlpha,\n WebGLConstants.ZERO\n ),\n };\n this.stencilTest = {\n enabled: defaultValue(stencilTest.enabled, false),\n frontFunction: defaultValue(\n stencilTest.frontFunction,\n WebGLConstants.ALWAYS\n ),\n backFunction: defaultValue(stencilTest.backFunction, WebGLConstants.ALWAYS),\n reference: defaultValue(stencilTest.reference, 0),\n mask: defaultValue(stencilTest.mask, ~0),\n frontOperation: {\n fail: defaultValue(stencilTestFrontOperation.fail, WebGLConstants.KEEP),\n zFail: defaultValue(stencilTestFrontOperation.zFail, WebGLConstants.KEEP),\n zPass: defaultValue(stencilTestFrontOperation.zPass, WebGLConstants.KEEP),\n },\n backOperation: {\n fail: defaultValue(stencilTestBackOperation.fail, WebGLConstants.KEEP),\n zFail: defaultValue(stencilTestBackOperation.zFail, WebGLConstants.KEEP),\n zPass: defaultValue(stencilTestBackOperation.zPass, WebGLConstants.KEEP),\n },\n };\n this.sampleCoverage = {\n enabled: defaultValue(sampleCoverage.enabled, false),\n value: defaultValue(sampleCoverage.value, 1.0),\n invert: defaultValue(sampleCoverage.invert, false),\n };\n this.viewport = defined(viewport)\n ? new BoundingRectangle(\n viewport.x,\n viewport.y,\n viewport.width,\n viewport.height\n )\n : undefined;\n\n //>>includeStart('debug', pragmas.debug);\n if (\n this.lineWidth < ContextLimits.minimumAliasedLineWidth ||\n this.lineWidth > ContextLimits.maximumAliasedLineWidth\n ) {\n throw new DeveloperError(\n \"renderState.lineWidth is out of range. Check minimumAliasedLineWidth and maximumAliasedLineWidth.\"\n );\n }\n if (!WindingOrder.validate(this.frontFace)) {\n throw new DeveloperError(\"Invalid renderState.frontFace.\");\n }\n if (!validateCullFace(this.cull.face)) {\n throw new DeveloperError(\"Invalid renderState.cull.face.\");\n }\n if (\n this.scissorTest.rectangle.width < 0 ||\n this.scissorTest.rectangle.height < 0\n ) {\n throw new DeveloperError(\n \"renderState.scissorTest.rectangle.width and renderState.scissorTest.rectangle.height must be greater than or equal to zero.\"\n );\n }\n if (this.depthRange.near > this.depthRange.far) {\n // WebGL specific - not an error in GL ES\n throw new DeveloperError(\n \"renderState.depthRange.near can not be greater than renderState.depthRange.far.\"\n );\n }\n if (this.depthRange.near < 0) {\n // Would be clamped by GL\n throw new DeveloperError(\n \"renderState.depthRange.near must be greater than or equal to zero.\"\n );\n }\n if (this.depthRange.far > 1) {\n // Would be clamped by GL\n throw new DeveloperError(\n \"renderState.depthRange.far must be less than or equal to one.\"\n );\n }\n if (!validateDepthFunction(this.depthTest.func)) {\n throw new DeveloperError(\"Invalid renderState.depthTest.func.\");\n }\n if (\n this.blending.color.red < 0.0 ||\n this.blending.color.red > 1.0 ||\n this.blending.color.green < 0.0 ||\n this.blending.color.green > 1.0 ||\n this.blending.color.blue < 0.0 ||\n this.blending.color.blue > 1.0 ||\n this.blending.color.alpha < 0.0 ||\n this.blending.color.alpha > 1.0\n ) {\n // Would be clamped by GL\n throw new DeveloperError(\n \"renderState.blending.color components must be greater than or equal to zero and less than or equal to one.\"\n );\n }\n if (!validateBlendEquation(this.blending.equationRgb)) {\n throw new DeveloperError(\"Invalid renderState.blending.equationRgb.\");\n }\n if (!validateBlendEquation(this.blending.equationAlpha)) {\n throw new DeveloperError(\"Invalid renderState.blending.equationAlpha.\");\n }\n if (!validateBlendFunction(this.blending.functionSourceRgb)) {\n throw new DeveloperError(\"Invalid renderState.blending.functionSourceRgb.\");\n }\n if (!validateBlendFunction(this.blending.functionSourceAlpha)) {\n throw new DeveloperError(\n \"Invalid renderState.blending.functionSourceAlpha.\"\n );\n }\n if (!validateBlendFunction(this.blending.functionDestinationRgb)) {\n throw new DeveloperError(\n \"Invalid renderState.blending.functionDestinationRgb.\"\n );\n }\n if (!validateBlendFunction(this.blending.functionDestinationAlpha)) {\n throw new DeveloperError(\n \"Invalid renderState.blending.functionDestinationAlpha.\"\n );\n }\n if (!validateStencilFunction(this.stencilTest.frontFunction)) {\n throw new DeveloperError(\"Invalid renderState.stencilTest.frontFunction.\");\n }\n if (!validateStencilFunction(this.stencilTest.backFunction)) {\n throw new DeveloperError(\"Invalid renderState.stencilTest.backFunction.\");\n }\n if (!validateStencilOperation(this.stencilTest.frontOperation.fail)) {\n throw new DeveloperError(\n \"Invalid renderState.stencilTest.frontOperation.fail.\"\n );\n }\n if (!validateStencilOperation(this.stencilTest.frontOperation.zFail)) {\n throw new DeveloperError(\n \"Invalid renderState.stencilTest.frontOperation.zFail.\"\n );\n }\n if (!validateStencilOperation(this.stencilTest.frontOperation.zPass)) {\n throw new DeveloperError(\n \"Invalid renderState.stencilTest.frontOperation.zPass.\"\n );\n }\n if (!validateStencilOperation(this.stencilTest.backOperation.fail)) {\n throw new DeveloperError(\n \"Invalid renderState.stencilTest.backOperation.fail.\"\n );\n }\n if (!validateStencilOperation(this.stencilTest.backOperation.zFail)) {\n throw new DeveloperError(\n \"Invalid renderState.stencilTest.backOperation.zFail.\"\n );\n }\n if (!validateStencilOperation(this.stencilTest.backOperation.zPass)) {\n throw new DeveloperError(\n \"Invalid renderState.stencilTest.backOperation.zPass.\"\n );\n }\n\n if (defined(this.viewport)) {\n if (this.viewport.width < 0) {\n throw new DeveloperError(\n \"renderState.viewport.width must be greater than or equal to zero.\"\n );\n }\n if (this.viewport.height < 0) {\n throw new DeveloperError(\n \"renderState.viewport.height must be greater than or equal to zero.\"\n );\n }\n\n if (this.viewport.width > ContextLimits.maximumViewportWidth) {\n throw new DeveloperError(\n `renderState.viewport.width must be less than or equal to the maximum viewport width (${ContextLimits.maximumViewportWidth.toString()}). Check maximumViewportWidth.`\n );\n }\n if (this.viewport.height > ContextLimits.maximumViewportHeight) {\n throw new DeveloperError(\n `renderState.viewport.height must be less than or equal to the maximum viewport height (${ContextLimits.maximumViewportHeight.toString()}). Check maximumViewportHeight.`\n );\n }\n }\n //>>includeEnd('debug');\n\n this.id = 0;\n this._applyFunctions = [];\n}\n\nlet nextRenderStateId = 0;\nlet renderStateCache = {};\n\n/**\n * Validates and then finds or creates an immutable render state, which defines the pipeline\n * state for a {@link DrawCommand} or {@link ClearCommand}. All inputs states are optional. Omitted states\n * use the defaults shown in the example below.\n *\n * @param {object} [renderState] The states defining the render state as shown in the example below.\n *\n * @exception {RuntimeError} renderState.lineWidth is out of range.\n * @exception {DeveloperError} Invalid renderState.frontFace.\n * @exception {DeveloperError} Invalid renderState.cull.face.\n * @exception {DeveloperError} scissorTest.rectangle.width and scissorTest.rectangle.height must be greater than or equal to zero.\n * @exception {DeveloperError} renderState.depthRange.near can't be greater than renderState.depthRange.far.\n * @exception {DeveloperError} renderState.depthRange.near must be greater than or equal to zero.\n * @exception {DeveloperError} renderState.depthRange.far must be less than or equal to zero.\n * @exception {DeveloperError} Invalid renderState.depthTest.func.\n * @exception {DeveloperError} renderState.blending.color components must be greater than or equal to zero and less than or equal to one\n * @exception {DeveloperError} Invalid renderState.blending.equationRgb.\n * @exception {DeveloperError} Invalid renderState.blending.equationAlpha.\n * @exception {DeveloperError} Invalid renderState.blending.functionSourceRgb.\n * @exception {DeveloperError} Invalid renderState.blending.functionSourceAlpha.\n * @exception {DeveloperError} Invalid renderState.blending.functionDestinationRgb.\n * @exception {DeveloperError} Invalid renderState.blending.functionDestinationAlpha.\n * @exception {DeveloperError} Invalid renderState.stencilTest.frontFunction.\n * @exception {DeveloperError} Invalid renderState.stencilTest.backFunction.\n * @exception {DeveloperError} Invalid renderState.stencilTest.frontOperation.fail.\n * @exception {DeveloperError} Invalid renderState.stencilTest.frontOperation.zFail.\n * @exception {DeveloperError} Invalid renderState.stencilTest.frontOperation.zPass.\n * @exception {DeveloperError} Invalid renderState.stencilTest.backOperation.fail.\n * @exception {DeveloperError} Invalid renderState.stencilTest.backOperation.zFail.\n * @exception {DeveloperError} Invalid renderState.stencilTest.backOperation.zPass.\n * @exception {DeveloperError} renderState.viewport.width must be greater than or equal to zero.\n * @exception {DeveloperError} renderState.viewport.width must be less than or equal to the maximum viewport width.\n * @exception {DeveloperError} renderState.viewport.height must be greater than or equal to zero.\n * @exception {DeveloperError} renderState.viewport.height must be less than or equal to the maximum viewport height.\n *\n *\n * @example\n * const defaults = {\n * frontFace : WindingOrder.COUNTER_CLOCKWISE,\n * cull : {\n * enabled : false,\n * face : CullFace.BACK\n * },\n * lineWidth : 1,\n * polygonOffset : {\n * enabled : false,\n * factor : 0,\n * units : 0\n * },\n * scissorTest : {\n * enabled : false,\n * rectangle : {\n * x : 0,\n * y : 0,\n * width : 0,\n * height : 0\n * }\n * },\n * depthRange : {\n * near : 0,\n * far : 1\n * },\n * depthTest : {\n * enabled : false,\n * func : DepthFunction.LESS\n * },\n * colorMask : {\n * red : true,\n * green : true,\n * blue : true,\n * alpha : true\n * },\n * depthMask : true,\n * stencilMask : ~0,\n * blending : {\n * enabled : false,\n * color : {\n * red : 0.0,\n * green : 0.0,\n * blue : 0.0,\n * alpha : 0.0\n * },\n * equationRgb : BlendEquation.ADD,\n * equationAlpha : BlendEquation.ADD,\n * functionSourceRgb : BlendFunction.ONE,\n * functionSourceAlpha : BlendFunction.ONE,\n * functionDestinationRgb : BlendFunction.ZERO,\n * functionDestinationAlpha : BlendFunction.ZERO\n * },\n * stencilTest : {\n * enabled : false,\n * frontFunction : StencilFunction.ALWAYS,\n * backFunction : StencilFunction.ALWAYS,\n * reference : 0,\n * mask : ~0,\n * frontOperation : {\n * fail : StencilOperation.KEEP,\n * zFail : StencilOperation.KEEP,\n * zPass : StencilOperation.KEEP\n * },\n * backOperation : {\n * fail : StencilOperation.KEEP,\n * zFail : StencilOperation.KEEP,\n * zPass : StencilOperation.KEEP\n * }\n * },\n * sampleCoverage : {\n * enabled : false,\n * value : 1.0,\n * invert : false\n * }\n * };\n *\n * const rs = RenderState.fromCache(defaults);\n *\n * @see DrawCommand\n * @see ClearCommand\n *\n * @private\n */\nRenderState.fromCache = function (renderState) {\n const partialKey = JSON.stringify(renderState);\n let cachedState = renderStateCache[partialKey];\n if (defined(cachedState)) {\n ++cachedState.referenceCount;\n return cachedState.state;\n }\n\n // Cache miss. Fully define render state and try again.\n let states = new RenderState(renderState);\n const fullKey = JSON.stringify(states);\n cachedState = renderStateCache[fullKey];\n if (!defined(cachedState)) {\n states.id = nextRenderStateId++;\n //>>includeStart('debug', pragmas.debug);\n states = freezeRenderState(states);\n //>>includeEnd('debug');\n cachedState = {\n referenceCount: 0,\n state: states,\n };\n\n // Cache full render state. Multiple partially defined render states may map to this.\n renderStateCache[fullKey] = cachedState;\n }\n\n ++cachedState.referenceCount;\n\n // Cache partial render state so we can skip validation on a cache hit for a partially defined render state\n renderStateCache[partialKey] = {\n referenceCount: 1,\n state: cachedState.state,\n };\n\n return cachedState.state;\n};\n\n/**\n * @private\n */\nRenderState.removeFromCache = function (renderState) {\n const states = new RenderState(renderState);\n const fullKey = JSON.stringify(states);\n const fullCachedState = renderStateCache[fullKey];\n\n // decrement partial key reference count\n const partialKey = JSON.stringify(renderState);\n const cachedState = renderStateCache[partialKey];\n if (defined(cachedState)) {\n --cachedState.referenceCount;\n\n if (cachedState.referenceCount === 0) {\n // remove partial key\n delete renderStateCache[partialKey];\n\n // decrement full key reference count\n if (defined(fullCachedState)) {\n --fullCachedState.referenceCount;\n }\n }\n }\n\n // remove full key if reference count is zero\n if (defined(fullCachedState) && fullCachedState.referenceCount === 0) {\n delete renderStateCache[fullKey];\n }\n};\n\n/**\n * This function is for testing purposes only.\n * @private\n */\nRenderState.getCache = function () {\n return renderStateCache;\n};\n\n/**\n * This function is for testing purposes only.\n * @private\n */\nRenderState.clearCache = function () {\n renderStateCache = {};\n};\n\nfunction enableOrDisable(gl, glEnum, enable) {\n if (enable) {\n gl.enable(glEnum);\n } else {\n gl.disable(glEnum);\n }\n}\n\nfunction applyFrontFace(gl, renderState) {\n gl.frontFace(renderState.frontFace);\n}\n\nfunction applyCull(gl, renderState) {\n const cull = renderState.cull;\n const enabled = cull.enabled;\n\n enableOrDisable(gl, gl.CULL_FACE, enabled);\n\n if (enabled) {\n gl.cullFace(cull.face);\n }\n}\n\nfunction applyLineWidth(gl, renderState) {\n gl.lineWidth(renderState.lineWidth);\n}\n\nfunction applyPolygonOffset(gl, renderState) {\n const polygonOffset = renderState.polygonOffset;\n const enabled = polygonOffset.enabled;\n\n enableOrDisable(gl, gl.POLYGON_OFFSET_FILL, enabled);\n\n if (enabled) {\n gl.polygonOffset(polygonOffset.factor, polygonOffset.units);\n }\n}\n\nfunction applyScissorTest(gl, renderState, passState) {\n const scissorTest = renderState.scissorTest;\n const enabled = defined(passState.scissorTest)\n ? passState.scissorTest.enabled\n : scissorTest.enabled;\n\n enableOrDisable(gl, gl.SCISSOR_TEST, enabled);\n\n if (enabled) {\n const rectangle = defined(passState.scissorTest)\n ? passState.scissorTest.rectangle\n : scissorTest.rectangle;\n gl.scissor(rectangle.x, rectangle.y, rectangle.width, rectangle.height);\n }\n}\n\nfunction applyDepthRange(gl, renderState) {\n const depthRange = renderState.depthRange;\n gl.depthRange(depthRange.near, depthRange.far);\n}\n\nfunction applyDepthTest(gl, renderState) {\n const depthTest = renderState.depthTest;\n const enabled = depthTest.enabled;\n\n enableOrDisable(gl, gl.DEPTH_TEST, enabled);\n\n if (enabled) {\n gl.depthFunc(depthTest.func);\n }\n}\n\nfunction applyColorMask(gl, renderState) {\n const colorMask = renderState.colorMask;\n gl.colorMask(colorMask.red, colorMask.green, colorMask.blue, colorMask.alpha);\n}\n\nfunction applyDepthMask(gl, renderState) {\n gl.depthMask(renderState.depthMask);\n}\n\nfunction applyStencilMask(gl, renderState) {\n gl.stencilMask(renderState.stencilMask);\n}\n\nfunction applyBlendingColor(gl, color) {\n gl.blendColor(color.red, color.green, color.blue, color.alpha);\n}\n\nfunction applyBlending(gl, renderState, passState) {\n const blending = renderState.blending;\n const enabled = defined(passState.blendingEnabled)\n ? passState.blendingEnabled\n : blending.enabled;\n\n enableOrDisable(gl, gl.BLEND, enabled);\n\n if (enabled) {\n applyBlendingColor(gl, blending.color);\n gl.blendEquationSeparate(blending.equationRgb, blending.equationAlpha);\n gl.blendFuncSeparate(\n blending.functionSourceRgb,\n blending.functionDestinationRgb,\n blending.functionSourceAlpha,\n blending.functionDestinationAlpha\n );\n }\n}\n\nfunction applyStencilTest(gl, renderState) {\n const stencilTest = renderState.stencilTest;\n const enabled = stencilTest.enabled;\n\n enableOrDisable(gl, gl.STENCIL_TEST, enabled);\n\n if (enabled) {\n const frontFunction = stencilTest.frontFunction;\n const backFunction = stencilTest.backFunction;\n const reference = stencilTest.reference;\n const mask = stencilTest.mask;\n\n // Section 6.8 of the WebGL spec requires the reference and masks to be the same for\n // front- and back-face tests. This call prevents invalid operation errors when calling\n // stencilFuncSeparate on Firefox. Perhaps they should delay validation to avoid requiring this.\n gl.stencilFunc(frontFunction, reference, mask);\n gl.stencilFuncSeparate(gl.BACK, backFunction, reference, mask);\n gl.stencilFuncSeparate(gl.FRONT, frontFunction, reference, mask);\n\n const frontOperation = stencilTest.frontOperation;\n const frontOperationFail = frontOperation.fail;\n const frontOperationZFail = frontOperation.zFail;\n const frontOperationZPass = frontOperation.zPass;\n\n gl.stencilOpSeparate(\n gl.FRONT,\n frontOperationFail,\n frontOperationZFail,\n frontOperationZPass\n );\n\n const backOperation = stencilTest.backOperation;\n const backOperationFail = backOperation.fail;\n const backOperationZFail = backOperation.zFail;\n const backOperationZPass = backOperation.zPass;\n\n gl.stencilOpSeparate(\n gl.BACK,\n backOperationFail,\n backOperationZFail,\n backOperationZPass\n );\n }\n}\n\nfunction applySampleCoverage(gl, renderState) {\n const sampleCoverage = renderState.sampleCoverage;\n const enabled = sampleCoverage.enabled;\n\n enableOrDisable(gl, gl.SAMPLE_COVERAGE, enabled);\n\n if (enabled) {\n gl.sampleCoverage(sampleCoverage.value, sampleCoverage.invert);\n }\n}\n\nconst scratchViewport = new BoundingRectangle();\n\nfunction applyViewport(gl, renderState, passState) {\n let viewport = defaultValue(renderState.viewport, passState.viewport);\n if (!defined(viewport)) {\n viewport = scratchViewport;\n viewport.width = passState.context.drawingBufferWidth;\n viewport.height = passState.context.drawingBufferHeight;\n }\n\n passState.context.uniformState.viewport = viewport;\n gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);\n}\n\nRenderState.apply = function (gl, renderState, passState) {\n applyFrontFace(gl, renderState);\n applyCull(gl, renderState);\n applyLineWidth(gl, renderState);\n applyPolygonOffset(gl, renderState);\n applyDepthRange(gl, renderState);\n applyDepthTest(gl, renderState);\n applyColorMask(gl, renderState);\n applyDepthMask(gl, renderState);\n applyStencilMask(gl, renderState);\n applyStencilTest(gl, renderState);\n applySampleCoverage(gl, renderState);\n applyScissorTest(gl, renderState, passState);\n applyBlending(gl, renderState, passState);\n applyViewport(gl, renderState, passState);\n};\n\nfunction createFuncs(previousState, nextState) {\n const funcs = [];\n\n if (previousState.frontFace !== nextState.frontFace) {\n funcs.push(applyFrontFace);\n }\n\n if (\n previousState.cull.enabled !== nextState.cull.enabled ||\n previousState.cull.face !== nextState.cull.face\n ) {\n funcs.push(applyCull);\n }\n\n if (previousState.lineWidth !== nextState.lineWidth) {\n funcs.push(applyLineWidth);\n }\n\n if (\n previousState.polygonOffset.enabled !== nextState.polygonOffset.enabled ||\n previousState.polygonOffset.factor !== nextState.polygonOffset.factor ||\n previousState.polygonOffset.units !== nextState.polygonOffset.units\n ) {\n funcs.push(applyPolygonOffset);\n }\n\n if (\n previousState.depthRange.near !== nextState.depthRange.near ||\n previousState.depthRange.far !== nextState.depthRange.far\n ) {\n funcs.push(applyDepthRange);\n }\n\n if (\n previousState.depthTest.enabled !== nextState.depthTest.enabled ||\n previousState.depthTest.func !== nextState.depthTest.func\n ) {\n funcs.push(applyDepthTest);\n }\n\n if (\n previousState.colorMask.red !== nextState.colorMask.red ||\n previousState.colorMask.green !== nextState.colorMask.green ||\n previousState.colorMask.blue !== nextState.colorMask.blue ||\n previousState.colorMask.alpha !== nextState.colorMask.alpha\n ) {\n funcs.push(applyColorMask);\n }\n\n if (previousState.depthMask !== nextState.depthMask) {\n funcs.push(applyDepthMask);\n }\n\n if (previousState.stencilMask !== nextState.stencilMask) {\n funcs.push(applyStencilMask);\n }\n\n if (\n previousState.stencilTest.enabled !== nextState.stencilTest.enabled ||\n previousState.stencilTest.frontFunction !==\n nextState.stencilTest.frontFunction ||\n previousState.stencilTest.backFunction !==\n nextState.stencilTest.backFunction ||\n previousState.stencilTest.reference !== nextState.stencilTest.reference ||\n previousState.stencilTest.mask !== nextState.stencilTest.mask ||\n previousState.stencilTest.frontOperation.fail !==\n nextState.stencilTest.frontOperation.fail ||\n previousState.stencilTest.frontOperation.zFail !==\n nextState.stencilTest.frontOperation.zFail ||\n previousState.stencilTest.backOperation.fail !==\n nextState.stencilTest.backOperation.fail ||\n previousState.stencilTest.backOperation.zFail !==\n nextState.stencilTest.backOperation.zFail ||\n previousState.stencilTest.backOperation.zPass !==\n nextState.stencilTest.backOperation.zPass\n ) {\n funcs.push(applyStencilTest);\n }\n\n if (\n previousState.sampleCoverage.enabled !== nextState.sampleCoverage.enabled ||\n previousState.sampleCoverage.value !== nextState.sampleCoverage.value ||\n previousState.sampleCoverage.invert !== nextState.sampleCoverage.invert\n ) {\n funcs.push(applySampleCoverage);\n }\n\n return funcs;\n}\n\nRenderState.partialApply = function (\n gl,\n previousRenderState,\n renderState,\n previousPassState,\n passState,\n clear\n) {\n if (previousRenderState !== renderState) {\n // When a new render state is applied, instead of making WebGL calls for all the states or first\n // comparing the states one-by-one with the previous state (basically a linear search), we take\n // advantage of RenderState's immutability, and store a dynamically populated sparse data structure\n // containing functions that make the minimum number of WebGL calls when transitioning from one state\n // to the other. In practice, this works well since state-to-state transitions generally only require a\n // few WebGL calls, especially if commands are stored by state.\n let funcs = renderState._applyFunctions[previousRenderState.id];\n if (!defined(funcs)) {\n funcs = createFuncs(previousRenderState, renderState);\n renderState._applyFunctions[previousRenderState.id] = funcs;\n }\n\n const len = funcs.length;\n for (let i = 0; i < len; ++i) {\n funcs[i](gl, renderState);\n }\n }\n\n const previousScissorTest = defined(previousPassState.scissorTest)\n ? previousPassState.scissorTest\n : previousRenderState.scissorTest;\n const scissorTest = defined(passState.scissorTest)\n ? passState.scissorTest\n : renderState.scissorTest;\n\n // Our scissor rectangle can get out of sync with the GL scissor rectangle on clears.\n // Seems to be a problem only on ANGLE. See https://github.com/CesiumGS/cesium/issues/2994\n if (previousScissorTest !== scissorTest || clear) {\n applyScissorTest(gl, renderState, passState);\n }\n\n const previousBlendingEnabled = defined(previousPassState.blendingEnabled)\n ? previousPassState.blendingEnabled\n : previousRenderState.blending.enabled;\n const blendingEnabled = defined(passState.blendingEnabled)\n ? passState.blendingEnabled\n : renderState.blending.enabled;\n if (\n previousBlendingEnabled !== blendingEnabled ||\n (blendingEnabled && previousRenderState.blending !== renderState.blending)\n ) {\n applyBlending(gl, renderState, passState);\n }\n\n if (\n previousRenderState !== renderState ||\n previousPassState !== passState ||\n previousPassState.context !== passState.context\n ) {\n applyViewport(gl, renderState, passState);\n }\n};\n\nRenderState.getState = function (renderState) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(renderState)) {\n throw new DeveloperError(\"renderState is required.\");\n }\n //>>includeEnd('debug');\n\n return {\n frontFace: renderState.frontFace,\n cull: {\n enabled: renderState.cull.enabled,\n face: renderState.cull.face,\n },\n lineWidth: renderState.lineWidth,\n polygonOffset: {\n enabled: renderState.polygonOffset.enabled,\n factor: renderState.polygonOffset.factor,\n units: renderState.polygonOffset.units,\n },\n scissorTest: {\n enabled: renderState.scissorTest.enabled,\n rectangle: BoundingRectangle.clone(renderState.scissorTest.rectangle),\n },\n depthRange: {\n near: renderState.depthRange.near,\n far: renderState.depthRange.far,\n },\n depthTest: {\n enabled: renderState.depthTest.enabled,\n func: renderState.depthTest.func,\n },\n colorMask: {\n red: renderState.colorMask.red,\n green: renderState.colorMask.green,\n blue: renderState.colorMask.blue,\n alpha: renderState.colorMask.alpha,\n },\n depthMask: renderState.depthMask,\n stencilMask: renderState.stencilMask,\n blending: {\n enabled: renderState.blending.enabled,\n color: Color.clone(renderState.blending.color),\n equationRgb: renderState.blending.equationRgb,\n equationAlpha: renderState.blending.equationAlpha,\n functionSourceRgb: renderState.blending.functionSourceRgb,\n functionSourceAlpha: renderState.blending.functionSourceAlpha,\n functionDestinationRgb: renderState.blending.functionDestinationRgb,\n functionDestinationAlpha: renderState.blending.functionDestinationAlpha,\n },\n stencilTest: {\n enabled: renderState.stencilTest.enabled,\n frontFunction: renderState.stencilTest.frontFunction,\n backFunction: renderState.stencilTest.backFunction,\n reference: renderState.stencilTest.reference,\n mask: renderState.stencilTest.mask,\n frontOperation: {\n fail: renderState.stencilTest.frontOperation.fail,\n zFail: renderState.stencilTest.frontOperation.zFail,\n zPass: renderState.stencilTest.frontOperation.zPass,\n },\n backOperation: {\n fail: renderState.stencilTest.backOperation.fail,\n zFail: renderState.stencilTest.backOperation.zFail,\n zPass: renderState.stencilTest.backOperation.zPass,\n },\n },\n sampleCoverage: {\n enabled: renderState.sampleCoverage.enabled,\n value: renderState.sampleCoverage.value,\n invert: renderState.sampleCoverage.invert,\n },\n viewport: defined(renderState.viewport)\n ? BoundingRectangle.clone(renderState.viewport)\n : undefined,\n };\n};\nexport default RenderState;\n", "import Cartesian2 from \"./Cartesian2.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * A 2x2 matrix, indexable as a column-major order array.\n * Constructor parameters are in row-major order for code readability.\n * @alias Matrix2\n * @constructor\n * @implements {ArrayLike}\n *\n * @param {number} [column0Row0=0.0] The value for column 0, row 0.\n * @param {number} [column1Row0=0.0] The value for column 1, row 0.\n * @param {number} [column0Row1=0.0] The value for column 0, row 1.\n * @param {number} [column1Row1=0.0] The value for column 1, row 1.\n *\n * @see Matrix2.fromArray\n * @see Matrix2.fromColumnMajorArray\n * @see Matrix2.fromRowMajorArray\n * @see Matrix2.fromScale\n * @see Matrix2.fromUniformScale\n * @see Matrix2.fromRotation\n * @see Matrix3\n * @see Matrix4\n */\nfunction Matrix2(column0Row0, column1Row0, column0Row1, column1Row1) {\n this[0] = defaultValue(column0Row0, 0.0);\n this[1] = defaultValue(column0Row1, 0.0);\n this[2] = defaultValue(column1Row0, 0.0);\n this[3] = defaultValue(column1Row1, 0.0);\n}\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nMatrix2.packedLength = 4;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Matrix2} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nMatrix2.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value[0];\n array[startingIndex++] = value[1];\n array[startingIndex++] = value[2];\n array[startingIndex++] = value[3];\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Matrix2} [result] The object into which to store the result.\n * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.\n */\nMatrix2.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Matrix2();\n }\n\n result[0] = array[startingIndex++];\n result[1] = array[startingIndex++];\n result[2] = array[startingIndex++];\n result[3] = array[startingIndex++];\n return result;\n};\n\n/**\n * Flattens an array of Matrix2s into an array of components. The components\n * are stored in column-major order.\n *\n * @param {Matrix2[]} array The array of matrices to pack.\n * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.\n * @returns {number[]} The packed array.\n */\nMatrix2.packArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n const length = array.length;\n const resultLength = length * 4;\n if (!defined(result)) {\n result = new Array(resultLength);\n } else if (!Array.isArray(result) && result.length !== resultLength) {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"If result is a typed array, it must have exactly array.length * 4 elements\"\n );\n //>>includeEnd('debug');\n } else if (result.length !== resultLength) {\n result.length = resultLength;\n }\n\n for (let i = 0; i < length; ++i) {\n Matrix2.pack(array[i], result, i * 4);\n }\n return result;\n};\n\n/**\n * Unpacks an array of column-major matrix components into an array of Matrix2s.\n *\n * @param {number[]} array The array of components to unpack.\n * @param {Matrix2[]} [result] The array onto which to store the result.\n * @returns {Matrix2[]} The unpacked array.\n */\nMatrix2.unpackArray = function (array, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.typeOf.number.greaterThanOrEquals(\"array.length\", array.length, 4);\n if (array.length % 4 !== 0) {\n throw new DeveloperError(\"array length must be a multiple of 4.\");\n }\n //>>includeEnd('debug');\n\n const length = array.length;\n if (!defined(result)) {\n result = new Array(length / 4);\n } else {\n result.length = length / 4;\n }\n\n for (let i = 0; i < length; i += 4) {\n const index = i / 4;\n result[index] = Matrix2.unpack(array, i, result[index]);\n }\n return result;\n};\n\n/**\n * Duplicates a Matrix2 instance.\n *\n * @param {Matrix2} matrix The matrix to duplicate.\n * @param {Matrix2} [result] The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)\n */\nMatrix2.clone = function (matrix, result) {\n if (!defined(matrix)) {\n return undefined;\n }\n if (!defined(result)) {\n return new Matrix2(matrix[0], matrix[2], matrix[1], matrix[3]);\n }\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n return result;\n};\n\n/**\n * Creates a Matrix2 from 4 consecutive elements in an array.\n *\n * @function\n * @param {number[]} array The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.\n * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to first column first row position in the matrix.\n * @param {Matrix2} [result] The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.\n *\n * @example\n * // Create the Matrix2:\n * // [1.0, 2.0]\n * // [1.0, 2.0]\n *\n * const v = [1.0, 1.0, 2.0, 2.0];\n * const m = Cesium.Matrix2.fromArray(v);\n *\n * // Create same Matrix2 with using an offset into an array\n * const v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0];\n * const m2 = Cesium.Matrix2.fromArray(v2, 2);\n */\nMatrix2.fromArray = Matrix2.unpack;\n/**\n * Creates a Matrix2 instance from a column-major order array.\n *\n * @param {number[]} values The column-major order array.\n * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.\n */\nMatrix2.fromColumnMajorArray = function (values, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"values\", values);\n //>>includeEnd('debug');\n\n return Matrix2.clone(values, result);\n};\n\n/**\n * Creates a Matrix2 instance from a row-major order array.\n * The resulting matrix will be in column-major order.\n *\n * @param {number[]} values The row-major order array.\n * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.\n */\nMatrix2.fromRowMajorArray = function (values, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"values\", values);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix2(values[0], values[1], values[2], values[3]);\n }\n result[0] = values[0];\n result[1] = values[2];\n result[2] = values[1];\n result[3] = values[3];\n return result;\n};\n\n/**\n * Computes a Matrix2 instance representing a non-uniform scale.\n *\n * @param {Cartesian2} scale The x and y scale factors.\n * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [7.0, 0.0]\n * // [0.0, 8.0]\n * const m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0));\n */\nMatrix2.fromScale = function (scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix2(scale.x, 0.0, 0.0, scale.y);\n }\n\n result[0] = scale.x;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = scale.y;\n return result;\n};\n\n/**\n * Computes a Matrix2 instance representing a uniform scale.\n *\n * @param {number} scale The uniform scale factor.\n * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.\n *\n * @example\n * // Creates\n * // [2.0, 0.0]\n * // [0.0, 2.0]\n * const m = Cesium.Matrix2.fromUniformScale(2.0);\n */\nMatrix2.fromUniformScale = function (scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"scale\", scale);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return new Matrix2(scale, 0.0, 0.0, scale);\n }\n\n result[0] = scale;\n result[1] = 0.0;\n result[2] = 0.0;\n result[3] = scale;\n return result;\n};\n\n/**\n * Creates a rotation matrix.\n *\n * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.\n * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.\n * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.\n *\n * @example\n * // Rotate a point 45 degrees counterclockwise.\n * const p = new Cesium.Cartesian2(5, 6);\n * const m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0));\n * const rotated = Cesium.Matrix2.multiplyByVector(m, p, new Cesium.Cartesian2());\n */\nMatrix2.fromRotation = function (angle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"angle\", angle);\n //>>includeEnd('debug');\n\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n\n if (!defined(result)) {\n return new Matrix2(cosAngle, -sinAngle, sinAngle, cosAngle);\n }\n result[0] = cosAngle;\n result[1] = sinAngle;\n result[2] = -sinAngle;\n result[3] = cosAngle;\n return result;\n};\n\n/**\n * Creates an Array from the provided Matrix2 instance.\n * The array will be in column-major order.\n *\n * @param {Matrix2} matrix The matrix to use..\n * @param {number[]} [result] The Array onto which to store the result.\n * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.\n */\nMatrix2.toArray = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n return [matrix[0], matrix[1], matrix[2], matrix[3]];\n }\n result[0] = matrix[0];\n result[1] = matrix[1];\n result[2] = matrix[2];\n result[3] = matrix[3];\n return result;\n};\n\n/**\n * Computes the array index of the element at the provided row and column.\n *\n * @param {number} row The zero-based index of the row.\n * @param {number} column The zero-based index of the column.\n * @returns {number} The index of the element at the provided row and column.\n *\n * @exception {DeveloperError} row must be 0 or 1.\n * @exception {DeveloperError} column must be 0 or 1.\n *\n * @example\n * const myMatrix = new Cesium.Matrix2();\n * const column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0);\n * const column1Row0 = myMatrix[column1Row0Index]\n * myMatrix[column1Row0Index] = 10.0;\n */\nMatrix2.getElementIndex = function (column, row) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThanOrEquals(\"row\", row, 0);\n Check.typeOf.number.lessThanOrEquals(\"row\", row, 1);\n\n Check.typeOf.number.greaterThanOrEquals(\"column\", column, 0);\n Check.typeOf.number.lessThanOrEquals(\"column\", column, 1);\n //>>includeEnd('debug');\n\n return column * 2 + row;\n};\n\n/**\n * Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.\n *\n * @param {Matrix2} matrix The matrix to use.\n * @param {number} index The zero-based index of the column to retrieve.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0 or 1.\n */\nMatrix2.getColumn = function (matrix, index, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 1);\n\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const startIndex = index * 2;\n const x = matrix[startIndex];\n const y = matrix[startIndex + 1];\n\n result.x = x;\n result.y = y;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.\n *\n * @param {Matrix2} matrix The matrix to use.\n * @param {number} index The zero-based index of the column to set.\n * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified column.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0 or 1.\n */\nMatrix2.setColumn = function (matrix, index, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 1);\n\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result = Matrix2.clone(matrix, result);\n const startIndex = index * 2;\n result[startIndex] = cartesian.x;\n result[startIndex + 1] = cartesian.y;\n return result;\n};\n\n/**\n * Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.\n *\n * @param {Matrix2} matrix The matrix to use.\n * @param {number} index The zero-based index of the row to retrieve.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0 or 1.\n */\nMatrix2.getRow = function (matrix, index, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 1);\n\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = matrix[index];\n const y = matrix[index + 2];\n\n result.x = x;\n result.y = y;\n return result;\n};\n\n/**\n * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.\n *\n * @param {Matrix2} matrix The matrix to use.\n * @param {number} index The zero-based index of the row to set.\n * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified row.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @exception {DeveloperError} index must be 0 or 1.\n */\nMatrix2.setRow = function (matrix, index, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n\n Check.typeOf.number.greaterThanOrEquals(\"index\", index, 0);\n Check.typeOf.number.lessThanOrEquals(\"index\", index, 1);\n\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result = Matrix2.clone(matrix, result);\n result[index] = cartesian.x;\n result[index + 2] = cartesian.y;\n return result;\n};\n\nconst scaleScratch1 = new Cartesian2();\n\n/**\n * Computes a new matrix that replaces the scale with the provided scale.\n * This assumes the matrix is an affine transformation.\n *\n * @param {Matrix2} matrix The matrix to use.\n * @param {Cartesian2} scale The scale that replaces the scale of the provided matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @see Matrix2.setUniformScale\n * @see Matrix2.fromScale\n * @see Matrix2.fromUniformScale\n * @see Matrix2.multiplyByScale\n * @see Matrix2.multiplyByUniformScale\n * @see Matrix2.getScale\n */\nMatrix2.setScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const existingScale = Matrix2.getScale(matrix, scaleScratch1);\n const scaleRatioX = scale.x / existingScale.x;\n const scaleRatioY = scale.y / existingScale.y;\n\n result[0] = matrix[0] * scaleRatioX;\n result[1] = matrix[1] * scaleRatioX;\n result[2] = matrix[2] * scaleRatioY;\n result[3] = matrix[3] * scaleRatioY;\n\n return result;\n};\n\nconst scaleScratch2 = new Cartesian2();\n\n/**\n * Computes a new matrix that replaces the scale with the provided uniform scale.\n * This assumes the matrix is an affine transformation.\n *\n * @param {Matrix2} matrix The matrix to use.\n * @param {number} scale The uniform scale that replaces the scale of the provided matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @see Matrix2.setScale\n * @see Matrix2.fromScale\n * @see Matrix2.fromUniformScale\n * @see Matrix2.multiplyByScale\n * @see Matrix2.multiplyByUniformScale\n * @see Matrix2.getScale\n */\nMatrix2.setUniformScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const existingScale = Matrix2.getScale(matrix, scaleScratch2);\n const scaleRatioX = scale / existingScale.x;\n const scaleRatioY = scale / existingScale.y;\n\n result[0] = matrix[0] * scaleRatioX;\n result[1] = matrix[1] * scaleRatioX;\n result[2] = matrix[2] * scaleRatioY;\n result[3] = matrix[3] * scaleRatioY;\n\n return result;\n};\n\nconst scratchColumn = new Cartesian2();\n\n/**\n * Extracts the non-uniform scale assuming the matrix is an affine transformation.\n *\n * @param {Matrix2} matrix The matrix.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n *\n * @see Matrix2.multiplyByScale\n * @see Matrix2.multiplyByUniformScale\n * @see Matrix2.fromScale\n * @see Matrix2.fromUniformScale\n * @see Matrix2.setScale\n * @see Matrix2.setUniformScale\n */\nMatrix2.getScale = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = Cartesian2.magnitude(\n Cartesian2.fromElements(matrix[0], matrix[1], scratchColumn)\n );\n result.y = Cartesian2.magnitude(\n Cartesian2.fromElements(matrix[2], matrix[3], scratchColumn)\n );\n return result;\n};\n\nconst scaleScratch3 = new Cartesian2();\n\n/**\n * Computes the maximum scale assuming the matrix is an affine transformation.\n * The maximum scale is the maximum length of the column vectors.\n *\n * @param {Matrix2} matrix The matrix.\n * @returns {number} The maximum scale.\n */\nMatrix2.getMaximumScale = function (matrix) {\n Matrix2.getScale(matrix, scaleScratch3);\n return Cartesian2.maximumComponent(scaleScratch3);\n};\n\nconst scaleScratch4 = new Cartesian2();\n\n/**\n * Sets the rotation assuming the matrix is an affine transformation.\n *\n * @param {Matrix2} matrix The matrix.\n * @param {Matrix2} rotation The rotation matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @see Matrix2.fromRotation\n * @see Matrix2.getRotation\n */\nMatrix2.setRotation = function (matrix, rotation, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scale = Matrix2.getScale(matrix, scaleScratch4);\n\n result[0] = rotation[0] * scale.x;\n result[1] = rotation[1] * scale.x;\n result[2] = rotation[2] * scale.y;\n result[3] = rotation[3] * scale.y;\n\n return result;\n};\n\nconst scaleScratch5 = new Cartesian2();\n\n/**\n * Extracts the rotation matrix assuming the matrix is an affine transformation.\n *\n * @param {Matrix2} matrix The matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @see Matrix2.setRotation\n * @see Matrix2.fromRotation\n */\nMatrix2.getRotation = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const scale = Matrix2.getScale(matrix, scaleScratch5);\n\n result[0] = matrix[0] / scale.x;\n result[1] = matrix[1] / scale.x;\n result[2] = matrix[2] / scale.y;\n result[3] = matrix[3] / scale.y;\n\n return result;\n};\n\n/**\n * Computes the product of two matrices.\n *\n * @param {Matrix2} left The first matrix.\n * @param {Matrix2} right The second matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.multiply = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const column0Row0 = left[0] * right[0] + left[2] * right[1];\n const column1Row0 = left[0] * right[2] + left[2] * right[3];\n const column0Row1 = left[1] * right[0] + left[3] * right[1];\n const column1Row1 = left[1] * right[2] + left[3] * right[3];\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column1Row0;\n result[3] = column1Row1;\n return result;\n};\n\n/**\n * Computes the sum of two matrices.\n *\n * @param {Matrix2} left The first matrix.\n * @param {Matrix2} right The second matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = left[0] + right[0];\n result[1] = left[1] + right[1];\n result[2] = left[2] + right[2];\n result[3] = left[3] + right[3];\n return result;\n};\n\n/**\n * Computes the difference of two matrices.\n *\n * @param {Matrix2} left The first matrix.\n * @param {Matrix2} right The second matrix.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = left[0] - right[0];\n result[1] = left[1] - right[1];\n result[2] = left[2] - right[2];\n result[3] = left[3] - right[3];\n return result;\n};\n\n/**\n * Computes the product of a matrix and a column vector.\n *\n * @param {Matrix2} matrix The matrix.\n * @param {Cartesian2} cartesian The column.\n * @param {Cartesian2} result The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter.\n */\nMatrix2.multiplyByVector = function (matrix, cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const x = matrix[0] * cartesian.x + matrix[2] * cartesian.y;\n const y = matrix[1] * cartesian.x + matrix[3] * cartesian.y;\n\n result.x = x;\n result.y = y;\n return result;\n};\n\n/**\n * Computes the product of a matrix and a scalar.\n *\n * @param {Matrix2} matrix The matrix.\n * @param {number} scalar The number to multiply by.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.multiplyByScalar = function (matrix, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scalar;\n result[1] = matrix[1] * scalar;\n result[2] = matrix[2] * scalar;\n result[3] = matrix[3] * scalar;\n return result;\n};\n\n/**\n * Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.\n *\n * @param {Matrix2} matrix The matrix on the left-hand side.\n * @param {Cartesian2} scale The non-uniform scale on the right-hand side.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n *\n * @example\n * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromScale(scale), m);\n * Cesium.Matrix2.multiplyByScale(m, scale, m);\n *\n * @see Matrix2.multiplyByUniformScale\n * @see Matrix2.fromScale\n * @see Matrix2.fromUniformScale\n * @see Matrix2.setScale\n * @see Matrix2.setUniformScale\n * @see Matrix2.getScale\n */\nMatrix2.multiplyByScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scale.x;\n result[1] = matrix[1] * scale.x;\n result[2] = matrix[2] * scale.y;\n result[3] = matrix[3] * scale.y;\n\n return result;\n};\n\n/**\n * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.\n *\n * @param {Matrix2} matrix The matrix on the left-hand side.\n * @param {number} scale The uniform scale on the right-hand side.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n *\n * @example\n * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromUniformScale(scale), m);\n * Cesium.Matrix2.multiplyByUniformScale(m, scale, m);\n *\n * @see Matrix2.multiplyByScale\n * @see Matrix2.fromScale\n * @see Matrix2.fromUniformScale\n * @see Matrix2.setScale\n * @see Matrix2.setUniformScale\n * @see Matrix2.getScale\n */\nMatrix2.multiplyByUniformScale = function (matrix, scale, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.number(\"scale\", scale);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = matrix[0] * scale;\n result[1] = matrix[1] * scale;\n result[2] = matrix[2] * scale;\n result[3] = matrix[3] * scale;\n\n return result;\n};\n\n/**\n * Creates a negated copy of the provided matrix.\n *\n * @param {Matrix2} matrix The matrix to negate.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.negate = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = -matrix[0];\n result[1] = -matrix[1];\n result[2] = -matrix[2];\n result[3] = -matrix[3];\n return result;\n};\n\n/**\n * Computes the transpose of the provided matrix.\n *\n * @param {Matrix2} matrix The matrix to transpose.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.transpose = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const column0Row0 = matrix[0];\n const column0Row1 = matrix[2];\n const column1Row0 = matrix[1];\n const column1Row1 = matrix[3];\n\n result[0] = column0Row0;\n result[1] = column0Row1;\n result[2] = column1Row0;\n result[3] = column1Row1;\n return result;\n};\n\n/**\n * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.\n *\n * @param {Matrix2} matrix The matrix with signed elements.\n * @param {Matrix2} result The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter.\n */\nMatrix2.abs = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result[0] = Math.abs(matrix[0]);\n result[1] = Math.abs(matrix[1]);\n result[2] = Math.abs(matrix[2]);\n result[3] = Math.abs(matrix[3]);\n\n return result;\n};\n\n/**\n * Compares the provided matrices componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Matrix2} [left] The first matrix.\n * @param {Matrix2} [right] The second matrix.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nMatrix2.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left[0] === right[0] &&\n left[1] === right[1] &&\n left[2] === right[2] &&\n left[3] === right[3])\n );\n};\n\n/**\n * @private\n */\nMatrix2.equalsArray = function (matrix, array, offset) {\n return (\n matrix[0] === array[offset] &&\n matrix[1] === array[offset + 1] &&\n matrix[2] === array[offset + 2] &&\n matrix[3] === array[offset + 3]\n );\n};\n\n/**\n * Compares the provided matrices componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Matrix2} [left] The first matrix.\n * @param {Matrix2} [right] The second matrix.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nMatrix2.equalsEpsilon = function (left, right, epsilon) {\n epsilon = defaultValue(epsilon, 0);\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(left[0] - right[0]) <= epsilon &&\n Math.abs(left[1] - right[1]) <= epsilon &&\n Math.abs(left[2] - right[2]) <= epsilon &&\n Math.abs(left[3] - right[3]) <= epsilon)\n );\n};\n\n/**\n * An immutable Matrix2 instance initialized to the identity matrix.\n *\n * @type {Matrix2}\n * @constant\n */\nMatrix2.IDENTITY = Object.freeze(new Matrix2(1.0, 0.0, 0.0, 1.0));\n\n/**\n * An immutable Matrix2 instance initialized to the zero matrix.\n *\n * @type {Matrix2}\n * @constant\n */\nMatrix2.ZERO = Object.freeze(new Matrix2(0.0, 0.0, 0.0, 0.0));\n\n/**\n * The index into Matrix2 for column 0, row 0.\n *\n * @type {number}\n * @constant\n *\n * @example\n * const matrix = new Cesium.Matrix2();\n * matrix[Cesium.Matrix2.COLUMN0ROW0] = 5.0; // set column 0, row 0 to 5.0\n */\nMatrix2.COLUMN0ROW0 = 0;\n\n/**\n * The index into Matrix2 for column 0, row 1.\n *\n * @type {number}\n * @constant\n *\n * @example\n * const matrix = new Cesium.Matrix2();\n * matrix[Cesium.Matrix2.COLUMN0ROW1] = 5.0; // set column 0, row 1 to 5.0\n */\nMatrix2.COLUMN0ROW1 = 1;\n\n/**\n * The index into Matrix2 for column 1, row 0.\n *\n * @type {number}\n * @constant\n *\n * @example\n * const matrix = new Cesium.Matrix2();\n * matrix[Cesium.Matrix2.COLUMN1ROW0] = 5.0; // set column 1, row 0 to 5.0\n */\nMatrix2.COLUMN1ROW0 = 2;\n\n/**\n * The index into Matrix2 for column 1, row 1.\n *\n * @type {number}\n * @constant\n *\n * @example\n * const matrix = new Cesium.Matrix2();\n * matrix[Cesium.Matrix2.COLUMN1ROW1] = 5.0; // set column 1, row 1 to 5.0\n */\nMatrix2.COLUMN1ROW1 = 3;\n\nObject.defineProperties(Matrix2.prototype, {\n /**\n * Gets the number of items in the collection.\n * @memberof Matrix2.prototype\n *\n * @type {number}\n */\n length: {\n get: function () {\n return Matrix2.packedLength;\n },\n },\n});\n\n/**\n * Duplicates the provided Matrix2 instance.\n *\n * @param {Matrix2} [result] The object onto which to store the result.\n * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.\n */\nMatrix2.prototype.clone = function (result) {\n return Matrix2.clone(this, result);\n};\n\n/**\n * Compares this matrix to the provided matrix componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Matrix2} [right] The right hand side matrix.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nMatrix2.prototype.equals = function (right) {\n return Matrix2.equals(this, right);\n};\n\n/**\n * Compares this matrix to the provided matrix componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Matrix2} [right] The right hand side matrix.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nMatrix2.prototype.equalsEpsilon = function (right, epsilon) {\n return Matrix2.equalsEpsilon(this, right, epsilon);\n};\n\n/**\n * Creates a string representing this Matrix with each row being\n * on a separate line and in the format '(column0, column1)'.\n *\n * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1)'.\n */\nMatrix2.prototype.toString = function () {\n return `(${this[0]}, ${this[2]})\\n` + `(${this[1]}, ${this[3]})`;\n};\nexport default Matrix2;\n", "import Cartesian2 from \"../Core/Cartesian2.js\";\nimport Cartesian3 from \"../Core/Cartesian3.js\";\nimport Cartesian4 from \"../Core/Cartesian4.js\";\nimport Color from \"../Core/Color.js\";\nimport defined from \"../Core/defined.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport Matrix2 from \"../Core/Matrix2.js\";\nimport Matrix3 from \"../Core/Matrix3.js\";\nimport Matrix4 from \"../Core/Matrix4.js\";\nimport RuntimeError from \"../Core/RuntimeError.js\";\n\n/**\n * @private\n * @constructor\n */\nfunction createUniform(gl, activeUniform, uniformName, location) {\n switch (activeUniform.type) {\n case gl.FLOAT:\n return new UniformFloat(gl, activeUniform, uniformName, location);\n case gl.FLOAT_VEC2:\n return new UniformFloatVec2(gl, activeUniform, uniformName, location);\n case gl.FLOAT_VEC3:\n return new UniformFloatVec3(gl, activeUniform, uniformName, location);\n case gl.FLOAT_VEC4:\n return new UniformFloatVec4(gl, activeUniform, uniformName, location);\n case gl.SAMPLER_2D:\n case gl.SAMPLER_CUBE:\n return new UniformSampler(gl, activeUniform, uniformName, location);\n case gl.INT:\n case gl.BOOL:\n return new UniformInt(gl, activeUniform, uniformName, location);\n case gl.INT_VEC2:\n case gl.BOOL_VEC2:\n return new UniformIntVec2(gl, activeUniform, uniformName, location);\n case gl.INT_VEC3:\n case gl.BOOL_VEC3:\n return new UniformIntVec3(gl, activeUniform, uniformName, location);\n case gl.INT_VEC4:\n case gl.BOOL_VEC4:\n return new UniformIntVec4(gl, activeUniform, uniformName, location);\n case gl.FLOAT_MAT2:\n return new UniformMat2(gl, activeUniform, uniformName, location);\n case gl.FLOAT_MAT3:\n return new UniformMat3(gl, activeUniform, uniformName, location);\n case gl.FLOAT_MAT4:\n return new UniformMat4(gl, activeUniform, uniformName, location);\n default:\n throw new RuntimeError(\n `Unrecognized uniform type: ${activeUniform.type} for uniform \"${uniformName}\".`\n );\n }\n}\n\n/**\n * @private\n * @constructor\n */\nfunction UniformFloat(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = 0.0;\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformFloat.prototype.set = function () {\n if (this.value !== this._value) {\n this._value = this.value;\n this._gl.uniform1f(this._location, this.value);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformFloatVec2(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Cartesian2();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformFloatVec2.prototype.set = function () {\n const v = this.value;\n if (!Cartesian2.equals(v, this._value)) {\n Cartesian2.clone(v, this._value);\n this._gl.uniform2f(this._location, v.x, v.y);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformFloatVec3(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = undefined;\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformFloatVec3.prototype.set = function () {\n const v = this.value;\n\n if (defined(v.red)) {\n if (!Color.equals(v, this._value)) {\n this._value = Color.clone(v, this._value);\n this._gl.uniform3f(this._location, v.red, v.green, v.blue);\n }\n } else if (defined(v.x)) {\n if (!Cartesian3.equals(v, this._value)) {\n this._value = Cartesian3.clone(v, this._value);\n this._gl.uniform3f(this._location, v.x, v.y, v.z);\n }\n } else {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(`Invalid vec3 value for uniform \"${this.name}\".`);\n //>>includeEnd('debug');\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformFloatVec4(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = undefined;\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformFloatVec4.prototype.set = function () {\n const v = this.value;\n\n if (defined(v.red)) {\n if (!Color.equals(v, this._value)) {\n this._value = Color.clone(v, this._value);\n this._gl.uniform4f(this._location, v.red, v.green, v.blue, v.alpha);\n }\n } else if (defined(v.x)) {\n if (!Cartesian4.equals(v, this._value)) {\n this._value = Cartesian4.clone(v, this._value);\n this._gl.uniform4f(this._location, v.x, v.y, v.z, v.w);\n }\n } else {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(`Invalid vec4 value for uniform \"${this.name}\".`);\n //>>includeEnd('debug');\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformSampler(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n\n this._gl = gl;\n this._location = location;\n\n this.textureUnitIndex = undefined;\n}\n\nUniformSampler.prototype.set = function () {\n const gl = this._gl;\n gl.activeTexture(gl.TEXTURE0 + this.textureUnitIndex);\n\n const v = this.value;\n gl.bindTexture(v._target, v._texture);\n};\n\nUniformSampler.prototype._setSampler = function (textureUnitIndex) {\n this.textureUnitIndex = textureUnitIndex;\n this._gl.uniform1i(this._location, textureUnitIndex);\n return textureUnitIndex + 1;\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformInt(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = 0.0;\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformInt.prototype.set = function () {\n if (this.value !== this._value) {\n this._value = this.value;\n this._gl.uniform1i(this._location, this.value);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n/**\n * @private\n * @constructor\n */\nfunction UniformIntVec2(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Cartesian2();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformIntVec2.prototype.set = function () {\n const v = this.value;\n if (!Cartesian2.equals(v, this._value)) {\n Cartesian2.clone(v, this._value);\n this._gl.uniform2i(this._location, v.x, v.y);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n/**\n * @private\n * @constructor\n */\nfunction UniformIntVec3(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Cartesian3();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformIntVec3.prototype.set = function () {\n const v = this.value;\n if (!Cartesian3.equals(v, this._value)) {\n Cartesian3.clone(v, this._value);\n this._gl.uniform3i(this._location, v.x, v.y, v.z);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n/**\n * @private\n * @constructor\n */\nfunction UniformIntVec4(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Cartesian4();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformIntVec4.prototype.set = function () {\n const v = this.value;\n if (!Cartesian4.equals(v, this._value)) {\n Cartesian4.clone(v, this._value);\n this._gl.uniform4i(this._location, v.x, v.y, v.z, v.w);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\nconst scratchUniformArray = new Float32Array(4);\n/**\n * @private\n * @constructor\n */\nfunction UniformMat2(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Matrix2();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformMat2.prototype.set = function () {\n if (!Matrix2.equalsArray(this.value, this._value, 0)) {\n Matrix2.clone(this.value, this._value);\n\n const array = Matrix2.toArray(this.value, scratchUniformArray);\n this._gl.uniformMatrix2fv(this._location, false, array);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\nconst scratchMat3Array = new Float32Array(9);\n/**\n * @private\n * @constructor\n */\nfunction UniformMat3(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Matrix3();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformMat3.prototype.set = function () {\n if (!Matrix3.equalsArray(this.value, this._value, 0)) {\n Matrix3.clone(this.value, this._value);\n\n const array = Matrix3.toArray(this.value, scratchMat3Array);\n this._gl.uniformMatrix3fv(this._location, false, array);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\nconst scratchMat4Array = new Float32Array(16);\n/**\n * @private\n * @constructor\n */\nfunction UniformMat4(gl, activeUniform, uniformName, location) {\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = undefined;\n this._value = new Matrix4();\n\n this._gl = gl;\n this._location = location;\n}\n\nUniformMat4.prototype.set = function () {\n if (!Matrix4.equalsArray(this.value, this._value, 0)) {\n Matrix4.clone(this.value, this._value);\n\n const array = Matrix4.toArray(this.value, scratchMat4Array);\n this._gl.uniformMatrix4fv(this._location, false, array);\n }\n};\nexport default createUniform;\n", "import Cartesian2 from \"../Core/Cartesian2.js\";\nimport Cartesian3 from \"../Core/Cartesian3.js\";\nimport Cartesian4 from \"../Core/Cartesian4.js\";\nimport Color from \"../Core/Color.js\";\nimport defined from \"../Core/defined.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport Matrix2 from \"../Core/Matrix2.js\";\nimport Matrix3 from \"../Core/Matrix3.js\";\nimport Matrix4 from \"../Core/Matrix4.js\";\nimport RuntimeError from \"../Core/RuntimeError.js\";\n\n/**\n * @private\n * @constructor\n */\nfunction createUniformArray(gl, activeUniform, uniformName, locations) {\n switch (activeUniform.type) {\n case gl.FLOAT:\n return new UniformArrayFloat(gl, activeUniform, uniformName, locations);\n case gl.FLOAT_VEC2:\n return new UniformArrayFloatVec2(\n gl,\n activeUniform,\n uniformName,\n locations\n );\n case gl.FLOAT_VEC3:\n return new UniformArrayFloatVec3(\n gl,\n activeUniform,\n uniformName,\n locations\n );\n case gl.FLOAT_VEC4:\n return new UniformArrayFloatVec4(\n gl,\n activeUniform,\n uniformName,\n locations\n );\n case gl.SAMPLER_2D:\n case gl.SAMPLER_CUBE:\n return new UniformArraySampler(gl, activeUniform, uniformName, locations);\n case gl.INT:\n case gl.BOOL:\n return new UniformArrayInt(gl, activeUniform, uniformName, locations);\n case gl.INT_VEC2:\n case gl.BOOL_VEC2:\n return new UniformArrayIntVec2(gl, activeUniform, uniformName, locations);\n case gl.INT_VEC3:\n case gl.BOOL_VEC3:\n return new UniformArrayIntVec3(gl, activeUniform, uniformName, locations);\n case gl.INT_VEC4:\n case gl.BOOL_VEC4:\n return new UniformArrayIntVec4(gl, activeUniform, uniformName, locations);\n case gl.FLOAT_MAT2:\n return new UniformArrayMat2(gl, activeUniform, uniformName, locations);\n case gl.FLOAT_MAT3:\n return new UniformArrayMat3(gl, activeUniform, uniformName, locations);\n case gl.FLOAT_MAT4:\n return new UniformArrayMat4(gl, activeUniform, uniformName, locations);\n default:\n throw new RuntimeError(\n `Unrecognized uniform type: ${activeUniform.type} for uniform \"${uniformName}\".`\n );\n }\n}\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayFloat(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayFloat.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (v !== arraybuffer[i]) {\n arraybuffer[i] = v;\n changed = true;\n }\n }\n\n if (changed) {\n this._gl.uniform1fv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayFloatVec2(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length * 2);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayFloatVec2.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Cartesian2.equalsArray(v, arraybuffer, j)) {\n Cartesian2.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 2;\n }\n\n if (changed) {\n this._gl.uniform2fv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayFloatVec3(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length * 3);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayFloatVec3.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (defined(v.red)) {\n if (\n v.red !== arraybuffer[j] ||\n v.green !== arraybuffer[j + 1] ||\n v.blue !== arraybuffer[j + 2]\n ) {\n arraybuffer[j] = v.red;\n arraybuffer[j + 1] = v.green;\n arraybuffer[j + 2] = v.blue;\n changed = true;\n }\n } else if (defined(v.x)) {\n if (!Cartesian3.equalsArray(v, arraybuffer, j)) {\n Cartesian3.pack(v, arraybuffer, j);\n changed = true;\n }\n } else {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\"Invalid vec3 value.\");\n //>>includeEnd('debug');\n }\n\n j += 3;\n }\n\n if (changed) {\n this._gl.uniform3fv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayFloatVec4(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length * 4);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayFloatVec4.prototype.set = function () {\n // PERFORMANCE_IDEA: if it is a common case that only a few elements\n // in a uniform array change, we could use heuristics to determine\n // when it is better to call uniform4f for each element that changed\n // vs. call uniform4fv once to set the entire array. This applies\n // to all uniform array types, not just vec4. We might not care\n // once we have uniform buffers since that will be the fast path.\n\n // PERFORMANCE_IDEA: Micro-optimization (I bet it works though):\n // As soon as changed is true, break into a separate loop that\n // does the copy without the equals check.\n\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (defined(v.red)) {\n if (!Color.equalsArray(v, arraybuffer, j)) {\n Color.pack(v, arraybuffer, j);\n changed = true;\n }\n } else if (defined(v.x)) {\n if (!Cartesian4.equalsArray(v, arraybuffer, j)) {\n Cartesian4.pack(v, arraybuffer, j);\n changed = true;\n }\n } else {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\"Invalid vec4 value.\");\n //>>includeEnd('debug');\n }\n\n j += 4;\n }\n\n if (changed) {\n this._gl.uniform4fv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArraySampler(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length);\n\n this._gl = gl;\n this._locations = locations;\n\n this.textureUnitIndex = undefined;\n}\n\nUniformArraySampler.prototype.set = function () {\n const gl = this._gl;\n const textureUnitIndex = gl.TEXTURE0 + this.textureUnitIndex;\n\n const value = this.value;\n const length = value.length;\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n gl.activeTexture(textureUnitIndex + i);\n gl.bindTexture(v._target, v._texture);\n }\n};\n\nUniformArraySampler.prototype._setSampler = function (textureUnitIndex) {\n this.textureUnitIndex = textureUnitIndex;\n\n const locations = this._locations;\n const length = locations.length;\n for (let i = 0; i < length; ++i) {\n const index = textureUnitIndex + i;\n this._gl.uniform1i(locations[i], index);\n }\n\n return textureUnitIndex + length;\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayInt(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Int32Array(length);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayInt.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (v !== arraybuffer[i]) {\n arraybuffer[i] = v;\n changed = true;\n }\n }\n\n if (changed) {\n this._gl.uniform1iv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayIntVec2(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Int32Array(length * 2);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayIntVec2.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Cartesian2.equalsArray(v, arraybuffer, j)) {\n Cartesian2.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 2;\n }\n\n if (changed) {\n this._gl.uniform2iv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayIntVec3(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Int32Array(length * 3);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayIntVec3.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Cartesian3.equalsArray(v, arraybuffer, j)) {\n Cartesian3.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 3;\n }\n\n if (changed) {\n this._gl.uniform3iv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayIntVec4(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Int32Array(length * 4);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayIntVec4.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Cartesian4.equalsArray(v, arraybuffer, j)) {\n Cartesian4.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 4;\n }\n\n if (changed) {\n this._gl.uniform4iv(this._location, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayMat2(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length * 4);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayMat2.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Matrix2.equalsArray(v, arraybuffer, j)) {\n Matrix2.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 4;\n }\n\n if (changed) {\n this._gl.uniformMatrix2fv(this._location, false, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayMat3(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length * 9);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayMat3.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Matrix3.equalsArray(v, arraybuffer, j)) {\n Matrix3.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 9;\n }\n\n if (changed) {\n this._gl.uniformMatrix3fv(this._location, false, arraybuffer);\n }\n};\n\n///////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n * @constructor\n */\nfunction UniformArrayMat4(gl, activeUniform, uniformName, locations) {\n const length = locations.length;\n\n /**\n * @type {string}\n * @readonly\n */\n this.name = uniformName;\n\n this.value = new Array(length);\n this._value = new Float32Array(length * 16);\n\n this._gl = gl;\n this._location = locations[0];\n}\n\nUniformArrayMat4.prototype.set = function () {\n const value = this.value;\n const length = value.length;\n const arraybuffer = this._value;\n let changed = false;\n let j = 0;\n\n for (let i = 0; i < length; ++i) {\n const v = value[i];\n\n if (!Matrix4.equalsArray(v, arraybuffer, j)) {\n Matrix4.pack(v, arraybuffer, j);\n changed = true;\n }\n j += 16;\n }\n\n if (changed) {\n this._gl.uniformMatrix4fv(this._location, false, arraybuffer);\n }\n};\nexport default createUniformArray;\n", "import Check from \"../Core/Check.js\";\nimport defaultValue from \"../Core/defaultValue.js\";\nimport defined from \"../Core/defined.js\";\nimport destroyObject from \"../Core/destroyObject.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport RuntimeError from \"../Core/RuntimeError.js\";\nimport AutomaticUniforms from \"./AutomaticUniforms.js\";\nimport ContextLimits from \"./ContextLimits.js\";\nimport createUniform from \"./createUniform.js\";\nimport createUniformArray from \"./createUniformArray.js\";\n\nlet nextShaderProgramId = 0;\n\n/**\n * @private\n */\nfunction ShaderProgram(options) {\n let vertexShaderText = options.vertexShaderText;\n let fragmentShaderText = options.fragmentShaderText;\n\n if (typeof spector !== \"undefined\") {\n // The #line statements common in Cesium shaders interfere with the ability of the\n // SpectorJS to show errors on the correct line. So remove them when SpectorJS\n // is active.\n vertexShaderText = vertexShaderText.replace(/^#line/gm, \"//#line\");\n fragmentShaderText = fragmentShaderText.replace(/^#line/gm, \"//#line\");\n }\n\n const modifiedFS = handleUniformPrecisionMismatches(\n vertexShaderText,\n fragmentShaderText\n );\n\n this._gl = options.gl;\n this._logShaderCompilation = options.logShaderCompilation;\n this._debugShaders = options.debugShaders;\n this._attributeLocations = options.attributeLocations;\n\n this._program = undefined;\n this._numberOfVertexAttributes = undefined;\n this._vertexAttributes = undefined;\n this._uniformsByName = undefined;\n this._uniforms = undefined;\n this._automaticUniforms = undefined;\n this._manualUniforms = undefined;\n this._duplicateUniformNames = modifiedFS.duplicateUniformNames;\n this._cachedShader = undefined; // Used by ShaderCache\n\n /**\n * @private\n */\n this.maximumTextureUnitIndex = undefined;\n\n this._vertexShaderSource = options.vertexShaderSource;\n this._vertexShaderText = options.vertexShaderText;\n this._fragmentShaderSource = options.fragmentShaderSource;\n this._fragmentShaderText = modifiedFS.fragmentShaderText;\n\n /**\n * @private\n */\n this.id = nextShaderProgramId++;\n}\n\nShaderProgram.fromCache = function (options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.context\", options.context);\n //>>includeEnd('debug');\n\n return options.context.shaderCache.getShaderProgram(options);\n};\n\nShaderProgram.replaceCache = function (options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.context\", options.context);\n //>>includeEnd('debug');\n\n return options.context.shaderCache.replaceShaderProgram(options);\n};\n\nObject.defineProperties(ShaderProgram.prototype, {\n /**\n * GLSL source for the shader program's vertex shader.\n * @memberof ShaderProgram.prototype\n *\n * @type {ShaderSource}\n * @readonly\n */\n vertexShaderSource: {\n get: function () {\n return this._vertexShaderSource;\n },\n },\n /**\n * GLSL source for the shader program's fragment shader.\n * @memberof ShaderProgram.prototype\n *\n * @type {ShaderSource}\n * @readonly\n */\n fragmentShaderSource: {\n get: function () {\n return this._fragmentShaderSource;\n },\n },\n vertexAttributes: {\n get: function () {\n initialize(this);\n return this._vertexAttributes;\n },\n },\n numberOfVertexAttributes: {\n get: function () {\n initialize(this);\n return this._numberOfVertexAttributes;\n },\n },\n allUniforms: {\n get: function () {\n initialize(this);\n return this._uniformsByName;\n },\n },\n});\n\nfunction extractUniforms(shaderText) {\n const uniformNames = [];\n const uniformLines = shaderText.match(/uniform.*?(?![^{]*})(?=[=\\[;])/g);\n if (defined(uniformLines)) {\n const len = uniformLines.length;\n for (let i = 0; i < len; i++) {\n const line = uniformLines[i].trim();\n const name = line.slice(line.lastIndexOf(\" \") + 1);\n uniformNames.push(name);\n }\n }\n return uniformNames;\n}\n\nfunction handleUniformPrecisionMismatches(\n vertexShaderText,\n fragmentShaderText\n) {\n // If a uniform exists in both the vertex and fragment shader but with different precision qualifiers,\n // give the fragment shader uniform a different name. This fixes shader compilation errors on devices\n // that only support mediump in the fragment shader.\n const duplicateUniformNames = {};\n\n if (!ContextLimits.highpFloatSupported || !ContextLimits.highpIntSupported) {\n let i, j;\n let uniformName;\n let duplicateName;\n const vertexShaderUniforms = extractUniforms(vertexShaderText);\n const fragmentShaderUniforms = extractUniforms(fragmentShaderText);\n const vertexUniformsCount = vertexShaderUniforms.length;\n const fragmentUniformsCount = fragmentShaderUniforms.length;\n\n for (i = 0; i < vertexUniformsCount; i++) {\n for (j = 0; j < fragmentUniformsCount; j++) {\n if (vertexShaderUniforms[i] === fragmentShaderUniforms[j]) {\n uniformName = vertexShaderUniforms[i];\n duplicateName = `czm_mediump_${uniformName}`;\n // Update fragmentShaderText with renamed uniforms\n const re = new RegExp(`${uniformName}\\\\b`, \"g\");\n fragmentShaderText = fragmentShaderText.replace(re, duplicateName);\n duplicateUniformNames[duplicateName] = uniformName;\n }\n }\n }\n }\n\n return {\n fragmentShaderText: fragmentShaderText,\n duplicateUniformNames: duplicateUniformNames,\n };\n}\n\nconst consolePrefix = \"[Cesium WebGL] \";\n\nfunction createAndLinkProgram(gl, shader) {\n const vsSource = shader._vertexShaderText;\n const fsSource = shader._fragmentShaderText;\n\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n gl.shaderSource(vertexShader, vsSource);\n gl.compileShader(vertexShader);\n\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n gl.shaderSource(fragmentShader, fsSource);\n gl.compileShader(fragmentShader);\n\n const program = gl.createProgram();\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n\n const attributeLocations = shader._attributeLocations;\n if (defined(attributeLocations)) {\n for (const attribute in attributeLocations) {\n if (attributeLocations.hasOwnProperty(attribute)) {\n gl.bindAttribLocation(\n program,\n attributeLocations[attribute],\n attribute\n );\n }\n }\n }\n\n gl.linkProgram(program);\n let log;\n\n // For performance: if linker succeeds, return without checking compile status\n if (gl.getProgramParameter(program, gl.LINK_STATUS)) {\n if (shader._logShaderCompilation) {\n log = gl.getShaderInfoLog(vertexShader);\n if (defined(log) && log.length > 0) {\n console.log(`${consolePrefix}Vertex shader compile log: ${log}`);\n }\n\n log = gl.getShaderInfoLog(fragmentShader);\n if (defined(log) && log.length > 0) {\n console.log(`${consolePrefix}Fragment shader compile log: ${log}`);\n }\n\n log = gl.getProgramInfoLog(program);\n if (defined(log) && log.length > 0) {\n console.log(`${consolePrefix}Shader program link log: ${log}`);\n }\n }\n\n gl.deleteShader(vertexShader);\n gl.deleteShader(fragmentShader);\n\n return program;\n }\n\n // Program failed to link. Try to find and report the reason\n let errorMessage;\n const debugShaders = shader._debugShaders;\n\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n log = gl.getShaderInfoLog(fragmentShader);\n console.error(`${consolePrefix}Fragment shader compile log: ${log}`);\n console.error(`${consolePrefix} Fragment shader source:\\n${fsSource}`);\n errorMessage = `Fragment shader failed to compile. Compile log: ${log}`;\n } else if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n log = gl.getShaderInfoLog(vertexShader);\n console.error(`${consolePrefix}Vertex shader compile log: ${log}`);\n console.error(`${consolePrefix} Vertex shader source:\\n${vsSource}`);\n errorMessage = `Vertex shader failed to compile. Compile log: ${log}`;\n } else {\n log = gl.getProgramInfoLog(program);\n console.error(`${consolePrefix}Shader program link log: ${log}`);\n logTranslatedSource(vertexShader, \"vertex\");\n logTranslatedSource(fragmentShader, \"fragment\");\n errorMessage = `Program failed to link. Link log: ${log}`;\n }\n\n gl.deleteShader(vertexShader);\n gl.deleteShader(fragmentShader);\n gl.deleteProgram(program);\n throw new RuntimeError(errorMessage);\n\n function logTranslatedSource(compiledShader, name) {\n if (!defined(debugShaders)) {\n return;\n }\n const translation = debugShaders.getTranslatedShaderSource(compiledShader);\n if (translation === \"\") {\n console.error(`${consolePrefix}${name} shader translation failed.`);\n return;\n }\n console.error(\n `${consolePrefix}Translated ${name} shaderSource:\\n${translation}`\n );\n }\n}\n\nfunction findVertexAttributes(gl, program, numberOfAttributes) {\n const attributes = {};\n for (let i = 0; i < numberOfAttributes; ++i) {\n const attr = gl.getActiveAttrib(program, i);\n const location = gl.getAttribLocation(program, attr.name);\n\n attributes[attr.name] = {\n name: attr.name,\n type: attr.type,\n index: location,\n };\n }\n\n return attributes;\n}\n\nfunction findUniforms(gl, program) {\n const uniformsByName = {};\n const uniforms = [];\n const samplerUniforms = [];\n\n const numberOfUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n for (let i = 0; i < numberOfUniforms; ++i) {\n const activeUniform = gl.getActiveUniform(program, i);\n const suffix = \"[0]\";\n const uniformName =\n activeUniform.name.indexOf(\n suffix,\n activeUniform.name.length - suffix.length\n ) !== -1\n ? activeUniform.name.slice(0, activeUniform.name.length - 3)\n : activeUniform.name;\n\n // Ignore GLSL built-in uniforms returned in Firefox.\n if (uniformName.indexOf(\"gl_\") !== 0) {\n if (activeUniform.name.indexOf(\"[\") < 0) {\n // Single uniform\n const location = gl.getUniformLocation(program, uniformName);\n\n // IE 11.0.9 needs this check since getUniformLocation can return null\n // if the uniform is not active (e.g., it is optimized out). Looks like\n // getActiveUniform() above returns uniforms that are not actually active.\n if (location !== null) {\n const uniform = createUniform(\n gl,\n activeUniform,\n uniformName,\n location\n );\n\n uniformsByName[uniformName] = uniform;\n uniforms.push(uniform);\n\n if (uniform._setSampler) {\n samplerUniforms.push(uniform);\n }\n }\n } else {\n // Uniform array\n\n let uniformArray;\n let locations;\n let value;\n let loc;\n\n // On some platforms - Nexus 4 in Firefox for one - an array of sampler2D ends up being represented\n // as separate uniforms, one for each array element. Check for and handle that case.\n const indexOfBracket = uniformName.indexOf(\"[\");\n if (indexOfBracket >= 0) {\n // We're assuming the array elements show up in numerical order - it seems to be true.\n uniformArray = uniformsByName[uniformName.slice(0, indexOfBracket)];\n\n // Nexus 4 with Android 4.3 needs this check, because it reports a uniform\n // with the strange name webgl_3467e0265d05c3c1[1] in our globe surface shader.\n if (!defined(uniformArray)) {\n continue;\n }\n\n locations = uniformArray._locations;\n\n // On the Nexus 4 in Chrome, we get one uniform per sampler, just like in Firefox,\n // but the size is not 1 like it is in Firefox. So if we push locations here,\n // we'll end up adding too many locations.\n if (locations.length <= 1) {\n value = uniformArray.value;\n loc = gl.getUniformLocation(program, uniformName);\n\n // Workaround for IE 11.0.9. See above.\n if (loc !== null) {\n locations.push(loc);\n value.push(gl.getUniform(program, loc));\n }\n }\n } else {\n locations = [];\n for (let j = 0; j < activeUniform.size; ++j) {\n loc = gl.getUniformLocation(program, `${uniformName}[${j}]`);\n\n // Workaround for IE 11.0.9. See above.\n if (loc !== null) {\n locations.push(loc);\n }\n }\n uniformArray = createUniformArray(\n gl,\n activeUniform,\n uniformName,\n locations\n );\n\n uniformsByName[uniformName] = uniformArray;\n uniforms.push(uniformArray);\n\n if (uniformArray._setSampler) {\n samplerUniforms.push(uniformArray);\n }\n }\n }\n }\n }\n\n return {\n uniformsByName: uniformsByName,\n uniforms: uniforms,\n samplerUniforms: samplerUniforms,\n };\n}\n\nfunction partitionUniforms(shader, uniforms) {\n const automaticUniforms = [];\n const manualUniforms = [];\n\n for (const uniform in uniforms) {\n if (uniforms.hasOwnProperty(uniform)) {\n const uniformObject = uniforms[uniform];\n let uniformName = uniform;\n // if it's a duplicate uniform, use its original name so it is updated correctly\n const duplicateUniform = shader._duplicateUniformNames[uniformName];\n if (defined(duplicateUniform)) {\n uniformObject.name = duplicateUniform;\n uniformName = duplicateUniform;\n }\n const automaticUniform = AutomaticUniforms[uniformName];\n if (defined(automaticUniform)) {\n automaticUniforms.push({\n uniform: uniformObject,\n automaticUniform: automaticUniform,\n });\n } else {\n manualUniforms.push(uniformObject);\n }\n }\n }\n\n return {\n automaticUniforms: automaticUniforms,\n manualUniforms: manualUniforms,\n };\n}\n\nfunction setSamplerUniforms(gl, program, samplerUniforms) {\n gl.useProgram(program);\n\n let textureUnitIndex = 0;\n const length = samplerUniforms.length;\n for (let i = 0; i < length; ++i) {\n textureUnitIndex = samplerUniforms[i]._setSampler(textureUnitIndex);\n }\n\n gl.useProgram(null);\n\n return textureUnitIndex;\n}\n\nfunction initialize(shader) {\n if (defined(shader._program)) {\n return;\n }\n\n reinitialize(shader);\n}\n\nfunction reinitialize(shader) {\n const oldProgram = shader._program;\n\n const gl = shader._gl;\n const program = createAndLinkProgram(gl, shader, shader._debugShaders);\n const numberOfVertexAttributes = gl.getProgramParameter(\n program,\n gl.ACTIVE_ATTRIBUTES\n );\n const uniforms = findUniforms(gl, program);\n const partitionedUniforms = partitionUniforms(\n shader,\n uniforms.uniformsByName\n );\n\n shader._program = program;\n shader._numberOfVertexAttributes = numberOfVertexAttributes;\n shader._vertexAttributes = findVertexAttributes(\n gl,\n program,\n numberOfVertexAttributes\n );\n shader._uniformsByName = uniforms.uniformsByName;\n shader._uniforms = uniforms.uniforms;\n shader._automaticUniforms = partitionedUniforms.automaticUniforms;\n shader._manualUniforms = partitionedUniforms.manualUniforms;\n\n shader.maximumTextureUnitIndex = setSamplerUniforms(\n gl,\n program,\n uniforms.samplerUniforms\n );\n\n if (oldProgram) {\n shader._gl.deleteProgram(oldProgram);\n }\n\n // If SpectorJS is active, add the hook to make the shader editor work.\n // https://github.com/BabylonJS/Spector.js/blob/master/documentation/extension.md#shader-editor\n if (typeof spector !== \"undefined\") {\n shader._program.__SPECTOR_rebuildProgram = function (\n vertexSourceCode, // The new vertex shader source\n fragmentSourceCode, // The new fragment shader source\n onCompiled, // Callback triggered by your engine when the compilation is successful. It needs to send back the new linked program.\n onError // Callback triggered by your engine in case of error. It needs to send the WebGL error to allow the editor to display the error in the gutter.\n ) {\n const originalVS = shader._vertexShaderText;\n const originalFS = shader._fragmentShaderText;\n\n // SpectorJS likes to replace `!=` with `! =` for unknown reasons,\n // and that causes glsl compile failures. So fix that up.\n const regex = / ! = /g;\n shader._vertexShaderText = vertexSourceCode.replace(regex, \" != \");\n shader._fragmentShaderText = fragmentSourceCode.replace(regex, \" != \");\n\n try {\n reinitialize(shader);\n onCompiled(shader._program);\n } catch (e) {\n shader._vertexShaderText = originalVS;\n shader._fragmentShaderText = originalFS;\n\n // Only pass on the WebGL error:\n const errorMatcher = /(?:Compile|Link) error: ([^]*)/;\n const match = errorMatcher.exec(e.message);\n if (match) {\n onError(match[1]);\n } else {\n onError(e.message);\n }\n }\n };\n }\n}\n\nShaderProgram.prototype._bind = function () {\n initialize(this);\n this._gl.useProgram(this._program);\n};\n\nShaderProgram.prototype._setUniforms = function (\n uniformMap,\n uniformState,\n validate\n) {\n let len;\n let i;\n\n if (defined(uniformMap)) {\n const manualUniforms = this._manualUniforms;\n len = manualUniforms.length;\n for (i = 0; i < len; ++i) {\n const mu = manualUniforms[i];\n mu.value = uniformMap[mu.name]();\n }\n }\n\n const automaticUniforms = this._automaticUniforms;\n len = automaticUniforms.length;\n for (i = 0; i < len; ++i) {\n const au = automaticUniforms[i];\n au.uniform.value = au.automaticUniform.getValue(uniformState);\n }\n\n ///////////////////////////////////////////////////////////////////\n\n // It appears that assigning the uniform values above and then setting them here\n // (which makes the GL calls) is faster than removing this loop and making\n // the GL calls above. I suspect this is because each GL call pollutes the\n // L2 cache making our JavaScript and the browser/driver ping-pong cache lines.\n const uniforms = this._uniforms;\n len = uniforms.length;\n for (i = 0; i < len; ++i) {\n uniforms[i].set();\n }\n\n if (validate) {\n const gl = this._gl;\n const program = this._program;\n\n gl.validateProgram(program);\n //>>includeStart('debug', pragmas.debug);\n if (!gl.getProgramParameter(program, gl.VALIDATE_STATUS)) {\n throw new DeveloperError(\n `Program validation failed. Program info log: ${gl.getProgramInfoLog(\n program\n )}`\n );\n }\n //>>includeEnd('debug');\n }\n};\n\nShaderProgram.prototype.isDestroyed = function () {\n return false;\n};\n\nShaderProgram.prototype.destroy = function () {\n this._cachedShader.cache.releaseShaderProgram(this);\n return undefined;\n};\n\nShaderProgram.prototype.finalDestroy = function () {\n this._gl.deleteProgram(this._program);\n return destroyObject(this);\n};\nexport default ShaderProgram;\n", "import BoundingRectangle from \"../Core/BoundingRectangle.js\";\nimport Check from \"../Core/Check.js\";\nimport Color from \"../Core/Color.js\";\nimport defined from \"../Core/defined.js\";\nimport destroyObject from \"../Core/destroyObject.js\";\nimport DeveloperError from \"../Core/DeveloperError.js\";\nimport PrimitiveType from \"../Core/PrimitiveType.js\";\nimport ViewportQuadVS from \"../Shaders/ViewportQuadVS.js\";\nimport ClearCommand from \"./ClearCommand.js\";\nimport DrawCommand from \"./DrawCommand.js\";\nimport Framebuffer from \"./Framebuffer.js\";\nimport RenderState from \"./RenderState.js\";\nimport ShaderProgram from \"./ShaderProgram.js\";\n\n/**\n * @private\n */\nfunction ComputeEngine(context) {\n this._context = context;\n}\n\nlet renderStateScratch;\nconst drawCommandScratch = new DrawCommand({\n primitiveType: PrimitiveType.TRIANGLES,\n});\nconst clearCommandScratch = new ClearCommand({\n color: new Color(0.0, 0.0, 0.0, 0.0),\n});\n\nfunction createFramebuffer(context, outputTexture) {\n return new Framebuffer({\n context: context,\n colorTextures: [outputTexture],\n destroyAttachments: false,\n });\n}\n\nfunction createViewportQuadShader(context, fragmentShaderSource) {\n return ShaderProgram.fromCache({\n context: context,\n vertexShaderSource: ViewportQuadVS,\n fragmentShaderSource: fragmentShaderSource,\n attributeLocations: {\n position: 0,\n textureCoordinates: 1,\n },\n });\n}\n\nfunction createRenderState(width, height) {\n if (\n !defined(renderStateScratch) ||\n renderStateScratch.viewport.width !== width ||\n renderStateScratch.viewport.height !== height\n ) {\n renderStateScratch = RenderState.fromCache({\n viewport: new BoundingRectangle(0, 0, width, height),\n });\n }\n return renderStateScratch;\n}\n\nComputeEngine.prototype.execute = function (computeCommand) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"computeCommand\", computeCommand);\n //>>includeEnd('debug');\n\n // This may modify the command's resources, so do error checking afterwards\n if (defined(computeCommand.preExecute)) {\n computeCommand.preExecute(computeCommand);\n }\n\n //>>includeStart('debug', pragmas.debug);\n if (\n !defined(computeCommand.fragmentShaderSource) &&\n !defined(computeCommand.shaderProgram)\n ) {\n throw new DeveloperError(\n \"computeCommand.fragmentShaderSource or computeCommand.shaderProgram is required.\"\n );\n }\n\n Check.defined(\"computeCommand.outputTexture\", computeCommand.outputTexture);\n //>>includeEnd('debug');\n\n const outputTexture = computeCommand.outputTexture;\n const width = outputTexture.width;\n const height = outputTexture.height;\n\n const context = this._context;\n const vertexArray = defined(computeCommand.vertexArray)\n ? computeCommand.vertexArray\n : context.getViewportQuadVertexArray();\n const shaderProgram = defined(computeCommand.shaderProgram)\n ? computeCommand.shaderProgram\n : createViewportQuadShader(context, computeCommand.fragmentShaderSource);\n const framebuffer = createFramebuffer(context, outputTexture);\n const renderState = createRenderState(width, height);\n const uniformMap = computeCommand.uniformMap;\n\n const clearCommand = clearCommandScratch;\n clearCommand.framebuffer = framebuffer;\n clearCommand.renderState = renderState;\n clearCommand.execute(context);\n\n const drawCommand = drawCommandScratch;\n drawCommand.vertexArray = vertexArray;\n drawCommand.renderState = renderState;\n drawCommand.shaderProgram = shaderProgram;\n drawCommand.uniformMap = uniformMap;\n drawCommand.framebuffer = framebuffer;\n drawCommand.execute(context);\n\n framebuffer.destroy();\n\n if (!computeCommand.persists) {\n shaderProgram.destroy();\n if (defined(computeCommand.vertexArray)) {\n vertexArray.destroy();\n }\n }\n\n if (defined(computeCommand.postExecute)) {\n computeCommand.postExecute(outputTexture);\n }\n};\n\nComputeEngine.prototype.isDestroyed = function () {\n return false;\n};\n\nComputeEngine.prototype.destroy = function () {\n return destroyObject(this);\n};\nexport default ComputeEngine;\n", "import defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport WebGLConstants from \"./WebGLConstants.js\";\n\n/**\n * WebGL component datatypes. Components are intrinsics,\n * which form attributes, which form vertices.\n *\n * @enum {number}\n */\nconst ComponentDatatype = {\n /**\n * 8-bit signed byte corresponding to gl.BYTE and the type\n * of an element in Int8Array.\n *\n * @type {number}\n * @constant\n */\n BYTE: WebGLConstants.BYTE,\n\n /**\n * 8-bit unsigned byte corresponding to UNSIGNED_BYTE and the type\n * of an element in Uint8Array.\n *\n * @type {number}\n * @constant\n */\n UNSIGNED_BYTE: WebGLConstants.UNSIGNED_BYTE,\n\n /**\n * 16-bit signed short corresponding to SHORT and the type\n * of an element in Int16Array.\n *\n * @type {number}\n * @constant\n */\n SHORT: WebGLConstants.SHORT,\n\n /**\n * 16-bit unsigned short corresponding to UNSIGNED_SHORT and the type\n * of an element in Uint16Array.\n *\n * @type {number}\n * @constant\n */\n UNSIGNED_SHORT: WebGLConstants.UNSIGNED_SHORT,\n\n /**\n * 32-bit signed int corresponding to INT and the type\n * of an element in Int32Array.\n *\n * @memberOf ComponentDatatype\n *\n * @type {number}\n * @constant\n */\n INT: WebGLConstants.INT,\n\n /**\n * 32-bit unsigned int corresponding to UNSIGNED_INT and the type\n * of an element in Uint32Array.\n *\n * @memberOf ComponentDatatype\n *\n * @type {number}\n * @constant\n */\n UNSIGNED_INT: WebGLConstants.UNSIGNED_INT,\n\n /**\n * 32-bit floating-point corresponding to FLOAT and the type\n * of an element in Float32Array.\n *\n * @type {number}\n * @constant\n */\n FLOAT: WebGLConstants.FLOAT,\n\n /**\n * 64-bit floating-point corresponding to gl.DOUBLE (in Desktop OpenGL;\n * this is not supported in WebGL, and is emulated in Cesium via {@link GeometryPipeline.encodeAttribute})\n * and the type of an element in Float64Array.\n *\n * @memberOf ComponentDatatype\n *\n * @type {number}\n * @constant\n * @default 0x140A\n */\n DOUBLE: WebGLConstants.DOUBLE,\n};\n\n/**\n * Returns the size, in bytes, of the corresponding datatype.\n *\n * @param {ComponentDatatype} componentDatatype The component datatype to get the size of.\n * @returns {number} The size in bytes.\n *\n * @exception {DeveloperError} componentDatatype is not a valid value.\n *\n * @example\n * // Returns Int8Array.BYTES_PER_ELEMENT\n * const size = Cesium.ComponentDatatype.getSizeInBytes(Cesium.ComponentDatatype.BYTE);\n */\nComponentDatatype.getSizeInBytes = function (componentDatatype) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(componentDatatype)) {\n throw new DeveloperError(\"value is required.\");\n }\n //>>includeEnd('debug');\n\n switch (componentDatatype) {\n case ComponentDatatype.BYTE:\n return Int8Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.UNSIGNED_BYTE:\n return Uint8Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.SHORT:\n return Int16Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.UNSIGNED_SHORT:\n return Uint16Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.INT:\n return Int32Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.UNSIGNED_INT:\n return Uint32Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.FLOAT:\n return Float32Array.BYTES_PER_ELEMENT;\n case ComponentDatatype.DOUBLE:\n return Float64Array.BYTES_PER_ELEMENT;\n //>>includeStart('debug', pragmas.debug);\n default:\n throw new DeveloperError(\"componentDatatype is not a valid value.\");\n //>>includeEnd('debug');\n }\n};\n\n/**\n * Gets the {@link ComponentDatatype} for the provided TypedArray instance.\n *\n * @param {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} array The typed array.\n * @returns {ComponentDatatype} The ComponentDatatype for the provided array, or undefined if the array is not a TypedArray.\n */\nComponentDatatype.fromTypedArray = function (array) {\n if (array instanceof Int8Array) {\n return ComponentDatatype.BYTE;\n }\n if (array instanceof Uint8Array) {\n return ComponentDatatype.UNSIGNED_BYTE;\n }\n if (array instanceof Int16Array) {\n return ComponentDatatype.SHORT;\n }\n if (array instanceof Uint16Array) {\n return ComponentDatatype.UNSIGNED_SHORT;\n }\n if (array instanceof Int32Array) {\n return ComponentDatatype.INT;\n }\n if (array instanceof Uint32Array) {\n return ComponentDatatype.UNSIGNED_INT;\n }\n if (array instanceof Float32Array) {\n return ComponentDatatype.FLOAT;\n }\n if (array instanceof Float64Array) {\n return ComponentDatatype.DOUBLE;\n }\n\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(\n \"array must be an Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, or Float64Array.\"\n );\n //>>includeEnd('debug');\n};\n\n/**\n * Validates that the provided component datatype is a valid {@link ComponentDatatype}\n *\n * @param {ComponentDatatype} componentDatatype The component datatype to validate.\n * @returns {boolean} true if the provided component datatype is a valid value; otherwise, false.\n *\n * @example\n * if (!Cesium.ComponentDatatype.validate(componentDatatype)) {\n * throw new Cesium.DeveloperError('componentDatatype must be a valid value.');\n * }\n */\nComponentDatatype.validate = function (componentDatatype) {\n return (\n defined(componentDatatype) &&\n (componentDatatype === ComponentDatatype.BYTE ||\n componentDatatype === ComponentDatatype.UNSIGNED_BYTE ||\n componentDatatype === ComponentDatatype.SHORT ||\n componentDatatype === ComponentDatatype.UNSIGNED_SHORT ||\n componentDatatype === ComponentDatatype.INT ||\n componentDatatype === ComponentDatatype.UNSIGNED_INT ||\n componentDatatype === ComponentDatatype.FLOAT ||\n componentDatatype === ComponentDatatype.DOUBLE)\n );\n};\n\n/**\n * Creates a typed array corresponding to component data type.\n *\n * @param {ComponentDatatype} componentDatatype The component data type.\n * @param {number|Array} valuesOrLength The length of the array to create or an array.\n * @returns {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} A typed array.\n *\n * @exception {DeveloperError} componentDatatype is not a valid value.\n *\n * @example\n * // creates a Float32Array with length of 100\n * const typedArray = Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, 100);\n */\nComponentDatatype.createTypedArray = function (\n componentDatatype,\n valuesOrLength\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(componentDatatype)) {\n throw new DeveloperError(\"componentDatatype is required.\");\n }\n if (!defined(valuesOrLength)) {\n throw new DeveloperError(\"valuesOrLength is required.\");\n }\n //>>includeEnd('debug');\n\n switch (componentDatatype) {\n case ComponentDatatype.BYTE:\n return new Int8Array(valuesOrLength);\n case ComponentDatatype.UNSIGNED_BYTE:\n return new Uint8Array(valuesOrLength);\n case ComponentDatatype.SHORT:\n return new Int16Array(valuesOrLength);\n case ComponentDatatype.UNSIGNED_SHORT:\n return new Uint16Array(valuesOrLength);\n case ComponentDatatype.INT:\n return new Int32Array(valuesOrLength);\n case ComponentDatatype.UNSIGNED_INT:\n return new Uint32Array(valuesOrLength);\n case ComponentDatatype.FLOAT:\n return new Float32Array(valuesOrLength);\n case ComponentDatatype.DOUBLE:\n return new Float64Array(valuesOrLength);\n //>>includeStart('debug', pragmas.debug);\n default:\n throw new DeveloperError(\"componentDatatype is not a valid value.\");\n //>>includeEnd('debug');\n }\n};\n\n/**\n * Creates a typed view of an array of bytes.\n *\n * @param {ComponentDatatype} componentDatatype The type of the view to create.\n * @param {ArrayBuffer} buffer The buffer storage to use for the view.\n * @param {number} [byteOffset] The offset, in bytes, to the first element in the view.\n * @param {number} [length] The number of elements in the view.\n * @returns {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} A typed array view of the buffer.\n *\n * @exception {DeveloperError} componentDatatype is not a valid value.\n */\nComponentDatatype.createArrayBufferView = function (\n componentDatatype,\n buffer,\n byteOffset,\n length\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(componentDatatype)) {\n throw new DeveloperError(\"componentDatatype is required.\");\n }\n if (!defined(buffer)) {\n throw new DeveloperError(\"buffer is required.\");\n }\n //>>includeEnd('debug');\n\n byteOffset = defaultValue(byteOffset, 0);\n length = defaultValue(\n length,\n (buffer.byteLength - byteOffset) /\n ComponentDatatype.getSizeInBytes(componentDatatype)\n );\n\n switch (componentDatatype) {\n case ComponentDatatype.BYTE:\n return new Int8Array(buffer, byteOffset, length);\n case ComponentDatatype.UNSIGNED_BYTE:\n return new Uint8Array(buffer, byteOffset, length);\n case ComponentDatatype.SHORT:\n return new Int16Array(buffer, byteOffset, length);\n case ComponentDatatype.UNSIGNED_SHORT:\n return new Uint16Array(buffer, byteOffset, length);\n case ComponentDatatype.INT:\n return new Int32Array(buffer, byteOffset, length);\n case ComponentDatatype.UNSIGNED_INT:\n return new Uint32Array(buffer, byteOffset, length);\n case ComponentDatatype.FLOAT:\n return new Float32Array(buffer, byteOffset, length);\n case ComponentDatatype.DOUBLE:\n return new Float64Array(buffer, byteOffset, length);\n //>>includeStart('debug', pragmas.debug);\n default:\n throw new DeveloperError(\"componentDatatype is not a valid value.\");\n //>>includeEnd('debug');\n }\n};\n\n/**\n * Get the ComponentDatatype from its name.\n *\n * @param {string} name The name of the ComponentDatatype.\n * @returns {ComponentDatatype} The ComponentDatatype.\n *\n * @exception {DeveloperError} name is not a valid value.\n */\nComponentDatatype.fromName = function (name) {\n switch (name) {\n case \"BYTE\":\n return ComponentDatatype.BYTE;\n case \"UNSIGNED_BYTE\":\n return ComponentDatatype.UNSIGNED_BYTE;\n case \"SHORT\":\n return ComponentDatatype.SHORT;\n case \"UNSIGNED_SHORT\":\n return ComponentDatatype.UNSIGNED_SHORT;\n case \"INT\":\n return ComponentDatatype.INT;\n case \"UNSIGNED_INT\":\n return ComponentDatatype.UNSIGNED_INT;\n case \"FLOAT\":\n return ComponentDatatype.FLOAT;\n case \"DOUBLE\":\n return ComponentDatatype.DOUBLE;\n //>>includeStart('debug', pragmas.debug);\n default:\n throw new DeveloperError(\"name is not a valid value.\");\n //>>includeEnd('debug');\n }\n};\nexport default Object.freeze(ComponentDatatype);\n", "import defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\nconst warnings = {};\n\n/**\n * Logs a one time message to the console. Use this function instead of\n * console.log directly since this does not log duplicate messages\n * unless it is called from multiple workers.\n *\n * @function oneTimeWarning\n *\n * @param {string} identifier The unique identifier for this warning.\n * @param {string} [message=identifier] The message to log to the console.\n *\n * @example\n * for(let i=0;i>includeStart('debug', pragmas.debug);\n if (!defined(identifier)) {\n throw new DeveloperError(\"identifier is required.\");\n }\n //>>includeEnd('debug');\n\n if (!defined(warnings[identifier])) {\n warnings[identifier] = true;\n console.warn(defaultValue(message, identifier));\n }\n}\n\noneTimeWarning.geometryOutlines =\n \"Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.\";\n\noneTimeWarning.geometryZIndex =\n \"Entity geometry with zIndex are unsupported when height or extrudedHeight are defined. zIndex will be ignored\";\n\noneTimeWarning.geometryHeightReference =\n \"Entity corridor, ellipse, polygon or rectangle with heightReference must also have a defined height. heightReference will be ignored\";\noneTimeWarning.geometryExtrudedHeightReference =\n \"Entity corridor, ellipse, polygon or rectangle with extrudedHeightReference must also have a defined extrudedHeight. extrudedHeightReference will be ignored\";\nexport default oneTimeWarning;\n", "import defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport oneTimeWarning from \"./oneTimeWarning.js\";\n\n/**\n * Logs a deprecation message to the console. Use this function instead of\n * console.log directly since this does not log duplicate messages\n * unless it is called from multiple workers.\n *\n * @function deprecationWarning\n *\n * @param {string} identifier The unique identifier for this deprecated API.\n * @param {string} message The message to log to the console.\n *\n * @example\n * // Deprecated function or class\n * function Foo() {\n * deprecationWarning('Foo', 'Foo was deprecated in Cesium 1.01. It will be removed in 1.03. Use newFoo instead.');\n * // ...\n * }\n *\n * // Deprecated function\n * Bar.prototype.func = function() {\n * deprecationWarning('Bar.func', 'Bar.func() was deprecated in Cesium 1.01. It will be removed in 1.03. Use Bar.newFunc() instead.');\n * // ...\n * };\n *\n * // Deprecated property\n * Object.defineProperties(Bar.prototype, {\n * prop : {\n * get : function() {\n * deprecationWarning('Bar.prop', 'Bar.prop was deprecated in Cesium 1.01. It will be removed in 1.03. Use Bar.newProp instead.');\n * // ...\n * },\n * set : function(value) {\n * deprecationWarning('Bar.prop', 'Bar.prop was deprecated in Cesium 1.01. It will be removed in 1.03. Use Bar.newProp instead.');\n * // ...\n * }\n * }\n * });\n *\n * @private\n */\nfunction deprecationWarning(identifier, message) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(identifier) || !defined(message)) {\n throw new DeveloperError(\"identifier and message are required.\");\n }\n //>>includeEnd('debug');\n\n oneTimeWarning(identifier, message);\n}\nexport default deprecationWarning;\n", "/**\n * @private\n */\nconst GeometryType = {\n NONE: 0,\n TRIANGLES: 1,\n LINES: 2,\n POLYLINES: 3,\n};\nexport default Object.freeze(GeometryType);\n", "import Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport FeatureDetection from \"./FeatureDetection.js\";\nimport CesiumMath from \"./Math.js\";\nimport Matrix3 from \"./Matrix3.js\";\n\n/**\n * A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.\n * @alias Quaternion\n * @constructor\n *\n * @param {number} [x=0.0] The X component.\n * @param {number} [y=0.0] The Y component.\n * @param {number} [z=0.0] The Z component.\n * @param {number} [w=0.0] The W component.\n *\n * @see PackableForInterpolation\n */\nfunction Quaternion(x, y, z, w) {\n /**\n * The X component.\n * @type {number}\n * @default 0.0\n */\n this.x = defaultValue(x, 0.0);\n\n /**\n * The Y component.\n * @type {number}\n * @default 0.0\n */\n this.y = defaultValue(y, 0.0);\n\n /**\n * The Z component.\n * @type {number}\n * @default 0.0\n */\n this.z = defaultValue(z, 0.0);\n\n /**\n * The W component.\n * @type {number}\n * @default 0.0\n */\n this.w = defaultValue(w, 0.0);\n}\n\nlet fromAxisAngleScratch = new Cartesian3();\n\n/**\n * Computes a quaternion representing a rotation around an axis.\n *\n * @param {Cartesian3} axis The axis of rotation.\n * @param {number} angle The angle in radians to rotate around the axis.\n * @param {Quaternion} [result] The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided.\n */\nQuaternion.fromAxisAngle = function (axis, angle, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"axis\", axis);\n Check.typeOf.number(\"angle\", angle);\n //>>includeEnd('debug');\n\n const halfAngle = angle / 2.0;\n const s = Math.sin(halfAngle);\n fromAxisAngleScratch = Cartesian3.normalize(axis, fromAxisAngleScratch);\n\n const x = fromAxisAngleScratch.x * s;\n const y = fromAxisAngleScratch.y * s;\n const z = fromAxisAngleScratch.z * s;\n const w = Math.cos(halfAngle);\n if (!defined(result)) {\n return new Quaternion(x, y, z, w);\n }\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\nconst fromRotationMatrixNext = [1, 2, 0];\nconst fromRotationMatrixQuat = new Array(3);\n/**\n * Computes a Quaternion from the provided Matrix3 instance.\n *\n * @param {Matrix3} matrix The rotation matrix.\n * @param {Quaternion} [result] The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided.\n *\n * @see Matrix3.fromQuaternion\n */\nQuaternion.fromRotationMatrix = function (matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"matrix\", matrix);\n //>>includeEnd('debug');\n\n let root;\n let x;\n let y;\n let z;\n let w;\n\n const m00 = matrix[Matrix3.COLUMN0ROW0];\n const m11 = matrix[Matrix3.COLUMN1ROW1];\n const m22 = matrix[Matrix3.COLUMN2ROW2];\n const trace = m00 + m11 + m22;\n\n if (trace > 0.0) {\n // |w| > 1/2, may as well choose w > 1/2\n root = Math.sqrt(trace + 1.0); // 2w\n w = 0.5 * root;\n root = 0.5 / root; // 1/(4w)\n\n x = (matrix[Matrix3.COLUMN1ROW2] - matrix[Matrix3.COLUMN2ROW1]) * root;\n y = (matrix[Matrix3.COLUMN2ROW0] - matrix[Matrix3.COLUMN0ROW2]) * root;\n z = (matrix[Matrix3.COLUMN0ROW1] - matrix[Matrix3.COLUMN1ROW0]) * root;\n } else {\n // |w| <= 1/2\n const next = fromRotationMatrixNext;\n\n let i = 0;\n if (m11 > m00) {\n i = 1;\n }\n if (m22 > m00 && m22 > m11) {\n i = 2;\n }\n const j = next[i];\n const k = next[j];\n\n root = Math.sqrt(\n matrix[Matrix3.getElementIndex(i, i)] -\n matrix[Matrix3.getElementIndex(j, j)] -\n matrix[Matrix3.getElementIndex(k, k)] +\n 1.0\n );\n\n const quat = fromRotationMatrixQuat;\n quat[i] = 0.5 * root;\n root = 0.5 / root;\n w =\n (matrix[Matrix3.getElementIndex(k, j)] -\n matrix[Matrix3.getElementIndex(j, k)]) *\n root;\n quat[j] =\n (matrix[Matrix3.getElementIndex(j, i)] +\n matrix[Matrix3.getElementIndex(i, j)]) *\n root;\n quat[k] =\n (matrix[Matrix3.getElementIndex(k, i)] +\n matrix[Matrix3.getElementIndex(i, k)]) *\n root;\n\n x = -quat[0];\n y = -quat[1];\n z = -quat[2];\n }\n\n if (!defined(result)) {\n return new Quaternion(x, y, z, w);\n }\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\nconst scratchHPRQuaternion = new Quaternion();\nlet scratchHeadingQuaternion = new Quaternion();\nlet scratchPitchQuaternion = new Quaternion();\nlet scratchRollQuaternion = new Quaternion();\n\n/**\n * Computes a rotation from the given heading, pitch and roll angles. Heading is the rotation about the\n * negative z axis. Pitch is the rotation about the negative y axis. Roll is the rotation about\n * the positive x axis.\n *\n * @param {HeadingPitchRoll} headingPitchRoll The rotation expressed as a heading, pitch and roll.\n * @param {Quaternion} [result] The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if none was provided.\n */\nQuaternion.fromHeadingPitchRoll = function (headingPitchRoll, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"headingPitchRoll\", headingPitchRoll);\n //>>includeEnd('debug');\n\n scratchRollQuaternion = Quaternion.fromAxisAngle(\n Cartesian3.UNIT_X,\n headingPitchRoll.roll,\n scratchHPRQuaternion\n );\n scratchPitchQuaternion = Quaternion.fromAxisAngle(\n Cartesian3.UNIT_Y,\n -headingPitchRoll.pitch,\n result\n );\n result = Quaternion.multiply(\n scratchPitchQuaternion,\n scratchRollQuaternion,\n scratchPitchQuaternion\n );\n scratchHeadingQuaternion = Quaternion.fromAxisAngle(\n Cartesian3.UNIT_Z,\n -headingPitchRoll.heading,\n scratchHPRQuaternion\n );\n return Quaternion.multiply(scratchHeadingQuaternion, result, result);\n};\n\nconst sampledQuaternionAxis = new Cartesian3();\nconst sampledQuaternionRotation = new Cartesian3();\nconst sampledQuaternionTempQuaternion = new Quaternion();\nconst sampledQuaternionQuaternion0 = new Quaternion();\nconst sampledQuaternionQuaternion0Conjugate = new Quaternion();\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {number}\n */\nQuaternion.packedLength = 4;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {Quaternion} value The value to pack.\n * @param {number[]} array The array to pack into.\n * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {number[]} The array that was packed into\n */\nQuaternion.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n array[startingIndex++] = value.x;\n array[startingIndex++] = value.y;\n array[startingIndex++] = value.z;\n array[startingIndex] = value.w;\n\n return array;\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {number[]} array The packed array.\n * @param {number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {Quaternion} [result] The object into which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided.\n */\nQuaternion.unpack = function (array, startingIndex, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n if (!defined(result)) {\n result = new Quaternion();\n }\n result.x = array[startingIndex];\n result.y = array[startingIndex + 1];\n result.z = array[startingIndex + 2];\n result.w = array[startingIndex + 3];\n return result;\n};\n\n/**\n * The number of elements used to store the object into an array in its interpolatable form.\n * @type {number}\n */\nQuaternion.packedInterpolationLength = 3;\n\n/**\n * Converts a packed array into a form suitable for interpolation.\n *\n * @param {number[]} packedArray The packed array.\n * @param {number} [startingIndex=0] The index of the first element to be converted.\n * @param {number} [lastIndex=packedArray.length] The index of the last element to be converted.\n * @param {number[]} [result] The object into which to store the result.\n */\nQuaternion.convertPackedArrayForInterpolation = function (\n packedArray,\n startingIndex,\n lastIndex,\n result\n) {\n Quaternion.unpack(\n packedArray,\n lastIndex * 4,\n sampledQuaternionQuaternion0Conjugate\n );\n Quaternion.conjugate(\n sampledQuaternionQuaternion0Conjugate,\n sampledQuaternionQuaternion0Conjugate\n );\n\n for (let i = 0, len = lastIndex - startingIndex + 1; i < len; i++) {\n const offset = i * 3;\n Quaternion.unpack(\n packedArray,\n (startingIndex + i) * 4,\n sampledQuaternionTempQuaternion\n );\n\n Quaternion.multiply(\n sampledQuaternionTempQuaternion,\n sampledQuaternionQuaternion0Conjugate,\n sampledQuaternionTempQuaternion\n );\n\n if (sampledQuaternionTempQuaternion.w < 0) {\n Quaternion.negate(\n sampledQuaternionTempQuaternion,\n sampledQuaternionTempQuaternion\n );\n }\n\n Quaternion.computeAxis(\n sampledQuaternionTempQuaternion,\n sampledQuaternionAxis\n );\n const angle = Quaternion.computeAngle(sampledQuaternionTempQuaternion);\n if (!defined(result)) {\n result = [];\n }\n result[offset] = sampledQuaternionAxis.x * angle;\n result[offset + 1] = sampledQuaternionAxis.y * angle;\n result[offset + 2] = sampledQuaternionAxis.z * angle;\n }\n};\n\n/**\n * Retrieves an instance from a packed array converted with {@link convertPackedArrayForInterpolation}.\n *\n * @param {number[]} array The array previously packed for interpolation.\n * @param {number[]} sourceArray The original packed array.\n * @param {number} [firstIndex=0] The firstIndex used to convert the array.\n * @param {number} [lastIndex=packedArray.length] The lastIndex used to convert the array.\n * @param {Quaternion} [result] The object into which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided.\n */\nQuaternion.unpackInterpolationResult = function (\n array,\n sourceArray,\n firstIndex,\n lastIndex,\n result\n) {\n if (!defined(result)) {\n result = new Quaternion();\n }\n Cartesian3.fromArray(array, 0, sampledQuaternionRotation);\n const magnitude = Cartesian3.magnitude(sampledQuaternionRotation);\n\n Quaternion.unpack(sourceArray, lastIndex * 4, sampledQuaternionQuaternion0);\n\n if (magnitude === 0) {\n Quaternion.clone(Quaternion.IDENTITY, sampledQuaternionTempQuaternion);\n } else {\n Quaternion.fromAxisAngle(\n sampledQuaternionRotation,\n magnitude,\n sampledQuaternionTempQuaternion\n );\n }\n\n return Quaternion.multiply(\n sampledQuaternionTempQuaternion,\n sampledQuaternionQuaternion0,\n result\n );\n};\n\n/**\n * Duplicates a Quaternion instance.\n *\n * @param {Quaternion} quaternion The quaternion to duplicate.\n * @param {Quaternion} [result] The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided. (Returns undefined if quaternion is undefined)\n */\nQuaternion.clone = function (quaternion, result) {\n if (!defined(quaternion)) {\n return undefined;\n }\n\n if (!defined(result)) {\n return new Quaternion(\n quaternion.x,\n quaternion.y,\n quaternion.z,\n quaternion.w\n );\n }\n\n result.x = quaternion.x;\n result.y = quaternion.y;\n result.z = quaternion.z;\n result.w = quaternion.w;\n return result;\n};\n\n/**\n * Computes the conjugate of the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to conjugate.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.conjugate = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = -quaternion.x;\n result.y = -quaternion.y;\n result.z = -quaternion.z;\n result.w = quaternion.w;\n return result;\n};\n\n/**\n * Computes magnitude squared for the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to conjugate.\n * @returns {number} The magnitude squared.\n */\nQuaternion.magnitudeSquared = function (quaternion) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n //>>includeEnd('debug');\n\n return (\n quaternion.x * quaternion.x +\n quaternion.y * quaternion.y +\n quaternion.z * quaternion.z +\n quaternion.w * quaternion.w\n );\n};\n\n/**\n * Computes magnitude for the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to conjugate.\n * @returns {number} The magnitude.\n */\nQuaternion.magnitude = function (quaternion) {\n return Math.sqrt(Quaternion.magnitudeSquared(quaternion));\n};\n\n/**\n * Computes the normalized form of the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to normalize.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.normalize = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const inverseMagnitude = 1.0 / Quaternion.magnitude(quaternion);\n const x = quaternion.x * inverseMagnitude;\n const y = quaternion.y * inverseMagnitude;\n const z = quaternion.z * inverseMagnitude;\n const w = quaternion.w * inverseMagnitude;\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\n/**\n * Computes the inverse of the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to normalize.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.inverse = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const magnitudeSquared = Quaternion.magnitudeSquared(quaternion);\n result = Quaternion.conjugate(quaternion, result);\n return Quaternion.multiplyByScalar(result, 1.0 / magnitudeSquared, result);\n};\n\n/**\n * Computes the componentwise sum of two quaternions.\n *\n * @param {Quaternion} left The first quaternion.\n * @param {Quaternion} right The second quaternion.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.add = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x + right.x;\n result.y = left.y + right.y;\n result.z = left.z + right.z;\n result.w = left.w + right.w;\n return result;\n};\n\n/**\n * Computes the componentwise difference of two quaternions.\n *\n * @param {Quaternion} left The first quaternion.\n * @param {Quaternion} right The second quaternion.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.subtract = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = left.x - right.x;\n result.y = left.y - right.y;\n result.z = left.z - right.z;\n result.w = left.w - right.w;\n return result;\n};\n\n/**\n * Negates the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to be negated.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.negate = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = -quaternion.x;\n result.y = -quaternion.y;\n result.z = -quaternion.z;\n result.w = -quaternion.w;\n return result;\n};\n\n/**\n * Computes the dot (scalar) product of two quaternions.\n *\n * @param {Quaternion} left The first quaternion.\n * @param {Quaternion} right The second quaternion.\n * @returns {number} The dot product.\n */\nQuaternion.dot = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n //>>includeEnd('debug');\n\n return (\n left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w\n );\n};\n\n/**\n * Computes the product of two quaternions.\n *\n * @param {Quaternion} left The first quaternion.\n * @param {Quaternion} right The second quaternion.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.multiply = function (left, right, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"left\", left);\n Check.typeOf.object(\"right\", right);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const leftX = left.x;\n const leftY = left.y;\n const leftZ = left.z;\n const leftW = left.w;\n\n const rightX = right.x;\n const rightY = right.y;\n const rightZ = right.z;\n const rightW = right.w;\n\n const x = leftW * rightX + leftX * rightW + leftY * rightZ - leftZ * rightY;\n const y = leftW * rightY - leftX * rightZ + leftY * rightW + leftZ * rightX;\n const z = leftW * rightZ + leftX * rightY - leftY * rightX + leftZ * rightW;\n const w = leftW * rightW - leftX * rightX - leftY * rightY - leftZ * rightZ;\n\n result.x = x;\n result.y = y;\n result.z = z;\n result.w = w;\n return result;\n};\n\n/**\n * Multiplies the provided quaternion componentwise by the provided scalar.\n *\n * @param {Quaternion} quaternion The quaternion to be scaled.\n * @param {number} scalar The scalar to multiply with.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.multiplyByScalar = function (quaternion, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = quaternion.x * scalar;\n result.y = quaternion.y * scalar;\n result.z = quaternion.z * scalar;\n result.w = quaternion.w * scalar;\n return result;\n};\n\n/**\n * Divides the provided quaternion componentwise by the provided scalar.\n *\n * @param {Quaternion} quaternion The quaternion to be divided.\n * @param {number} scalar The scalar to divide by.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.divideByScalar = function (quaternion, scalar, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n Check.typeOf.number(\"scalar\", scalar);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n result.x = quaternion.x / scalar;\n result.y = quaternion.y / scalar;\n result.z = quaternion.z / scalar;\n result.w = quaternion.w / scalar;\n return result;\n};\n\n/**\n * Computes the axis of rotation of the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to use.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nQuaternion.computeAxis = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const w = quaternion.w;\n if (Math.abs(w - 1.0) < CesiumMath.EPSILON6) {\n result.x = result.y = result.z = 0;\n return result;\n }\n\n const scalar = 1.0 / Math.sqrt(1.0 - w * w);\n\n result.x = quaternion.x * scalar;\n result.y = quaternion.y * scalar;\n result.z = quaternion.z * scalar;\n return result;\n};\n\n/**\n * Computes the angle of rotation of the provided quaternion.\n *\n * @param {Quaternion} quaternion The quaternion to use.\n * @returns {number} The angle of rotation.\n */\nQuaternion.computeAngle = function (quaternion) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n //>>includeEnd('debug');\n\n if (Math.abs(quaternion.w - 1.0) < CesiumMath.EPSILON6) {\n return 0.0;\n }\n return 2.0 * Math.acos(quaternion.w);\n};\n\nlet lerpScratch = new Quaternion();\n/**\n * Computes the linear interpolation or extrapolation at t using the provided quaternions.\n *\n * @param {Quaternion} start The value corresponding to t at 0.0.\n * @param {Quaternion} end The value corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.lerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n lerpScratch = Quaternion.multiplyByScalar(end, t, lerpScratch);\n result = Quaternion.multiplyByScalar(start, 1.0 - t, result);\n return Quaternion.add(lerpScratch, result, result);\n};\n\nlet slerpEndNegated = new Quaternion();\nlet slerpScaledP = new Quaternion();\nlet slerpScaledR = new Quaternion();\n/**\n * Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.\n *\n * @param {Quaternion} start The value corresponding to t at 0.0.\n * @param {Quaternion} end The value corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n *\n * @see Quaternion#fastSlerp\n */\nQuaternion.slerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n let dot = Quaternion.dot(start, end);\n\n // The angle between start must be acute. Since q and -q represent\n // the same rotation, negate q to get the acute angle.\n let r = end;\n if (dot < 0.0) {\n dot = -dot;\n r = slerpEndNegated = Quaternion.negate(end, slerpEndNegated);\n }\n\n // dot > 0, as the dot product approaches 1, the angle between the\n // quaternions vanishes. use linear interpolation.\n if (1.0 - dot < CesiumMath.EPSILON6) {\n return Quaternion.lerp(start, r, t, result);\n }\n\n const theta = Math.acos(dot);\n slerpScaledP = Quaternion.multiplyByScalar(\n start,\n Math.sin((1 - t) * theta),\n slerpScaledP\n );\n slerpScaledR = Quaternion.multiplyByScalar(\n r,\n Math.sin(t * theta),\n slerpScaledR\n );\n result = Quaternion.add(slerpScaledP, slerpScaledR, result);\n return Quaternion.multiplyByScalar(result, 1.0 / Math.sin(theta), result);\n};\n\n/**\n * The logarithmic quaternion function.\n *\n * @param {Quaternion} quaternion The unit quaternion.\n * @param {Cartesian3} result The object onto which to store the result.\n * @returns {Cartesian3} The modified result parameter.\n */\nQuaternion.log = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"quaternion\", quaternion);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const theta = CesiumMath.acosClamped(quaternion.w);\n let thetaOverSinTheta = 0.0;\n\n if (theta !== 0.0) {\n thetaOverSinTheta = theta / Math.sin(theta);\n }\n\n return Cartesian3.multiplyByScalar(quaternion, thetaOverSinTheta, result);\n};\n\n/**\n * The exponential quaternion function.\n *\n * @param {Cartesian3} cartesian The cartesian.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n */\nQuaternion.exp = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const theta = Cartesian3.magnitude(cartesian);\n let sinThetaOverTheta = 0.0;\n\n if (theta !== 0.0) {\n sinThetaOverTheta = Math.sin(theta) / theta;\n }\n\n result.x = cartesian.x * sinThetaOverTheta;\n result.y = cartesian.y * sinThetaOverTheta;\n result.z = cartesian.z * sinThetaOverTheta;\n result.w = Math.cos(theta);\n\n return result;\n};\n\nconst squadScratchCartesian0 = new Cartesian3();\nconst squadScratchCartesian1 = new Cartesian3();\nconst squadScratchQuaternion0 = new Quaternion();\nconst squadScratchQuaternion1 = new Quaternion();\n\n/**\n * Computes an inner quadrangle point.\n *
This will compute quaternions that ensure a squad curve is C1.
\n *\n * @param {Quaternion} q0 The first quaternion.\n * @param {Quaternion} q1 The second quaternion.\n * @param {Quaternion} q2 The third quaternion.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n *\n * @see Quaternion#squad\n */\nQuaternion.computeInnerQuadrangle = function (q0, q1, q2, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"q0\", q0);\n Check.typeOf.object(\"q1\", q1);\n Check.typeOf.object(\"q2\", q2);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const qInv = Quaternion.conjugate(q1, squadScratchQuaternion0);\n Quaternion.multiply(qInv, q2, squadScratchQuaternion1);\n const cart0 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian0);\n\n Quaternion.multiply(qInv, q0, squadScratchQuaternion1);\n const cart1 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian1);\n\n Cartesian3.add(cart0, cart1, cart0);\n Cartesian3.multiplyByScalar(cart0, 0.25, cart0);\n Cartesian3.negate(cart0, cart0);\n Quaternion.exp(cart0, squadScratchQuaternion0);\n\n return Quaternion.multiply(q1, squadScratchQuaternion0, result);\n};\n\n/**\n * Computes the spherical quadrangle interpolation between quaternions.\n *\n * @param {Quaternion} q0 The first quaternion.\n * @param {Quaternion} q1 The second quaternion.\n * @param {Quaternion} s0 The first inner quadrangle.\n * @param {Quaternion} s1 The second inner quadrangle.\n * @param {number} t The time in [0,1] used to interpolate.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n *\n *\n * @example\n * // 1. compute the squad interpolation between two quaternions on a curve\n * const s0 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[i - 1], quaternions[i], quaternions[i + 1], new Cesium.Quaternion());\n * const s1 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[i], quaternions[i + 1], quaternions[i + 2], new Cesium.Quaternion());\n * const q = Cesium.Quaternion.squad(quaternions[i], quaternions[i + 1], s0, s1, t, new Cesium.Quaternion());\n *\n * // 2. compute the squad interpolation as above but where the first quaternion is a end point.\n * const s1 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[0], quaternions[1], quaternions[2], new Cesium.Quaternion());\n * const q = Cesium.Quaternion.squad(quaternions[0], quaternions[1], quaternions[0], s1, t, new Cesium.Quaternion());\n *\n * @see Quaternion#computeInnerQuadrangle\n */\nQuaternion.squad = function (q0, q1, s0, s1, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"q0\", q0);\n Check.typeOf.object(\"q1\", q1);\n Check.typeOf.object(\"s0\", s0);\n Check.typeOf.object(\"s1\", s1);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const slerp0 = Quaternion.slerp(q0, q1, t, squadScratchQuaternion0);\n const slerp1 = Quaternion.slerp(s0, s1, t, squadScratchQuaternion1);\n return Quaternion.slerp(slerp0, slerp1, 2.0 * t * (1.0 - t), result);\n};\n\nconst fastSlerpScratchQuaternion = new Quaternion();\n// eslint-disable-next-line no-loss-of-precision\nconst opmu = 1.90110745351730037;\nconst u = FeatureDetection.supportsTypedArrays() ? new Float32Array(8) : [];\nconst v = FeatureDetection.supportsTypedArrays() ? new Float32Array(8) : [];\nconst bT = FeatureDetection.supportsTypedArrays() ? new Float32Array(8) : [];\nconst bD = FeatureDetection.supportsTypedArrays() ? new Float32Array(8) : [];\n\nfor (let i = 0; i < 7; ++i) {\n const s = i + 1.0;\n const t = 2.0 * s + 1.0;\n u[i] = 1.0 / (s * t);\n v[i] = s / t;\n}\n\nu[7] = opmu / (8.0 * 17.0);\nv[7] = (opmu * 8.0) / 17.0;\n\n/**\n * Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.\n * This implementation is faster than {@link Quaternion#slerp}, but is only accurate up to 10-6.\n *\n * @param {Quaternion} start The value corresponding to t at 0.0.\n * @param {Quaternion} end The value corresponding to t at 1.0.\n * @param {number} t The point along t at which to interpolate.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter.\n *\n * @see Quaternion#slerp\n */\nQuaternion.fastSlerp = function (start, end, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"start\", start);\n Check.typeOf.object(\"end\", end);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n let x = Quaternion.dot(start, end);\n\n let sign;\n if (x >= 0) {\n sign = 1.0;\n } else {\n sign = -1.0;\n x = -x;\n }\n\n const xm1 = x - 1.0;\n const d = 1.0 - t;\n const sqrT = t * t;\n const sqrD = d * d;\n\n for (let i = 7; i >= 0; --i) {\n bT[i] = (u[i] * sqrT - v[i]) * xm1;\n bD[i] = (u[i] * sqrD - v[i]) * xm1;\n }\n\n const cT =\n sign *\n t *\n (1.0 +\n bT[0] *\n (1.0 +\n bT[1] *\n (1.0 +\n bT[2] *\n (1.0 +\n bT[3] *\n (1.0 +\n bT[4] *\n (1.0 + bT[5] * (1.0 + bT[6] * (1.0 + bT[7]))))))));\n const cD =\n d *\n (1.0 +\n bD[0] *\n (1.0 +\n bD[1] *\n (1.0 +\n bD[2] *\n (1.0 +\n bD[3] *\n (1.0 +\n bD[4] *\n (1.0 + bD[5] * (1.0 + bD[6] * (1.0 + bD[7]))))))));\n\n const temp = Quaternion.multiplyByScalar(\n start,\n cD,\n fastSlerpScratchQuaternion\n );\n Quaternion.multiplyByScalar(end, cT, result);\n return Quaternion.add(temp, result, result);\n};\n\n/**\n * Computes the spherical quadrangle interpolation between quaternions.\n * An implementation that is faster than {@link Quaternion#squad}, but less accurate.\n *\n * @param {Quaternion} q0 The first quaternion.\n * @param {Quaternion} q1 The second quaternion.\n * @param {Quaternion} s0 The first inner quadrangle.\n * @param {Quaternion} s1 The second inner quadrangle.\n * @param {number} t The time in [0,1] used to interpolate.\n * @param {Quaternion} result The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new instance if none was provided.\n *\n * @see Quaternion#squad\n */\nQuaternion.fastSquad = function (q0, q1, s0, s1, t, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"q0\", q0);\n Check.typeOf.object(\"q1\", q1);\n Check.typeOf.object(\"s0\", s0);\n Check.typeOf.object(\"s1\", s1);\n Check.typeOf.number(\"t\", t);\n Check.typeOf.object(\"result\", result);\n //>>includeEnd('debug');\n\n const slerp0 = Quaternion.fastSlerp(q0, q1, t, squadScratchQuaternion0);\n const slerp1 = Quaternion.fastSlerp(s0, s1, t, squadScratchQuaternion1);\n return Quaternion.fastSlerp(slerp0, slerp1, 2.0 * t * (1.0 - t), result);\n};\n\n/**\n * Compares the provided quaternions componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Quaternion} [left] The first quaternion.\n * @param {Quaternion} [right] The second quaternion.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nQuaternion.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.x === right.x &&\n left.y === right.y &&\n left.z === right.z &&\n left.w === right.w)\n );\n};\n\n/**\n * Compares the provided quaternions componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Quaternion} [left] The first quaternion.\n * @param {Quaternion} [right] The second quaternion.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nQuaternion.equalsEpsilon = function (left, right, epsilon) {\n epsilon = defaultValue(epsilon, 0);\n\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(left.x - right.x) <= epsilon &&\n Math.abs(left.y - right.y) <= epsilon &&\n Math.abs(left.z - right.z) <= epsilon &&\n Math.abs(left.w - right.w) <= epsilon)\n );\n};\n\n/**\n * An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 0.0).\n *\n * @type {Quaternion}\n * @constant\n */\nQuaternion.ZERO = Object.freeze(new Quaternion(0.0, 0.0, 0.0, 0.0));\n\n/**\n * An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 1.0).\n *\n * @type {Quaternion}\n * @constant\n */\nQuaternion.IDENTITY = Object.freeze(new Quaternion(0.0, 0.0, 0.0, 1.0));\n\n/**\n * Duplicates this Quaternion instance.\n *\n * @param {Quaternion} [result] The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided.\n */\nQuaternion.prototype.clone = function (result) {\n return Quaternion.clone(this, result);\n};\n\n/**\n * Compares this and the provided quaternion componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {Quaternion} [right] The right hand side quaternion.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nQuaternion.prototype.equals = function (right) {\n return Quaternion.equals(this, right);\n};\n\n/**\n * Compares this and the provided quaternion componentwise and returns\n * true if they are within the provided epsilon,\n * false otherwise.\n *\n * @param {Quaternion} [right] The right hand side quaternion.\n * @param {number} [epsilon=0] The epsilon to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nQuaternion.prototype.equalsEpsilon = function (right, epsilon) {\n return Quaternion.equalsEpsilon(this, right, epsilon);\n};\n\n/**\n * Returns a string representing this quaternion in the format (x, y, z, w).\n *\n * @returns {string} A string representing this Quaternion.\n */\nQuaternion.prototype.toString = function () {\n return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;\n};\nexport default Quaternion;\n", "import Check from \"./Check.js\";\n\n/**\n * Finds an item in a sorted array.\n *\n * @function\n * @param {Array} array The sorted array to search.\n * @param {*} itemToFind The item to find in the array.\n * @param {binarySearchComparator} comparator The function to use to compare the item to\n * elements in the array.\n * @returns {number} The index of itemToFind in the array, if it exists. If itemToFind\n * does not exist, the return value is a negative number which is the bitwise complement (~)\n * of the index before which the itemToFind should be inserted in order to maintain the\n * sorted order of the array.\n *\n * @example\n * // Create a comparator function to search through an array of numbers.\n * function comparator(a, b) {\n * return a - b;\n * };\n * const numbers = [0, 2, 4, 6, 8];\n * const index = Cesium.binarySearch(numbers, 6, comparator); // 3\n */\nfunction binarySearch(array, itemToFind, comparator) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n Check.defined(\"itemToFind\", itemToFind);\n Check.defined(\"comparator\", comparator);\n //>>includeEnd('debug');\n\n let low = 0;\n let high = array.length - 1;\n let i;\n let comparison;\n\n while (low <= high) {\n i = ~~((low + high) / 2);\n comparison = comparator(array[i], itemToFind);\n if (comparison < 0) {\n low = i + 1;\n continue;\n }\n if (comparison > 0) {\n high = i - 1;\n continue;\n }\n return i;\n }\n return ~(high + 1);\n}\n\n/**\n * A function used to compare two items while performing a binary search.\n * @callback binarySearchComparator\n *\n * @param {*} a An item in the array.\n * @param {*} b The item being searched for.\n * @returns {number} Returns a negative value if a is less than b,\n * a positive value if a is greater than b, or\n * 0 if a is equal to b.\n *\n * @example\n * function compareNumbers(a, b) {\n * return a - b;\n * }\n */\nexport default binarySearch;\n", "/**\n * A set of Earth Orientation Parameters (EOP) sampled at a time.\n *\n * @alias EarthOrientationParametersSample\n * @constructor\n *\n * @param {number} xPoleWander The pole wander about the X axis, in radians.\n * @param {number} yPoleWander The pole wander about the Y axis, in radians.\n * @param {number} xPoleOffset The offset to the Celestial Intermediate Pole (CIP) about the X axis, in radians.\n * @param {number} yPoleOffset The offset to the Celestial Intermediate Pole (CIP) about the Y axis, in radians.\n * @param {number} ut1MinusUtc The difference in time standards, UT1 - UTC, in seconds.\n *\n * @private\n */\nfunction EarthOrientationParametersSample(\n xPoleWander,\n yPoleWander,\n xPoleOffset,\n yPoleOffset,\n ut1MinusUtc\n) {\n /**\n * The pole wander about the X axis, in radians.\n * @type {number}\n */\n this.xPoleWander = xPoleWander;\n\n /**\n * The pole wander about the Y axis, in radians.\n * @type {number}\n */\n this.yPoleWander = yPoleWander;\n\n /**\n * The offset to the Celestial Intermediate Pole (CIP) about the X axis, in radians.\n * @type {number}\n */\n this.xPoleOffset = xPoleOffset;\n\n /**\n * The offset to the Celestial Intermediate Pole (CIP) about the Y axis, in radians.\n * @type {number}\n */\n this.yPoleOffset = yPoleOffset;\n\n /**\n * The difference in time standards, UT1 - UTC, in seconds.\n * @type {number}\n */\n this.ut1MinusUtc = ut1MinusUtc;\n}\nexport default EarthOrientationParametersSample;\n", "/**\n * Represents a Gregorian date in a more precise format than the JavaScript Date object.\n * In addition to submillisecond precision, this object can also represent leap seconds.\n * @alias GregorianDate\n * @constructor\n *\n * @param {number} [year] The year as a whole number.\n * @param {number} [month] The month as a whole number with range [1, 12].\n * @param {number} [day] The day of the month as a whole number starting at 1.\n * @param {number} [hour] The hour as a whole number with range [0, 23].\n * @param {number} [minute] The minute of the hour as a whole number with range [0, 59].\n * @param {number} [second] The second of the minute as a whole number with range [0, 60], with 60 representing a leap second.\n * @param {number} [millisecond] The millisecond of the second as a floating point number with range [0.0, 1000.0).\n * @param {boolean} [isLeapSecond] Whether this time is during a leap second.\n *\n * @see JulianDate#toGregorianDate\n */\nfunction GregorianDate(\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond,\n isLeapSecond\n) {\n /**\n * Gets or sets the year as a whole number.\n * @type {number}\n */\n this.year = year;\n /**\n * Gets or sets the month as a whole number with range [1, 12].\n * @type {number}\n */\n this.month = month;\n /**\n * Gets or sets the day of the month as a whole number starting at 1.\n * @type {number}\n */\n this.day = day;\n /**\n * Gets or sets the hour as a whole number with range [0, 23].\n * @type {number}\n */\n this.hour = hour;\n /**\n * Gets or sets the minute of the hour as a whole number with range [0, 59].\n * @type {number}\n */\n this.minute = minute;\n /**\n * Gets or sets the second of the minute as a whole number with range [0, 60], with 60 representing a leap second.\n * @type {number}\n */\n this.second = second;\n /**\n * Gets or sets the millisecond of the second as a floating point number with range [0.0, 1000.0).\n * @type {number}\n */\n this.millisecond = millisecond;\n /**\n * Gets or sets whether this time is during a leap second.\n * @type {boolean}\n */\n this.isLeapSecond = isLeapSecond;\n}\nexport default GregorianDate;\n", "import DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Determines if a given date is a leap year.\n *\n * @function isLeapYear\n *\n * @param {number} year The year to be tested.\n * @returns {boolean} True if year is a leap year.\n *\n * @example\n * const leapYear = Cesium.isLeapYear(2000); // true\n */\nfunction isLeapYear(year) {\n //>>includeStart('debug', pragmas.debug);\n if (year === null || isNaN(year)) {\n throw new DeveloperError(\"year is required and must be a number.\");\n }\n //>>includeEnd('debug');\n\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\nexport default isLeapYear;\n", "/**\n * Describes a single leap second, which is constructed from a {@link JulianDate} and a\n * numerical offset representing the number of seconds TAI is ahead of the UTC time standard.\n * @alias LeapSecond\n * @constructor\n *\n * @param {JulianDate} [date] A Julian date representing the time of the leap second.\n * @param {number} [offset] The cumulative number of seconds that TAI is ahead of UTC at the provided date.\n */\nfunction LeapSecond(date, offset) {\n /**\n * Gets or sets the date at which this leap second occurs.\n * @type {JulianDate}\n */\n this.julianDate = date;\n\n /**\n * Gets or sets the cumulative number of seconds between the UTC and TAI time standards at the time\n * of this leap second.\n * @type {number}\n */\n this.offset = offset;\n}\nexport default LeapSecond;\n", "/**\n * Constants for time conversions like those done by {@link JulianDate}.\n *\n * @namespace TimeConstants\n *\n * @see JulianDate\n *\n * @private\n */\nconst TimeConstants = {\n /**\n * The number of seconds in one millisecond: 0.001\n * @type {number}\n * @constant\n */\n SECONDS_PER_MILLISECOND: 0.001,\n\n /**\n * The number of seconds in one minute: 60.\n * @type {number}\n * @constant\n */\n SECONDS_PER_MINUTE: 60.0,\n\n /**\n * The number of minutes in one hour: 60.\n * @type {number}\n * @constant\n */\n MINUTES_PER_HOUR: 60.0,\n\n /**\n * The number of hours in one day: 24.\n * @type {number}\n * @constant\n */\n HOURS_PER_DAY: 24.0,\n\n /**\n * The number of seconds in one hour: 3600.\n * @type {number}\n * @constant\n */\n SECONDS_PER_HOUR: 3600.0,\n\n /**\n * The number of minutes in one day: 1440.\n * @type {number}\n * @constant\n */\n MINUTES_PER_DAY: 1440.0,\n\n /**\n * The number of seconds in one day, ignoring leap seconds: 86400.\n * @type {number}\n * @constant\n */\n SECONDS_PER_DAY: 86400.0,\n\n /**\n * The number of days in one Julian century: 36525.\n * @type {number}\n * @constant\n */\n DAYS_PER_JULIAN_CENTURY: 36525.0,\n\n /**\n * One trillionth of a second.\n * @type {number}\n * @constant\n */\n PICOSECOND: 0.000000001,\n\n /**\n * The number of days to subtract from a Julian date to determine the\n * modified Julian date, which gives the number of days since midnight\n * on November 17, 1858.\n * @type {number}\n * @constant\n */\n MODIFIED_JULIAN_DATE_DIFFERENCE: 2400000.5,\n};\nexport default Object.freeze(TimeConstants);\n", "/**\n * Provides the type of time standards which JulianDate can take as input.\n *\n * @enum {number}\n *\n * @see JulianDate\n */\nconst TimeStandard = {\n /**\n * Represents the coordinated Universal Time (UTC) time standard.\n *\n * UTC is related to TAI according to the relationship\n * UTC = TAI - deltaT where deltaT is the number of leap\n * seconds which have been introduced as of the time in TAI.\n *\n * @type {number}\n * @constant\n */\n UTC: 0,\n\n /**\n * Represents the International Atomic Time (TAI) time standard.\n * TAI is the principal time standard to which the other time standards are related.\n *\n * @type {number}\n * @constant\n */\n TAI: 1,\n};\nexport default Object.freeze(TimeStandard);\n", "import binarySearch from \"./binarySearch.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport GregorianDate from \"./GregorianDate.js\";\nimport isLeapYear from \"./isLeapYear.js\";\nimport LeapSecond from \"./LeapSecond.js\";\nimport TimeConstants from \"./TimeConstants.js\";\nimport TimeStandard from \"./TimeStandard.js\";\n\nconst gregorianDateScratch = new GregorianDate();\nconst daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nconst daysInLeapFeburary = 29;\n\nfunction compareLeapSecondDates(leapSecond, dateToFind) {\n return JulianDate.compare(leapSecond.julianDate, dateToFind.julianDate);\n}\n\n// we don't really need a leap second instance, anything with a julianDate property will do\nconst binarySearchScratchLeapSecond = new LeapSecond();\n\nfunction convertUtcToTai(julianDate) {\n //Even though julianDate is in UTC, we'll treat it as TAI and\n //search the leap second table for it.\n binarySearchScratchLeapSecond.julianDate = julianDate;\n const leapSeconds = JulianDate.leapSeconds;\n let index = binarySearch(\n leapSeconds,\n binarySearchScratchLeapSecond,\n compareLeapSecondDates\n );\n\n if (index < 0) {\n index = ~index;\n }\n\n if (index >= leapSeconds.length) {\n index = leapSeconds.length - 1;\n }\n\n let offset = leapSeconds[index].offset;\n if (index > 0) {\n //Now we have the index of the closest leap second that comes on or after our UTC time.\n //However, if the difference between the UTC date being converted and the TAI\n //defined leap second is greater than the offset, we are off by one and need to use\n //the previous leap second.\n const difference = JulianDate.secondsDifference(\n leapSeconds[index].julianDate,\n julianDate\n );\n if (difference > offset) {\n index--;\n offset = leapSeconds[index].offset;\n }\n }\n\n JulianDate.addSeconds(julianDate, offset, julianDate);\n}\n\nfunction convertTaiToUtc(julianDate, result) {\n binarySearchScratchLeapSecond.julianDate = julianDate;\n const leapSeconds = JulianDate.leapSeconds;\n let index = binarySearch(\n leapSeconds,\n binarySearchScratchLeapSecond,\n compareLeapSecondDates\n );\n if (index < 0) {\n index = ~index;\n }\n\n //All times before our first leap second get the first offset.\n if (index === 0) {\n return JulianDate.addSeconds(julianDate, -leapSeconds[0].offset, result);\n }\n\n //All times after our leap second get the last offset.\n if (index >= leapSeconds.length) {\n return JulianDate.addSeconds(\n julianDate,\n -leapSeconds[index - 1].offset,\n result\n );\n }\n\n //Compute the difference between the found leap second and the time we are converting.\n const difference = JulianDate.secondsDifference(\n leapSeconds[index].julianDate,\n julianDate\n );\n\n if (difference === 0) {\n //The date is in our leap second table.\n return JulianDate.addSeconds(\n julianDate,\n -leapSeconds[index].offset,\n result\n );\n }\n\n if (difference <= 1.0) {\n //The requested date is during the moment of a leap second, then we cannot convert to UTC\n return undefined;\n }\n\n //The time is in between two leap seconds, index is the leap second after the date\n //we're converting, so we subtract one to get the correct LeapSecond instance.\n return JulianDate.addSeconds(\n julianDate,\n -leapSeconds[--index].offset,\n result\n );\n}\n\nfunction setComponents(wholeDays, secondsOfDay, julianDate) {\n const extraDays = (secondsOfDay / TimeConstants.SECONDS_PER_DAY) | 0;\n wholeDays += extraDays;\n secondsOfDay -= TimeConstants.SECONDS_PER_DAY * extraDays;\n\n if (secondsOfDay < 0) {\n wholeDays--;\n secondsOfDay += TimeConstants.SECONDS_PER_DAY;\n }\n\n julianDate.dayNumber = wholeDays;\n julianDate.secondsOfDay = secondsOfDay;\n return julianDate;\n}\n\nfunction computeJulianDateComponents(\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond\n) {\n // Algorithm from page 604 of the Explanatory Supplement to the\n // Astronomical Almanac (Seidelmann 1992).\n\n const a = ((month - 14) / 12) | 0;\n const b = year + 4800 + a;\n let dayNumber =\n (((1461 * b) / 4) | 0) +\n (((367 * (month - 2 - 12 * a)) / 12) | 0) -\n (((3 * (((b + 100) / 100) | 0)) / 4) | 0) +\n day -\n 32075;\n\n // JulianDates are noon-based\n hour = hour - 12;\n if (hour < 0) {\n hour += 24;\n }\n\n const secondsOfDay =\n second +\n (hour * TimeConstants.SECONDS_PER_HOUR +\n minute * TimeConstants.SECONDS_PER_MINUTE +\n millisecond * TimeConstants.SECONDS_PER_MILLISECOND);\n\n if (secondsOfDay >= 43200.0) {\n dayNumber -= 1;\n }\n\n return [dayNumber, secondsOfDay];\n}\n\n//Regular expressions used for ISO8601 date parsing.\n//YYYY\nconst matchCalendarYear = /^(\\d{4})$/;\n//YYYY-MM (YYYYMM is invalid)\nconst matchCalendarMonth = /^(\\d{4})-(\\d{2})$/;\n//YYYY-DDD or YYYYDDD\nconst matchOrdinalDate = /^(\\d{4})-?(\\d{3})$/;\n//YYYY-Www or YYYYWww or YYYY-Www-D or YYYYWwwD\nconst matchWeekDate = /^(\\d{4})-?W(\\d{2})-?(\\d{1})?$/;\n//YYYY-MM-DD or YYYYMMDD\nconst matchCalendarDate = /^(\\d{4})-?(\\d{2})-?(\\d{2})$/;\n// Match utc offset\nconst utcOffset = /([Z+\\-])?(\\d{2})?:?(\\d{2})?$/;\n// Match hours HH or HH.xxxxx\nconst matchHours = /^(\\d{2})(\\.\\d+)?/.source + utcOffset.source;\n// Match hours/minutes HH:MM HHMM.xxxxx\nconst matchHoursMinutes = /^(\\d{2}):?(\\d{2})(\\.\\d+)?/.source + utcOffset.source;\n// Match hours/minutes HH:MM:SS HHMMSS.xxxxx\nconst matchHoursMinutesSeconds =\n /^(\\d{2}):?(\\d{2}):?(\\d{2})(\\.\\d+)?/.source + utcOffset.source;\n\nconst iso8601ErrorMessage = \"Invalid ISO 8601 date.\";\n\n/**\n * Represents an astronomical Julian date, which is the number of days since noon on January 1, -4712 (4713 BC).\n * For increased precision, this class stores the whole number part of the date and the seconds\n * part of the date in separate components. In order to be safe for arithmetic and represent\n * leap seconds, the date is always stored in the International Atomic Time standard\n * {@link TimeStandard.TAI}.\n * @alias JulianDate\n * @constructor\n *\n * @param {number} [julianDayNumber=0.0] The Julian Day Number representing the number of whole days. Fractional days will also be handled correctly.\n * @param {number} [secondsOfDay=0.0] The number of seconds into the current Julian Day Number. Fractional seconds, negative seconds and seconds greater than a day will be handled correctly.\n * @param {TimeStandard} [timeStandard=TimeStandard.UTC] The time standard in which the first two parameters are defined.\n */\nfunction JulianDate(julianDayNumber, secondsOfDay, timeStandard) {\n /**\n * Gets or sets the number of whole days.\n * @type {number}\n */\n this.dayNumber = undefined;\n\n /**\n * Gets or sets the number of seconds into the current day.\n * @type {number}\n */\n this.secondsOfDay = undefined;\n\n julianDayNumber = defaultValue(julianDayNumber, 0.0);\n secondsOfDay = defaultValue(secondsOfDay, 0.0);\n timeStandard = defaultValue(timeStandard, TimeStandard.UTC);\n\n //If julianDayNumber is fractional, make it an integer and add the number of seconds the fraction represented.\n const wholeDays = julianDayNumber | 0;\n secondsOfDay =\n secondsOfDay +\n (julianDayNumber - wholeDays) * TimeConstants.SECONDS_PER_DAY;\n\n setComponents(wholeDays, secondsOfDay, this);\n\n if (timeStandard === TimeStandard.UTC) {\n convertUtcToTai(this);\n }\n}\n\n/**\n * Creates a new instance from a GregorianDate.\n *\n * @param {GregorianDate} date A GregorianDate.\n * @param {JulianDate} [result] An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter or a new instance if none was provided.\n *\n * @exception {DeveloperError} date must be a valid GregorianDate.\n */\nJulianDate.fromGregorianDate = function (date, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!(date instanceof GregorianDate)) {\n throw new DeveloperError(\"date must be a valid GregorianDate.\");\n }\n //>>includeEnd('debug');\n\n const components = computeJulianDateComponents(\n date.year,\n date.month,\n date.day,\n date.hour,\n date.minute,\n date.second,\n date.millisecond\n );\n if (!defined(result)) {\n return new JulianDate(components[0], components[1], TimeStandard.UTC);\n }\n setComponents(components[0], components[1], result);\n convertUtcToTai(result);\n return result;\n};\n\n/**\n * Creates a new instance from a JavaScript Date.\n *\n * @param {Date} date A JavaScript Date.\n * @param {JulianDate} [result] An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter or a new instance if none was provided.\n *\n * @exception {DeveloperError} date must be a valid JavaScript Date.\n */\nJulianDate.fromDate = function (date, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!(date instanceof Date) || isNaN(date.getTime())) {\n throw new DeveloperError(\"date must be a valid JavaScript Date.\");\n }\n //>>includeEnd('debug');\n\n const components = computeJulianDateComponents(\n date.getUTCFullYear(),\n date.getUTCMonth() + 1,\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds(),\n date.getUTCMilliseconds()\n );\n if (!defined(result)) {\n return new JulianDate(components[0], components[1], TimeStandard.UTC);\n }\n setComponents(components[0], components[1], result);\n convertUtcToTai(result);\n return result;\n};\n\n/**\n * Creates a new instance from a from an {@link http://en.wikipedia.org/wiki/ISO_8601|ISO 8601} date.\n * This method is superior to Date.parse because it will handle all valid formats defined by the ISO 8601\n * specification, including leap seconds and sub-millisecond times, which discarded by most JavaScript implementations.\n *\n * @param {string} iso8601String An ISO 8601 date.\n * @param {JulianDate} [result] An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter or a new instance if none was provided.\n *\n * @exception {DeveloperError} Invalid ISO 8601 date.\n */\nJulianDate.fromIso8601 = function (iso8601String, result) {\n //>>includeStart('debug', pragmas.debug);\n if (typeof iso8601String !== \"string\") {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug');\n\n //Comma and decimal point both indicate a fractional number according to ISO 8601,\n //start out by blanket replacing , with . which is the only valid such symbol in JS.\n iso8601String = iso8601String.replace(\",\", \".\");\n\n //Split the string into its date and time components, denoted by a mandatory T\n let tokens = iso8601String.split(\"T\");\n let year;\n let month = 1;\n let day = 1;\n let hour = 0;\n let minute = 0;\n let second = 0;\n let millisecond = 0;\n\n //Lacking a time is okay, but a missing date is illegal.\n const date = tokens[0];\n const time = tokens[1];\n let tmp;\n let inLeapYear;\n //>>includeStart('debug', pragmas.debug);\n if (!defined(date)) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n\n let dashCount;\n //>>includeEnd('debug');\n\n //First match the date against possible regular expressions.\n tokens = date.match(matchCalendarDate);\n if (tokens !== null) {\n //>>includeStart('debug', pragmas.debug);\n dashCount = date.split(\"-\").length - 1;\n if (dashCount > 0 && dashCount !== 2) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug');\n year = +tokens[1];\n month = +tokens[2];\n day = +tokens[3];\n } else {\n tokens = date.match(matchCalendarMonth);\n if (tokens !== null) {\n year = +tokens[1];\n month = +tokens[2];\n } else {\n tokens = date.match(matchCalendarYear);\n if (tokens !== null) {\n year = +tokens[1];\n } else {\n //Not a year/month/day so it must be an ordinal date.\n let dayOfYear;\n tokens = date.match(matchOrdinalDate);\n if (tokens !== null) {\n year = +tokens[1];\n dayOfYear = +tokens[2];\n inLeapYear = isLeapYear(year);\n\n //This validation is only applicable for this format.\n //>>includeStart('debug', pragmas.debug);\n if (\n dayOfYear < 1 ||\n (inLeapYear && dayOfYear > 366) ||\n (!inLeapYear && dayOfYear > 365)\n ) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug')\n } else {\n tokens = date.match(matchWeekDate);\n if (tokens !== null) {\n //ISO week date to ordinal date from\n //http://en.wikipedia.org/w/index.php?title=ISO_week_date&oldid=474176775\n year = +tokens[1];\n const weekNumber = +tokens[2];\n const dayOfWeek = +tokens[3] || 0;\n\n //>>includeStart('debug', pragmas.debug);\n dashCount = date.split(\"-\").length - 1;\n if (\n dashCount > 0 &&\n ((!defined(tokens[3]) && dashCount !== 1) ||\n (defined(tokens[3]) && dashCount !== 2))\n ) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug')\n\n const january4 = new Date(Date.UTC(year, 0, 4));\n dayOfYear = weekNumber * 7 + dayOfWeek - january4.getUTCDay() - 3;\n } else {\n //None of our regular expressions succeeded in parsing the date properly.\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(iso8601ErrorMessage);\n //>>includeEnd('debug')\n }\n }\n //Split an ordinal date into month/day.\n tmp = new Date(Date.UTC(year, 0, 1));\n tmp.setUTCDate(dayOfYear);\n month = tmp.getUTCMonth() + 1;\n day = tmp.getUTCDate();\n }\n }\n }\n\n //Now that we have all of the date components, validate them to make sure nothing is out of range.\n inLeapYear = isLeapYear(year);\n //>>includeStart('debug', pragmas.debug);\n if (\n month < 1 ||\n month > 12 ||\n day < 1 ||\n ((month !== 2 || !inLeapYear) && day > daysInMonth[month - 1]) ||\n (inLeapYear && month === 2 && day > daysInLeapFeburary)\n ) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug')\n\n //Now move onto the time string, which is much simpler.\n //If no time is specified, it is considered the beginning of the day, UTC to match Javascript's implementation.\n let offsetIndex;\n if (defined(time)) {\n tokens = time.match(matchHoursMinutesSeconds);\n if (tokens !== null) {\n //>>includeStart('debug', pragmas.debug);\n dashCount = time.split(\":\").length - 1;\n if (dashCount > 0 && dashCount !== 2 && dashCount !== 3) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug')\n\n hour = +tokens[1];\n minute = +tokens[2];\n second = +tokens[3];\n millisecond = +(tokens[4] || 0) * 1000.0;\n offsetIndex = 5;\n } else {\n tokens = time.match(matchHoursMinutes);\n if (tokens !== null) {\n //>>includeStart('debug', pragmas.debug);\n dashCount = time.split(\":\").length - 1;\n if (dashCount > 2) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug')\n\n hour = +tokens[1];\n minute = +tokens[2];\n second = +(tokens[3] || 0) * 60.0;\n offsetIndex = 4;\n } else {\n tokens = time.match(matchHours);\n if (tokens !== null) {\n hour = +tokens[1];\n minute = +(tokens[2] || 0) * 60.0;\n offsetIndex = 3;\n } else {\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(iso8601ErrorMessage);\n //>>includeEnd('debug')\n }\n }\n }\n\n //Validate that all values are in proper range. Minutes and hours have special cases at 60 and 24.\n //>>includeStart('debug', pragmas.debug);\n if (\n minute >= 60 ||\n second >= 61 ||\n hour > 24 ||\n (hour === 24 && (minute > 0 || second > 0 || millisecond > 0))\n ) {\n throw new DeveloperError(iso8601ErrorMessage);\n }\n //>>includeEnd('debug');\n\n //Check the UTC offset value, if no value exists, use local time\n //a Z indicates UTC, + or - are offsets.\n const offset = tokens[offsetIndex];\n const offsetHours = +tokens[offsetIndex + 1];\n const offsetMinutes = +(tokens[offsetIndex + 2] || 0);\n switch (offset) {\n case \"+\":\n hour = hour - offsetHours;\n minute = minute - offsetMinutes;\n break;\n case \"-\":\n hour = hour + offsetHours;\n minute = minute + offsetMinutes;\n break;\n case \"Z\":\n break;\n default:\n minute =\n minute +\n new Date(\n Date.UTC(year, month - 1, day, hour, minute)\n ).getTimezoneOffset();\n break;\n }\n }\n\n //ISO8601 denotes a leap second by any time having a seconds component of 60 seconds.\n //If that's the case, we need to temporarily subtract a second in order to build a UTC date.\n //Then we add it back in after converting to TAI.\n const isLeapSecond = second === 60;\n if (isLeapSecond) {\n second--;\n }\n\n //Even if we successfully parsed the string into its components, after applying UTC offset or\n //special cases like 24:00:00 denoting midnight, we need to normalize the data appropriately.\n\n //milliseconds can never be greater than 1000, and seconds can't be above 60, so we start with minutes\n while (minute >= 60) {\n minute -= 60;\n hour++;\n }\n\n while (hour >= 24) {\n hour -= 24;\n day++;\n }\n\n tmp = inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];\n while (day > tmp) {\n day -= tmp;\n month++;\n\n if (month > 12) {\n month -= 12;\n year++;\n }\n\n tmp =\n inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];\n }\n\n //If UTC offset is at the beginning/end of the day, minutes can be negative.\n while (minute < 0) {\n minute += 60;\n hour--;\n }\n\n while (hour < 0) {\n hour += 24;\n day--;\n }\n\n while (day < 1) {\n month--;\n if (month < 1) {\n month += 12;\n year--;\n }\n\n tmp =\n inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];\n day += tmp;\n }\n\n //Now create the JulianDate components from the Gregorian date and actually create our instance.\n const components = computeJulianDateComponents(\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond\n );\n\n if (!defined(result)) {\n result = new JulianDate(components[0], components[1], TimeStandard.UTC);\n } else {\n setComponents(components[0], components[1], result);\n convertUtcToTai(result);\n }\n\n //If we were on a leap second, add it back.\n if (isLeapSecond) {\n JulianDate.addSeconds(result, 1, result);\n }\n\n return result;\n};\n\n/**\n * Creates a new instance that represents the current system time.\n * This is equivalent to calling JulianDate.fromDate(new Date());.\n *\n * @param {JulianDate} [result] An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter or a new instance if none was provided.\n */\nJulianDate.now = function (result) {\n return JulianDate.fromDate(new Date(), result);\n};\n\nconst toGregorianDateScratch = new JulianDate(0, 0, TimeStandard.TAI);\n\n/**\n * Creates a {@link GregorianDate} from the provided instance.\n *\n * @param {JulianDate} julianDate The date to be converted.\n * @param {GregorianDate} [result] An existing instance to use for the result.\n * @returns {GregorianDate} The modified result parameter or a new instance if none was provided.\n */\nJulianDate.toGregorianDate = function (julianDate, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n //>>includeEnd('debug');\n\n let isLeapSecond = false;\n let thisUtc = convertTaiToUtc(julianDate, toGregorianDateScratch);\n if (!defined(thisUtc)) {\n //Conversion to UTC will fail if we are during a leap second.\n //If that's the case, subtract a second and convert again.\n //JavaScript doesn't support leap seconds, so this results in second 59 being repeated twice.\n JulianDate.addSeconds(julianDate, -1, toGregorianDateScratch);\n thisUtc = convertTaiToUtc(toGregorianDateScratch, toGregorianDateScratch);\n isLeapSecond = true;\n }\n\n let julianDayNumber = thisUtc.dayNumber;\n const secondsOfDay = thisUtc.secondsOfDay;\n\n if (secondsOfDay >= 43200.0) {\n julianDayNumber += 1;\n }\n\n // Algorithm from page 604 of the Explanatory Supplement to the\n // Astronomical Almanac (Seidelmann 1992).\n let L = (julianDayNumber + 68569) | 0;\n const N = ((4 * L) / 146097) | 0;\n L = (L - (((146097 * N + 3) / 4) | 0)) | 0;\n const I = ((4000 * (L + 1)) / 1461001) | 0;\n L = (L - (((1461 * I) / 4) | 0) + 31) | 0;\n const J = ((80 * L) / 2447) | 0;\n const day = (L - (((2447 * J) / 80) | 0)) | 0;\n L = (J / 11) | 0;\n const month = (J + 2 - 12 * L) | 0;\n const year = (100 * (N - 49) + I + L) | 0;\n\n let hour = (secondsOfDay / TimeConstants.SECONDS_PER_HOUR) | 0;\n let remainingSeconds = secondsOfDay - hour * TimeConstants.SECONDS_PER_HOUR;\n const minute = (remainingSeconds / TimeConstants.SECONDS_PER_MINUTE) | 0;\n remainingSeconds =\n remainingSeconds - minute * TimeConstants.SECONDS_PER_MINUTE;\n let second = remainingSeconds | 0;\n const millisecond =\n (remainingSeconds - second) / TimeConstants.SECONDS_PER_MILLISECOND;\n\n // JulianDates are noon-based\n hour += 12;\n if (hour > 23) {\n hour -= 24;\n }\n\n //If we were on a leap second, add it back.\n if (isLeapSecond) {\n second += 1;\n }\n\n if (!defined(result)) {\n return new GregorianDate(\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond,\n isLeapSecond\n );\n }\n\n result.year = year;\n result.month = month;\n result.day = day;\n result.hour = hour;\n result.minute = minute;\n result.second = second;\n result.millisecond = millisecond;\n result.isLeapSecond = isLeapSecond;\n return result;\n};\n\n/**\n * Creates a JavaScript Date from the provided instance.\n * Since JavaScript dates are only accurate to the nearest millisecond and\n * cannot represent a leap second, consider using {@link JulianDate.toGregorianDate} instead.\n * If the provided JulianDate is during a leap second, the previous second is used.\n *\n * @param {JulianDate} julianDate The date to be converted.\n * @returns {Date} A new instance representing the provided date.\n */\nJulianDate.toDate = function (julianDate) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n //>>includeEnd('debug');\n\n const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);\n let second = gDate.second;\n if (gDate.isLeapSecond) {\n second -= 1;\n }\n return new Date(\n Date.UTC(\n gDate.year,\n gDate.month - 1,\n gDate.day,\n gDate.hour,\n gDate.minute,\n second,\n gDate.millisecond\n )\n );\n};\n\n/**\n * Creates an ISO8601 representation of the provided date.\n *\n * @param {JulianDate} julianDate The date to be converted.\n * @param {number} [precision] The number of fractional digits used to represent the seconds component. By default, the most precise representation is used.\n * @returns {string} The ISO8601 representation of the provided date.\n */\nJulianDate.toIso8601 = function (julianDate, precision) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n //>>includeEnd('debug');\n\n const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);\n let year = gDate.year;\n let month = gDate.month;\n let day = gDate.day;\n let hour = gDate.hour;\n const minute = gDate.minute;\n const second = gDate.second;\n const millisecond = gDate.millisecond;\n\n // special case - Iso8601.MAXIMUM_VALUE produces a string which we can't parse unless we adjust.\n // 10000-01-01T00:00:00 is the same instant as 9999-12-31T24:00:00\n if (\n year === 10000 &&\n month === 1 &&\n day === 1 &&\n hour === 0 &&\n minute === 0 &&\n second === 0 &&\n millisecond === 0\n ) {\n year = 9999;\n month = 12;\n day = 31;\n hour = 24;\n }\n\n let millisecondStr;\n\n if (!defined(precision) && millisecond !== 0) {\n //Forces milliseconds into a number with at least 3 digits to whatever the default toString() precision is.\n millisecondStr = (millisecond * 0.01).toString().replace(\".\", \"\");\n return `${year.toString().padStart(4, \"0\")}-${month\n .toString()\n .padStart(2, \"0\")}-${day\n .toString()\n .padStart(2, \"0\")}T${hour\n .toString()\n .padStart(2, \"0\")}:${minute\n .toString()\n .padStart(2, \"0\")}:${second\n .toString()\n .padStart(2, \"0\")}.${millisecondStr}Z`;\n }\n\n //Precision is either 0 or milliseconds is 0 with undefined precision, in either case, leave off milliseconds entirely\n if (!defined(precision) || precision === 0) {\n return `${year.toString().padStart(4, \"0\")}-${month\n .toString()\n .padStart(2, \"0\")}-${day\n .toString()\n .padStart(2, \"0\")}T${hour\n .toString()\n .padStart(2, \"0\")}:${minute\n .toString()\n .padStart(2, \"0\")}:${second.toString().padStart(2, \"0\")}Z`;\n }\n\n //Forces milliseconds into a number with at least 3 digits to whatever the specified precision is.\n millisecondStr = (millisecond * 0.01)\n .toFixed(precision)\n .replace(\".\", \"\")\n .slice(0, precision);\n return `${year.toString().padStart(4, \"0\")}-${month\n .toString()\n .padStart(2, \"0\")}-${day\n .toString()\n .padStart(2, \"0\")}T${hour\n .toString()\n .padStart(2, \"0\")}:${minute\n .toString()\n .padStart(2, \"0\")}:${second\n .toString()\n .padStart(2, \"0\")}.${millisecondStr}Z`;\n};\n\n/**\n * Duplicates a JulianDate instance.\n *\n * @param {JulianDate} julianDate The date to duplicate.\n * @param {JulianDate} [result] An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter or a new instance if none was provided. Returns undefined if julianDate is undefined.\n */\nJulianDate.clone = function (julianDate, result) {\n if (!defined(julianDate)) {\n return undefined;\n }\n if (!defined(result)) {\n return new JulianDate(\n julianDate.dayNumber,\n julianDate.secondsOfDay,\n TimeStandard.TAI\n );\n }\n result.dayNumber = julianDate.dayNumber;\n result.secondsOfDay = julianDate.secondsOfDay;\n return result;\n};\n\n/**\n * Compares two instances.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {number} A negative value if left is less than right, a positive value if left is greater than right, or zero if left and right are equal.\n */\nJulianDate.compare = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"left is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"right is required.\");\n }\n //>>includeEnd('debug');\n\n const julianDayNumberDifference = left.dayNumber - right.dayNumber;\n if (julianDayNumberDifference !== 0) {\n return julianDayNumberDifference;\n }\n return left.secondsOfDay - right.secondsOfDay;\n};\n\n/**\n * Compares two instances and returns true if they are equal, false otherwise.\n *\n * @param {JulianDate} [left] The first instance.\n * @param {JulianDate} [right] The second instance.\n * @returns {boolean} true if the dates are equal; otherwise, false.\n */\nJulianDate.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.dayNumber === right.dayNumber &&\n left.secondsOfDay === right.secondsOfDay)\n );\n};\n\n/**\n * Compares two instances and returns true if they are within epsilon seconds of\n * each other. That is, in order for the dates to be considered equal (and for\n * this function to return true), the absolute value of the difference between them, in\n * seconds, must be less than epsilon.\n *\n * @param {JulianDate} [left] The first instance.\n * @param {JulianDate} [right] The second instance.\n * @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances.\n * @returns {boolean} true if the two dates are within epsilon seconds of each other; otherwise false.\n */\nJulianDate.equalsEpsilon = function (left, right, epsilon) {\n epsilon = defaultValue(epsilon, 0);\n\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n Math.abs(JulianDate.secondsDifference(left, right)) <= epsilon)\n );\n};\n\n/**\n * Computes the total number of whole and fractional days represented by the provided instance.\n *\n * @param {JulianDate} julianDate The date.\n * @returns {number} The Julian date as single floating point number.\n */\nJulianDate.totalDays = function (julianDate) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n //>>includeEnd('debug');\n return (\n julianDate.dayNumber +\n julianDate.secondsOfDay / TimeConstants.SECONDS_PER_DAY\n );\n};\n\n/**\n * Computes the difference in seconds between the provided instance.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {number} The difference, in seconds, when subtracting right from left.\n */\nJulianDate.secondsDifference = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"left is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"right is required.\");\n }\n //>>includeEnd('debug');\n\n const dayDifference =\n (left.dayNumber - right.dayNumber) * TimeConstants.SECONDS_PER_DAY;\n return dayDifference + (left.secondsOfDay - right.secondsOfDay);\n};\n\n/**\n * Computes the difference in days between the provided instance.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {number} The difference, in days, when subtracting right from left.\n */\nJulianDate.daysDifference = function (left, right) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(left)) {\n throw new DeveloperError(\"left is required.\");\n }\n if (!defined(right)) {\n throw new DeveloperError(\"right is required.\");\n }\n //>>includeEnd('debug');\n\n const dayDifference = left.dayNumber - right.dayNumber;\n const secondDifference =\n (left.secondsOfDay - right.secondsOfDay) / TimeConstants.SECONDS_PER_DAY;\n return dayDifference + secondDifference;\n};\n\n/**\n * Computes the number of seconds the provided instance is ahead of UTC.\n *\n * @param {JulianDate} julianDate The date.\n * @returns {number} The number of seconds the provided instance is ahead of UTC\n */\nJulianDate.computeTaiMinusUtc = function (julianDate) {\n binarySearchScratchLeapSecond.julianDate = julianDate;\n const leapSeconds = JulianDate.leapSeconds;\n let index = binarySearch(\n leapSeconds,\n binarySearchScratchLeapSecond,\n compareLeapSecondDates\n );\n if (index < 0) {\n index = ~index;\n --index;\n if (index < 0) {\n index = 0;\n }\n }\n return leapSeconds[index].offset;\n};\n\n/**\n * Adds the provided number of seconds to the provided date instance.\n *\n * @param {JulianDate} julianDate The date.\n * @param {number} seconds The number of seconds to add or subtract.\n * @param {JulianDate} result An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter.\n */\nJulianDate.addSeconds = function (julianDate, seconds, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n if (!defined(seconds)) {\n throw new DeveloperError(\"seconds is required.\");\n }\n if (!defined(result)) {\n throw new DeveloperError(\"result is required.\");\n }\n //>>includeEnd('debug');\n\n return setComponents(\n julianDate.dayNumber,\n julianDate.secondsOfDay + seconds,\n result\n );\n};\n\n/**\n * Adds the provided number of minutes to the provided date instance.\n *\n * @param {JulianDate} julianDate The date.\n * @param {number} minutes The number of minutes to add or subtract.\n * @param {JulianDate} result An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter.\n */\nJulianDate.addMinutes = function (julianDate, minutes, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n if (!defined(minutes)) {\n throw new DeveloperError(\"minutes is required.\");\n }\n if (!defined(result)) {\n throw new DeveloperError(\"result is required.\");\n }\n //>>includeEnd('debug');\n\n const newSecondsOfDay =\n julianDate.secondsOfDay + minutes * TimeConstants.SECONDS_PER_MINUTE;\n return setComponents(julianDate.dayNumber, newSecondsOfDay, result);\n};\n\n/**\n * Adds the provided number of hours to the provided date instance.\n *\n * @param {JulianDate} julianDate The date.\n * @param {number} hours The number of hours to add or subtract.\n * @param {JulianDate} result An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter.\n */\nJulianDate.addHours = function (julianDate, hours, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n if (!defined(hours)) {\n throw new DeveloperError(\"hours is required.\");\n }\n if (!defined(result)) {\n throw new DeveloperError(\"result is required.\");\n }\n //>>includeEnd('debug');\n\n const newSecondsOfDay =\n julianDate.secondsOfDay + hours * TimeConstants.SECONDS_PER_HOUR;\n return setComponents(julianDate.dayNumber, newSecondsOfDay, result);\n};\n\n/**\n * Adds the provided number of days to the provided date instance.\n *\n * @param {JulianDate} julianDate The date.\n * @param {number} days The number of days to add or subtract.\n * @param {JulianDate} result An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter.\n */\nJulianDate.addDays = function (julianDate, days, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(julianDate)) {\n throw new DeveloperError(\"julianDate is required.\");\n }\n if (!defined(days)) {\n throw new DeveloperError(\"days is required.\");\n }\n if (!defined(result)) {\n throw new DeveloperError(\"result is required.\");\n }\n //>>includeEnd('debug');\n\n const newJulianDayNumber = julianDate.dayNumber + days;\n return setComponents(newJulianDayNumber, julianDate.secondsOfDay, result);\n};\n\n/**\n * Compares the provided instances and returns true if left is earlier than right, false otherwise.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {boolean} true if left is earlier than right, false otherwise.\n */\nJulianDate.lessThan = function (left, right) {\n return JulianDate.compare(left, right) < 0;\n};\n\n/**\n * Compares the provided instances and returns true if left is earlier than or equal to right, false otherwise.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {boolean} true if left is earlier than or equal to right, false otherwise.\n */\nJulianDate.lessThanOrEquals = function (left, right) {\n return JulianDate.compare(left, right) <= 0;\n};\n\n/**\n * Compares the provided instances and returns true if left is later than right, false otherwise.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {boolean} true if left is later than right, false otherwise.\n */\nJulianDate.greaterThan = function (left, right) {\n return JulianDate.compare(left, right) > 0;\n};\n\n/**\n * Compares the provided instances and returns true if left is later than or equal to right, false otherwise.\n *\n * @param {JulianDate} left The first instance.\n * @param {JulianDate} right The second instance.\n * @returns {boolean} true if left is later than or equal to right, false otherwise.\n */\nJulianDate.greaterThanOrEquals = function (left, right) {\n return JulianDate.compare(left, right) >= 0;\n};\n\n/**\n * Duplicates this instance.\n *\n * @param {JulianDate} [result] An existing instance to use for the result.\n * @returns {JulianDate} The modified result parameter or a new instance if none was provided.\n */\nJulianDate.prototype.clone = function (result) {\n return JulianDate.clone(this, result);\n};\n\n/**\n * Compares this and the provided instance and returns true if they are equal, false otherwise.\n *\n * @param {JulianDate} [right] The second instance.\n * @returns {boolean} true if the dates are equal; otherwise, false.\n */\nJulianDate.prototype.equals = function (right) {\n return JulianDate.equals(this, right);\n};\n\n/**\n * Compares this and the provided instance and returns true if they are within epsilon seconds of\n * each other. That is, in order for the dates to be considered equal (and for\n * this function to return true), the absolute value of the difference between them, in\n * seconds, must be less than epsilon.\n *\n * @param {JulianDate} [right] The second instance.\n * @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances.\n * @returns {boolean} true if the two dates are within epsilon seconds of each other; otherwise false.\n */\nJulianDate.prototype.equalsEpsilon = function (right, epsilon) {\n return JulianDate.equalsEpsilon(this, right, epsilon);\n};\n\n/**\n * Creates a string representing this date in ISO8601 format.\n *\n * @returns {string} A string representing this date in ISO8601 format.\n */\nJulianDate.prototype.toString = function () {\n return JulianDate.toIso8601(this);\n};\n\n/**\n * Gets or sets the list of leap seconds used throughout Cesium.\n * @memberof JulianDate\n * @type {LeapSecond[]}\n */\nJulianDate.leapSeconds = [\n new LeapSecond(new JulianDate(2441317, 43210.0, TimeStandard.TAI), 10), // January 1, 1972 00:00:00 UTC\n new LeapSecond(new JulianDate(2441499, 43211.0, TimeStandard.TAI), 11), // July 1, 1972 00:00:00 UTC\n new LeapSecond(new JulianDate(2441683, 43212.0, TimeStandard.TAI), 12), // January 1, 1973 00:00:00 UTC\n new LeapSecond(new JulianDate(2442048, 43213.0, TimeStandard.TAI), 13), // January 1, 1974 00:00:00 UTC\n new LeapSecond(new JulianDate(2442413, 43214.0, TimeStandard.TAI), 14), // January 1, 1975 00:00:00 UTC\n new LeapSecond(new JulianDate(2442778, 43215.0, TimeStandard.TAI), 15), // January 1, 1976 00:00:00 UTC\n new LeapSecond(new JulianDate(2443144, 43216.0, TimeStandard.TAI), 16), // January 1, 1977 00:00:00 UTC\n new LeapSecond(new JulianDate(2443509, 43217.0, TimeStandard.TAI), 17), // January 1, 1978 00:00:00 UTC\n new LeapSecond(new JulianDate(2443874, 43218.0, TimeStandard.TAI), 18), // January 1, 1979 00:00:00 UTC\n new LeapSecond(new JulianDate(2444239, 43219.0, TimeStandard.TAI), 19), // January 1, 1980 00:00:00 UTC\n new LeapSecond(new JulianDate(2444786, 43220.0, TimeStandard.TAI), 20), // July 1, 1981 00:00:00 UTC\n new LeapSecond(new JulianDate(2445151, 43221.0, TimeStandard.TAI), 21), // July 1, 1982 00:00:00 UTC\n new LeapSecond(new JulianDate(2445516, 43222.0, TimeStandard.TAI), 22), // July 1, 1983 00:00:00 UTC\n new LeapSecond(new JulianDate(2446247, 43223.0, TimeStandard.TAI), 23), // July 1, 1985 00:00:00 UTC\n new LeapSecond(new JulianDate(2447161, 43224.0, TimeStandard.TAI), 24), // January 1, 1988 00:00:00 UTC\n new LeapSecond(new JulianDate(2447892, 43225.0, TimeStandard.TAI), 25), // January 1, 1990 00:00:00 UTC\n new LeapSecond(new JulianDate(2448257, 43226.0, TimeStandard.TAI), 26), // January 1, 1991 00:00:00 UTC\n new LeapSecond(new JulianDate(2448804, 43227.0, TimeStandard.TAI), 27), // July 1, 1992 00:00:00 UTC\n new LeapSecond(new JulianDate(2449169, 43228.0, TimeStandard.TAI), 28), // July 1, 1993 00:00:00 UTC\n new LeapSecond(new JulianDate(2449534, 43229.0, TimeStandard.TAI), 29), // July 1, 1994 00:00:00 UTC\n new LeapSecond(new JulianDate(2450083, 43230.0, TimeStandard.TAI), 30), // January 1, 1996 00:00:00 UTC\n new LeapSecond(new JulianDate(2450630, 43231.0, TimeStandard.TAI), 31), // July 1, 1997 00:00:00 UTC\n new LeapSecond(new JulianDate(2451179, 43232.0, TimeStandard.TAI), 32), // January 1, 1999 00:00:00 UTC\n new LeapSecond(new JulianDate(2453736, 43233.0, TimeStandard.TAI), 33), // January 1, 2006 00:00:00 UTC\n new LeapSecond(new JulianDate(2454832, 43234.0, TimeStandard.TAI), 34), // January 1, 2009 00:00:00 UTC\n new LeapSecond(new JulianDate(2456109, 43235.0, TimeStandard.TAI), 35), // July 1, 2012 00:00:00 UTC\n new LeapSecond(new JulianDate(2457204, 43236.0, TimeStandard.TAI), 36), // July 1, 2015 00:00:00 UTC\n new LeapSecond(new JulianDate(2457754, 43237.0, TimeStandard.TAI), 37), // January 1, 2017 00:00:00 UTC\n];\nexport default JulianDate;\n", "import Uri from \"urijs\";\nimport appendForwardSlash from \"./appendForwardSlash.js\";\nimport Check from \"./Check.js\";\nimport clone from \"./clone.js\";\nimport combine from \"./combine.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defer from \"./defer.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport getAbsoluteUri from \"./getAbsoluteUri.js\";\nimport getBaseUri from \"./getBaseUri.js\";\nimport getExtensionFromUri from \"./getExtensionFromUri.js\";\nimport getImagePixels from \"./getImagePixels.js\";\nimport isBlobUri from \"./isBlobUri.js\";\nimport isCrossOriginUrl from \"./isCrossOriginUrl.js\";\nimport isDataUri from \"./isDataUri.js\";\nimport loadAndExecuteScript from \"./loadAndExecuteScript.js\";\nimport CesiumMath from \"./Math.js\";\nimport objectToQuery from \"./objectToQuery.js\";\nimport queryToObject from \"./queryToObject.js\";\nimport Request from \"./Request.js\";\nimport RequestErrorEvent from \"./RequestErrorEvent.js\";\nimport RequestScheduler from \"./RequestScheduler.js\";\nimport RequestState from \"./RequestState.js\";\nimport RuntimeError from \"./RuntimeError.js\";\nimport TrustedServers from \"./TrustedServers.js\";\n\nconst xhrBlobSupported = (function () {\n try {\n const xhr = new XMLHttpRequest();\n xhr.open(\"GET\", \"#\", true);\n xhr.responseType = \"blob\";\n return xhr.responseType === \"blob\";\n } catch (e) {\n return false;\n }\n})();\n\n/**\n * @typedef {object} Resource.ConstructorOptions\n *\n * Initialization options for the Resource constructor\n *\n * @property {string} url The url of the resource.\n * @property {object} [queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @property {object} [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @property {object} [headers={}] Additional HTTP headers that will be sent.\n * @property {Proxy} [proxy] A proxy to be used when loading the resource.\n * @property {Resource.RetryCallback} [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @property {number} [retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @property {Request} [request] A Request object that will be used. Intended for internal use only.\n * @property {boolean} [parseUrl=true] If true, parse the url for query parameters; otherwise store the url without change\n */\n\n/**\n * A resource that includes the location and any other parameters we need to retrieve it or create derived resources. It also provides the ability to retry requests.\n *\n * @alias Resource\n * @constructor\n *\n * @param {string|Resource.ConstructorOptions} options A url or an object describing initialization options\n *\n * @example\n * function refreshTokenRetryCallback(resource, error) {\n * if (error.statusCode === 403) {\n * // 403 status code means a new token should be generated\n * return getNewAccessToken()\n * .then(function(token) {\n * resource.queryParameters.access_token = token;\n * return true;\n * })\n * .catch(function() {\n * return false;\n * });\n * }\n *\n * return false;\n * }\n *\n * const resource = new Resource({\n * url: 'http://server.com/path/to/resource.json',\n * proxy: new DefaultProxy('/proxy/'),\n * headers: {\n * 'X-My-Header': 'valueOfHeader'\n * },\n * queryParameters: {\n * 'access_token': '123-435-456-000'\n * },\n * retryCallback: refreshTokenRetryCallback,\n * retryAttempts: 1\n * });\n */\nfunction Resource(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n if (typeof options === \"string\") {\n options = {\n url: options,\n };\n }\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.string(\"options.url\", options.url);\n //>>includeEnd('debug');\n\n this._url = undefined;\n this._templateValues = defaultClone(options.templateValues, {});\n this._queryParameters = defaultClone(options.queryParameters, {});\n\n /**\n * Additional HTTP headers that will be sent with the request.\n *\n * @type {object}\n */\n this.headers = defaultClone(options.headers, {});\n\n /**\n * A Request object that will be used. Intended for internal use only.\n *\n * @type {Request}\n */\n this.request = defaultValue(options.request, new Request());\n\n /**\n * A proxy to be used when loading the resource.\n *\n * @type {Proxy}\n */\n this.proxy = options.proxy;\n\n /**\n * Function to call when a request for this resource fails. If it returns true or a Promise that resolves to true, the request will be retried.\n *\n * @type {Function}\n */\n this.retryCallback = options.retryCallback;\n\n /**\n * The number of times the retryCallback should be called before giving up.\n *\n * @type {number}\n */\n this.retryAttempts = defaultValue(options.retryAttempts, 0);\n this._retryCount = 0;\n\n const parseUrl = defaultValue(options.parseUrl, true);\n if (parseUrl) {\n this.parseUrl(options.url, true, true);\n } else {\n this._url = options.url;\n }\n\n this._credits = options.credits;\n}\n\n/**\n * Clones a value if it is defined, otherwise returns the default value\n *\n * @param {object} [value] The value to clone.\n * @param {object} [defaultValue] The default value.\n *\n * @returns {object} A clone of value or the defaultValue.\n *\n * @private\n */\nfunction defaultClone(value, defaultValue) {\n return defined(value) ? clone(value) : defaultValue;\n}\n\n/**\n * A helper function to create a resource depending on whether we have a String or a Resource\n *\n * @param {Resource|string} resource A Resource or a String to use when creating a new Resource.\n *\n * @returns {Resource} If resource is a String, a Resource constructed with the url and options. Otherwise the resource parameter is returned.\n *\n * @private\n */\nResource.createIfNeeded = function (resource) {\n if (resource instanceof Resource) {\n // Keep existing request object. This function is used internally to duplicate a Resource, so that it can't\n // be modified outside of a class that holds it (eg. an imagery or terrain provider). Since the Request objects\n // are managed outside of the providers, by the tile loading code, we want to keep the request property the same so if it is changed\n // in the underlying tiling code the requests for this resource will use it.\n return resource.getDerivedResource({\n request: resource.request,\n });\n }\n\n if (typeof resource !== \"string\") {\n return resource;\n }\n\n return new Resource({\n url: resource,\n });\n};\n\nlet supportsImageBitmapOptionsPromise;\n/**\n * A helper function to check whether createImageBitmap supports passing ImageBitmapOptions.\n *\n * @returns {Promise} A promise that resolves to true if this browser supports creating an ImageBitmap with options.\n *\n * @private\n */\nResource.supportsImageBitmapOptions = function () {\n // Until the HTML folks figure out what to do about this, we need to actually try loading an image to\n // know if this browser supports passing options to the createImageBitmap function.\n // https://github.com/whatwg/html/pull/4248\n //\n // We also need to check whether the colorSpaceConversion option is supported.\n // We do this by loading a PNG with an embedded color profile, first with\n // colorSpaceConversion: \"none\" and then with colorSpaceConversion: \"default\".\n // If the pixel color is different then we know the option is working.\n // As of Webkit 17612.3.6.1.6 the createImageBitmap promise resolves but the\n // option is not actually supported.\n if (defined(supportsImageBitmapOptionsPromise)) {\n return supportsImageBitmapOptionsPromise;\n }\n\n if (typeof createImageBitmap !== \"function\") {\n supportsImageBitmapOptionsPromise = Promise.resolve(false);\n return supportsImageBitmapOptionsPromise;\n }\n\n const imageDataUri =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAAE4g3rEiDgAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADElEQVQI12Ng6GAAAAEUAIngE3ZiAAAAAElFTkSuQmCC\";\n\n supportsImageBitmapOptionsPromise = Resource.fetchBlob({\n url: imageDataUri,\n })\n .then(function (blob) {\n const imageBitmapOptions = {\n imageOrientation: \"flipY\", // default is \"none\"\n premultiplyAlpha: \"none\", // default is \"default\"\n colorSpaceConversion: \"none\", // default is \"default\"\n };\n return Promise.all([\n createImageBitmap(blob, imageBitmapOptions),\n createImageBitmap(blob),\n ]);\n })\n .then(function (imageBitmaps) {\n // Check whether the colorSpaceConversion option had any effect on the green channel\n const colorWithOptions = getImagePixels(imageBitmaps[0]);\n const colorWithDefaults = getImagePixels(imageBitmaps[1]);\n return colorWithOptions[1] !== colorWithDefaults[1];\n })\n .catch(function () {\n return false;\n });\n\n return supportsImageBitmapOptionsPromise;\n};\n\nObject.defineProperties(Resource, {\n /**\n * Returns true if blobs are supported.\n *\n * @memberof Resource\n * @type {boolean}\n *\n * @readonly\n */\n isBlobSupported: {\n get: function () {\n return xhrBlobSupported;\n },\n },\n});\n\nObject.defineProperties(Resource.prototype, {\n /**\n * Query parameters appended to the url.\n *\n * @memberof Resource.prototype\n * @type {object}\n *\n * @readonly\n */\n queryParameters: {\n get: function () {\n return this._queryParameters;\n },\n },\n\n /**\n * The key/value pairs used to replace template parameters in the url.\n *\n * @memberof Resource.prototype\n * @type {object}\n *\n * @readonly\n */\n templateValues: {\n get: function () {\n return this._templateValues;\n },\n },\n\n /**\n * The url to the resource with template values replaced, query string appended and encoded by proxy if one was set.\n *\n * @memberof Resource.prototype\n * @type {string}\n */\n url: {\n get: function () {\n return this.getUrlComponent(true, true);\n },\n set: function (value) {\n this.parseUrl(value, false, false);\n },\n },\n\n /**\n * The file extension of the resource.\n *\n * @memberof Resource.prototype\n * @type {string}\n *\n * @readonly\n */\n extension: {\n get: function () {\n return getExtensionFromUri(this._url);\n },\n },\n\n /**\n * True if the Resource refers to a data URI.\n *\n * @memberof Resource.prototype\n * @type {boolean}\n */\n isDataUri: {\n get: function () {\n return isDataUri(this._url);\n },\n },\n\n /**\n * True if the Resource refers to a blob URI.\n *\n * @memberof Resource.prototype\n * @type {boolean}\n */\n isBlobUri: {\n get: function () {\n return isBlobUri(this._url);\n },\n },\n\n /**\n * True if the Resource refers to a cross origin URL.\n *\n * @memberof Resource.prototype\n * @type {boolean}\n */\n isCrossOriginUrl: {\n get: function () {\n return isCrossOriginUrl(this._url);\n },\n },\n\n /**\n * True if the Resource has request headers. This is equivalent to checking if the headers property has any keys.\n *\n * @memberof Resource.prototype\n * @type {boolean}\n */\n hasHeaders: {\n get: function () {\n return Object.keys(this.headers).length > 0;\n },\n },\n\n /**\n * Gets the credits required for attribution of an asset.\n * @private\n */\n credits: {\n get: function () {\n return this._credits;\n },\n },\n});\n\n/**\n * Override Object#toString so that implicit string conversion gives the\n * complete URL represented by this Resource.\n *\n * @returns {string} The URL represented by this Resource\n */\nResource.prototype.toString = function () {\n return this.getUrlComponent(true, true);\n};\n\n/**\n * Parse a url string, and store its info\n *\n * @param {string} url The input url string.\n * @param {boolean} merge If true, we'll merge with the resource's existing queryParameters. Otherwise they will be replaced.\n * @param {boolean} preserveQuery If true duplicate parameters will be concatenated into an array. If false, keys in url will take precedence.\n * @param {string} [baseUrl] If supplied, and input url is a relative url, it will be made absolute relative to baseUrl\n *\n * @private\n */\nResource.prototype.parseUrl = function (url, merge, preserveQuery, baseUrl) {\n let uri = new Uri(url);\n const query = parseQueryString(uri.query());\n\n this._queryParameters = merge\n ? combineQueryParameters(query, this.queryParameters, preserveQuery)\n : query;\n\n // Remove unneeded info from the Uri\n uri.search(\"\");\n uri.fragment(\"\");\n\n if (defined(baseUrl) && uri.scheme() === \"\") {\n uri = uri.absoluteTo(getAbsoluteUri(baseUrl));\n }\n\n this._url = uri.toString();\n};\n\n/**\n * Parses a query string and returns the object equivalent.\n *\n * @param {string} queryString The query string\n * @returns {object}\n *\n * @private\n */\nfunction parseQueryString(queryString) {\n if (queryString.length === 0) {\n return {};\n }\n\n // Special case where the querystring is just a string, not key/value pairs\n if (queryString.indexOf(\"=\") === -1) {\n return { [queryString]: undefined };\n }\n\n return queryToObject(queryString);\n}\n\n/**\n * This combines a map of query parameters.\n *\n * @param {object} q1 The first map of query parameters. Values in this map will take precedence if preserveQueryParameters is false.\n * @param {object} q2 The second map of query parameters.\n * @param {boolean} preserveQueryParameters If true duplicate parameters will be concatenated into an array. If false, keys in q1 will take precedence.\n *\n * @returns {object} The combined map of query parameters.\n *\n * @example\n * const q1 = {\n * a: 1,\n * b: 2\n * };\n * const q2 = {\n * a: 3,\n * c: 4\n * };\n * const q3 = {\n * b: [5, 6],\n * d: 7\n * }\n *\n * // Returns\n * // {\n * // a: [1, 3],\n * // b: 2,\n * // c: 4\n * // };\n * combineQueryParameters(q1, q2, true);\n *\n * // Returns\n * // {\n * // a: 1,\n * // b: 2,\n * // c: 4\n * // };\n * combineQueryParameters(q1, q2, false);\n *\n * // Returns\n * // {\n * // a: 1,\n * // b: [2, 5, 6],\n * // d: 7\n * // };\n * combineQueryParameters(q1, q3, true);\n *\n * // Returns\n * // {\n * // a: 1,\n * // b: 2,\n * // d: 7\n * // };\n * combineQueryParameters(q1, q3, false);\n *\n * @private\n */\nfunction combineQueryParameters(q1, q2, preserveQueryParameters) {\n if (!preserveQueryParameters) {\n return combine(q1, q2);\n }\n\n const result = clone(q1, true);\n for (const param in q2) {\n if (q2.hasOwnProperty(param)) {\n let value = result[param];\n const q2Value = q2[param];\n if (defined(value)) {\n if (!Array.isArray(value)) {\n value = result[param] = [value];\n }\n\n result[param] = value.concat(q2Value);\n } else {\n result[param] = Array.isArray(q2Value) ? q2Value.slice() : q2Value;\n }\n }\n }\n\n return result;\n}\n\n/**\n * Returns the url, optional with the query string and processed by a proxy.\n *\n * @param {boolean} [query=false] If true, the query string is included.\n * @param {boolean} [proxy=false] If true, the url is processed by the proxy object, if defined.\n *\n * @returns {string} The url with all the requested components.\n */\nResource.prototype.getUrlComponent = function (query, proxy) {\n if (this.isDataUri) {\n return this._url;\n }\n\n let url = this._url;\n if (query) {\n url = `${url}${stringifyQuery(this.queryParameters)}`;\n }\n\n // Restore the placeholders, which may have been escaped in objectToQuery or elsewhere\n url = url.replace(/%7B/g, \"{\").replace(/%7D/g, \"}\");\n\n const templateValues = this._templateValues;\n if (Object.keys(templateValues).length > 0) {\n url = url.replace(/{(.*?)}/g, function (match, key) {\n const replacement = templateValues[key];\n if (defined(replacement)) {\n // use the replacement value from templateValues if there is one...\n return encodeURIComponent(replacement);\n }\n // otherwise leave it unchanged\n return match;\n });\n }\n\n if (proxy && defined(this.proxy)) {\n url = this.proxy.getURL(url);\n }\n\n return url;\n};\n\n/**\n * Converts a query object into a string.\n *\n * @param {object} queryObject The object with query parameters\n * @returns {string}\n *\n * @private\n */\nfunction stringifyQuery(queryObject) {\n const keys = Object.keys(queryObject);\n\n if (keys.length === 0) {\n return \"\";\n }\n if (keys.length === 1 && !defined(queryObject[keys[0]])) {\n // We have 1 key with an undefined value, so this is just a string, not key/value pairs\n return `?${keys[0]}`;\n }\n\n return `?${objectToQuery(queryObject)}`;\n}\n\n/**\n * Combines the specified object and the existing query parameters. This allows you to add many parameters at once,\n * as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.\n *\n * @param {object} params The query parameters\n * @param {boolean} [useAsDefault=false] If true the params will be used as the default values, so they will only be set if they are undefined.\n */\nResource.prototype.setQueryParameters = function (params, useAsDefault) {\n if (useAsDefault) {\n this._queryParameters = combineQueryParameters(\n this._queryParameters,\n params,\n false\n );\n } else {\n this._queryParameters = combineQueryParameters(\n params,\n this._queryParameters,\n false\n );\n }\n};\n\n/**\n * Combines the specified object and the existing query parameters. This allows you to add many parameters at once,\n * as opposed to adding them one at a time to the queryParameters property.\n *\n * @param {object} params The query parameters\n */\nResource.prototype.appendQueryParameters = function (params) {\n this._queryParameters = combineQueryParameters(\n params,\n this._queryParameters,\n true\n );\n};\n\n/**\n * Combines the specified object and the existing template values. This allows you to add many values at once,\n * as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.\n *\n * @param {object} template The template values\n * @param {boolean} [useAsDefault=false] If true the values will be used as the default values, so they will only be set if they are undefined.\n */\nResource.prototype.setTemplateValues = function (template, useAsDefault) {\n if (useAsDefault) {\n this._templateValues = combine(this._templateValues, template);\n } else {\n this._templateValues = combine(template, this._templateValues);\n }\n};\n\n/**\n * Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.\n *\n * @param {object} options An object with the following properties\n * @param {string} [options.url] The url that will be resolved relative to the url of the current instance.\n * @param {object} [options.queryParameters] An object containing query parameters that will be combined with those of the current instance.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}). These will be combined with those of the current instance.\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The function to call when loading the resource fails.\n * @param {number} [options.retryAttempts] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {boolean} [options.preserveQueryParameters=false] If true, this will keep all query parameters from the current resource and derived resource. If false, derived parameters will replace those of the current resource.\n *\n * @returns {Resource} The resource derived from the current one.\n */\nResource.prototype.getDerivedResource = function (options) {\n const resource = this.clone();\n resource._retryCount = 0;\n\n if (defined(options.url)) {\n const preserveQuery = defaultValue(options.preserveQueryParameters, false);\n resource.parseUrl(options.url, true, preserveQuery, this._url);\n }\n\n if (defined(options.queryParameters)) {\n resource._queryParameters = combine(\n options.queryParameters,\n resource.queryParameters\n );\n }\n if (defined(options.templateValues)) {\n resource._templateValues = combine(\n options.templateValues,\n resource.templateValues\n );\n }\n if (defined(options.headers)) {\n resource.headers = combine(options.headers, resource.headers);\n }\n if (defined(options.proxy)) {\n resource.proxy = options.proxy;\n }\n if (defined(options.request)) {\n resource.request = options.request;\n }\n if (defined(options.retryCallback)) {\n resource.retryCallback = options.retryCallback;\n }\n if (defined(options.retryAttempts)) {\n resource.retryAttempts = options.retryAttempts;\n }\n\n return resource;\n};\n\n/**\n * Called when a resource fails to load. This will call the retryCallback function if defined until retryAttempts is reached.\n *\n * @param {RequestErrorEvent} [error] The error that was encountered.\n *\n * @returns {Promise} A promise to a boolean, that if true will cause the resource request to be retried.\n *\n * @private\n */\nResource.prototype.retryOnError = function (error) {\n const retryCallback = this.retryCallback;\n if (\n typeof retryCallback !== \"function\" ||\n this._retryCount >= this.retryAttempts\n ) {\n return Promise.resolve(false);\n }\n\n const that = this;\n return Promise.resolve(retryCallback(this, error)).then(function (result) {\n ++that._retryCount;\n\n return result;\n });\n};\n\n/**\n * Duplicates a Resource instance.\n *\n * @param {Resource} [result] The object onto which to store the result.\n *\n * @returns {Resource} The modified result parameter or a new Resource instance if one was not provided.\n */\nResource.prototype.clone = function (result) {\n if (!defined(result)) {\n return new Resource({\n url: this._url,\n queryParameters: this.queryParameters,\n templateValues: this.templateValues,\n headers: this.headers,\n proxy: this.proxy,\n retryCallback: this.retryCallback,\n retryAttempts: this.retryAttempts,\n request: this.request.clone(),\n parseUrl: false,\n credits: defined(this.credits) ? this.credits.slice() : undefined,\n });\n }\n\n result._url = this._url;\n result._queryParameters = clone(this._queryParameters);\n result._templateValues = clone(this._templateValues);\n result.headers = clone(this.headers);\n result.proxy = this.proxy;\n result.retryCallback = this.retryCallback;\n result.retryAttempts = this.retryAttempts;\n result._retryCount = 0;\n result.request = this.request.clone();\n\n return result;\n};\n\n/**\n * Returns the base path of the Resource.\n *\n * @param {boolean} [includeQuery = false] Whether or not to include the query string and fragment form the uri\n *\n * @returns {string} The base URI of the resource\n */\nResource.prototype.getBaseUri = function (includeQuery) {\n return getBaseUri(this.getUrlComponent(includeQuery), includeQuery);\n};\n\n/**\n * Appends a forward slash to the URL.\n */\nResource.prototype.appendForwardSlash = function () {\n this._url = appendForwardSlash(this._url);\n};\n\n/**\n * Asynchronously loads the resource as raw binary data. Returns a promise that will resolve to\n * an ArrayBuffer once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n * @example\n * // load a single URL asynchronously\n * resource.fetchArrayBuffer().then(function(arrayBuffer) {\n * // use the data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchArrayBuffer = function () {\n return this.fetch({\n responseType: \"arraybuffer\",\n });\n};\n\n/**\n * Creates a Resource and calls fetchArrayBuffer() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchArrayBuffer = function (options) {\n const resource = new Resource(options);\n return resource.fetchArrayBuffer();\n};\n\n/**\n * Asynchronously loads the given resource as a blob. Returns a promise that will resolve to\n * a Blob once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n * @example\n * // load a single URL asynchronously\n * resource.fetchBlob().then(function(blob) {\n * // use the data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchBlob = function () {\n return this.fetch({\n responseType: \"blob\",\n });\n};\n\n/**\n * Creates a Resource and calls fetchBlob() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchBlob = function (options) {\n const resource = new Resource(options);\n return resource.fetchBlob();\n};\n\n/**\n * Asynchronously loads the given image resource. Returns a promise that will resolve to\n * an {@link https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap|ImageBitmap} if preferImageBitmap is true and the browser supports createImageBitmap or otherwise an\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement|Image} once loaded, or reject if the image failed to load.\n *\n * @param {object} [options] An object with the following properties.\n * @param {boolean} [options.preferBlob=false] If true, we will load the image via a blob.\n * @param {boolean} [options.preferImageBitmap=false] If true, image will be decoded during fetch and an ImageBitmap is returned.\n * @param {boolean} [options.flipY=false] If true, image will be vertically flipped during decode. Only applies if the browser supports createImageBitmap.\n * @param {boolean} [options.skipColorSpaceConversion=false] If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports createImageBitmap.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * // load a single image asynchronously\n * resource.fetchImage().then(function(image) {\n * // use the loaded image\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * // load several images in parallel\n * Promise.all([resource1.fetchImage(), resource2.fetchImage()]).then(function(images) {\n * // images is an array containing all the loaded images\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchImage = function (options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n const preferImageBitmap = defaultValue(options.preferImageBitmap, false);\n const preferBlob = defaultValue(options.preferBlob, false);\n const flipY = defaultValue(options.flipY, false);\n const skipColorSpaceConversion = defaultValue(\n options.skipColorSpaceConversion,\n false\n );\n\n checkAndResetRequest(this.request);\n // We try to load the image normally if\n // 1. Blobs aren't supported\n // 2. It's a data URI\n // 3. It's a blob URI\n // 4. It doesn't have request headers and we preferBlob is false\n if (\n !xhrBlobSupported ||\n this.isDataUri ||\n this.isBlobUri ||\n (!this.hasHeaders && !preferBlob)\n ) {\n return fetchImage({\n resource: this,\n flipY: flipY,\n skipColorSpaceConversion: skipColorSpaceConversion,\n preferImageBitmap: preferImageBitmap,\n });\n }\n\n const blobPromise = this.fetchBlob();\n if (!defined(blobPromise)) {\n return;\n }\n\n let supportsImageBitmap;\n let useImageBitmap;\n let generatedBlobResource;\n let generatedBlob;\n return Resource.supportsImageBitmapOptions()\n .then(function (result) {\n supportsImageBitmap = result;\n useImageBitmap = supportsImageBitmap && preferImageBitmap;\n return blobPromise;\n })\n .then(function (blob) {\n if (!defined(blob)) {\n return;\n }\n generatedBlob = blob;\n if (useImageBitmap) {\n return Resource.createImageBitmapFromBlob(blob, {\n flipY: flipY,\n premultiplyAlpha: false,\n skipColorSpaceConversion: skipColorSpaceConversion,\n });\n }\n const blobUrl = window.URL.createObjectURL(blob);\n generatedBlobResource = new Resource({\n url: blobUrl,\n });\n\n return fetchImage({\n resource: generatedBlobResource,\n flipY: flipY,\n skipColorSpaceConversion: skipColorSpaceConversion,\n preferImageBitmap: false,\n });\n })\n .then(function (image) {\n if (!defined(image)) {\n return;\n }\n\n // The blob object may be needed for use by a TileDiscardPolicy,\n // so attach it to the image.\n image.blob = generatedBlob;\n\n if (useImageBitmap) {\n return image;\n }\n\n window.URL.revokeObjectURL(generatedBlobResource.url);\n return image;\n })\n .catch(function (error) {\n if (defined(generatedBlobResource)) {\n window.URL.revokeObjectURL(generatedBlobResource.url);\n }\n\n // If the blob load succeeded but the image decode failed, attach the blob\n // to the error object for use by a TileDiscardPolicy.\n // In particular, BingMapsImageryProvider uses this to detect the\n // zero-length response that is returned when a tile is not available.\n error.blob = generatedBlob;\n\n return Promise.reject(error);\n });\n};\n\n/**\n * Fetches an image and returns a promise to it.\n *\n * @param {object} [options] An object with the following properties.\n * @param {Resource} [options.resource] Resource object that points to an image to fetch.\n * @param {boolean} [options.preferImageBitmap] If true, image will be decoded during fetch and an ImageBitmap is returned.\n * @param {boolean} [options.flipY] If true, image will be vertically flipped during decode. Only applies if the browser supports createImageBitmap.\n * @param {boolean} [options.skipColorSpaceConversion=false] If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports createImageBitmap.\n * @private\n */\nfunction fetchImage(options) {\n const resource = options.resource;\n const flipY = options.flipY;\n const skipColorSpaceConversion = options.skipColorSpaceConversion;\n const preferImageBitmap = options.preferImageBitmap;\n\n const request = resource.request;\n request.url = resource.url;\n request.requestFunction = function () {\n let crossOrigin = false;\n\n // data URIs can't have crossorigin set.\n if (!resource.isDataUri && !resource.isBlobUri) {\n crossOrigin = resource.isCrossOriginUrl;\n }\n\n const deferred = defer();\n Resource._Implementations.createImage(\n request,\n crossOrigin,\n deferred,\n flipY,\n skipColorSpaceConversion,\n preferImageBitmap\n );\n\n return deferred.promise;\n };\n\n const promise = RequestScheduler.request(request);\n if (!defined(promise)) {\n return;\n }\n\n return promise.catch(function (e) {\n // Don't retry cancelled or otherwise aborted requests\n if (request.state !== RequestState.FAILED) {\n return Promise.reject(e);\n }\n return resource.retryOnError(e).then(function (retry) {\n if (retry) {\n // Reset request so it can try again\n request.state = RequestState.UNISSUED;\n request.deferred = undefined;\n\n return fetchImage({\n resource: resource,\n flipY: flipY,\n skipColorSpaceConversion: skipColorSpaceConversion,\n preferImageBitmap: preferImageBitmap,\n });\n }\n return Promise.reject(e);\n });\n });\n}\n\n/**\n * Creates a Resource and calls fetchImage() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {boolean} [options.flipY=false] Whether to vertically flip the image during fetch and decode. Only applies when requesting an image and the browser supports createImageBitmap.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {boolean} [options.preferBlob=false] If true, we will load the image via a blob.\n * @param {boolean} [options.preferImageBitmap=false] If true, image will be decoded during fetch and an ImageBitmap is returned.\n * @param {boolean} [options.skipColorSpaceConversion=false] If true, any custom gamma or color profiles in the image will be ignored. Only applies when requesting an image and the browser supports createImageBitmap.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchImage = function (options) {\n const resource = new Resource(options);\n return resource.fetchImage({\n flipY: options.flipY,\n skipColorSpaceConversion: options.skipColorSpaceConversion,\n preferBlob: options.preferBlob,\n preferImageBitmap: options.preferImageBitmap,\n });\n};\n\n/**\n * Asynchronously loads the given resource as text. Returns a promise that will resolve to\n * a String once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n * @example\n * // load text from a URL, setting a custom header\n * const resource = new Resource({\n * url: 'http://someUrl.com/someJson.txt',\n * headers: {\n * 'X-Custom-Header' : 'some value'\n * }\n * });\n * resource.fetchText().then(function(text) {\n * // Do something with the text\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest|XMLHttpRequest}\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchText = function () {\n return this.fetch({\n responseType: \"text\",\n });\n};\n\n/**\n * Creates a Resource and calls fetchText() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchText = function (options) {\n const resource = new Resource(options);\n return resource.fetchText();\n};\n\n// note: */* below is */* but that ends the comment block early\n/**\n * Asynchronously loads the given resource as JSON. Returns a promise that will resolve to\n * a JSON object once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled. This function\n * adds 'Accept: application/json,*/*;q=0.01' to the request headers, if not\n * already specified.\n *\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.fetchJson().then(function(jsonData) {\n * // Do something with the JSON object\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchJson = function () {\n const promise = this.fetch({\n responseType: \"text\",\n headers: {\n Accept: \"application/json,*/*;q=0.01\",\n },\n });\n\n if (!defined(promise)) {\n return undefined;\n }\n\n return promise.then(function (value) {\n if (!defined(value)) {\n return;\n }\n return JSON.parse(value);\n });\n};\n\n/**\n * Creates a Resource and calls fetchJson() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchJson = function (options) {\n const resource = new Resource(options);\n return resource.fetchJson();\n};\n\n/**\n * Asynchronously loads the given resource as XML. Returns a promise that will resolve to\n * an XML Document once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * // load XML from a URL, setting a custom header\n * Cesium.loadXML('http://someUrl.com/someXML.xml', {\n * 'X-Custom-Header' : 'some value'\n * }).then(function(document) {\n * // Do something with the document\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest|XMLHttpRequest}\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchXML = function () {\n return this.fetch({\n responseType: \"document\",\n overrideMimeType: \"text/xml\",\n });\n};\n\n/**\n * Creates a Resource and calls fetchXML() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchXML = function (options) {\n const resource = new Resource(options);\n return resource.fetchXML();\n};\n\n/**\n * Requests a resource using JSONP.\n *\n * @param {string} [callbackParameterName='callback'] The callback parameter name that the server expects.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * // load a data asynchronously\n * resource.fetchJsonp().then(function(data) {\n * // use the loaded data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetchJsonp = function (callbackParameterName) {\n callbackParameterName = defaultValue(callbackParameterName, \"callback\");\n\n checkAndResetRequest(this.request);\n\n //generate a unique function name\n let functionName;\n do {\n functionName = `loadJsonp${CesiumMath.nextRandomNumber()\n .toString()\n .substring(2, 8)}`;\n } while (defined(window[functionName]));\n\n return fetchJsonp(this, callbackParameterName, functionName);\n};\n\nfunction fetchJsonp(resource, callbackParameterName, functionName) {\n const callbackQuery = {};\n callbackQuery[callbackParameterName] = functionName;\n resource.setQueryParameters(callbackQuery);\n\n const request = resource.request;\n const url = resource.url;\n request.url = url;\n request.requestFunction = function () {\n const deferred = defer();\n\n //assign a function with that name in the global scope\n window[functionName] = function (data) {\n deferred.resolve(data);\n\n try {\n delete window[functionName];\n } catch (e) {\n window[functionName] = undefined;\n }\n };\n\n Resource._Implementations.loadAndExecuteScript(url, functionName, deferred);\n return deferred.promise;\n };\n\n const promise = RequestScheduler.request(request);\n if (!defined(promise)) {\n return;\n }\n\n return promise.catch(function (e) {\n if (request.state !== RequestState.FAILED) {\n return Promise.reject(e);\n }\n\n return resource.retryOnError(e).then(function (retry) {\n if (retry) {\n // Reset request so it can try again\n request.state = RequestState.UNISSUED;\n request.deferred = undefined;\n\n return fetchJsonp(resource, callbackParameterName, functionName);\n }\n\n return Promise.reject(e);\n });\n });\n}\n\n/**\n * Creates a Resource from a URL and calls fetchJsonp() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.callbackParameterName='callback'] The callback parameter name that the server expects.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetchJsonp = function (options) {\n const resource = new Resource(options);\n return resource.fetchJsonp(options.callbackParameterName);\n};\n\n/**\n * @private\n */\nResource.prototype._makeRequest = function (options) {\n const resource = this;\n checkAndResetRequest(resource.request);\n\n const request = resource.request;\n const url = resource.url;\n request.url = url;\n\n request.requestFunction = function () {\n const responseType = options.responseType;\n const headers = combine(options.headers, resource.headers);\n const overrideMimeType = options.overrideMimeType;\n const method = options.method;\n const data = options.data;\n const deferred = defer();\n const xhr = Resource._Implementations.loadWithXhr(\n url,\n responseType,\n method,\n data,\n headers,\n deferred,\n overrideMimeType\n );\n if (defined(xhr) && defined(xhr.abort)) {\n request.cancelFunction = function () {\n xhr.abort();\n };\n }\n return deferred.promise;\n };\n\n const promise = RequestScheduler.request(request);\n if (!defined(promise)) {\n return;\n }\n\n return promise\n .then(function (data) {\n // explicitly set to undefined to ensure GC of request response data. See #8843\n request.cancelFunction = undefined;\n return data;\n })\n .catch(function (e) {\n request.cancelFunction = undefined;\n if (request.state !== RequestState.FAILED) {\n return Promise.reject(e);\n }\n\n return resource.retryOnError(e).then(function (retry) {\n if (retry) {\n // Reset request so it can try again\n request.state = RequestState.UNISSUED;\n request.deferred = undefined;\n\n return resource.fetch(options);\n }\n\n return Promise.reject(e);\n });\n });\n};\n\n/**\n * Checks to make sure the Resource isn't already being requested.\n *\n * @param {Request} request The request to check.\n *\n * @private\n */\nfunction checkAndResetRequest(request) {\n if (\n request.state === RequestState.ISSUED ||\n request.state === RequestState.ACTIVE\n ) {\n throw new RuntimeError(\"The Resource is already being fetched.\");\n }\n\n request.state = RequestState.UNISSUED;\n request.deferred = undefined;\n}\n\nconst dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;\n\nfunction decodeDataUriText(isBase64, data) {\n const result = decodeURIComponent(data);\n if (isBase64) {\n return atob(result);\n }\n return result;\n}\n\nfunction decodeDataUriArrayBuffer(isBase64, data) {\n const byteString = decodeDataUriText(isBase64, data);\n const buffer = new ArrayBuffer(byteString.length);\n const view = new Uint8Array(buffer);\n for (let i = 0; i < byteString.length; i++) {\n view[i] = byteString.charCodeAt(i);\n }\n return buffer;\n}\n\nfunction decodeDataUri(dataUriRegexResult, responseType) {\n responseType = defaultValue(responseType, \"\");\n const mimeType = dataUriRegexResult[1];\n const isBase64 = !!dataUriRegexResult[2];\n const data = dataUriRegexResult[3];\n let buffer;\n let parser;\n\n switch (responseType) {\n case \"\":\n case \"text\":\n return decodeDataUriText(isBase64, data);\n case \"arraybuffer\":\n return decodeDataUriArrayBuffer(isBase64, data);\n case \"blob\":\n buffer = decodeDataUriArrayBuffer(isBase64, data);\n return new Blob([buffer], {\n type: mimeType,\n });\n case \"document\":\n parser = new DOMParser();\n return parser.parseFromString(\n decodeDataUriText(isBase64, data),\n mimeType\n );\n case \"json\":\n return JSON.parse(decodeDataUriText(isBase64, data));\n default:\n //>>includeStart('debug', pragmas.debug);\n throw new DeveloperError(`Unhandled responseType: ${responseType}`);\n //>>includeEnd('debug');\n }\n}\n\n/**\n * Asynchronously loads the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled. It's recommended that you use\n * the more specific functions eg. fetchJson, fetchBlob, etc.\n *\n * @param {object} [options] Object with the following properties:\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.fetch()\n * .then(function(body) {\n * // use the data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.fetch = function (options) {\n options = defaultClone(options, {});\n options.method = \"GET\";\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls fetch() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.fetch = function (options) {\n const resource = new Resource(options);\n return resource.fetch({\n // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n });\n};\n\n/**\n * Asynchronously deletes the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @param {object} [options] Object with the following properties:\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.delete()\n * .then(function(body) {\n * // use the data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.delete = function (options) {\n options = defaultClone(options, {});\n options.method = \"DELETE\";\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls delete() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.data] Data that is posted with the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.delete = function (options) {\n const resource = new Resource(options);\n return resource.delete({\n // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n data: options.data,\n });\n};\n\n/**\n * Asynchronously gets headers the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @param {object} [options] Object with the following properties:\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.head()\n * .then(function(headers) {\n * // use the data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.head = function (options) {\n options = defaultClone(options, {});\n options.method = \"HEAD\";\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls head() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.head = function (options) {\n const resource = new Resource(options);\n return resource.head({\n // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n });\n};\n\n/**\n * Asynchronously gets options the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @param {object} [options] Object with the following properties:\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.options()\n * .then(function(headers) {\n * // use the data\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.options = function (options) {\n options = defaultClone(options, {});\n options.method = \"OPTIONS\";\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls options() on it.\n *\n * @param {string|object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.options = function (options) {\n const resource = new Resource(options);\n return resource.options({\n // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n });\n};\n\n/**\n * Asynchronously posts data to the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @param {object} data Data that is posted with the resource.\n * @param {object} [options] Object with the following properties:\n * @param {object} [options.data] Data that is posted with the resource.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.post(data)\n * .then(function(result) {\n * // use the result\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.post = function (data, options) {\n Check.defined(\"data\", data);\n\n options = defaultClone(options, {});\n options.method = \"POST\";\n options.data = data;\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls post() on it.\n *\n * @param {object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} options.data Data that is posted with the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.post = function (options) {\n const resource = new Resource(options);\n return resource.post(options.data, {\n // Make copy of just the needed fields because headers can be passed to both the constructor and to post\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n });\n};\n\n/**\n * Asynchronously puts data to the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @param {object} data Data that is posted with the resource.\n * @param {object} [options] Object with the following properties:\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.put(data)\n * .then(function(result) {\n * // use the result\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.put = function (data, options) {\n Check.defined(\"data\", data);\n\n options = defaultClone(options, {});\n options.method = \"PUT\";\n options.data = data;\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls put() on it.\n *\n * @param {object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} options.data Data that is posted with the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.put = function (options) {\n const resource = new Resource(options);\n return resource.put(options.data, {\n // Make copy of just the needed fields because headers can be passed to both the constructor and to post\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n });\n};\n\n/**\n * Asynchronously patches data to the given resource. Returns a promise that will resolve to\n * the result once loaded, or reject if the resource failed to load. The data is loaded\n * using XMLHttpRequest, which means that in order to make requests to another origin,\n * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.\n *\n * @param {object} data Data that is posted with the resource.\n * @param {object} [options] Object with the following properties:\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {object} [options.headers] Additional HTTP headers to send with the request, if any.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n *\n *\n * @example\n * resource.patch(data)\n * .then(function(result) {\n * // use the result\n * }).catch(function(error) {\n * // an error occurred\n * });\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}\n */\nResource.prototype.patch = function (data, options) {\n Check.defined(\"data\", data);\n\n options = defaultClone(options, {});\n options.method = \"PATCH\";\n options.data = data;\n\n return this._makeRequest(options);\n};\n\n/**\n * Creates a Resource from a URL and calls patch() on it.\n *\n * @param {object} options A url or an object with the following properties\n * @param {string} options.url The url of the resource.\n * @param {object} options.data Data that is posted with the resource.\n * @param {object} [options.queryParameters] An object containing query parameters that will be sent when retrieving the resource.\n * @param {object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).\n * @param {object} [options.headers={}] Additional HTTP headers that will be sent.\n * @param {Proxy} [options.proxy] A proxy to be used when loading the resource.\n * @param {Resource.RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.\n * @param {number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.\n * @param {Request} [options.request] A Request object that will be used. Intended for internal use only.\n * @param {string} [options.responseType] The type of response. This controls the type of item returned.\n * @param {string} [options.overrideMimeType] Overrides the MIME type returned by the server.\n * @returns {Promise|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle is true and the request does not have high enough priority.\n */\nResource.patch = function (options) {\n const resource = new Resource(options);\n return resource.patch(options.data, {\n // Make copy of just the needed fields because headers can be passed to both the constructor and to post\n responseType: options.responseType,\n overrideMimeType: options.overrideMimeType,\n });\n};\n\n/**\n * Contains implementations of functions that can be replaced for testing\n *\n * @private\n */\nResource._Implementations = {};\n\nResource._Implementations.loadImageElement = function (\n url,\n crossOrigin,\n deferred\n) {\n const image = new Image();\n\n image.onload = function () {\n // work-around a known issue with Firefox and dimensionless SVG, see:\n // - https://github.com/whatwg/html/issues/3510\n // - https://bugzilla.mozilla.org/show_bug.cgi?id=700533\n if (\n image.naturalWidth === 0 &&\n image.naturalHeight === 0 &&\n image.width === 0 &&\n image.height === 0\n ) {\n // these values affect rasterization and will likely mar the content\n // until Firefox takes a stance on the issue, marred content is better than no content\n // Chromium uses a more refined heuristic about its choice given nil viewBox, and a better stance and solution is\n // proposed later in the original issue thread:\n // - Chromium behavior: https://github.com/CesiumGS/cesium/issues/9188#issuecomment-704400825\n // - Cesium's stance/solve: https://github.com/CesiumGS/cesium/issues/9188#issuecomment-720645777\n image.width = 300;\n image.height = 150;\n }\n deferred.resolve(image);\n };\n\n image.onerror = function (e) {\n deferred.reject(e);\n };\n\n if (crossOrigin) {\n if (TrustedServers.contains(url)) {\n image.crossOrigin = \"use-credentials\";\n } else {\n image.crossOrigin = \"\";\n }\n }\n\n image.src = url;\n};\n\nResource._Implementations.createImage = function (\n request,\n crossOrigin,\n deferred,\n flipY,\n skipColorSpaceConversion,\n preferImageBitmap\n) {\n const url = request.url;\n // Passing an Image to createImageBitmap will force it to run on the main thread\n // since DOM elements don't exist on workers. We convert it to a blob so it's non-blocking.\n // See:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1044102#c38\n // https://bugs.chromium.org/p/chromium/issues/detail?id=580202#c10\n Resource.supportsImageBitmapOptions()\n .then(function (supportsImageBitmap) {\n // We can only use ImageBitmap if we can flip on decode.\n // See: https://github.com/CesiumGS/cesium/pull/7579#issuecomment-466146898\n if (!(supportsImageBitmap && preferImageBitmap)) {\n Resource._Implementations.loadImageElement(url, crossOrigin, deferred);\n return;\n }\n const responseType = \"blob\";\n const method = \"GET\";\n const xhrDeferred = defer();\n const xhr = Resource._Implementations.loadWithXhr(\n url,\n responseType,\n method,\n undefined,\n undefined,\n xhrDeferred,\n undefined,\n undefined,\n undefined\n );\n\n if (defined(xhr) && defined(xhr.abort)) {\n request.cancelFunction = function () {\n xhr.abort();\n };\n }\n return xhrDeferred.promise\n .then(function (blob) {\n if (!defined(blob)) {\n deferred.reject(\n new RuntimeError(\n `Successfully retrieved ${url} but it contained no content.`\n )\n );\n return;\n }\n\n return Resource.createImageBitmapFromBlob(blob, {\n flipY: flipY,\n premultiplyAlpha: false,\n skipColorSpaceConversion: skipColorSpaceConversion,\n });\n })\n .then(function (image) {\n deferred.resolve(image);\n });\n })\n .catch(function (e) {\n deferred.reject(e);\n });\n};\n\n/**\n * Wrapper for createImageBitmap\n *\n * @private\n */\nResource.createImageBitmapFromBlob = function (blob, options) {\n Check.defined(\"options\", options);\n Check.typeOf.bool(\"options.flipY\", options.flipY);\n Check.typeOf.bool(\"options.premultiplyAlpha\", options.premultiplyAlpha);\n Check.typeOf.bool(\n \"options.skipColorSpaceConversion\",\n options.skipColorSpaceConversion\n );\n\n return createImageBitmap(blob, {\n imageOrientation: options.flipY ? \"flipY\" : \"none\",\n premultiplyAlpha: options.premultiplyAlpha ? \"premultiply\" : \"none\",\n colorSpaceConversion: options.skipColorSpaceConversion ? \"none\" : \"default\",\n });\n};\n\nfunction decodeResponse(loadWithHttpResponse, responseType) {\n switch (responseType) {\n case \"text\":\n return loadWithHttpResponse.toString(\"utf8\");\n case \"json\":\n return JSON.parse(loadWithHttpResponse.toString(\"utf8\"));\n default:\n return new Uint8Array(loadWithHttpResponse).buffer;\n }\n}\n\nfunction loadWithHttpRequest(\n url,\n responseType,\n method,\n data,\n headers,\n deferred,\n overrideMimeType\n) {\n // Note: only the 'json' and 'text' responseTypes transforms the loaded buffer\n let URL;\n let zlib;\n Promise.all([import(\"url\"), import(\"zlib\")])\n .then(([urlImport, zlibImport]) => {\n URL = urlImport.parse(url);\n zlib = zlibImport;\n\n return URL.protocol === \"https:\" ? import(\"https\") : import(\"http\");\n })\n .then((http) => {\n const options = {\n protocol: URL.protocol,\n hostname: URL.hostname,\n port: URL.port,\n path: URL.path,\n query: URL.query,\n method: method,\n headers: headers,\n };\n http\n .request(options)\n .on(\"response\", function (res) {\n if (res.statusCode < 200 || res.statusCode >= 300) {\n deferred.reject(\n new RequestErrorEvent(res.statusCode, res, res.headers)\n );\n return;\n }\n\n const chunkArray = [];\n res.on(\"data\", function (chunk) {\n chunkArray.push(chunk);\n });\n\n res.on(\"end\", function () {\n // eslint-disable-next-line no-undef\n const result = Buffer.concat(chunkArray);\n if (res.headers[\"content-encoding\"] === \"gzip\") {\n zlib.gunzip(result, function (error, resultUnzipped) {\n if (error) {\n deferred.reject(\n new RuntimeError(\"Error decompressing response.\")\n );\n } else {\n deferred.resolve(\n decodeResponse(resultUnzipped, responseType)\n );\n }\n });\n } else {\n deferred.resolve(decodeResponse(result, responseType));\n }\n });\n })\n .on(\"error\", function (e) {\n deferred.reject(new RequestErrorEvent());\n })\n .end();\n });\n}\n\nconst noXMLHttpRequest = typeof XMLHttpRequest === \"undefined\";\nResource._Implementations.loadWithXhr = function (\n url,\n responseType,\n method,\n data,\n headers,\n deferred,\n overrideMimeType\n) {\n const dataUriRegexResult = dataUriRegex.exec(url);\n if (dataUriRegexResult !== null) {\n deferred.resolve(decodeDataUri(dataUriRegexResult, responseType));\n return;\n }\n\n if (noXMLHttpRequest) {\n loadWithHttpRequest(\n url,\n responseType,\n method,\n data,\n headers,\n deferred,\n overrideMimeType\n );\n return;\n }\n\n const xhr = new XMLHttpRequest();\n\n if (TrustedServers.contains(url)) {\n xhr.withCredentials = true;\n }\n\n xhr.open(method, url, true);\n\n if (defined(overrideMimeType) && defined(xhr.overrideMimeType)) {\n xhr.overrideMimeType(overrideMimeType);\n }\n\n if (defined(headers)) {\n for (const key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n if (defined(responseType)) {\n xhr.responseType = responseType;\n }\n\n // While non-standard, file protocol always returns a status of 0 on success\n let localFile = false;\n if (typeof url === \"string\") {\n localFile =\n url.indexOf(\"file://\") === 0 ||\n (typeof window !== \"undefined\" && window.location.origin === \"file://\");\n }\n\n xhr.onload = function () {\n if (\n (xhr.status < 200 || xhr.status >= 300) &&\n !(localFile && xhr.status === 0)\n ) {\n deferred.reject(\n new RequestErrorEvent(\n xhr.status,\n xhr.response,\n xhr.getAllResponseHeaders()\n )\n );\n return;\n }\n\n const response = xhr.response;\n const browserResponseType = xhr.responseType;\n\n if (method === \"HEAD\" || method === \"OPTIONS\") {\n const responseHeaderString = xhr.getAllResponseHeaders();\n const splitHeaders = responseHeaderString.trim().split(/[\\r\\n]+/);\n\n const responseHeaders = {};\n splitHeaders.forEach(function (line) {\n const parts = line.split(\": \");\n const header = parts.shift();\n responseHeaders[header] = parts.join(\": \");\n });\n\n deferred.resolve(responseHeaders);\n return;\n }\n\n //All modern browsers will go into either the first or second if block or last else block.\n //Other code paths support older browsers that either do not support the supplied responseType\n //or do not support the xhr.response property.\n if (xhr.status === 204) {\n // accept no content\n deferred.resolve();\n } else if (\n defined(response) &&\n (!defined(responseType) || browserResponseType === responseType)\n ) {\n deferred.resolve(response);\n } else if (responseType === \"json\" && typeof response === \"string\") {\n try {\n deferred.resolve(JSON.parse(response));\n } catch (e) {\n deferred.reject(e);\n }\n } else if (\n (browserResponseType === \"\" || browserResponseType === \"document\") &&\n defined(xhr.responseXML) &&\n xhr.responseXML.hasChildNodes()\n ) {\n deferred.resolve(xhr.responseXML);\n } else if (\n (browserResponseType === \"\" || browserResponseType === \"text\") &&\n defined(xhr.responseText)\n ) {\n deferred.resolve(xhr.responseText);\n } else {\n deferred.reject(\n new RuntimeError(\"Invalid XMLHttpRequest response type.\")\n );\n }\n };\n\n xhr.onerror = function (e) {\n deferred.reject(new RequestErrorEvent());\n };\n\n xhr.send(data);\n\n return xhr;\n};\n\nResource._Implementations.loadAndExecuteScript = function (\n url,\n functionName,\n deferred\n) {\n return loadAndExecuteScript(url, functionName).catch(function (e) {\n deferred.reject(e);\n });\n};\n\n/**\n * The default implementations\n *\n * @private\n */\nResource._DefaultImplementations = {};\nResource._DefaultImplementations.createImage =\n Resource._Implementations.createImage;\nResource._DefaultImplementations.loadWithXhr =\n Resource._Implementations.loadWithXhr;\nResource._DefaultImplementations.loadAndExecuteScript =\n Resource._Implementations.loadAndExecuteScript;\n\n/**\n * A resource instance initialized to the current browser location\n *\n * @type {Resource}\n * @constant\n */\nResource.DEFAULT = Object.freeze(\n new Resource({\n url:\n typeof document === \"undefined\"\n ? \"\"\n : document.location.href.split(\"?\")[0],\n })\n);\n\n/**\n * A function that returns the value of the property.\n * @callback Resource.RetryCallback\n *\n * @param {Resource} [resource] The resource that failed to load.\n * @param {RequestErrorEvent} [error] The error that occurred during the loading of the resource.\n * @returns {boolean|Promise} If true or a promise that resolved to true, the resource will be retried. Otherwise the failure will be returned.\n */\nexport default Resource;\n", "/**\n * @private\n */\nfunction appendForwardSlash(url) {\n if (url.length === 0 || url[url.length - 1] !== \"/\") {\n url = `${url}/`;\n }\n return url;\n}\nexport default appendForwardSlash;\n", "import defaultValue from \"./defaultValue.js\";\n\n/**\n * Clones an object, returning a new object containing the same properties.\n *\n * @function\n *\n * @param {object} object The object to clone.\n * @param {boolean} [deep=false] If true, all properties will be deep cloned recursively.\n * @returns {object} The cloned object.\n */\nfunction clone(object, deep) {\n if (object === null || typeof object !== \"object\") {\n return object;\n }\n\n deep = defaultValue(deep, false);\n\n const result = new object.constructor();\n for (const propertyName in object) {\n if (object.hasOwnProperty(propertyName)) {\n let value = object[propertyName];\n if (deep) {\n value = clone(value, deep);\n }\n result[propertyName] = value;\n }\n }\n\n return result;\n}\nexport default clone;\n", "import defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\n\n/**\n * Merges two objects, copying their properties onto a new combined object. When two objects have the same\n * property, the value of the property on the first object is used. If either object is undefined,\n * it will be treated as an empty object.\n *\n * @example\n * const object1 = {\n * propOne : 1,\n * propTwo : {\n * value1 : 10\n * }\n * }\n * const object2 = {\n * propTwo : 2\n * }\n * const final = Cesium.combine(object1, object2);\n *\n * // final === {\n * // propOne : 1,\n * // propTwo : {\n * // value1 : 10\n * // }\n * // }\n *\n * @param {object} [object1] The first object to merge.\n * @param {object} [object2] The second object to merge.\n * @param {boolean} [deep=false] Perform a recursive merge.\n * @returns {object} The combined object containing all properties from both objects.\n *\n * @function\n */\nfunction combine(object1, object2, deep) {\n deep = defaultValue(deep, false);\n\n const result = {};\n\n const object1Defined = defined(object1);\n const object2Defined = defined(object2);\n let property;\n let object1Value;\n let object2Value;\n if (object1Defined) {\n for (property in object1) {\n if (object1.hasOwnProperty(property)) {\n object1Value = object1[property];\n if (\n object2Defined &&\n deep &&\n typeof object1Value === \"object\" &&\n object2.hasOwnProperty(property)\n ) {\n object2Value = object2[property];\n if (typeof object2Value === \"object\") {\n result[property] = combine(object1Value, object2Value, deep);\n } else {\n result[property] = object1Value;\n }\n } else {\n result[property] = object1Value;\n }\n }\n }\n }\n if (object2Defined) {\n for (property in object2) {\n if (\n object2.hasOwnProperty(property) &&\n !result.hasOwnProperty(property)\n ) {\n object2Value = object2[property];\n result[property] = object2Value;\n }\n }\n }\n return result;\n}\nexport default combine;\n", "/**\n * A function used to resolve a promise upon completion .\n * @callback defer.resolve\n *\n * @param {*} value The resulting value.\n */\n\n/**\n * A function used to reject a promise upon failure.\n * @callback defer.reject\n *\n * @param {*} error The error.\n */\n\n/**\n * An object which contains a promise object, and functions to resolve or reject the promise.\n *\n * @typedef {object} defer.deferred\n * @property {defer.resolve} resolve Resolves the promise when called.\n * @property {defer.reject} reject Rejects the promise when called.\n * @property {Promise} promise Promise object.\n */\n\n/**\n * Creates a deferred object, containing a promise object, and functions to resolve or reject the promise.\n * @returns {defer.deferred}\n * @private\n */\nfunction defer() {\n let resolve;\n let reject;\n const promise = new Promise(function (res, rej) {\n resolve = res;\n reject = rej;\n });\n\n return {\n resolve: resolve,\n reject: reject,\n promise: promise,\n };\n}\n\nexport default defer;\n", "import Uri from \"urijs\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Given a relative Uri and a base Uri, returns the absolute Uri of the relative Uri.\n * @function\n *\n * @param {string} relative The relative Uri.\n * @param {string} [base] The base Uri.\n * @returns {string} The absolute Uri of the given relative Uri.\n *\n * @example\n * //absolute Uri will be \"https://test.com/awesome.png\";\n * const absoluteUri = Cesium.getAbsoluteUri('awesome.png', 'https://test.com');\n */\nfunction getAbsoluteUri(relative, base) {\n let documentObject;\n if (typeof document !== \"undefined\") {\n documentObject = document;\n }\n\n return getAbsoluteUri._implementation(relative, base, documentObject);\n}\n\ngetAbsoluteUri._implementation = function (relative, base, documentObject) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(relative)) {\n throw new DeveloperError(\"relative uri is required.\");\n }\n //>>includeEnd('debug');\n\n if (!defined(base)) {\n if (typeof documentObject === \"undefined\") {\n return relative;\n }\n base = defaultValue(documentObject.baseURI, documentObject.location.href);\n }\n\n const relativeUri = new Uri(relative);\n if (relativeUri.scheme() !== \"\") {\n return relativeUri.toString();\n }\n return relativeUri.absoluteTo(base).toString();\n};\nexport default getAbsoluteUri;\n", "import Uri from \"urijs\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Given a URI, returns the base path of the URI.\n * @function\n *\n * @param {string} uri The Uri.\n * @param {boolean} [includeQuery = false] Whether or not to include the query string and fragment form the uri\n * @returns {string} The base path of the Uri.\n *\n * @example\n * // basePath will be \"/Gallery/\";\n * const basePath = Cesium.getBaseUri('/Gallery/simple.czml?value=true&example=false');\n *\n * // basePath will be \"/Gallery/?value=true&example=false\";\n * const basePath = Cesium.getBaseUri('/Gallery/simple.czml?value=true&example=false', true);\n */\nfunction getBaseUri(uri, includeQuery) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(uri)) {\n throw new DeveloperError(\"uri is required.\");\n }\n //>>includeEnd('debug');\n\n let basePath = \"\";\n const i = uri.lastIndexOf(\"/\");\n if (i !== -1) {\n basePath = uri.substring(0, i + 1);\n }\n\n if (!includeQuery) {\n return basePath;\n }\n\n uri = new Uri(uri);\n if (uri.query().length !== 0) {\n basePath += `?${uri.query()}`;\n }\n if (uri.fragment().length !== 0) {\n basePath += `#${uri.fragment()}`;\n }\n\n return basePath;\n}\nexport default getBaseUri;\n", "import Uri from \"urijs\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Given a URI, returns the extension of the URI.\n * @function getExtensionFromUri\n *\n * @param {string} uri The Uri.\n * @returns {string} The extension of the Uri.\n *\n * @example\n * //extension will be \"czml\";\n * const extension = Cesium.getExtensionFromUri('/Gallery/simple.czml?value=true&example=false');\n */\nfunction getExtensionFromUri(uri) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(uri)) {\n throw new DeveloperError(\"uri is required.\");\n }\n //>>includeEnd('debug');\n\n const uriObject = new Uri(uri);\n uriObject.normalize();\n let path = uriObject.path();\n let index = path.lastIndexOf(\"/\");\n if (index !== -1) {\n path = path.substr(index + 1);\n }\n index = path.lastIndexOf(\".\");\n if (index === -1) {\n path = \"\";\n } else {\n path = path.substr(index + 1);\n }\n return path;\n}\nexport default getExtensionFromUri;\n", "import defined from \"./defined.js\";\n\nconst context2DsByWidthAndHeight = {};\n\n/**\n * Extract a pixel array from a loaded image. Draws the image\n * into a canvas so it can read the pixels back.\n *\n * @function getImagePixels\n *\n * @param {HTMLImageElement|ImageBitmap} image The image to extract pixels from.\n * @param {number} width The width of the image. If not defined, then image.width is assigned.\n * @param {number} height The height of the image. If not defined, then image.height is assigned.\n * @returns {ImageData} The pixels of the image.\n */\nfunction getImagePixels(image, width, height) {\n if (!defined(width)) {\n width = image.width;\n }\n if (!defined(height)) {\n height = image.height;\n }\n\n let context2DsByHeight = context2DsByWidthAndHeight[width];\n if (!defined(context2DsByHeight)) {\n context2DsByHeight = {};\n context2DsByWidthAndHeight[width] = context2DsByHeight;\n }\n\n let context2d = context2DsByHeight[height];\n if (!defined(context2d)) {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n // Since we re-use contexts, use the willReadFrequently option \u2013 See https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently\n context2d = canvas.getContext(\"2d\", { willReadFrequently: true });\n context2d.globalCompositeOperation = \"copy\";\n context2DsByHeight[height] = context2d;\n }\n\n context2d.drawImage(image, 0, 0, width, height);\n return context2d.getImageData(0, 0, width, height).data;\n}\nexport default getImagePixels;\n", "import Check from \"./Check.js\";\n\nconst blobUriRegex = /^blob:/i;\n\n/**\n * Determines if the specified uri is a blob uri.\n *\n * @function isBlobUri\n *\n * @param {string} uri The uri to test.\n * @returns {boolean} true when the uri is a blob uri; otherwise, false.\n *\n * @private\n */\nfunction isBlobUri(uri) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.string(\"uri\", uri);\n //>>includeEnd('debug');\n\n return blobUriRegex.test(uri);\n}\nexport default isBlobUri;\n", "import defined from \"./defined.js\";\n\nlet a;\n\n/**\n * Given a URL, determine whether that URL is considered cross-origin to the current page.\n *\n * @private\n */\nfunction isCrossOriginUrl(url) {\n if (!defined(a)) {\n a = document.createElement(\"a\");\n }\n\n // copy window location into the anchor to get consistent results\n // when the port is default for the protocol (e.g. 80 for HTTP)\n a.href = window.location.href;\n\n // host includes both hostname and port if the port is not standard\n const host = a.host;\n const protocol = a.protocol;\n\n a.href = url;\n // IE only absolutizes href on get, not set\n // eslint-disable-next-line no-self-assign\n a.href = a.href;\n\n return protocol !== a.protocol || host !== a.host;\n}\nexport default isCrossOriginUrl;\n", "import Check from \"./Check.js\";\n\nconst dataUriRegex = /^data:/i;\n\n/**\n * Determines if the specified uri is a data uri.\n *\n * @function isDataUri\n *\n * @param {string} uri The uri to test.\n * @returns {boolean} true when the uri is a data uri; otherwise, false.\n *\n * @private\n */\nfunction isDataUri(uri) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.string(\"uri\", uri);\n //>>includeEnd('debug');\n\n return dataUriRegex.test(uri);\n}\nexport default isDataUri;\n", "/**\n * @private\n */\nfunction loadAndExecuteScript(url) {\n const script = document.createElement(\"script\");\n script.async = true;\n script.src = url;\n\n return new Promise((resolve, reject) => {\n if (window.crossOriginIsolated) {\n script.setAttribute(\"crossorigin\", \"anonymous\");\n }\n\n const head = document.getElementsByTagName(\"head\")[0];\n script.onload = function () {\n script.onload = undefined;\n head.removeChild(script);\n resolve();\n };\n script.onerror = function (e) {\n reject(e);\n };\n\n head.appendChild(script);\n });\n}\nexport default loadAndExecuteScript;\n", "import defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Converts an object representing a set of name/value pairs into a query string,\n * with names and values encoded properly for use in a URL. Values that are arrays\n * will produce multiple values with the same name.\n * @function objectToQuery\n *\n * @param {object} obj The object containing data to encode.\n * @returns {string} An encoded query string.\n *\n *\n * @example\n * const str = Cesium.objectToQuery({\n * key1 : 'some value',\n * key2 : 'a/b',\n * key3 : ['x', 'y']\n * });\n *\n * @see queryToObject\n * // str will be:\n * // 'key1=some%20value&key2=a%2Fb&key3=x&key3=y'\n */\nfunction objectToQuery(obj) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(obj)) {\n throw new DeveloperError(\"obj is required.\");\n }\n //>>includeEnd('debug');\n\n let result = \"\";\n for (const propName in obj) {\n if (obj.hasOwnProperty(propName)) {\n const value = obj[propName];\n\n const part = `${encodeURIComponent(propName)}=`;\n if (Array.isArray(value)) {\n for (let i = 0, len = value.length; i < len; ++i) {\n result += `${part + encodeURIComponent(value[i])}&`;\n }\n } else {\n result += `${part + encodeURIComponent(value)}&`;\n }\n }\n }\n\n // trim last &\n result = result.slice(0, -1);\n\n // This function used to replace %20 with + which is more compact and readable.\n // However, some servers didn't properly handle + as a space.\n // https://github.com/CesiumGS/cesium/issues/2192\n\n return result;\n}\nexport default objectToQuery;\n", "import defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Parses a query string into an object, where the keys and values of the object are the\n * name/value pairs from the query string, decoded. If a name appears multiple times,\n * the value in the object will be an array of values.\n * @function queryToObject\n *\n * @param {string} queryString The query string.\n * @returns {object} An object containing the parameters parsed from the query string.\n *\n *\n * @example\n * const obj = Cesium.queryToObject('key1=some%20value&key2=a%2Fb&key3=x&key3=y');\n * // obj will be:\n * // {\n * // key1 : 'some value',\n * // key2 : 'a/b',\n * // key3 : ['x', 'y']\n * // }\n *\n * @see objectToQuery\n */\nfunction queryToObject(queryString) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(queryString)) {\n throw new DeveloperError(\"queryString is required.\");\n }\n //>>includeEnd('debug');\n\n const result = {};\n if (queryString === \"\") {\n return result;\n }\n const parts = queryString.replace(/\\+/g, \"%20\").split(/[&;]/);\n for (let i = 0, len = parts.length; i < len; ++i) {\n const subparts = parts[i].split(\"=\");\n\n const name = decodeURIComponent(subparts[0]);\n let value = subparts[1];\n if (defined(value)) {\n value = decodeURIComponent(value);\n } else {\n value = \"\";\n }\n\n const resultValue = result[name];\n if (typeof resultValue === \"string\") {\n // expand the single value to an array\n result[name] = [resultValue, value];\n } else if (Array.isArray(resultValue)) {\n resultValue.push(value);\n } else {\n result[name] = value;\n }\n }\n return result;\n}\nexport default queryToObject;\n", "/**\n * State of the request.\n *\n * @enum {number}\n */\nconst RequestState = {\n /**\n * Initial unissued state.\n *\n * @type {number}\n * @constant\n */\n UNISSUED: 0,\n\n /**\n * Issued but not yet active. Will become active when open slots are available.\n *\n * @type {number}\n * @constant\n */\n ISSUED: 1,\n\n /**\n * Actual http request has been sent.\n *\n * @type {number}\n * @constant\n */\n ACTIVE: 2,\n\n /**\n * Request completed successfully.\n *\n * @type {number}\n * @constant\n */\n RECEIVED: 3,\n\n /**\n * Request was cancelled, either explicitly or automatically because of low priority.\n *\n * @type {number}\n * @constant\n */\n CANCELLED: 4,\n\n /**\n * Request failed.\n *\n * @type {number}\n * @constant\n */\n FAILED: 5,\n};\nexport default Object.freeze(RequestState);\n", "/**\n * An enum identifying the type of request. Used for finer grained logging and priority sorting.\n *\n * @enum {number}\n */\nconst RequestType = {\n /**\n * Terrain request.\n *\n * @type {number}\n * @constant\n */\n TERRAIN: 0,\n\n /**\n * Imagery request.\n *\n * @type {number}\n * @constant\n */\n IMAGERY: 1,\n\n /**\n * 3D Tiles request.\n *\n * @type {number}\n * @constant\n */\n TILES3D: 2,\n\n /**\n * Other request.\n *\n * @type {number}\n * @constant\n */\n OTHER: 3,\n};\nexport default Object.freeze(RequestType);\n", "import defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport RequestState from \"./RequestState.js\";\nimport RequestType from \"./RequestType.js\";\n\n/**\n * Stores information for making a request. In general this does not need to be constructed directly.\n *\n * @alias Request\n * @constructor\n\n * @param {object} [options] An object with the following properties:\n * @param {string} [options.url] The url to request.\n * @param {Request.RequestCallback} [options.requestFunction] The function that makes the actual data request.\n * @param {Request.CancelCallback} [options.cancelFunction] The function that is called when the request is cancelled.\n * @param {Request.PriorityCallback} [options.priorityFunction] The function that is called to update the request's priority, which occurs once per frame.\n * @param {number} [options.priority=0.0] The initial priority of the request.\n * @param {boolean} [options.throttle=false] Whether to throttle and prioritize the request. If false, the request will be sent immediately. If true, the request will be throttled and sent based on priority.\n * @param {boolean} [options.throttleByServer=false] Whether to throttle the request by server.\n * @param {RequestType} [options.type=RequestType.OTHER] The type of request.\n * @param {string} [options.serverKey] A key used to identify the server that a request is going to.\n */\nfunction Request(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n const throttleByServer = defaultValue(options.throttleByServer, false);\n const throttle = defaultValue(options.throttle, false);\n\n /**\n * The URL to request.\n *\n * @type {string}\n */\n this.url = options.url;\n\n /**\n * The function that makes the actual data request.\n *\n * @type {Request.RequestCallback}\n */\n this.requestFunction = options.requestFunction;\n\n /**\n * The function that is called when the request is cancelled.\n *\n * @type {Request.CancelCallback}\n */\n this.cancelFunction = options.cancelFunction;\n\n /**\n * The function that is called to update the request's priority, which occurs once per frame.\n *\n * @type {Request.PriorityCallback}\n */\n this.priorityFunction = options.priorityFunction;\n\n /**\n * Priority is a unit-less value where lower values represent higher priority.\n * For world-based objects, this is usually the distance from the camera.\n * A request that does not have a priority function defaults to a priority of 0.\n *\n * If priorityFunction is defined, this value is updated every frame with the result of that call.\n *\n * @type {number}\n * @default 0.0\n */\n this.priority = defaultValue(options.priority, 0.0);\n\n /**\n * Whether to throttle and prioritize the request. If false, the request will be sent immediately. If true, the\n * request will be throttled and sent based on priority.\n *\n * @type {boolean}\n * @readonly\n *\n * @default false\n */\n this.throttle = throttle;\n\n /**\n * Whether to throttle the request by server. Browsers typically support about 6-8 parallel connections\n * for HTTP/1 servers, and an unlimited amount of connections for HTTP/2 servers. Setting this value\n * to true is preferable for requests going through HTTP/1 servers.\n *\n * @type {boolean}\n * @readonly\n *\n * @default false\n */\n this.throttleByServer = throttleByServer;\n\n /**\n * Type of request.\n *\n * @type {RequestType}\n * @readonly\n *\n * @default RequestType.OTHER\n */\n this.type = defaultValue(options.type, RequestType.OTHER);\n\n /**\n * A key used to identify the server that a request is going to. It is derived from the url's authority and scheme.\n *\n * @type {string}\n *\n * @private\n */\n this.serverKey = options.serverKey;\n\n /**\n * The current state of the request.\n *\n * @type {RequestState}\n * @readonly\n */\n this.state = RequestState.UNISSUED;\n\n /**\n * The requests's deferred promise.\n *\n * @type {object}\n *\n * @private\n */\n this.deferred = undefined;\n\n /**\n * Whether the request was explicitly cancelled.\n *\n * @type {boolean}\n *\n * @private\n */\n this.cancelled = false;\n}\n\n/**\n * Mark the request as cancelled.\n *\n * @private\n */\nRequest.prototype.cancel = function () {\n this.cancelled = true;\n};\n\n/**\n * Duplicates a Request instance.\n *\n * @param {Request} [result] The object onto which to store the result.\n *\n * @returns {Request} The modified result parameter or a new Resource instance if one was not provided.\n */\nRequest.prototype.clone = function (result) {\n if (!defined(result)) {\n return new Request(this);\n }\n\n result.url = this.url;\n result.requestFunction = this.requestFunction;\n result.cancelFunction = this.cancelFunction;\n result.priorityFunction = this.priorityFunction;\n result.priority = this.priority;\n result.throttle = this.throttle;\n result.throttleByServer = this.throttleByServer;\n result.type = this.type;\n result.serverKey = this.serverKey;\n\n // These get defaulted because the cloned request hasn't been issued\n result.state = RequestState.UNISSUED;\n result.deferred = undefined;\n result.cancelled = false;\n\n return result;\n};\n\n/**\n * The function that makes the actual data request.\n * @callback Request.RequestCallback\n * @returns {Promise} A promise for the requested data.\n */\n\n/**\n * The function that is called when the request is cancelled.\n * @callback Request.CancelCallback\n */\n\n/**\n * The function that is called to update the request's priority, which occurs once per frame.\n * @callback Request.PriorityCallback\n * @returns {number} The updated priority value.\n */\nexport default Request;\n", "/**\n * Parses the result of XMLHttpRequest's getAllResponseHeaders() method into\n * a dictionary.\n *\n * @function parseResponseHeaders\n *\n * @param {string} headerString The header string returned by getAllResponseHeaders(). The format is\n * described here: http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders()-method\n * @returns {object} A dictionary of key/value pairs, where each key is the name of a header and the corresponding value\n * is that header's value.\n *\n * @private\n */\nfunction parseResponseHeaders(headerString) {\n const headers = {};\n\n if (!headerString) {\n return headers;\n }\n\n const headerPairs = headerString.split(\"\\u000d\\u000a\");\n\n for (let i = 0; i < headerPairs.length; ++i) {\n const headerPair = headerPairs[i];\n // Can't use split() here because it does the wrong thing\n // if the header value has the string \": \" in it.\n const index = headerPair.indexOf(\"\\u003a\\u0020\");\n if (index > 0) {\n const key = headerPair.substring(0, index);\n const val = headerPair.substring(index + 2);\n headers[key] = val;\n }\n }\n\n return headers;\n}\nexport default parseResponseHeaders;\n", "import defined from \"./defined.js\";\nimport parseResponseHeaders from \"./parseResponseHeaders.js\";\n\n/**\n * An event that is raised when a request encounters an error.\n *\n * @constructor\n * @alias RequestErrorEvent\n *\n * @param {number} [statusCode] The HTTP error status code, such as 404.\n * @param {object} [response] The response included along with the error.\n * @param {string|object} [responseHeaders] The response headers, represented either as an object literal or as a\n * string in the format returned by XMLHttpRequest's getAllResponseHeaders() function.\n */\nfunction RequestErrorEvent(statusCode, response, responseHeaders) {\n /**\n * The HTTP error status code, such as 404. If the error does not have a particular\n * HTTP code, this property will be undefined.\n *\n * @type {number}\n */\n this.statusCode = statusCode;\n\n /**\n * The response included along with the error. If the error does not include a response,\n * this property will be undefined.\n *\n * @type {object}\n */\n this.response = response;\n\n /**\n * The headers included in the response, represented as an object literal of key/value pairs.\n * If the error does not include any headers, this property will be undefined.\n *\n * @type {object}\n */\n this.responseHeaders = responseHeaders;\n\n if (typeof this.responseHeaders === \"string\") {\n this.responseHeaders = parseResponseHeaders(this.responseHeaders);\n }\n}\n\n/**\n * Creates a string representing this RequestErrorEvent.\n * @memberof RequestErrorEvent\n *\n * @returns {string} A string representing the provided RequestErrorEvent.\n */\nRequestErrorEvent.prototype.toString = function () {\n let str = \"Request has failed.\";\n if (defined(this.statusCode)) {\n str += ` Status Code: ${this.statusCode}`;\n }\n return str;\n};\nexport default RequestErrorEvent;\n", "import Uri from \"urijs\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defer from \"./defer.js\";\nimport defined from \"./defined.js\";\nimport Event from \"./Event.js\";\nimport Heap from \"./Heap.js\";\nimport isBlobUri from \"./isBlobUri.js\";\nimport isDataUri from \"./isDataUri.js\";\nimport RequestState from \"./RequestState.js\";\n\nfunction sortRequests(a, b) {\n return a.priority - b.priority;\n}\n\nconst statistics = {\n numberOfAttemptedRequests: 0,\n numberOfActiveRequests: 0,\n numberOfCancelledRequests: 0,\n numberOfCancelledActiveRequests: 0,\n numberOfFailedRequests: 0,\n numberOfActiveRequestsEver: 0,\n lastNumberOfActiveRequests: 0,\n};\n\nlet priorityHeapLength = 20;\nconst requestHeap = new Heap({\n comparator: sortRequests,\n});\nrequestHeap.maximumLength = priorityHeapLength;\nrequestHeap.reserve(priorityHeapLength);\n\nconst activeRequests = [];\nlet numberOfActiveRequestsByServer = {};\n\nconst pageUri =\n typeof document !== \"undefined\" ? new Uri(document.location.href) : new Uri();\n\nconst requestCompletedEvent = new Event();\n\n/**\n * The request scheduler is used to track and constrain the number of active requests in order to prioritize incoming requests. The ability\n * to retain control over the number of requests in CesiumJS is important because due to events such as changes in the camera position,\n * a lot of new requests may be generated and a lot of in-flight requests may become redundant. The request scheduler manually constrains the\n * number of requests so that newer requests wait in a shorter queue and don't have to compete for bandwidth with requests that have expired.\n *\n * @namespace RequestScheduler\n *\n */\nfunction RequestScheduler() {}\n\n/**\n * The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit.\n * @type {number}\n * @default 50\n */\nRequestScheduler.maximumRequests = 50;\n\n/**\n * The maximum number of simultaneous active requests per server. Un-throttled requests or servers specifically\n * listed in {@link requestsByServer} do not observe this limit.\n * @type {number}\n * @default 6\n */\nRequestScheduler.maximumRequestsPerServer = 6;\n\n/**\n * A per server key list of overrides to use for throttling instead of maximumRequestsPerServer.\n * Useful when streaming data from a known HTTP/2 or HTTP/3 server.\n * @type {object}\n *\n * @example\n * RequestScheduler.requestsByServer[\"myserver.com:443\"] = 18;\n *\n * @example\n * RequestScheduler.requestsByServer = {\n * \"api.cesium.com:443\": 18,\n * \"assets.cesium.com:443\": 18,\n * };\n */\nRequestScheduler.requestsByServer = {\n \"api.cesium.com:443\": 18,\n \"assets.ion.cesium.com:443\": 18,\n \"ibasemaps-api.arcgis.com:443\": 18,\n \"tile.googleapis.com:443\": 18,\n \"tile.openstreetmap.org:443\": 18,\n};\n\n/**\n * Specifies if the request scheduler should throttle incoming requests, or let the browser queue requests under its control.\n * @type {boolean}\n * @default true\n */\nRequestScheduler.throttleRequests = true;\n\n/**\n * When true, log statistics to the console every frame\n * @type {boolean}\n * @default false\n * @private\n */\nRequestScheduler.debugShowStatistics = false;\n\n/**\n * An event that's raised when a request is completed. Event handlers are passed\n * the error object if the request fails.\n *\n * @type {Event}\n * @default Event()\n * @private\n */\nRequestScheduler.requestCompletedEvent = requestCompletedEvent;\n\nObject.defineProperties(RequestScheduler, {\n /**\n * Returns the statistics used by the request scheduler.\n *\n * @memberof RequestScheduler\n *\n * @type {object}\n * @readonly\n * @private\n */\n statistics: {\n get: function () {\n return statistics;\n },\n },\n\n /**\n * The maximum size of the priority heap. This limits the number of requests that are sorted by priority. Only applies to requests that are not yet active.\n *\n * @memberof RequestScheduler\n *\n * @type {number}\n * @default 20\n * @private\n */\n priorityHeapLength: {\n get: function () {\n return priorityHeapLength;\n },\n set: function (value) {\n // If the new length shrinks the heap, need to cancel some of the requests.\n // Since this value is not intended to be tweaked regularly it is fine to just cancel the high priority requests.\n if (value < priorityHeapLength) {\n while (requestHeap.length > value) {\n const request = requestHeap.pop();\n cancelRequest(request);\n }\n }\n priorityHeapLength = value;\n requestHeap.maximumLength = value;\n requestHeap.reserve(value);\n },\n },\n});\n\nfunction updatePriority(request) {\n if (defined(request.priorityFunction)) {\n request.priority = request.priorityFunction();\n }\n}\n\n/**\n * Check if there are open slots for a particular server key. If desiredRequests is greater than 1, this checks if the queue has room for scheduling multiple requests.\n * @param {string} serverKey The server key returned by {@link RequestScheduler.getServerKey}.\n * @param {number} [desiredRequests=1] How many requests the caller plans to request\n * @return {boolean} True if there are enough open slots for desiredRequests more requests.\n * @private\n */\nRequestScheduler.serverHasOpenSlots = function (serverKey, desiredRequests) {\n desiredRequests = defaultValue(desiredRequests, 1);\n\n const maxRequests = defaultValue(\n RequestScheduler.requestsByServer[serverKey],\n RequestScheduler.maximumRequestsPerServer\n );\n const hasOpenSlotsServer =\n numberOfActiveRequestsByServer[serverKey] + desiredRequests <= maxRequests;\n\n return hasOpenSlotsServer;\n};\n\n/**\n * Check if the priority heap has open slots, regardless of which server they\n * are from. This is used in {@link Multiple3DTileContent} for determining when\n * all requests can be scheduled\n * @param {number} desiredRequests The number of requests the caller intends to make\n * @return {boolean} true if the heap has enough available slots to meet the desiredRequests. false otherwise.\n *\n * @private\n */\nRequestScheduler.heapHasOpenSlots = function (desiredRequests) {\n const hasOpenSlotsHeap =\n requestHeap.length + desiredRequests <= priorityHeapLength;\n return hasOpenSlotsHeap;\n};\n\nfunction issueRequest(request) {\n if (request.state === RequestState.UNISSUED) {\n request.state = RequestState.ISSUED;\n request.deferred = defer();\n }\n return request.deferred.promise;\n}\n\nfunction getRequestReceivedFunction(request) {\n return function (results) {\n if (request.state === RequestState.CANCELLED) {\n // If the data request comes back but the request is cancelled, ignore it.\n return;\n }\n // explicitly set to undefined to ensure GC of request response data. See #8843\n const deferred = request.deferred;\n\n --statistics.numberOfActiveRequests;\n --numberOfActiveRequestsByServer[request.serverKey];\n requestCompletedEvent.raiseEvent();\n request.state = RequestState.RECEIVED;\n request.deferred = undefined;\n\n deferred.resolve(results);\n };\n}\n\nfunction getRequestFailedFunction(request) {\n return function (error) {\n if (request.state === RequestState.CANCELLED) {\n // If the data request comes back but the request is cancelled, ignore it.\n return;\n }\n ++statistics.numberOfFailedRequests;\n --statistics.numberOfActiveRequests;\n --numberOfActiveRequestsByServer[request.serverKey];\n requestCompletedEvent.raiseEvent(error);\n request.state = RequestState.FAILED;\n request.deferred.reject(error);\n };\n}\n\nfunction startRequest(request) {\n const promise = issueRequest(request);\n request.state = RequestState.ACTIVE;\n activeRequests.push(request);\n ++statistics.numberOfActiveRequests;\n ++statistics.numberOfActiveRequestsEver;\n ++numberOfActiveRequestsByServer[request.serverKey];\n request\n .requestFunction()\n .then(getRequestReceivedFunction(request))\n .catch(getRequestFailedFunction(request));\n return promise;\n}\n\nfunction cancelRequest(request) {\n const active = request.state === RequestState.ACTIVE;\n request.state = RequestState.CANCELLED;\n ++statistics.numberOfCancelledRequests;\n // check that deferred has not been cleared since cancelRequest can be called\n // on a finished request, e.g. by clearForSpecs during tests\n if (defined(request.deferred)) {\n const deferred = request.deferred;\n request.deferred = undefined;\n deferred.reject();\n }\n\n if (active) {\n --statistics.numberOfActiveRequests;\n --numberOfActiveRequestsByServer[request.serverKey];\n ++statistics.numberOfCancelledActiveRequests;\n }\n\n if (defined(request.cancelFunction)) {\n request.cancelFunction();\n }\n}\n\n/**\n * Sort requests by priority and start requests.\n * @private\n */\nRequestScheduler.update = function () {\n let i;\n let request;\n\n // Loop over all active requests. Cancelled, failed, or received requests are removed from the array to make room for new requests.\n let removeCount = 0;\n const activeLength = activeRequests.length;\n for (i = 0; i < activeLength; ++i) {\n request = activeRequests[i];\n if (request.cancelled) {\n // Request was explicitly cancelled\n cancelRequest(request);\n }\n if (request.state !== RequestState.ACTIVE) {\n // Request is no longer active, remove from array\n ++removeCount;\n continue;\n }\n if (removeCount > 0) {\n // Shift back to fill in vacated slots from completed requests\n activeRequests[i - removeCount] = request;\n }\n }\n activeRequests.length -= removeCount;\n\n // Update priority of issued requests and resort the heap\n const issuedRequests = requestHeap.internalArray;\n const issuedLength = requestHeap.length;\n for (i = 0; i < issuedLength; ++i) {\n updatePriority(issuedRequests[i]);\n }\n requestHeap.resort();\n\n // Get the number of open slots and fill with the highest priority requests.\n // Un-throttled requests are automatically added to activeRequests, so activeRequests.length may exceed maximumRequests\n const openSlots = Math.max(\n RequestScheduler.maximumRequests - activeRequests.length,\n 0\n );\n let filledSlots = 0;\n while (filledSlots < openSlots && requestHeap.length > 0) {\n // Loop until all open slots are filled or the heap becomes empty\n request = requestHeap.pop();\n if (request.cancelled) {\n // Request was explicitly cancelled\n cancelRequest(request);\n continue;\n }\n\n if (\n request.throttleByServer &&\n !RequestScheduler.serverHasOpenSlots(request.serverKey)\n ) {\n // Open slots are available, but the request is throttled by its server. Cancel and try again later.\n cancelRequest(request);\n continue;\n }\n\n startRequest(request);\n ++filledSlots;\n }\n\n updateStatistics();\n};\n\n/**\n * Get the server key from a given url.\n *\n * @param {string} url The url.\n * @returns {string} The server key.\n * @private\n */\nRequestScheduler.getServerKey = function (url) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.string(\"url\", url);\n //>>includeEnd('debug');\n\n let uri = new Uri(url);\n if (uri.scheme() === \"\") {\n uri = uri.absoluteTo(pageUri);\n uri.normalize();\n }\n\n let serverKey = uri.authority();\n if (!/:/.test(serverKey)) {\n // If the authority does not contain a port number, add port 443 for https or port 80 for http\n serverKey = `${serverKey}:${uri.scheme() === \"https\" ? \"443\" : \"80\"}`;\n }\n\n const length = numberOfActiveRequestsByServer[serverKey];\n if (!defined(length)) {\n numberOfActiveRequestsByServer[serverKey] = 0;\n }\n\n return serverKey;\n};\n\n/**\n * Issue a request. If request.throttle is false, the request is sent immediately. Otherwise the request will be\n * queued and sorted by priority before being sent.\n *\n * @param {Request} request The request object.\n *\n * @returns {Promise|undefined} A Promise for the requested data, or undefined if this request does not have high enough priority to be issued.\n *\n * @private\n */\nRequestScheduler.request = function (request) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"request\", request);\n Check.typeOf.string(\"request.url\", request.url);\n Check.typeOf.func(\"request.requestFunction\", request.requestFunction);\n //>>includeEnd('debug');\n\n if (isDataUri(request.url) || isBlobUri(request.url)) {\n requestCompletedEvent.raiseEvent();\n request.state = RequestState.RECEIVED;\n return request.requestFunction();\n }\n\n ++statistics.numberOfAttemptedRequests;\n\n if (!defined(request.serverKey)) {\n request.serverKey = RequestScheduler.getServerKey(request.url);\n }\n\n if (\n RequestScheduler.throttleRequests &&\n request.throttleByServer &&\n !RequestScheduler.serverHasOpenSlots(request.serverKey)\n ) {\n // Server is saturated. Try again later.\n return undefined;\n }\n\n if (!RequestScheduler.throttleRequests || !request.throttle) {\n return startRequest(request);\n }\n\n if (activeRequests.length >= RequestScheduler.maximumRequests) {\n // Active requests are saturated. Try again later.\n return undefined;\n }\n\n // Insert into the priority heap and see if a request was bumped off. If this request is the lowest\n // priority it will be returned.\n updatePriority(request);\n const removedRequest = requestHeap.insert(request);\n\n if (defined(removedRequest)) {\n if (removedRequest === request) {\n // Request does not have high enough priority to be issued\n return undefined;\n }\n // A previously issued request has been bumped off the priority heap, so cancel it\n cancelRequest(removedRequest);\n }\n\n return issueRequest(request);\n};\n\nfunction updateStatistics() {\n if (!RequestScheduler.debugShowStatistics) {\n return;\n }\n\n if (\n statistics.numberOfActiveRequests === 0 &&\n statistics.lastNumberOfActiveRequests > 0\n ) {\n if (statistics.numberOfAttemptedRequests > 0) {\n console.log(\n `Number of attempted requests: ${statistics.numberOfAttemptedRequests}`\n );\n statistics.numberOfAttemptedRequests = 0;\n }\n\n if (statistics.numberOfCancelledRequests > 0) {\n console.log(\n `Number of cancelled requests: ${statistics.numberOfCancelledRequests}`\n );\n statistics.numberOfCancelledRequests = 0;\n }\n\n if (statistics.numberOfCancelledActiveRequests > 0) {\n console.log(\n `Number of cancelled active requests: ${statistics.numberOfCancelledActiveRequests}`\n );\n statistics.numberOfCancelledActiveRequests = 0;\n }\n\n if (statistics.numberOfFailedRequests > 0) {\n console.log(\n `Number of failed requests: ${statistics.numberOfFailedRequests}`\n );\n statistics.numberOfFailedRequests = 0;\n }\n }\n\n statistics.lastNumberOfActiveRequests = statistics.numberOfActiveRequests;\n}\n\n/**\n * For testing only. Clears any requests that may not have completed from previous tests.\n *\n * @private\n */\nRequestScheduler.clearForSpecs = function () {\n while (requestHeap.length > 0) {\n const request = requestHeap.pop();\n cancelRequest(request);\n }\n const length = activeRequests.length;\n for (let i = 0; i < length; ++i) {\n cancelRequest(activeRequests[i]);\n }\n activeRequests.length = 0;\n numberOfActiveRequestsByServer = {};\n\n // Clear stats\n statistics.numberOfAttemptedRequests = 0;\n statistics.numberOfActiveRequests = 0;\n statistics.numberOfCancelledRequests = 0;\n statistics.numberOfCancelledActiveRequests = 0;\n statistics.numberOfFailedRequests = 0;\n statistics.numberOfActiveRequestsEver = 0;\n statistics.lastNumberOfActiveRequests = 0;\n};\n\n/**\n * For testing only.\n *\n * @private\n */\nRequestScheduler.numberOfActiveRequestsByServer = function (serverKey) {\n return numberOfActiveRequestsByServer[serverKey];\n};\n\n/**\n * For testing only.\n *\n * @private\n */\nRequestScheduler.requestHeap = requestHeap;\nexport default RequestScheduler;\n", "import Check from \"./Check.js\";\nimport defined from \"./defined.js\";\n\n/**\n * A generic utility class for managing subscribers for a particular event.\n * This class is usually instantiated inside of a container class and\n * exposed as a property for others to subscribe to.\n *\n * @alias Event\n * @template Listener extends (...args: any[]) => void = (...args: any[]) => void\n * @constructor\n * @example\n * MyObject.prototype.myListener = function(arg1, arg2) {\n * this.myArg1Copy = arg1;\n * this.myArg2Copy = arg2;\n * }\n *\n * const myObjectInstance = new MyObject();\n * const evt = new Cesium.Event();\n * evt.addEventListener(MyObject.prototype.myListener, myObjectInstance);\n * evt.raiseEvent('1', '2');\n * evt.removeEventListener(MyObject.prototype.myListener);\n */\nfunction Event() {\n this._listeners = [];\n this._scopes = [];\n this._toRemove = [];\n this._insideRaiseEvent = false;\n}\n\nObject.defineProperties(Event.prototype, {\n /**\n * The number of listeners currently subscribed to the event.\n * @memberof Event.prototype\n * @type {number}\n * @readonly\n */\n numberOfListeners: {\n get: function () {\n return this._listeners.length - this._toRemove.length;\n },\n },\n});\n\n/**\n * Registers a callback function to be executed whenever the event is raised.\n * An optional scope can be provided to serve as the this pointer\n * in which the function will execute.\n *\n * @param {Listener} listener The function to be executed when the event is raised.\n * @param {object} [scope] An optional object scope to serve as the this\n * pointer in which the listener function will execute.\n * @returns {Event.RemoveCallback} A function that will remove this event listener when invoked.\n *\n * @see Event#raiseEvent\n * @see Event#removeEventListener\n */\nEvent.prototype.addEventListener = function (listener, scope) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.func(\"listener\", listener);\n //>>includeEnd('debug');\n\n this._listeners.push(listener);\n this._scopes.push(scope);\n\n const event = this;\n return function () {\n event.removeEventListener(listener, scope);\n };\n};\n\n/**\n * Unregisters a previously registered callback.\n *\n * @param {Listener} listener The function to be unregistered.\n * @param {object} [scope] The scope that was originally passed to addEventListener.\n * @returns {boolean} true if the listener was removed; false if the listener and scope are not registered with the event.\n *\n * @see Event#addEventListener\n * @see Event#raiseEvent\n */\nEvent.prototype.removeEventListener = function (listener, scope) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.func(\"listener\", listener);\n //>>includeEnd('debug');\n\n const listeners = this._listeners;\n const scopes = this._scopes;\n\n let index = -1;\n for (let i = 0; i < listeners.length; i++) {\n if (listeners[i] === listener && scopes[i] === scope) {\n index = i;\n break;\n }\n }\n\n if (index !== -1) {\n if (this._insideRaiseEvent) {\n //In order to allow removing an event subscription from within\n //a callback, we don't actually remove the items here. Instead\n //remember the index they are at and undefined their value.\n this._toRemove.push(index);\n listeners[index] = undefined;\n scopes[index] = undefined;\n } else {\n listeners.splice(index, 1);\n scopes.splice(index, 1);\n }\n return true;\n }\n\n return false;\n};\n\nfunction compareNumber(a, b) {\n return b - a;\n}\n\n/**\n * Raises the event by calling each registered listener with all supplied arguments.\n *\n * @param {...Parameters} arguments This method takes any number of parameters and passes them through to the listener functions.\n *\n * @see Event#addEventListener\n * @see Event#removeEventListener\n */\nEvent.prototype.raiseEvent = function () {\n this._insideRaiseEvent = true;\n\n let i;\n const listeners = this._listeners;\n const scopes = this._scopes;\n let length = listeners.length;\n\n for (i = 0; i < length; i++) {\n const listener = listeners[i];\n if (defined(listener)) {\n listeners[i].apply(scopes[i], arguments);\n }\n }\n\n //Actually remove items removed in removeEventListener.\n const toRemove = this._toRemove;\n length = toRemove.length;\n if (length > 0) {\n toRemove.sort(compareNumber);\n for (i = 0; i < length; i++) {\n const index = toRemove[i];\n listeners.splice(index, 1);\n scopes.splice(index, 1);\n }\n toRemove.length = 0;\n }\n\n this._insideRaiseEvent = false;\n};\n\n/**\n * A function that removes a listener.\n * @callback Event.RemoveCallback\n */\n\nexport default Event;\n", "import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\n\n/**\n * Array implementation of a heap.\n *\n * @alias Heap\n * @constructor\n * @private\n *\n * @param {object} options Object with the following properties:\n * @param {Heap.ComparatorCallback} options.comparator The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index.\n */\nfunction Heap(options) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"options\", options);\n Check.defined(\"options.comparator\", options.comparator);\n //>>includeEnd('debug');\n\n this._comparator = options.comparator;\n this._array = [];\n this._length = 0;\n this._maximumLength = undefined;\n}\n\nObject.defineProperties(Heap.prototype, {\n /**\n * Gets the length of the heap.\n *\n * @memberof Heap.prototype\n *\n * @type {number}\n * @readonly\n */\n length: {\n get: function () {\n return this._length;\n },\n },\n\n /**\n * Gets the internal array.\n *\n * @memberof Heap.prototype\n *\n * @type {Array}\n * @readonly\n */\n internalArray: {\n get: function () {\n return this._array;\n },\n },\n\n /**\n * Gets and sets the maximum length of the heap.\n *\n * @memberof Heap.prototype\n *\n * @type {number}\n */\n maximumLength: {\n get: function () {\n return this._maximumLength;\n },\n set: function (value) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.greaterThanOrEquals(\"maximumLength\", value, 0);\n //>>includeEnd('debug');\n const originalLength = this._length;\n if (value < originalLength) {\n const array = this._array;\n // Remove trailing references\n for (let i = value; i < originalLength; ++i) {\n array[i] = undefined;\n }\n this._length = value;\n array.length = value;\n }\n this._maximumLength = value;\n },\n },\n\n /**\n * The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index.\n *\n * @memberof Heap.prototype\n *\n * @type {Heap.ComparatorCallback}\n */\n comparator: {\n get: function () {\n return this._comparator;\n },\n },\n});\n\nfunction swap(array, a, b) {\n const temp = array[a];\n array[a] = array[b];\n array[b] = temp;\n}\n\n/**\n * Resizes the internal array of the heap.\n *\n * @param {number} [length] The length to resize internal array to. Defaults to the current length of the heap.\n */\nHeap.prototype.reserve = function (length) {\n length = defaultValue(length, this._length);\n this._array.length = length;\n};\n\n/**\n * Update the heap so that index and all descendants satisfy the heap property.\n *\n * @param {number} [index=0] The starting index to heapify from.\n */\nHeap.prototype.heapify = function (index) {\n index = defaultValue(index, 0);\n const length = this._length;\n const comparator = this._comparator;\n const array = this._array;\n let candidate = -1;\n let inserting = true;\n\n while (inserting) {\n const right = 2 * (index + 1);\n const left = right - 1;\n\n if (left < length && comparator(array[left], array[index]) < 0) {\n candidate = left;\n } else {\n candidate = index;\n }\n\n if (right < length && comparator(array[right], array[candidate]) < 0) {\n candidate = right;\n }\n if (candidate !== index) {\n swap(array, candidate, index);\n index = candidate;\n } else {\n inserting = false;\n }\n }\n};\n\n/**\n * Resort the heap.\n */\nHeap.prototype.resort = function () {\n const length = this._length;\n for (let i = Math.ceil(length / 2); i >= 0; --i) {\n this.heapify(i);\n }\n};\n\n/**\n * Insert an element into the heap. If the length would grow greater than maximumLength\n * of the heap, extra elements are removed.\n *\n * @param {*} element The element to insert\n *\n * @return {*} The element that was removed from the heap if the heap is at full capacity.\n */\nHeap.prototype.insert = function (element) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"element\", element);\n //>>includeEnd('debug');\n\n const array = this._array;\n const comparator = this._comparator;\n const maximumLength = this._maximumLength;\n\n let index = this._length++;\n if (index < array.length) {\n array[index] = element;\n } else {\n array.push(element);\n }\n\n while (index !== 0) {\n const parent = Math.floor((index - 1) / 2);\n if (comparator(array[index], array[parent]) < 0) {\n swap(array, index, parent);\n index = parent;\n } else {\n break;\n }\n }\n\n let removedElement;\n\n if (defined(maximumLength) && this._length > maximumLength) {\n removedElement = array[maximumLength];\n this._length = maximumLength;\n }\n\n return removedElement;\n};\n\n/**\n * Remove the element specified by index from the heap and return it.\n *\n * @param {number} [index=0] The index to remove.\n * @returns {*} The specified element of the heap.\n */\nHeap.prototype.pop = function (index) {\n index = defaultValue(index, 0);\n if (this._length === 0) {\n return undefined;\n }\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number.lessThan(\"index\", index, this._length);\n //>>includeEnd('debug');\n\n const array = this._array;\n const root = array[index];\n swap(array, index, --this._length);\n this.heapify(index);\n array[this._length] = undefined; // Remove trailing reference\n return root;\n};\n\n/**\n * The comparator to use for the heap.\n * @callback Heap.ComparatorCallback\n * @param {*} a An element in the heap.\n * @param {*} b An element in the heap.\n * @returns {number} If the result of the comparison is less than 0, sort a to a lower index than b, otherwise sort to a higher index.\n */\nexport default Heap;\n", "import Uri from \"urijs\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * A singleton that contains all of the servers that are trusted. Credentials will be sent with\n * any requests to these servers.\n *\n * @namespace TrustedServers\n *\n * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}\n */\nconst TrustedServers = {};\nlet _servers = {};\n\n/**\n * Adds a trusted server to the registry\n *\n * @param {string} host The host to be added.\n * @param {number} port The port used to access the host.\n *\n * @example\n * // Add a trusted server\n * TrustedServers.add('my.server.com', 80);\n */\nTrustedServers.add = function (host, port) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(host)) {\n throw new DeveloperError(\"host is required.\");\n }\n if (!defined(port) || port <= 0) {\n throw new DeveloperError(\"port is required to be greater than 0.\");\n }\n //>>includeEnd('debug');\n\n const authority = `${host.toLowerCase()}:${port}`;\n if (!defined(_servers[authority])) {\n _servers[authority] = true;\n }\n};\n\n/**\n * Removes a trusted server from the registry\n *\n * @param {string} host The host to be removed.\n * @param {number} port The port used to access the host.\n *\n * @example\n * // Remove a trusted server\n * TrustedServers.remove('my.server.com', 80);\n */\nTrustedServers.remove = function (host, port) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(host)) {\n throw new DeveloperError(\"host is required.\");\n }\n if (!defined(port) || port <= 0) {\n throw new DeveloperError(\"port is required to be greater than 0.\");\n }\n //>>includeEnd('debug');\n\n const authority = `${host.toLowerCase()}:${port}`;\n if (defined(_servers[authority])) {\n delete _servers[authority];\n }\n};\n\nfunction getAuthority(url) {\n const uri = new Uri(url);\n uri.normalize();\n\n // Removes username:password@ so we just have host[:port]\n let authority = uri.authority();\n if (authority.length === 0) {\n return undefined; // Relative URL\n }\n uri.authority(authority);\n\n if (authority.indexOf(\"@\") !== -1) {\n const parts = authority.split(\"@\");\n authority = parts[1];\n }\n\n // If the port is missing add one based on the scheme\n if (authority.indexOf(\":\") === -1) {\n let scheme = uri.scheme();\n if (scheme.length === 0) {\n scheme = window.location.protocol;\n scheme = scheme.substring(0, scheme.length - 1);\n }\n if (scheme === \"http\") {\n authority += \":80\";\n } else if (scheme === \"https\") {\n authority += \":443\";\n } else {\n return undefined;\n }\n }\n\n return authority;\n}\n\n/**\n * Tests whether a server is trusted or not. The server must have been added with the port if it is included in the url.\n *\n * @param {string} url The url to be tested against the trusted list\n *\n * @returns {boolean} Returns true if url is trusted, false otherwise.\n *\n * @example\n * // Add server\n * TrustedServers.add('my.server.com', 81);\n *\n * // Check if server is trusted\n * if (TrustedServers.contains('https://my.server.com:81/path/to/file.png')) {\n * // my.server.com:81 is trusted\n * }\n * if (TrustedServers.contains('https://my.server.com/path/to/file.png')) {\n * // my.server.com isn't trusted\n * }\n */\nTrustedServers.contains = function (url) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(url)) {\n throw new DeveloperError(\"url is required.\");\n }\n //>>includeEnd('debug');\n const authority = getAuthority(url);\n if (defined(authority) && defined(_servers[authority])) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Clears the registry\n *\n * @example\n * // Remove a trusted server\n * TrustedServers.clear();\n */\nTrustedServers.clear = function () {\n _servers = {};\n};\nexport default TrustedServers;\n", "import binarySearch from \"./binarySearch.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport EarthOrientationParametersSample from \"./EarthOrientationParametersSample.js\";\nimport JulianDate from \"./JulianDate.js\";\nimport LeapSecond from \"./LeapSecond.js\";\nimport Resource from \"./Resource.js\";\nimport RuntimeError from \"./RuntimeError.js\";\nimport TimeConstants from \"./TimeConstants.js\";\nimport TimeStandard from \"./TimeStandard.js\";\n\n/**\n * Specifies Earth polar motion coordinates and the difference between UT1 and UTC.\n * These Earth Orientation Parameters (EOP) are primarily used in the transformation from\n * the International Celestial Reference Frame (ICRF) to the International Terrestrial\n * Reference Frame (ITRF).\n * This object is normally not instantiated directly, use {@link EarthOrientationParameters.fromUrl}.\n *\n * @alias EarthOrientationParameters\n * @constructor\n *\n * @param {object} [options] Object with the following properties:\n * @param {object} [options.data] The actual EOP data. If neither this\n * parameter nor options.data is specified, all EOP values are assumed\n * to be 0.0.\n * @param {boolean} [options.addNewLeapSeconds=true] True if leap seconds that\n * are specified in the EOP data but not in {@link JulianDate.leapSeconds}\n * should be added to {@link JulianDate.leapSeconds}. False if\n * new leap seconds should be handled correctly in the context\n * of the EOP data but otherwise ignored.\n *\n * @private\n */\nfunction EarthOrientationParameters(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n this._dates = undefined;\n this._samples = undefined;\n\n this._dateColumn = -1;\n this._xPoleWanderRadiansColumn = -1;\n this._yPoleWanderRadiansColumn = -1;\n this._ut1MinusUtcSecondsColumn = -1;\n this._xCelestialPoleOffsetRadiansColumn = -1;\n this._yCelestialPoleOffsetRadiansColumn = -1;\n this._taiMinusUtcSecondsColumn = -1;\n\n this._columnCount = 0;\n this._lastIndex = -1;\n\n this._addNewLeapSeconds = defaultValue(options.addNewLeapSeconds, true);\n\n if (defined(options.data)) {\n // Use supplied EOP data.\n onDataReady(this, options.data);\n } else {\n // Use all zeros for EOP data.\n onDataReady(this, {\n columnNames: [\n \"dateIso8601\",\n \"modifiedJulianDateUtc\",\n \"xPoleWanderRadians\",\n \"yPoleWanderRadians\",\n \"ut1MinusUtcSeconds\",\n \"lengthOfDayCorrectionSeconds\",\n \"xCelestialPoleOffsetRadians\",\n \"yCelestialPoleOffsetRadians\",\n \"taiMinusUtcSeconds\",\n ],\n samples: [],\n });\n }\n}\n\n/**\n *\n * @param {Resource|string} [url] The URL from which to obtain EOP data. If neither this\n * parameter nor options.data is specified, all EOP values are assumed\n * to be 0.0. If options.data is specified, this parameter is\n * ignored.\n * @param {object} [options] Object with the following properties:\n * @param {boolean} [options.addNewLeapSeconds=true] True if leap seconds that\n * are specified in the EOP data but not in {@link JulianDate.leapSeconds}\n * should be added to {@link JulianDate.leapSeconds}. False if\n * new leap seconds should be handled correctly in the context\n * of the EOP data but otherwise ignored.\n *\n * @example\n * // An example EOP data file, EOP.json:\n * {\n * \"columnNames\" : [\"dateIso8601\",\"modifiedJulianDateUtc\",\"xPoleWanderRadians\",\"yPoleWanderRadians\",\"ut1MinusUtcSeconds\",\"lengthOfDayCorrectionSeconds\",\"xCelestialPoleOffsetRadians\",\"yCelestialPoleOffsetRadians\",\"taiMinusUtcSeconds\"],\n * \"samples\" : [\n * \"2011-07-01T00:00:00Z\",55743.0,2.117957047295119e-7,2.111518721609984e-6,-0.2908948,-2.956e-4,3.393695767766752e-11,3.3452143996557983e-10,34.0,\n * \"2011-07-02T00:00:00Z\",55744.0,2.193297093339541e-7,2.115460256837405e-6,-0.29065,-1.824e-4,-8.241832578862112e-11,5.623838700870617e-10,34.0,\n * \"2011-07-03T00:00:00Z\",55745.0,2.262286080161428e-7,2.1191157519929706e-6,-0.2905572,1.9e-6,-3.490658503988659e-10,6.981317007977318e-10,34.0\n * ]\n * }\n *\n * @example\n * // Loading the EOP data\n * const eop = await Cesium.EarthOrientationParameters.fromUrl('Data/EOP.json');\n * Cesium.Transforms.earthOrientationParameters = eop;\n */\nEarthOrientationParameters.fromUrl = async function (url, options) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"url\", url);\n //>>includeEnd('debug');\n\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n const resource = Resource.createIfNeeded(url);\n\n // Download EOP data.\n let eopData;\n try {\n eopData = await resource.fetchJson();\n } catch (e) {\n throw new RuntimeError(\n `An error occurred while retrieving the EOP data from the URL ${resource.url}.`\n );\n }\n\n return new EarthOrientationParameters({\n addNewLeapSeconds: options.addNewLeapSeconds,\n data: eopData,\n });\n};\n\n/**\n * A default {@link EarthOrientationParameters} instance that returns zero for all EOP values.\n */\nEarthOrientationParameters.NONE = Object.freeze({\n compute: function (date, result) {\n if (!defined(result)) {\n result = new EarthOrientationParametersSample(0.0, 0.0, 0.0, 0.0, 0.0);\n } else {\n result.xPoleWander = 0.0;\n result.yPoleWander = 0.0;\n result.xPoleOffset = 0.0;\n result.yPoleOffset = 0.0;\n result.ut1MinusUtc = 0.0;\n }\n return result;\n },\n});\n\n/**\n * Computes the Earth Orientation Parameters (EOP) for a given date by interpolating.\n * If the EOP data has not yet been download, this method returns undefined.\n *\n * @param {JulianDate} date The date for each to evaluate the EOP.\n * @param {EarthOrientationParametersSample} [result] The instance to which to copy the result.\n * If this parameter is undefined, a new instance is created and returned.\n * @returns {EarthOrientationParametersSample} The EOP evaluated at the given date, or\n * undefined if the data necessary to evaluate EOP at the date has not yet been\n * downloaded.\n *\n * @exception {RuntimeError} The loaded EOP data has an error and cannot be used.\n *\n * @see EarthOrientationParameters#fromUrl\n */\nEarthOrientationParameters.prototype.compute = function (date, result) {\n // We cannot compute until the samples are available.\n if (!defined(this._samples)) {\n return undefined;\n }\n\n if (!defined(result)) {\n result = new EarthOrientationParametersSample(0.0, 0.0, 0.0, 0.0, 0.0);\n }\n\n if (this._samples.length === 0) {\n result.xPoleWander = 0.0;\n result.yPoleWander = 0.0;\n result.xPoleOffset = 0.0;\n result.yPoleOffset = 0.0;\n result.ut1MinusUtc = 0.0;\n return result;\n }\n\n const dates = this._dates;\n const lastIndex = this._lastIndex;\n\n let before = 0;\n let after = 0;\n if (defined(lastIndex)) {\n const previousIndexDate = dates[lastIndex];\n const nextIndexDate = dates[lastIndex + 1];\n const isAfterPrevious = JulianDate.lessThanOrEquals(\n previousIndexDate,\n date\n );\n const isAfterLastSample = !defined(nextIndexDate);\n const isBeforeNext =\n isAfterLastSample || JulianDate.greaterThanOrEquals(nextIndexDate, date);\n\n if (isAfterPrevious && isBeforeNext) {\n before = lastIndex;\n\n if (!isAfterLastSample && nextIndexDate.equals(date)) {\n ++before;\n }\n after = before + 1;\n\n interpolate(this, dates, this._samples, date, before, after, result);\n return result;\n }\n }\n\n let index = binarySearch(dates, date, JulianDate.compare, this._dateColumn);\n if (index >= 0) {\n // If the next entry is the same date, use the later entry. This way, if two entries\n // describe the same moment, one before a leap second and the other after, then we will use\n // the post-leap second data.\n if (index < dates.length - 1 && dates[index + 1].equals(date)) {\n ++index;\n }\n before = index;\n after = index;\n } else {\n after = ~index;\n before = after - 1;\n\n // Use the first entry if the date requested is before the beginning of the data.\n if (before < 0) {\n before = 0;\n }\n }\n\n this._lastIndex = before;\n\n interpolate(this, dates, this._samples, date, before, after, result);\n return result;\n};\n\nfunction compareLeapSecondDates(leapSecond, dateToFind) {\n return JulianDate.compare(leapSecond.julianDate, dateToFind);\n}\n\nfunction onDataReady(eop, eopData) {\n if (!defined(eopData.columnNames)) {\n throw new RuntimeError(\n \"Error in loaded EOP data: The columnNames property is required.\"\n );\n }\n\n if (!defined(eopData.samples)) {\n throw new RuntimeError(\n \"Error in loaded EOP data: The samples property is required.\"\n );\n }\n\n const dateColumn = eopData.columnNames.indexOf(\"modifiedJulianDateUtc\");\n const xPoleWanderRadiansColumn = eopData.columnNames.indexOf(\n \"xPoleWanderRadians\"\n );\n const yPoleWanderRadiansColumn = eopData.columnNames.indexOf(\n \"yPoleWanderRadians\"\n );\n const ut1MinusUtcSecondsColumn = eopData.columnNames.indexOf(\n \"ut1MinusUtcSeconds\"\n );\n const xCelestialPoleOffsetRadiansColumn = eopData.columnNames.indexOf(\n \"xCelestialPoleOffsetRadians\"\n );\n const yCelestialPoleOffsetRadiansColumn = eopData.columnNames.indexOf(\n \"yCelestialPoleOffsetRadians\"\n );\n const taiMinusUtcSecondsColumn = eopData.columnNames.indexOf(\n \"taiMinusUtcSeconds\"\n );\n\n if (\n dateColumn < 0 ||\n xPoleWanderRadiansColumn < 0 ||\n yPoleWanderRadiansColumn < 0 ||\n ut1MinusUtcSecondsColumn < 0 ||\n xCelestialPoleOffsetRadiansColumn < 0 ||\n yCelestialPoleOffsetRadiansColumn < 0 ||\n taiMinusUtcSecondsColumn < 0\n ) {\n throw new RuntimeError(\n \"Error in loaded EOP data: The columnNames property must include modifiedJulianDateUtc, xPoleWanderRadians, yPoleWanderRadians, ut1MinusUtcSeconds, xCelestialPoleOffsetRadians, yCelestialPoleOffsetRadians, and taiMinusUtcSeconds columns\"\n );\n }\n\n const samples = (eop._samples = eopData.samples);\n const dates = (eop._dates = []);\n\n eop._dateColumn = dateColumn;\n eop._xPoleWanderRadiansColumn = xPoleWanderRadiansColumn;\n eop._yPoleWanderRadiansColumn = yPoleWanderRadiansColumn;\n eop._ut1MinusUtcSecondsColumn = ut1MinusUtcSecondsColumn;\n eop._xCelestialPoleOffsetRadiansColumn = xCelestialPoleOffsetRadiansColumn;\n eop._yCelestialPoleOffsetRadiansColumn = yCelestialPoleOffsetRadiansColumn;\n eop._taiMinusUtcSecondsColumn = taiMinusUtcSecondsColumn;\n\n eop._columnCount = eopData.columnNames.length;\n eop._lastIndex = undefined;\n\n let lastTaiMinusUtc;\n\n const addNewLeapSeconds = eop._addNewLeapSeconds;\n\n // Convert the ISO8601 dates to JulianDates.\n for (let i = 0, len = samples.length; i < len; i += eop._columnCount) {\n const mjd = samples[i + dateColumn];\n const taiMinusUtc = samples[i + taiMinusUtcSecondsColumn];\n const day = mjd + TimeConstants.MODIFIED_JULIAN_DATE_DIFFERENCE;\n const date = new JulianDate(day, taiMinusUtc, TimeStandard.TAI);\n dates.push(date);\n\n if (addNewLeapSeconds) {\n if (taiMinusUtc !== lastTaiMinusUtc && defined(lastTaiMinusUtc)) {\n // We crossed a leap second boundary, so add the leap second\n // if it does not already exist.\n const leapSeconds = JulianDate.leapSeconds;\n const leapSecondIndex = binarySearch(\n leapSeconds,\n date,\n compareLeapSecondDates\n );\n if (leapSecondIndex < 0) {\n const leapSecond = new LeapSecond(date, taiMinusUtc);\n leapSeconds.splice(~leapSecondIndex, 0, leapSecond);\n }\n }\n lastTaiMinusUtc = taiMinusUtc;\n }\n }\n}\n\nfunction fillResultFromIndex(eop, samples, index, columnCount, result) {\n const start = index * columnCount;\n result.xPoleWander = samples[start + eop._xPoleWanderRadiansColumn];\n result.yPoleWander = samples[start + eop._yPoleWanderRadiansColumn];\n result.xPoleOffset = samples[start + eop._xCelestialPoleOffsetRadiansColumn];\n result.yPoleOffset = samples[start + eop._yCelestialPoleOffsetRadiansColumn];\n result.ut1MinusUtc = samples[start + eop._ut1MinusUtcSecondsColumn];\n}\n\nfunction linearInterp(dx, y1, y2) {\n return y1 + dx * (y2 - y1);\n}\n\nfunction interpolate(eop, dates, samples, date, before, after, result) {\n const columnCount = eop._columnCount;\n\n // First check the bounds on the EOP data\n // If we are after the bounds of the data, return zeros.\n // The 'before' index should never be less than zero.\n if (after > dates.length - 1) {\n result.xPoleWander = 0;\n result.yPoleWander = 0;\n result.xPoleOffset = 0;\n result.yPoleOffset = 0;\n result.ut1MinusUtc = 0;\n return result;\n }\n\n const beforeDate = dates[before];\n const afterDate = dates[after];\n if (beforeDate.equals(afterDate) || date.equals(beforeDate)) {\n fillResultFromIndex(eop, samples, before, columnCount, result);\n return result;\n } else if (date.equals(afterDate)) {\n fillResultFromIndex(eop, samples, after, columnCount, result);\n return result;\n }\n\n const factor =\n JulianDate.secondsDifference(date, beforeDate) /\n JulianDate.secondsDifference(afterDate, beforeDate);\n\n const startBefore = before * columnCount;\n const startAfter = after * columnCount;\n\n // Handle UT1 leap second edge case\n let beforeUt1MinusUtc = samples[startBefore + eop._ut1MinusUtcSecondsColumn];\n let afterUt1MinusUtc = samples[startAfter + eop._ut1MinusUtcSecondsColumn];\n\n const offsetDifference = afterUt1MinusUtc - beforeUt1MinusUtc;\n if (offsetDifference > 0.5 || offsetDifference < -0.5) {\n // The absolute difference between the values is more than 0.5, so we may have\n // crossed a leap second. Check if this is the case and, if so, adjust the\n // afterValue to account for the leap second. This way, our interpolation will\n // produce reasonable results.\n const beforeTaiMinusUtc =\n samples[startBefore + eop._taiMinusUtcSecondsColumn];\n const afterTaiMinusUtc =\n samples[startAfter + eop._taiMinusUtcSecondsColumn];\n if (beforeTaiMinusUtc !== afterTaiMinusUtc) {\n if (afterDate.equals(date)) {\n // If we are at the end of the leap second interval, take the second value\n // Otherwise, the interpolation below will yield the wrong side of the\n // discontinuity\n // At the end of the leap second, we need to start accounting for the jump\n beforeUt1MinusUtc = afterUt1MinusUtc;\n } else {\n // Otherwise, remove the leap second so that the interpolation is correct\n afterUt1MinusUtc -= afterTaiMinusUtc - beforeTaiMinusUtc;\n }\n }\n }\n\n result.xPoleWander = linearInterp(\n factor,\n samples[startBefore + eop._xPoleWanderRadiansColumn],\n samples[startAfter + eop._xPoleWanderRadiansColumn]\n );\n result.yPoleWander = linearInterp(\n factor,\n samples[startBefore + eop._yPoleWanderRadiansColumn],\n samples[startAfter + eop._yPoleWanderRadiansColumn]\n );\n result.xPoleOffset = linearInterp(\n factor,\n samples[startBefore + eop._xCelestialPoleOffsetRadiansColumn],\n samples[startAfter + eop._xCelestialPoleOffsetRadiansColumn]\n );\n result.yPoleOffset = linearInterp(\n factor,\n samples[startBefore + eop._yCelestialPoleOffsetRadiansColumn],\n samples[startAfter + eop._yCelestialPoleOffsetRadiansColumn]\n );\n result.ut1MinusUtc = linearInterp(\n factor,\n beforeUt1MinusUtc,\n afterUt1MinusUtc\n );\n return result;\n}\n\nexport default EarthOrientationParameters;\n", "import defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\n\n/**\n * A rotation expressed as a heading, pitch, and roll. Heading is the rotation about the\n * negative z axis. Pitch is the rotation about the negative y axis. Roll is the rotation about\n * the positive x axis.\n * @alias HeadingPitchRoll\n * @constructor\n *\n * @param {number} [heading=0.0] The heading component in radians.\n * @param {number} [pitch=0.0] The pitch component in radians.\n * @param {number} [roll=0.0] The roll component in radians.\n */\nfunction HeadingPitchRoll(heading, pitch, roll) {\n /**\n * Gets or sets the heading.\n * @type {number}\n * @default 0.0\n */\n this.heading = defaultValue(heading, 0.0);\n /**\n * Gets or sets the pitch.\n * @type {number}\n * @default 0.0\n */\n this.pitch = defaultValue(pitch, 0.0);\n /**\n * Gets or sets the roll.\n * @type {number}\n * @default 0.0\n */\n this.roll = defaultValue(roll, 0.0);\n}\n\n/**\n * Computes the heading, pitch and roll from a quaternion (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles )\n *\n * @param {Quaternion} quaternion The quaternion from which to retrieve heading, pitch, and roll, all expressed in radians.\n * @param {HeadingPitchRoll} [result] The object in which to store the result. If not provided, a new instance is created and returned.\n * @returns {HeadingPitchRoll} The modified result parameter or a new HeadingPitchRoll instance if one was not provided.\n */\nHeadingPitchRoll.fromQuaternion = function (quaternion, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(quaternion)) {\n throw new DeveloperError(\"quaternion is required\");\n }\n //>>includeEnd('debug');\n if (!defined(result)) {\n result = new HeadingPitchRoll();\n }\n const test = 2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x);\n const denominatorRoll =\n 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y);\n const numeratorRoll =\n 2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z);\n const denominatorHeading =\n 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z);\n const numeratorHeading =\n 2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y);\n result.heading = -Math.atan2(numeratorHeading, denominatorHeading);\n result.roll = Math.atan2(numeratorRoll, denominatorRoll);\n result.pitch = -CesiumMath.asinClamped(test);\n return result;\n};\n\n/**\n * Returns a new HeadingPitchRoll instance from angles given in degrees.\n *\n * @param {number} heading the heading in degrees\n * @param {number} pitch the pitch in degrees\n * @param {number} roll the heading in degrees\n * @param {HeadingPitchRoll} [result] The object in which to store the result. If not provided, a new instance is created and returned.\n * @returns {HeadingPitchRoll} A new HeadingPitchRoll instance\n */\nHeadingPitchRoll.fromDegrees = function (heading, pitch, roll, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(heading)) {\n throw new DeveloperError(\"heading is required\");\n }\n if (!defined(pitch)) {\n throw new DeveloperError(\"pitch is required\");\n }\n if (!defined(roll)) {\n throw new DeveloperError(\"roll is required\");\n }\n //>>includeEnd('debug');\n if (!defined(result)) {\n result = new HeadingPitchRoll();\n }\n result.heading = heading * CesiumMath.RADIANS_PER_DEGREE;\n result.pitch = pitch * CesiumMath.RADIANS_PER_DEGREE;\n result.roll = roll * CesiumMath.RADIANS_PER_DEGREE;\n return result;\n};\n\n/**\n * Duplicates a HeadingPitchRoll instance.\n *\n * @param {HeadingPitchRoll} headingPitchRoll The HeadingPitchRoll to duplicate.\n * @param {HeadingPitchRoll} [result] The object onto which to store the result.\n * @returns {HeadingPitchRoll} The modified result parameter or a new HeadingPitchRoll instance if one was not provided. (Returns undefined if headingPitchRoll is undefined)\n */\nHeadingPitchRoll.clone = function (headingPitchRoll, result) {\n if (!defined(headingPitchRoll)) {\n return undefined;\n }\n if (!defined(result)) {\n return new HeadingPitchRoll(\n headingPitchRoll.heading,\n headingPitchRoll.pitch,\n headingPitchRoll.roll\n );\n }\n result.heading = headingPitchRoll.heading;\n result.pitch = headingPitchRoll.pitch;\n result.roll = headingPitchRoll.roll;\n return result;\n};\n\n/**\n * Compares the provided HeadingPitchRolls componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {HeadingPitchRoll} [left] The first HeadingPitchRoll.\n * @param {HeadingPitchRoll} [right] The second HeadingPitchRoll.\n * @returns {boolean} true if left and right are equal, false otherwise.\n */\nHeadingPitchRoll.equals = function (left, right) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n left.heading === right.heading &&\n left.pitch === right.pitch &&\n left.roll === right.roll)\n );\n};\n\n/**\n * Compares the provided HeadingPitchRolls componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {HeadingPitchRoll} [left] The first HeadingPitchRoll.\n * @param {HeadingPitchRoll} [right] The second HeadingPitchRoll.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if left and right are within the provided epsilon, false otherwise.\n */\nHeadingPitchRoll.equalsEpsilon = function (\n left,\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return (\n left === right ||\n (defined(left) &&\n defined(right) &&\n CesiumMath.equalsEpsilon(\n left.heading,\n right.heading,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.pitch,\n right.pitch,\n relativeEpsilon,\n absoluteEpsilon\n ) &&\n CesiumMath.equalsEpsilon(\n left.roll,\n right.roll,\n relativeEpsilon,\n absoluteEpsilon\n ))\n );\n};\n\n/**\n * Duplicates this HeadingPitchRoll instance.\n *\n * @param {HeadingPitchRoll} [result] The object onto which to store the result.\n * @returns {HeadingPitchRoll} The modified result parameter or a new HeadingPitchRoll instance if one was not provided.\n */\nHeadingPitchRoll.prototype.clone = function (result) {\n return HeadingPitchRoll.clone(this, result);\n};\n\n/**\n * Compares this HeadingPitchRoll against the provided HeadingPitchRoll componentwise and returns\n * true if they are equal, false otherwise.\n *\n * @param {HeadingPitchRoll} [right] The right hand side HeadingPitchRoll.\n * @returns {boolean} true if they are equal, false otherwise.\n */\nHeadingPitchRoll.prototype.equals = function (right) {\n return HeadingPitchRoll.equals(this, right);\n};\n\n/**\n * Compares this HeadingPitchRoll against the provided HeadingPitchRoll componentwise and returns\n * true if they pass an absolute or relative tolerance test,\n * false otherwise.\n *\n * @param {HeadingPitchRoll} [right] The right hand side HeadingPitchRoll.\n * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.\n * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.\n * @returns {boolean} true if they are within the provided epsilon, false otherwise.\n */\nHeadingPitchRoll.prototype.equalsEpsilon = function (\n right,\n relativeEpsilon,\n absoluteEpsilon\n) {\n return HeadingPitchRoll.equalsEpsilon(\n this,\n right,\n relativeEpsilon,\n absoluteEpsilon\n );\n};\n\n/**\n * Creates a string representing this HeadingPitchRoll in the format '(heading, pitch, roll)' in radians.\n *\n * @returns {string} A string representing the provided HeadingPitchRoll in the format '(heading, pitch, roll)'.\n */\nHeadingPitchRoll.prototype.toString = function () {\n return `(${this.heading}, ${this.pitch}, ${this.roll})`;\n};\nexport default HeadingPitchRoll;\n", "import defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport getAbsoluteUri from \"./getAbsoluteUri.js\";\nimport Resource from \"./Resource.js\";\n\n/*global CESIUM_BASE_URL,define,require*/\n\nconst cesiumScriptRegex = /((?:.*\\/)|^)Cesium\\.js(?:\\?|\\#|$)/;\nfunction getBaseUrlFromCesiumScript() {\n const scripts = document.getElementsByTagName(\"script\");\n for (let i = 0, len = scripts.length; i < len; ++i) {\n const src = scripts[i].getAttribute(\"src\");\n const result = cesiumScriptRegex.exec(src);\n if (result !== null) {\n return result[1];\n }\n }\n return undefined;\n}\n\nlet a;\nfunction tryMakeAbsolute(url) {\n if (typeof document === \"undefined\") {\n //Node.js and Web Workers. In both cases, the URL will already be absolute.\n return url;\n }\n\n if (!defined(a)) {\n a = document.createElement(\"a\");\n }\n a.href = url;\n\n // IE only absolutizes href on get, not set\n // eslint-disable-next-line no-self-assign\n a.href = a.href;\n return a.href;\n}\n\nlet baseResource;\nfunction getCesiumBaseUrl() {\n if (defined(baseResource)) {\n return baseResource;\n }\n\n let baseUrlString;\n if (typeof CESIUM_BASE_URL !== \"undefined\") {\n baseUrlString = CESIUM_BASE_URL;\n } else if (\n typeof define === \"object\" &&\n defined(define.amd) &&\n !define.amd.toUrlUndefined &&\n defined(require.toUrl)\n ) {\n baseUrlString = getAbsoluteUri(\n \"..\",\n buildModuleUrl(\"Core/buildModuleUrl.js\")\n );\n } else {\n baseUrlString = getBaseUrlFromCesiumScript();\n }\n\n //>>includeStart('debug', pragmas.debug);\n if (!defined(baseUrlString)) {\n throw new DeveloperError(\n \"Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL.\"\n );\n }\n //>>includeEnd('debug');\n\n baseResource = new Resource({\n url: tryMakeAbsolute(baseUrlString),\n });\n baseResource.appendForwardSlash();\n\n return baseResource;\n}\n\nfunction buildModuleUrlFromRequireToUrl(moduleID) {\n //moduleID will be non-relative, so require it relative to this module, in Core.\n return tryMakeAbsolute(require.toUrl(`../${moduleID}`));\n}\n\nfunction buildModuleUrlFromBaseUrl(moduleID) {\n const resource = getCesiumBaseUrl().getDerivedResource({\n url: moduleID,\n });\n return resource.url;\n}\n\nlet implementation;\n\n/**\n * Given a relative URL under the Cesium base URL, returns an absolute URL.\n * @function\n *\n * @param {string} relativeUrl The relative path.\n * @returns {string} The absolutely URL representation of the provided path.\n *\n * @example\n * const viewer = new Cesium.Viewer(\"cesiumContainer\", {\n * baseLayer: Cesium.ImageryLayer.fromProviderAsync(\n * Cesium.TileMapServiceImageryProvider.fromUrl(\n * Cesium.buildModuleUrl(\"Assets/Textures/NaturalEarthII\"),\n * )),\n * baseLayerPicker: false,\n * });\n */\nfunction buildModuleUrl(relativeUrl) {\n if (!defined(implementation)) {\n //select implementation\n if (\n typeof define === \"object\" &&\n defined(define.amd) &&\n !define.amd.toUrlUndefined &&\n defined(require.toUrl)\n ) {\n implementation = buildModuleUrlFromRequireToUrl;\n } else {\n implementation = buildModuleUrlFromBaseUrl;\n }\n }\n\n const url = implementation(relativeUrl);\n return url;\n}\n\n// exposed for testing\nbuildModuleUrl._cesiumScriptRegex = cesiumScriptRegex;\nbuildModuleUrl._buildModuleUrlFromBaseUrl = buildModuleUrlFromBaseUrl;\nbuildModuleUrl._clearBaseResource = function () {\n baseResource = undefined;\n};\n\n/**\n * Sets the base URL for resolving modules.\n * @param {string} value The new base URL.\n */\nbuildModuleUrl.setBaseUrl = function (value) {\n baseResource = Resource.DEFAULT.getDerivedResource({\n url: value,\n });\n};\n\n/**\n * Gets the base URL for resolving modules.\n *\n * @function\n * @returns {string} The configured base URL\n */\nbuildModuleUrl.getCesiumBaseUrl = getCesiumBaseUrl;\n\nexport default buildModuleUrl;\n", "/**\n * An IAU 2006 XYS value sampled at a particular time.\n *\n * @alias Iau2006XysSample\n * @constructor\n *\n * @param {number} x The X value.\n * @param {number} y The Y value.\n * @param {number} s The S value.\n *\n * @private\n */\nfunction Iau2006XysSample(x, y, s) {\n /**\n * The X value.\n * @type {number}\n */\n this.x = x;\n\n /**\n * The Y value.\n * @type {number}\n */\n this.y = y;\n\n /**\n * The S value.\n * @type {number}\n */\n this.s = s;\n}\nexport default Iau2006XysSample;\n", "import buildModuleUrl from \"./buildModuleUrl.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport Iau2006XysSample from \"./Iau2006XysSample.js\";\nimport JulianDate from \"./JulianDate.js\";\nimport Resource from \"./Resource.js\";\nimport TimeStandard from \"./TimeStandard.js\";\n\n/**\n * A set of IAU2006 XYS data that is used to evaluate the transformation between the International\n * Celestial Reference Frame (ICRF) and the International Terrestrial Reference Frame (ITRF).\n *\n * @alias Iau2006XysData\n * @constructor\n *\n * @param {object} [options] Object with the following properties:\n * @param {Resource|string} [options.xysFileUrlTemplate='Assets/IAU2006_XYS/IAU2006_XYS_{0}.json'] A template URL for obtaining the XYS data. In the template,\n * `{0}` will be replaced with the file index.\n * @param {number} [options.interpolationOrder=9] The order of interpolation to perform on the XYS data.\n * @param {number} [options.sampleZeroJulianEphemerisDate=2442396.5] The Julian ephemeris date (JED) of the\n * first XYS sample.\n * @param {number} [options.stepSizeDays=1.0] The step size, in days, between successive XYS samples.\n * @param {number} [options.samplesPerXysFile=1000] The number of samples in each XYS file.\n * @param {number} [options.totalSamples=27426] The total number of samples in all XYS files.\n *\n * @private\n */\nfunction Iau2006XysData(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n this._xysFileUrlTemplate = Resource.createIfNeeded(\n options.xysFileUrlTemplate\n );\n this._interpolationOrder = defaultValue(options.interpolationOrder, 9);\n this._sampleZeroJulianEphemerisDate = defaultValue(\n options.sampleZeroJulianEphemerisDate,\n 2442396.5\n );\n this._sampleZeroDateTT = new JulianDate(\n this._sampleZeroJulianEphemerisDate,\n 0.0,\n TimeStandard.TAI\n );\n this._stepSizeDays = defaultValue(options.stepSizeDays, 1.0);\n this._samplesPerXysFile = defaultValue(options.samplesPerXysFile, 1000);\n this._totalSamples = defaultValue(options.totalSamples, 27426);\n this._samples = new Array(this._totalSamples * 3);\n this._chunkDownloadsInProgress = [];\n\n const order = this._interpolationOrder;\n\n // Compute denominators and X values for interpolation.\n const denom = (this._denominators = new Array(order + 1));\n const xTable = (this._xTable = new Array(order + 1));\n\n const stepN = Math.pow(this._stepSizeDays, order);\n\n for (let i = 0; i <= order; ++i) {\n denom[i] = stepN;\n xTable[i] = i * this._stepSizeDays;\n\n for (let j = 0; j <= order; ++j) {\n if (j !== i) {\n denom[i] *= i - j;\n }\n }\n\n denom[i] = 1.0 / denom[i];\n }\n\n // Allocate scratch arrays for interpolation.\n this._work = new Array(order + 1);\n this._coef = new Array(order + 1);\n}\n\nconst julianDateScratch = new JulianDate(0, 0.0, TimeStandard.TAI);\n\nfunction getDaysSinceEpoch(xys, dayTT, secondTT) {\n const dateTT = julianDateScratch;\n dateTT.dayNumber = dayTT;\n dateTT.secondsOfDay = secondTT;\n return JulianDate.daysDifference(dateTT, xys._sampleZeroDateTT);\n}\n\n/**\n * Preloads XYS data for a specified date range.\n *\n * @param {number} startDayTT The Julian day number of the beginning of the interval to preload, expressed in\n * the Terrestrial Time (TT) time standard.\n * @param {number} startSecondTT The seconds past noon of the beginning of the interval to preload, expressed in\n * the Terrestrial Time (TT) time standard.\n * @param {number} stopDayTT The Julian day number of the end of the interval to preload, expressed in\n * the Terrestrial Time (TT) time standard.\n * @param {number} stopSecondTT The seconds past noon of the end of the interval to preload, expressed in\n * the Terrestrial Time (TT) time standard.\n * @returns {Promise} A promise that, when resolved, indicates that the requested interval has been\n * preloaded.\n */\nIau2006XysData.prototype.preload = function (\n startDayTT,\n startSecondTT,\n stopDayTT,\n stopSecondTT\n) {\n const startDaysSinceEpoch = getDaysSinceEpoch(\n this,\n startDayTT,\n startSecondTT\n );\n const stopDaysSinceEpoch = getDaysSinceEpoch(this, stopDayTT, stopSecondTT);\n\n let startIndex =\n (startDaysSinceEpoch / this._stepSizeDays - this._interpolationOrder / 2) |\n 0;\n if (startIndex < 0) {\n startIndex = 0;\n }\n\n let stopIndex =\n (stopDaysSinceEpoch / this._stepSizeDays - this._interpolationOrder / 2) |\n (0 + this._interpolationOrder);\n if (stopIndex >= this._totalSamples) {\n stopIndex = this._totalSamples - 1;\n }\n\n const startChunk = (startIndex / this._samplesPerXysFile) | 0;\n const stopChunk = (stopIndex / this._samplesPerXysFile) | 0;\n\n const promises = [];\n for (let i = startChunk; i <= stopChunk; ++i) {\n promises.push(requestXysChunk(this, i));\n }\n\n return Promise.all(promises);\n};\n\n/**\n * Computes the XYS values for a given date by interpolating. If the required data is not yet downloaded,\n * this method will return undefined.\n *\n * @param {number} dayTT The Julian day number for which to compute the XYS value, expressed in\n * the Terrestrial Time (TT) time standard.\n * @param {number} secondTT The seconds past noon of the date for which to compute the XYS value, expressed in\n * the Terrestrial Time (TT) time standard.\n * @param {Iau2006XysSample} [result] The instance to which to copy the interpolated result. If this parameter\n * is undefined, a new instance is allocated and returned.\n * @returns {Iau2006XysSample} The interpolated XYS values, or undefined if the required data for this\n * computation has not yet been downloaded.\n *\n * @see Iau2006XysData#preload\n */\nIau2006XysData.prototype.computeXysRadians = function (\n dayTT,\n secondTT,\n result\n) {\n const daysSinceEpoch = getDaysSinceEpoch(this, dayTT, secondTT);\n if (daysSinceEpoch < 0.0) {\n // Can't evaluate prior to the epoch of the data.\n return undefined;\n }\n\n const centerIndex = (daysSinceEpoch / this._stepSizeDays) | 0;\n if (centerIndex >= this._totalSamples) {\n // Can't evaluate after the last sample in the data.\n return undefined;\n }\n\n const degree = this._interpolationOrder;\n\n let firstIndex = centerIndex - ((degree / 2) | 0);\n if (firstIndex < 0) {\n firstIndex = 0;\n }\n let lastIndex = firstIndex + degree;\n if (lastIndex >= this._totalSamples) {\n lastIndex = this._totalSamples - 1;\n firstIndex = lastIndex - degree;\n if (firstIndex < 0) {\n firstIndex = 0;\n }\n }\n\n // Are all the samples we need present?\n // We can assume so if the first and last are present\n let isDataMissing = false;\n const samples = this._samples;\n if (!defined(samples[firstIndex * 3])) {\n requestXysChunk(this, (firstIndex / this._samplesPerXysFile) | 0);\n isDataMissing = true;\n }\n\n if (!defined(samples[lastIndex * 3])) {\n requestXysChunk(this, (lastIndex / this._samplesPerXysFile) | 0);\n isDataMissing = true;\n }\n\n if (isDataMissing) {\n return undefined;\n }\n\n if (!defined(result)) {\n result = new Iau2006XysSample(0.0, 0.0, 0.0);\n } else {\n result.x = 0.0;\n result.y = 0.0;\n result.s = 0.0;\n }\n\n const x = daysSinceEpoch - firstIndex * this._stepSizeDays;\n\n const work = this._work;\n const denom = this._denominators;\n const coef = this._coef;\n const xTable = this._xTable;\n\n let i, j;\n for (i = 0; i <= degree; ++i) {\n work[i] = x - xTable[i];\n }\n\n for (i = 0; i <= degree; ++i) {\n coef[i] = 1.0;\n\n for (j = 0; j <= degree; ++j) {\n if (j !== i) {\n coef[i] *= work[j];\n }\n }\n\n coef[i] *= denom[i];\n\n let sampleIndex = (firstIndex + i) * 3;\n result.x += coef[i] * samples[sampleIndex++];\n result.y += coef[i] * samples[sampleIndex++];\n result.s += coef[i] * samples[sampleIndex];\n }\n\n return result;\n};\n\nfunction requestXysChunk(xysData, chunkIndex) {\n if (xysData._chunkDownloadsInProgress[chunkIndex]) {\n // Chunk has already been requested.\n return xysData._chunkDownloadsInProgress[chunkIndex];\n }\n\n let chunkUrl;\n const xysFileUrlTemplate = xysData._xysFileUrlTemplate;\n if (defined(xysFileUrlTemplate)) {\n chunkUrl = xysFileUrlTemplate.getDerivedResource({\n templateValues: {\n 0: chunkIndex,\n },\n });\n } else {\n chunkUrl = new Resource({\n url: buildModuleUrl(`Assets/IAU2006_XYS/IAU2006_XYS_${chunkIndex}.json`),\n });\n }\n\n const promise = chunkUrl.fetchJson().then(function (chunk) {\n xysData._chunkDownloadsInProgress[chunkIndex] = false;\n\n const samples = xysData._samples;\n const newSamples = chunk.samples;\n const startIndex = chunkIndex * xysData._samplesPerXysFile * 3;\n\n for (let i = 0, len = newSamples.length; i < len; ++i) {\n samples[startIndex + i] = newSamples[i];\n }\n });\n xysData._chunkDownloadsInProgress[chunkIndex] = promise;\n\n return promise;\n}\nexport default Iau2006XysData;\n", "import Cartesian2 from \"./Cartesian2.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Cartesian4 from \"./Cartesian4.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport EarthOrientationParameters from \"./EarthOrientationParameters.js\";\nimport EarthOrientationParametersSample from \"./EarthOrientationParametersSample.js\";\nimport Ellipsoid from \"./Ellipsoid.js\";\nimport HeadingPitchRoll from \"./HeadingPitchRoll.js\";\nimport Iau2006XysData from \"./Iau2006XysData.js\";\nimport Iau2006XysSample from \"./Iau2006XysSample.js\";\nimport JulianDate from \"./JulianDate.js\";\nimport CesiumMath from \"./Math.js\";\nimport Matrix3 from \"./Matrix3.js\";\nimport Matrix4 from \"./Matrix4.js\";\nimport Quaternion from \"./Quaternion.js\";\nimport TimeConstants from \"./TimeConstants.js\";\n\n/**\n * Contains functions for transforming positions to various reference frames.\n *\n * @namespace Transforms\n */\nconst Transforms = {};\n\nconst vectorProductLocalFrame = {\n up: {\n south: \"east\",\n north: \"west\",\n west: \"south\",\n east: \"north\",\n },\n down: {\n south: \"west\",\n north: \"east\",\n west: \"north\",\n east: \"south\",\n },\n south: {\n up: \"west\",\n down: \"east\",\n west: \"down\",\n east: \"up\",\n },\n north: {\n up: \"east\",\n down: \"west\",\n west: \"up\",\n east: \"down\",\n },\n west: {\n up: \"north\",\n down: \"south\",\n north: \"down\",\n south: \"up\",\n },\n east: {\n up: \"south\",\n down: \"north\",\n north: \"up\",\n south: \"down\",\n },\n};\n\nconst degeneratePositionLocalFrame = {\n north: [-1, 0, 0],\n east: [0, 1, 0],\n up: [0, 0, 1],\n south: [1, 0, 0],\n west: [0, -1, 0],\n down: [0, 0, -1],\n};\n\nconst localFrameToFixedFrameCache = {};\n\nconst scratchCalculateCartesian = {\n east: new Cartesian3(),\n north: new Cartesian3(),\n up: new Cartesian3(),\n west: new Cartesian3(),\n south: new Cartesian3(),\n down: new Cartesian3(),\n};\nlet scratchFirstCartesian = new Cartesian3();\nlet scratchSecondCartesian = new Cartesian3();\nlet scratchThirdCartesian = new Cartesian3();\n/**\n * Generates a function that computes a 4x4 transformation matrix from a reference frame\n * centered at the provided origin to the provided ellipsoid's fixed reference frame.\n * @param {string} firstAxis name of the first axis of the local reference frame. Must be\n * 'east', 'north', 'up', 'west', 'south' or 'down'.\n * @param {string} secondAxis name of the second axis of the local reference frame. Must be\n * 'east', 'north', 'up', 'west', 'south' or 'down'.\n * @return {Transforms.LocalFrameToFixedFrame} The function that will computes a\n * 4x4 transformation matrix from a reference frame, with first axis and second axis compliant with the parameters,\n */\nTransforms.localFrameToFixedFrameGenerator = function (firstAxis, secondAxis) {\n if (\n !vectorProductLocalFrame.hasOwnProperty(firstAxis) ||\n !vectorProductLocalFrame[firstAxis].hasOwnProperty(secondAxis)\n ) {\n throw new DeveloperError(\n \"firstAxis and secondAxis must be east, north, up, west, south or down.\"\n );\n }\n const thirdAxis = vectorProductLocalFrame[firstAxis][secondAxis];\n\n /**\n * Computes a 4x4 transformation matrix from a reference frame\n * centered at the provided origin to the provided ellipsoid's fixed reference frame.\n * @callback Transforms.LocalFrameToFixedFrame\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.\n */\n let resultat;\n const hashAxis = firstAxis + secondAxis;\n if (defined(localFrameToFixedFrameCache[hashAxis])) {\n resultat = localFrameToFixedFrameCache[hashAxis];\n } else {\n resultat = function (origin, ellipsoid, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(origin)) {\n throw new DeveloperError(\"origin is required.\");\n }\n //>>includeEnd('debug');\n if (!defined(result)) {\n result = new Matrix4();\n }\n if (\n Cartesian3.equalsEpsilon(origin, Cartesian3.ZERO, CesiumMath.EPSILON14)\n ) {\n // If x, y, and z are zero, use the degenerate local frame, which is a special case\n Cartesian3.unpack(\n degeneratePositionLocalFrame[firstAxis],\n 0,\n scratchFirstCartesian\n );\n Cartesian3.unpack(\n degeneratePositionLocalFrame[secondAxis],\n 0,\n scratchSecondCartesian\n );\n Cartesian3.unpack(\n degeneratePositionLocalFrame[thirdAxis],\n 0,\n scratchThirdCartesian\n );\n } else if (\n CesiumMath.equalsEpsilon(origin.x, 0.0, CesiumMath.EPSILON14) &&\n CesiumMath.equalsEpsilon(origin.y, 0.0, CesiumMath.EPSILON14)\n ) {\n // If x and y are zero, assume origin is at a pole, which is a special case.\n const sign = CesiumMath.sign(origin.z);\n\n Cartesian3.unpack(\n degeneratePositionLocalFrame[firstAxis],\n 0,\n scratchFirstCartesian\n );\n if (firstAxis !== \"east\" && firstAxis !== \"west\") {\n Cartesian3.multiplyByScalar(\n scratchFirstCartesian,\n sign,\n scratchFirstCartesian\n );\n }\n\n Cartesian3.unpack(\n degeneratePositionLocalFrame[secondAxis],\n 0,\n scratchSecondCartesian\n );\n if (secondAxis !== \"east\" && secondAxis !== \"west\") {\n Cartesian3.multiplyByScalar(\n scratchSecondCartesian,\n sign,\n scratchSecondCartesian\n );\n }\n\n Cartesian3.unpack(\n degeneratePositionLocalFrame[thirdAxis],\n 0,\n scratchThirdCartesian\n );\n if (thirdAxis !== \"east\" && thirdAxis !== \"west\") {\n Cartesian3.multiplyByScalar(\n scratchThirdCartesian,\n sign,\n scratchThirdCartesian\n );\n }\n } else {\n ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);\n ellipsoid.geodeticSurfaceNormal(origin, scratchCalculateCartesian.up);\n\n const up = scratchCalculateCartesian.up;\n const east = scratchCalculateCartesian.east;\n east.x = -origin.y;\n east.y = origin.x;\n east.z = 0.0;\n Cartesian3.normalize(east, scratchCalculateCartesian.east);\n Cartesian3.cross(up, east, scratchCalculateCartesian.north);\n\n Cartesian3.multiplyByScalar(\n scratchCalculateCartesian.up,\n -1,\n scratchCalculateCartesian.down\n );\n Cartesian3.multiplyByScalar(\n scratchCalculateCartesian.east,\n -1,\n scratchCalculateCartesian.west\n );\n Cartesian3.multiplyByScalar(\n scratchCalculateCartesian.north,\n -1,\n scratchCalculateCartesian.south\n );\n\n scratchFirstCartesian = scratchCalculateCartesian[firstAxis];\n scratchSecondCartesian = scratchCalculateCartesian[secondAxis];\n scratchThirdCartesian = scratchCalculateCartesian[thirdAxis];\n }\n result[0] = scratchFirstCartesian.x;\n result[1] = scratchFirstCartesian.y;\n result[2] = scratchFirstCartesian.z;\n result[3] = 0.0;\n result[4] = scratchSecondCartesian.x;\n result[5] = scratchSecondCartesian.y;\n result[6] = scratchSecondCartesian.z;\n result[7] = 0.0;\n result[8] = scratchThirdCartesian.x;\n result[9] = scratchThirdCartesian.y;\n result[10] = scratchThirdCartesian.z;\n result[11] = 0.0;\n result[12] = origin.x;\n result[13] = origin.y;\n result[14] = origin.z;\n result[15] = 1.0;\n return result;\n };\n localFrameToFixedFrameCache[hashAxis] = resultat;\n }\n return resultat;\n};\n\n/**\n * Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame.\n * The local axes are defined as:\n *
\n *
The x axis points in the local east direction.
\n *
The y axis points in the local north direction.
\n *
The z axis points in the direction of the ellipsoid surface normal which passes through the position.
\n *
\n *\n * @function\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.\n *\n * @example\n * // Get the transform from local east-north-up at cartographic (0.0, 0.0) to Earth's fixed frame.\n * const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);\n */\nTransforms.eastNorthUpToFixedFrame = Transforms.localFrameToFixedFrameGenerator(\n \"east\",\n \"north\"\n);\n\n/**\n * Computes a 4x4 transformation matrix from a reference frame with an north-east-down axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame.\n * The local axes are defined as:\n *
\n *
The x axis points in the local north direction.
\n *
The y axis points in the local east direction.
\n *
The z axis points in the opposite direction of the ellipsoid surface normal which passes through the position.
\n *
\n *\n * @function\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.\n *\n * @example\n * // Get the transform from local north-east-down at cartographic (0.0, 0.0) to Earth's fixed frame.\n * const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const transform = Cesium.Transforms.northEastDownToFixedFrame(center);\n */\nTransforms.northEastDownToFixedFrame = Transforms.localFrameToFixedFrameGenerator(\n \"north\",\n \"east\"\n);\n\n/**\n * Computes a 4x4 transformation matrix from a reference frame with an north-up-east axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame.\n * The local axes are defined as:\n *
\n *
The x axis points in the local north direction.
\n *
The y axis points in the direction of the ellipsoid surface normal which passes through the position.
\n *
The z axis points in the local east direction.
\n *
\n *\n * @function\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.\n *\n * @example\n * // Get the transform from local north-up-east at cartographic (0.0, 0.0) to Earth's fixed frame.\n * const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const transform = Cesium.Transforms.northUpEastToFixedFrame(center);\n */\nTransforms.northUpEastToFixedFrame = Transforms.localFrameToFixedFrameGenerator(\n \"north\",\n \"up\"\n);\n\n/**\n * Computes a 4x4 transformation matrix from a reference frame with an north-west-up axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame.\n * The local axes are defined as:\n *
\n *
The x axis points in the local north direction.
\n *
The y axis points in the local west direction.
\n *
The z axis points in the direction of the ellipsoid surface normal which passes through the position.
\n *
\n *\n * @function\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.\n *\n * @example\n * // Get the transform from local north-West-Up at cartographic (0.0, 0.0) to Earth's fixed frame.\n * const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const transform = Cesium.Transforms.northWestUpToFixedFrame(center);\n */\nTransforms.northWestUpToFixedFrame = Transforms.localFrameToFixedFrameGenerator(\n \"north\",\n \"west\"\n);\n\nconst scratchHPRQuaternion = new Quaternion();\nconst scratchScale = new Cartesian3(1.0, 1.0, 1.0);\nconst scratchHPRMatrix4 = new Matrix4();\n\n/**\n * Computes a 4x4 transformation matrix from a reference frame with axes computed from the heading-pitch-roll angles\n * centered at the provided origin to the provided ellipsoid's fixed reference frame. Heading is the rotation from the local north\n * direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles\n * are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.\n *\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {HeadingPitchRoll} headingPitchRoll The heading, pitch, and roll.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Transforms.LocalFrameToFixedFrame} [fixedFrameTransform=Transforms.eastNorthUpToFixedFrame] A 4x4 transformation\n * matrix from a reference frame to the provided ellipsoid's fixed reference frame\n * @param {Matrix4} [result] The object onto which to store the result.\n * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.\n *\n * @example\n * // Get the transform from local heading-pitch-roll at cartographic (0.0, 0.0) to Earth's fixed frame.\n * const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const heading = -Cesium.Math.PI_OVER_TWO;\n * const pitch = Cesium.Math.PI_OVER_FOUR;\n * const roll = 0.0;\n * const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);\n * const transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, hpr);\n */\nTransforms.headingPitchRollToFixedFrame = function (\n origin,\n headingPitchRoll,\n ellipsoid,\n fixedFrameTransform,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"HeadingPitchRoll\", headingPitchRoll);\n //>>includeEnd('debug');\n\n fixedFrameTransform = defaultValue(\n fixedFrameTransform,\n Transforms.eastNorthUpToFixedFrame\n );\n const hprQuaternion = Quaternion.fromHeadingPitchRoll(\n headingPitchRoll,\n scratchHPRQuaternion\n );\n const hprMatrix = Matrix4.fromTranslationQuaternionRotationScale(\n Cartesian3.ZERO,\n hprQuaternion,\n scratchScale,\n scratchHPRMatrix4\n );\n result = fixedFrameTransform(origin, ellipsoid, result);\n return Matrix4.multiply(result, hprMatrix, result);\n};\n\nconst scratchENUMatrix4 = new Matrix4();\nconst scratchHPRMatrix3 = new Matrix3();\n\n/**\n * Computes a quaternion from a reference frame with axes computed from the heading-pitch-roll angles\n * centered at the provided origin. Heading is the rotation from the local north\n * direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles\n * are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.\n *\n * @param {Cartesian3} origin The center point of the local reference frame.\n * @param {HeadingPitchRoll} headingPitchRoll The heading, pitch, and roll.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Transforms.LocalFrameToFixedFrame} [fixedFrameTransform=Transforms.eastNorthUpToFixedFrame] A 4x4 transformation\n * matrix from a reference frame to the provided ellipsoid's fixed reference frame\n * @param {Quaternion} [result] The object onto which to store the result.\n * @returns {Quaternion} The modified result parameter or a new Quaternion instance if none was provided.\n *\n * @example\n * // Get the quaternion from local heading-pitch-roll at cartographic (0.0, 0.0) to Earth's fixed frame.\n * const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const heading = -Cesium.Math.PI_OVER_TWO;\n * const pitch = Cesium.Math.PI_OVER_FOUR;\n * const roll = 0.0;\n * const hpr = new HeadingPitchRoll(heading, pitch, roll);\n * const quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, hpr);\n */\nTransforms.headingPitchRollQuaternion = function (\n origin,\n headingPitchRoll,\n ellipsoid,\n fixedFrameTransform,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"HeadingPitchRoll\", headingPitchRoll);\n //>>includeEnd('debug');\n\n const transform = Transforms.headingPitchRollToFixedFrame(\n origin,\n headingPitchRoll,\n ellipsoid,\n fixedFrameTransform,\n scratchENUMatrix4\n );\n const rotation = Matrix4.getMatrix3(transform, scratchHPRMatrix3);\n return Quaternion.fromRotationMatrix(rotation, result);\n};\n\nconst noScale = new Cartesian3(1.0, 1.0, 1.0);\nconst hprCenterScratch = new Cartesian3();\nconst ffScratch = new Matrix4();\nconst hprTransformScratch = new Matrix4();\nconst hprRotationScratch = new Matrix3();\nconst hprQuaternionScratch = new Quaternion();\n/**\n * Computes heading-pitch-roll angles from a transform in a particular reference frame. Heading is the rotation from the local north\n * direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles\n * are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.\n *\n * @param {Matrix4} transform The transform\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Transforms.LocalFrameToFixedFrame} [fixedFrameTransform=Transforms.eastNorthUpToFixedFrame] A 4x4 transformation\n * matrix from a reference frame to the provided ellipsoid's fixed reference frame\n * @param {HeadingPitchRoll} [result] The object onto which to store the result.\n * @returns {HeadingPitchRoll} The modified result parameter or a new HeadingPitchRoll instance if none was provided.\n */\nTransforms.fixedFrameToHeadingPitchRoll = function (\n transform,\n ellipsoid,\n fixedFrameTransform,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"transform\", transform);\n //>>includeEnd('debug');\n\n ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);\n fixedFrameTransform = defaultValue(\n fixedFrameTransform,\n Transforms.eastNorthUpToFixedFrame\n );\n if (!defined(result)) {\n result = new HeadingPitchRoll();\n }\n\n const center = Matrix4.getTranslation(transform, hprCenterScratch);\n if (Cartesian3.equals(center, Cartesian3.ZERO)) {\n result.heading = 0;\n result.pitch = 0;\n result.roll = 0;\n return result;\n }\n let toFixedFrame = Matrix4.inverseTransformation(\n fixedFrameTransform(center, ellipsoid, ffScratch),\n ffScratch\n );\n let transformCopy = Matrix4.setScale(transform, noScale, hprTransformScratch);\n transformCopy = Matrix4.setTranslation(\n transformCopy,\n Cartesian3.ZERO,\n transformCopy\n );\n\n toFixedFrame = Matrix4.multiply(toFixedFrame, transformCopy, toFixedFrame);\n let quaternionRotation = Quaternion.fromRotationMatrix(\n Matrix4.getMatrix3(toFixedFrame, hprRotationScratch),\n hprQuaternionScratch\n );\n quaternionRotation = Quaternion.normalize(\n quaternionRotation,\n quaternionRotation\n );\n\n return HeadingPitchRoll.fromQuaternion(quaternionRotation, result);\n};\n\nconst gmstConstant0 = 6 * 3600 + 41 * 60 + 50.54841;\nconst gmstConstant1 = 8640184.812866;\nconst gmstConstant2 = 0.093104;\nconst gmstConstant3 = -6.2e-6;\nconst rateCoef = 1.1772758384668e-19;\nconst wgs84WRPrecessing = 7.2921158553e-5;\nconst twoPiOverSecondsInDay = CesiumMath.TWO_PI / 86400.0;\nlet dateInUtc = new JulianDate();\n\n/**\n * Computes a rotation matrix to transform a point or vector from True Equator Mean Equinox (TEME) axes to the\n * pseudo-fixed axes at a given time. This method treats the UT1 time standard as equivalent to UTC.\n *\n * @param {JulianDate} date The time at which to compute the rotation matrix.\n * @param {Matrix3} [result] The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if none was provided.\n *\n * @example\n * //Set the view to the inertial frame.\n * scene.postUpdate.addEventListener(function(scene, time) {\n * const now = Cesium.JulianDate.now();\n * const offset = Cesium.Matrix4.multiplyByPoint(camera.transform, camera.position, new Cesium.Cartesian3());\n * const transform = Cesium.Matrix4.fromRotationTranslation(Cesium.Transforms.computeTemeToPseudoFixedMatrix(now));\n * const inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());\n * Cesium.Matrix4.multiplyByPoint(inverseTransform, offset, offset);\n * camera.lookAtTransform(transform, offset);\n * });\n */\nTransforms.computeTemeToPseudoFixedMatrix = function (date, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(date)) {\n throw new DeveloperError(\"date is required.\");\n }\n //>>includeEnd('debug');\n\n // GMST is actually computed using UT1. We're using UTC as an approximation of UT1.\n // We do not want to use the function like convertTaiToUtc in JulianDate because\n // we explicitly do not want to fail when inside the leap second.\n\n dateInUtc = JulianDate.addSeconds(\n date,\n -JulianDate.computeTaiMinusUtc(date),\n dateInUtc\n );\n const utcDayNumber = dateInUtc.dayNumber;\n const utcSecondsIntoDay = dateInUtc.secondsOfDay;\n\n let t;\n const diffDays = utcDayNumber - 2451545;\n if (utcSecondsIntoDay >= 43200.0) {\n t = (diffDays + 0.5) / TimeConstants.DAYS_PER_JULIAN_CENTURY;\n } else {\n t = (diffDays - 0.5) / TimeConstants.DAYS_PER_JULIAN_CENTURY;\n }\n\n const gmst0 =\n gmstConstant0 +\n t * (gmstConstant1 + t * (gmstConstant2 + t * gmstConstant3));\n const angle = (gmst0 * twoPiOverSecondsInDay) % CesiumMath.TWO_PI;\n const ratio = wgs84WRPrecessing + rateCoef * (utcDayNumber - 2451545.5);\n const secondsSinceMidnight =\n (utcSecondsIntoDay + TimeConstants.SECONDS_PER_DAY * 0.5) %\n TimeConstants.SECONDS_PER_DAY;\n const gha = angle + ratio * secondsSinceMidnight;\n const cosGha = Math.cos(gha);\n const sinGha = Math.sin(gha);\n\n if (!defined(result)) {\n return new Matrix3(\n cosGha,\n sinGha,\n 0.0,\n -sinGha,\n cosGha,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n );\n }\n result[0] = cosGha;\n result[1] = -sinGha;\n result[2] = 0.0;\n result[3] = sinGha;\n result[4] = cosGha;\n result[5] = 0.0;\n result[6] = 0.0;\n result[7] = 0.0;\n result[8] = 1.0;\n return result;\n};\n\n/**\n * The source of IAU 2006 XYS data, used for computing the transformation between the\n * Fixed and ICRF axes.\n * @type {Iau2006XysData}\n *\n * @see Transforms.computeIcrfToFixedMatrix\n * @see Transforms.computeFixedToIcrfMatrix\n *\n * @private\n */\nTransforms.iau2006XysData = new Iau2006XysData();\n\n/**\n * The source of Earth Orientation Parameters (EOP) data, used for computing the transformation\n * between the Fixed and ICRF axes. By default, zero values are used for all EOP values,\n * yielding a reasonable but not completely accurate representation of the ICRF axes.\n * @type {EarthOrientationParameters}\n *\n * @see Transforms.computeIcrfToFixedMatrix\n * @see Transforms.computeFixedToIcrfMatrix\n *\n * @private\n */\nTransforms.earthOrientationParameters = EarthOrientationParameters.NONE;\n\nconst ttMinusTai = 32.184;\nconst j2000ttDays = 2451545.0;\n\n/**\n * Preloads the data necessary to transform between the ICRF and Fixed axes, in either\n * direction, over a given interval. This function returns a promise that, when resolved,\n * indicates that the preload has completed.\n *\n * @param {TimeInterval} timeInterval The interval to preload.\n * @returns {Promise} A promise that, when resolved, indicates that the preload has completed\n * and evaluation of the transformation between the fixed and ICRF axes will\n * no longer return undefined for a time inside the interval.\n *\n *\n * @example\n * const interval = new Cesium.TimeInterval(...);\n * await Cesium.Transforms.preloadIcrfFixed(interval));\n * // the data is now loaded\n *\n * @see Transforms.computeIcrfToFixedMatrix\n * @see Transforms.computeFixedToIcrfMatrix\n */\nTransforms.preloadIcrfFixed = function (timeInterval) {\n const startDayTT = timeInterval.start.dayNumber;\n const startSecondTT = timeInterval.start.secondsOfDay + ttMinusTai;\n const stopDayTT = timeInterval.stop.dayNumber;\n const stopSecondTT = timeInterval.stop.secondsOfDay + ttMinusTai;\n\n return Transforms.iau2006XysData.preload(\n startDayTT,\n startSecondTT,\n stopDayTT,\n stopSecondTT\n );\n};\n\n/**\n * Computes a rotation matrix to transform a point or vector from the International Celestial\n * Reference Frame (GCRF/ICRF) inertial frame axes to the Earth-Fixed frame axes (ITRF)\n * at a given time. This function may return undefined if the data necessary to\n * do the transformation is not yet loaded.\n *\n * @param {JulianDate} date The time at which to compute the rotation matrix.\n * @param {Matrix3} [result] The object onto which to store the result. If this parameter is\n * not specified, a new instance is created and returned.\n * @returns {Matrix3} The rotation matrix, or undefined if the data necessary to do the\n * transformation is not yet loaded.\n *\n *\n * @example\n * scene.postUpdate.addEventListener(function(scene, time) {\n * // View in ICRF.\n * const icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(time);\n * if (Cesium.defined(icrfToFixed)) {\n * const offset = Cesium.Cartesian3.clone(camera.position);\n * const transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed);\n * camera.lookAtTransform(transform, offset);\n * }\n * });\n *\n * @see Transforms.preloadIcrfFixed\n */\nTransforms.computeIcrfToFixedMatrix = function (date, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(date)) {\n throw new DeveloperError(\"date is required.\");\n }\n //>>includeEnd('debug');\n if (!defined(result)) {\n result = new Matrix3();\n }\n\n const fixedToIcrfMtx = Transforms.computeFixedToIcrfMatrix(date, result);\n if (!defined(fixedToIcrfMtx)) {\n return undefined;\n }\n\n return Matrix3.transpose(fixedToIcrfMtx, result);\n};\n\nconst xysScratch = new Iau2006XysSample(0.0, 0.0, 0.0);\nconst eopScratch = new EarthOrientationParametersSample(\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0\n);\nconst rotation1Scratch = new Matrix3();\nconst rotation2Scratch = new Matrix3();\n\n/**\n * Computes a rotation matrix to transform a point or vector from the Earth-Fixed frame axes (ITRF)\n * to the International Celestial Reference Frame (GCRF/ICRF) inertial frame axes\n * at a given time. This function may return undefined if the data necessary to\n * do the transformation is not yet loaded.\n *\n * @param {JulianDate} date The time at which to compute the rotation matrix.\n * @param {Matrix3} [result] The object onto which to store the result. If this parameter is\n * not specified, a new instance is created and returned.\n * @returns {Matrix3} The rotation matrix, or undefined if the data necessary to do the\n * transformation is not yet loaded.\n *\n *\n * @example\n * // Transform a point from the ICRF axes to the Fixed axes.\n * const now = Cesium.JulianDate.now();\n * const pointInFixed = Cesium.Cartesian3.fromDegrees(0.0, 0.0);\n * const fixedToIcrf = Cesium.Transforms.computeIcrfToFixedMatrix(now);\n * let pointInInertial = new Cesium.Cartesian3();\n * if (Cesium.defined(fixedToIcrf)) {\n * pointInInertial = Cesium.Matrix3.multiplyByVector(fixedToIcrf, pointInFixed, pointInInertial);\n * }\n *\n * @see Transforms.preloadIcrfFixed\n */\nTransforms.computeFixedToIcrfMatrix = function (date, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(date)) {\n throw new DeveloperError(\"date is required.\");\n }\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Matrix3();\n }\n\n // Compute pole wander\n const eop = Transforms.earthOrientationParameters.compute(date, eopScratch);\n if (!defined(eop)) {\n return undefined;\n }\n\n // There is no external conversion to Terrestrial Time (TT).\n // So use International Atomic Time (TAI) and convert using offsets.\n // Here we are assuming that dayTT and secondTT are positive\n const dayTT = date.dayNumber;\n // It's possible here that secondTT could roll over 86400\n // This does not seem to affect the precision (unit tests check for this)\n const secondTT = date.secondsOfDay + ttMinusTai;\n\n const xys = Transforms.iau2006XysData.computeXysRadians(\n dayTT,\n secondTT,\n xysScratch\n );\n if (!defined(xys)) {\n return undefined;\n }\n\n const x = xys.x + eop.xPoleOffset;\n const y = xys.y + eop.yPoleOffset;\n\n // Compute XYS rotation\n const a = 1.0 / (1.0 + Math.sqrt(1.0 - x * x - y * y));\n\n const rotation1 = rotation1Scratch;\n rotation1[0] = 1.0 - a * x * x;\n rotation1[3] = -a * x * y;\n rotation1[6] = x;\n rotation1[1] = -a * x * y;\n rotation1[4] = 1 - a * y * y;\n rotation1[7] = y;\n rotation1[2] = -x;\n rotation1[5] = -y;\n rotation1[8] = 1 - a * (x * x + y * y);\n\n const rotation2 = Matrix3.fromRotationZ(-xys.s, rotation2Scratch);\n const matrixQ = Matrix3.multiply(rotation1, rotation2, rotation1Scratch);\n\n // Similar to TT conversions above\n // It's possible here that secondTT could roll over 86400\n // This does not seem to affect the precision (unit tests check for this)\n const dateUt1day = date.dayNumber;\n const dateUt1sec =\n date.secondsOfDay - JulianDate.computeTaiMinusUtc(date) + eop.ut1MinusUtc;\n\n // Compute Earth rotation angle\n // The IERS standard for era is\n // era = 0.7790572732640 + 1.00273781191135448 * Tu\n // where\n // Tu = JulianDateInUt1 - 2451545.0\n // However, you get much more precision if you make the following simplification\n // era = a + (1 + b) * (JulianDayNumber + FractionOfDay - 2451545)\n // era = a + (JulianDayNumber - 2451545) + FractionOfDay + b (JulianDayNumber - 2451545 + FractionOfDay)\n // era = a + FractionOfDay + b (JulianDayNumber - 2451545 + FractionOfDay)\n // since (JulianDayNumber - 2451545) represents an integer number of revolutions which will be discarded anyway.\n const daysSinceJ2000 = dateUt1day - 2451545;\n const fractionOfDay = dateUt1sec / TimeConstants.SECONDS_PER_DAY;\n let era =\n 0.779057273264 +\n fractionOfDay +\n 0.00273781191135448 * (daysSinceJ2000 + fractionOfDay);\n era = (era % 1.0) * CesiumMath.TWO_PI;\n\n const earthRotation = Matrix3.fromRotationZ(era, rotation2Scratch);\n\n // pseudoFixed to ICRF\n const pfToIcrf = Matrix3.multiply(matrixQ, earthRotation, rotation1Scratch);\n\n // Compute pole wander matrix\n const cosxp = Math.cos(eop.xPoleWander);\n const cosyp = Math.cos(eop.yPoleWander);\n const sinxp = Math.sin(eop.xPoleWander);\n const sinyp = Math.sin(eop.yPoleWander);\n\n let ttt = dayTT - j2000ttDays + secondTT / TimeConstants.SECONDS_PER_DAY;\n ttt /= 36525.0;\n\n // approximate sp value in rad\n const sp = (-47.0e-6 * ttt * CesiumMath.RADIANS_PER_DEGREE) / 3600.0;\n const cossp = Math.cos(sp);\n const sinsp = Math.sin(sp);\n\n const fToPfMtx = rotation2Scratch;\n fToPfMtx[0] = cosxp * cossp;\n fToPfMtx[1] = cosxp * sinsp;\n fToPfMtx[2] = sinxp;\n fToPfMtx[3] = -cosyp * sinsp + sinyp * sinxp * cossp;\n fToPfMtx[4] = cosyp * cossp + sinyp * sinxp * sinsp;\n fToPfMtx[5] = -sinyp * cosxp;\n fToPfMtx[6] = -sinyp * sinsp - cosyp * sinxp * cossp;\n fToPfMtx[7] = sinyp * cossp - cosyp * sinxp * sinsp;\n fToPfMtx[8] = cosyp * cosxp;\n\n return Matrix3.multiply(pfToIcrf, fToPfMtx, result);\n};\n\nconst pointToWindowCoordinatesTemp = new Cartesian4();\n\n/**\n * Transform a point from model coordinates to window coordinates.\n *\n * @param {Matrix4} modelViewProjectionMatrix The 4x4 model-view-projection matrix.\n * @param {Matrix4} viewportTransformation The 4x4 viewport transformation.\n * @param {Cartesian3} point The point to transform.\n * @param {Cartesian2} [result] The object onto which to store the result.\n * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if none was provided.\n */\nTransforms.pointToWindowCoordinates = function (\n modelViewProjectionMatrix,\n viewportTransformation,\n point,\n result\n) {\n result = Transforms.pointToGLWindowCoordinates(\n modelViewProjectionMatrix,\n viewportTransformation,\n point,\n result\n );\n result.y = 2.0 * viewportTransformation[5] - result.y;\n return result;\n};\n\n/**\n * @private\n */\nTransforms.pointToGLWindowCoordinates = function (\n modelViewProjectionMatrix,\n viewportTransformation,\n point,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(modelViewProjectionMatrix)) {\n throw new DeveloperError(\"modelViewProjectionMatrix is required.\");\n }\n\n if (!defined(viewportTransformation)) {\n throw new DeveloperError(\"viewportTransformation is required.\");\n }\n\n if (!defined(point)) {\n throw new DeveloperError(\"point is required.\");\n }\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Cartesian2();\n }\n\n const tmp = pointToWindowCoordinatesTemp;\n\n Matrix4.multiplyByVector(\n modelViewProjectionMatrix,\n Cartesian4.fromElements(point.x, point.y, point.z, 1, tmp),\n tmp\n );\n Cartesian4.multiplyByScalar(tmp, 1.0 / tmp.w, tmp);\n Matrix4.multiplyByVector(viewportTransformation, tmp, tmp);\n return Cartesian2.fromCartesian4(tmp, result);\n};\n\nconst normalScratch = new Cartesian3();\nconst rightScratch = new Cartesian3();\nconst upScratch = new Cartesian3();\n\n/**\n * Transform a position and velocity to a rotation matrix.\n *\n * @param {Cartesian3} position The position to transform.\n * @param {Cartesian3} velocity The velocity vector to transform.\n * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.\n * @param {Matrix3} [result] The object onto which to store the result.\n * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if none was provided.\n */\nTransforms.rotationMatrixFromPositionVelocity = function (\n position,\n velocity,\n ellipsoid,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(position)) {\n throw new DeveloperError(\"position is required.\");\n }\n\n if (!defined(velocity)) {\n throw new DeveloperError(\"velocity is required.\");\n }\n //>>includeEnd('debug');\n\n const normal = defaultValue(ellipsoid, Ellipsoid.WGS84).geodeticSurfaceNormal(\n position,\n normalScratch\n );\n let right = Cartesian3.cross(velocity, normal, rightScratch);\n\n if (Cartesian3.equalsEpsilon(right, Cartesian3.ZERO, CesiumMath.EPSILON6)) {\n right = Cartesian3.clone(Cartesian3.UNIT_X, right);\n }\n\n const up = Cartesian3.cross(right, velocity, upScratch);\n Cartesian3.normalize(up, up);\n Cartesian3.cross(velocity, up, right);\n Cartesian3.negate(right, right);\n Cartesian3.normalize(right, right);\n\n if (!defined(result)) {\n result = new Matrix3();\n }\n\n result[0] = velocity.x;\n result[1] = velocity.y;\n result[2] = velocity.z;\n result[3] = right.x;\n result[4] = right.y;\n result[5] = right.z;\n result[6] = up.x;\n result[7] = up.y;\n result[8] = up.z;\n\n return result;\n};\n\nconst swizzleMatrix = new Matrix4(\n 0.0,\n 0.0,\n 1.0,\n 0.0,\n 1.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 1.0\n);\n\nconst scratchCartographic = new Cartographic();\nconst scratchCartesian3Projection = new Cartesian3();\nconst scratchCenter = new Cartesian3();\nconst scratchRotation = new Matrix3();\nconst scratchFromENU = new Matrix4();\nconst scratchToENU = new Matrix4();\n\n/**\n * @private\n */\nTransforms.basisTo2D = function (projection, matrix, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(projection)) {\n throw new DeveloperError(\"projection is required.\");\n }\n if (!defined(matrix)) {\n throw new DeveloperError(\"matrix is required.\");\n }\n if (!defined(result)) {\n throw new DeveloperError(\"result is required.\");\n }\n //>>includeEnd('debug');\n\n const rtcCenter = Matrix4.getTranslation(matrix, scratchCenter);\n const ellipsoid = projection.ellipsoid;\n\n // Get the 2D Center\n const cartographic = ellipsoid.cartesianToCartographic(\n rtcCenter,\n scratchCartographic\n );\n const projectedPosition = projection.project(\n cartographic,\n scratchCartesian3Projection\n );\n Cartesian3.fromElements(\n projectedPosition.z,\n projectedPosition.x,\n projectedPosition.y,\n projectedPosition\n );\n\n // Assuming the instance are positioned in WGS84, invert the WGS84 transform to get the local transform and then convert to 2D\n const fromENU = Transforms.eastNorthUpToFixedFrame(\n rtcCenter,\n ellipsoid,\n scratchFromENU\n );\n const toENU = Matrix4.inverseTransformation(fromENU, scratchToENU);\n const rotation = Matrix4.getMatrix3(matrix, scratchRotation);\n const local = Matrix4.multiplyByMatrix3(toENU, rotation, result);\n Matrix4.multiply(swizzleMatrix, local, result); // Swap x, y, z for 2D\n Matrix4.setTranslation(result, projectedPosition, result); // Use the projected center\n\n return result;\n};\n\n/**\n * @private\n */\nTransforms.wgs84To2DModelMatrix = function (projection, center, result) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(projection)) {\n throw new DeveloperError(\"projection is required.\");\n }\n if (!defined(center)) {\n throw new DeveloperError(\"center is required.\");\n }\n if (!defined(result)) {\n throw new DeveloperError(\"result is required.\");\n }\n //>>includeEnd('debug');\n\n const ellipsoid = projection.ellipsoid;\n\n const fromENU = Transforms.eastNorthUpToFixedFrame(\n center,\n ellipsoid,\n scratchFromENU\n );\n const toENU = Matrix4.inverseTransformation(fromENU, scratchToENU);\n\n const cartographic = ellipsoid.cartesianToCartographic(\n center,\n scratchCartographic\n );\n const projectedPosition = projection.project(\n cartographic,\n scratchCartesian3Projection\n );\n Cartesian3.fromElements(\n projectedPosition.z,\n projectedPosition.x,\n projectedPosition.y,\n projectedPosition\n );\n\n const translation = Matrix4.fromTranslation(\n projectedPosition,\n scratchFromENU\n );\n Matrix4.multiply(swizzleMatrix, toENU, result);\n Matrix4.multiply(translation, result, result);\n\n return result;\n};\nexport default Transforms;\n", "import Cartesian2 from \"./Cartesian2.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport GeometryType from \"./GeometryType.js\";\nimport Matrix2 from \"./Matrix2.js\";\nimport Matrix3 from \"./Matrix3.js\";\nimport Matrix4 from \"./Matrix4.js\";\nimport PrimitiveType from \"./PrimitiveType.js\";\nimport Quaternion from \"./Quaternion.js\";\nimport Rectangle from \"./Rectangle.js\";\nimport Transforms from \"./Transforms.js\";\n\n/**\n * A geometry representation with attributes forming vertices and optional index data\n * defining primitives. Geometries and an {@link Appearance}, which describes the shading,\n * can be assigned to a {@link Primitive} for visualization. A Primitive can\n * be created from many heterogeneous - in many cases - geometries for performance.\n *
\n * Geometries can be transformed and optimized using functions in {@link GeometryPipeline}.\n *
\n *\n * @alias Geometry\n * @constructor\n *\n * @param {object} options Object with the following properties:\n * @param {GeometryAttributes} options.attributes Attributes, which make up the geometry's vertices.\n * @param {PrimitiveType} [options.primitiveType=PrimitiveType.TRIANGLES] The type of primitives in the geometry.\n * @param {Uint16Array|Uint32Array} [options.indices] Optional index data that determines the primitives in the geometry.\n * @param {BoundingSphere} [options.boundingSphere] An optional bounding sphere that fully enclosed the geometry.\n *\n * @see PolygonGeometry\n * @see RectangleGeometry\n * @see EllipseGeometry\n * @see CircleGeometry\n * @see WallGeometry\n * @see SimplePolylineGeometry\n * @see BoxGeometry\n * @see EllipsoidGeometry\n *\n * @demo {@link https://sandcastle.cesium.com/index.html?src=Geometry%20and%20Appearances.html|Geometry and Appearances Demo}\n *\n * @example\n * // Create geometry with a position attribute and indexed lines.\n * const positions = new Float64Array([\n * 0.0, 0.0, 0.0,\n * 7500000.0, 0.0, 0.0,\n * 0.0, 7500000.0, 0.0\n * ]);\n *\n * const geometry = new Cesium.Geometry({\n * attributes : {\n * position : new Cesium.GeometryAttribute({\n * componentDatatype : Cesium.ComponentDatatype.DOUBLE,\n * componentsPerAttribute : 3,\n * values : positions\n * })\n * },\n * indices : new Uint16Array([0, 1, 1, 2, 2, 0]),\n * primitiveType : Cesium.PrimitiveType.LINES,\n * boundingSphere : Cesium.BoundingSphere.fromVertices(positions)\n * });\n */\nfunction Geometry(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"options.attributes\", options.attributes);\n //>>includeEnd('debug');\n\n /**\n * Attributes, which make up the geometry's vertices. Each property in this object corresponds to a\n * {@link GeometryAttribute} containing the attribute's data.\n *
\n * Attributes are always stored non-interleaved in a Geometry.\n *
\n *
\n * There are reserved attribute names with well-known semantics. The following attributes\n * are created by a Geometry (depending on the provided {@link VertexFormat}.\n *
\n *
position - 3D vertex position. 64-bit floating-point (for precision). 3 components per attribute. See {@link VertexFormat#position}.
\n *
normal - Normal (normalized), commonly used for lighting. 32-bit floating-point. 3 components per attribute. See {@link VertexFormat#normal}.
\n *
st - 2D texture coordinate. 32-bit floating-point. 2 components per attribute. See {@link VertexFormat#st}.
\n *
bitangent - Bitangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. See {@link VertexFormat#bitangent}.
\n *
tangent - Tangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. See {@link VertexFormat#tangent}.
\n *
\n * \n *
\n * The following attribute names are generally not created by a Geometry, but are added\n * to a Geometry by a {@link Primitive} or {@link GeometryPipeline} functions to prepare\n * the geometry for rendering.\n *
\n *
position3DHigh - High 32 bits for encoded 64-bit position computed with {@link GeometryPipeline.encodeAttribute}. 32-bit floating-point. 4 components per attribute.
\n *
position3DLow - Low 32 bits for encoded 64-bit position computed with {@link GeometryPipeline.encodeAttribute}. 32-bit floating-point. 4 components per attribute.
\n *
position3DHigh - High 32 bits for encoded 64-bit 2D (Columbus view) position computed with {@link GeometryPipeline.encodeAttribute}. 32-bit floating-point. 4 components per attribute.
\n *
position2DLow - Low 32 bits for encoded 64-bit 2D (Columbus view) position computed with {@link GeometryPipeline.encodeAttribute}. 32-bit floating-point. 4 components per attribute.
\n *
color - RGBA color (normalized) usually from {@link GeometryInstance#color}. 32-bit floating-point. 4 components per attribute.
\n *
pickColor - RGBA color used for picking. 32-bit floating-point. 4 components per attribute.
\n *
\n * \n *\n * @type GeometryAttributes\n *\n * @default undefined\n *\n *\n * @example\n * geometry.attributes.position = new Cesium.GeometryAttribute({\n * componentDatatype : Cesium.ComponentDatatype.FLOAT,\n * componentsPerAttribute : 3,\n * values : new Float32Array(0)\n * });\n *\n * @see GeometryAttribute\n * @see VertexFormat\n */\n this.attributes = options.attributes;\n\n /**\n * Optional index data that - along with {@link Geometry#primitiveType} -\n * determines the primitives in the geometry.\n *\n * @type {Array}\n *\n * @default undefined\n */\n this.indices = options.indices;\n\n /**\n * The type of primitives in the geometry. This is most often {@link PrimitiveType.TRIANGLES},\n * but can varying based on the specific geometry.\n *\n * @type PrimitiveType\n *\n * @default undefined\n */\n this.primitiveType = defaultValue(\n options.primitiveType,\n PrimitiveType.TRIANGLES\n );\n\n /**\n * An optional bounding sphere that fully encloses the geometry. This is\n * commonly used for culling.\n *\n * @type BoundingSphere\n *\n * @default undefined\n */\n this.boundingSphere = options.boundingSphere;\n\n /**\n * @private\n */\n this.geometryType = defaultValue(options.geometryType, GeometryType.NONE);\n\n /**\n * @private\n */\n this.boundingSphereCV = options.boundingSphereCV;\n\n /**\n * Used for computing the bounding sphere for geometry using the applyOffset vertex attribute\n * @private\n */\n this.offsetAttribute = options.offsetAttribute;\n}\n\n/**\n * Computes the number of vertices in a geometry. The runtime is linear with\n * respect to the number of attributes in a vertex, not the number of vertices.\n *\n * @param {Geometry} geometry The geometry.\n * @returns {number} The number of vertices in the geometry.\n *\n * @example\n * const numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);\n */\nGeometry.computeNumberOfVertices = function (geometry) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"geometry\", geometry);\n //>>includeEnd('debug');\n\n let numberOfVertices = -1;\n for (const property in geometry.attributes) {\n if (\n geometry.attributes.hasOwnProperty(property) &&\n defined(geometry.attributes[property]) &&\n defined(geometry.attributes[property].values)\n ) {\n const attribute = geometry.attributes[property];\n const num = attribute.values.length / attribute.componentsPerAttribute;\n //>>includeStart('debug', pragmas.debug);\n if (numberOfVertices !== num && numberOfVertices !== -1) {\n throw new DeveloperError(\n \"All attribute lists must have the same number of attributes.\"\n );\n }\n //>>includeEnd('debug');\n numberOfVertices = num;\n }\n }\n\n return numberOfVertices;\n};\n\nconst rectangleCenterScratch = new Cartographic();\nconst enuCenterScratch = new Cartesian3();\nconst fixedFrameToEnuScratch = new Matrix4();\nconst boundingRectanglePointsCartographicScratch = [\n new Cartographic(),\n new Cartographic(),\n new Cartographic(),\n];\nconst boundingRectanglePointsEnuScratch = [\n new Cartesian2(),\n new Cartesian2(),\n new Cartesian2(),\n];\nconst points2DScratch = [new Cartesian2(), new Cartesian2(), new Cartesian2()];\nconst pointEnuScratch = new Cartesian3();\nconst enuRotationScratch = new Quaternion();\nconst enuRotationMatrixScratch = new Matrix4();\nconst rotation2DScratch = new Matrix2();\n\n/**\n * For remapping texture coordinates when rendering GroundPrimitives with materials.\n * GroundPrimitive texture coordinates are computed to align with the cartographic coordinate system on the globe.\n * However, EllipseGeometry, RectangleGeometry, and PolygonGeometry all bake rotations to per-vertex texture coordinates\n * using different strategies.\n *\n * This method is used by EllipseGeometry and PolygonGeometry to approximate the same visual effect.\n * We encapsulate rotation and scale by computing a \"transformed\" texture coordinate system and computing\n * a set of reference points from which \"cartographic\" texture coordinates can be remapped to the \"transformed\"\n * system using distances to lines in 2D.\n *\n * This approximation becomes less accurate as the covered area increases, especially for GroundPrimitives near the poles,\n * but is generally reasonable for polygons and ellipses around the size of USA states.\n *\n * RectangleGeometry has its own version of this method that computes remapping coordinates using cartographic space\n * as an intermediary instead of local ENU, which is more accurate for large-area rectangles.\n *\n * @param {Cartesian3[]} positions Array of positions outlining the geometry\n * @param {number} stRotation Texture coordinate rotation.\n * @param {Ellipsoid} ellipsoid Ellipsoid for projecting and generating local vectors.\n * @param {Rectangle} boundingRectangle Bounding rectangle around the positions.\n * @returns {number[]} An array of 6 numbers specifying [minimum point, u extent, v extent] as points in the \"cartographic\" system.\n * @private\n */\nGeometry._textureCoordinateRotationPoints = function (\n positions,\n stRotation,\n ellipsoid,\n boundingRectangle\n) {\n let i;\n\n // Create a local east-north-up coordinate system centered on the polygon's bounding rectangle.\n // Project the southwest, northwest, and southeast corners of the bounding rectangle into the plane of ENU as 2D points.\n // These are the equivalents of (0,0), (0,1), and (1,0) in the texture coordinate system computed in ShadowVolumeAppearanceFS,\n // aka \"ENU texture space.\"\n const rectangleCenter = Rectangle.center(\n boundingRectangle,\n rectangleCenterScratch\n );\n const enuCenter = Cartographic.toCartesian(\n rectangleCenter,\n ellipsoid,\n enuCenterScratch\n );\n const enuToFixedFrame = Transforms.eastNorthUpToFixedFrame(\n enuCenter,\n ellipsoid,\n fixedFrameToEnuScratch\n );\n const fixedFrameToEnu = Matrix4.inverse(\n enuToFixedFrame,\n fixedFrameToEnuScratch\n );\n\n const boundingPointsEnu = boundingRectanglePointsEnuScratch;\n const boundingPointsCarto = boundingRectanglePointsCartographicScratch;\n\n boundingPointsCarto[0].longitude = boundingRectangle.west;\n boundingPointsCarto[0].latitude = boundingRectangle.south;\n\n boundingPointsCarto[1].longitude = boundingRectangle.west;\n boundingPointsCarto[1].latitude = boundingRectangle.north;\n\n boundingPointsCarto[2].longitude = boundingRectangle.east;\n boundingPointsCarto[2].latitude = boundingRectangle.south;\n\n let posEnu = pointEnuScratch;\n\n for (i = 0; i < 3; i++) {\n Cartographic.toCartesian(boundingPointsCarto[i], ellipsoid, posEnu);\n posEnu = Matrix4.multiplyByPointAsVector(fixedFrameToEnu, posEnu, posEnu);\n boundingPointsEnu[i].x = posEnu.x;\n boundingPointsEnu[i].y = posEnu.y;\n }\n\n // Rotate each point in the polygon around the up vector in the ENU by -stRotation and project into ENU as 2D.\n // Compute the bounding box of these rotated points in the 2D ENU plane.\n // Rotate the corners back by stRotation, then compute their equivalents in the ENU texture space using the corners computed earlier.\n const rotation = Quaternion.fromAxisAngle(\n Cartesian3.UNIT_Z,\n -stRotation,\n enuRotationScratch\n );\n const textureMatrix = Matrix3.fromQuaternion(\n rotation,\n enuRotationMatrixScratch\n );\n\n const positionsLength = positions.length;\n let enuMinX = Number.POSITIVE_INFINITY;\n let enuMinY = Number.POSITIVE_INFINITY;\n let enuMaxX = Number.NEGATIVE_INFINITY;\n let enuMaxY = Number.NEGATIVE_INFINITY;\n for (i = 0; i < positionsLength; i++) {\n posEnu = Matrix4.multiplyByPointAsVector(\n fixedFrameToEnu,\n positions[i],\n posEnu\n );\n posEnu = Matrix3.multiplyByVector(textureMatrix, posEnu, posEnu);\n\n enuMinX = Math.min(enuMinX, posEnu.x);\n enuMinY = Math.min(enuMinY, posEnu.y);\n enuMaxX = Math.max(enuMaxX, posEnu.x);\n enuMaxY = Math.max(enuMaxY, posEnu.y);\n }\n\n const toDesiredInComputed = Matrix2.fromRotation(\n stRotation,\n rotation2DScratch\n );\n\n const points2D = points2DScratch;\n points2D[0].x = enuMinX;\n points2D[0].y = enuMinY;\n\n points2D[1].x = enuMinX;\n points2D[1].y = enuMaxY;\n\n points2D[2].x = enuMaxX;\n points2D[2].y = enuMinY;\n\n const boundingEnuMin = boundingPointsEnu[0];\n const boundingPointsWidth = boundingPointsEnu[2].x - boundingEnuMin.x;\n const boundingPointsHeight = boundingPointsEnu[1].y - boundingEnuMin.y;\n\n for (i = 0; i < 3; i++) {\n const point2D = points2D[i];\n // rotate back\n Matrix2.multiplyByVector(toDesiredInComputed, point2D, point2D);\n\n // Convert point into east-north texture coordinate space\n point2D.x = (point2D.x - boundingEnuMin.x) / boundingPointsWidth;\n point2D.y = (point2D.y - boundingEnuMin.y) / boundingPointsHeight;\n }\n\n const minXYCorner = points2D[0];\n const maxYCorner = points2D[1];\n const maxXCorner = points2D[2];\n const result = new Array(6);\n Cartesian2.pack(minXYCorner, result);\n Cartesian2.pack(maxYCorner, result, 2);\n Cartesian2.pack(maxXCorner, result, 4);\n\n return result;\n};\nexport default Geometry;\n", "import defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Values and type information for geometry attributes. A {@link Geometry}\n * generally contains one or more attributes. All attributes together form\n * the geometry's vertices.\n *\n * @alias GeometryAttribute\n * @constructor\n *\n * @param {object} [options] Object with the following properties:\n * @param {ComponentDatatype} [options.componentDatatype] The datatype of each component in the attribute, e.g., individual elements in values.\n * @param {number} [options.componentsPerAttribute] A number between 1 and 4 that defines the number of components in an attributes.\n * @param {boolean} [options.normalize=false] When true and componentDatatype is an integer format, indicate that the components should be mapped to the range [0, 1] (unsigned) or [-1, 1] (signed) when they are accessed as floating-point for rendering.\n * @param {number[]|Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} [options.values] The values for the attributes stored in a typed array.\n *\n * @exception {DeveloperError} options.componentsPerAttribute must be between 1 and 4.\n *\n *\n * @example\n * const geometry = new Cesium.Geometry({\n * attributes : {\n * position : new Cesium.GeometryAttribute({\n * componentDatatype : Cesium.ComponentDatatype.FLOAT,\n * componentsPerAttribute : 3,\n * values : new Float32Array([\n * 0.0, 0.0, 0.0,\n * 7500000.0, 0.0, 0.0,\n * 0.0, 7500000.0, 0.0\n * ])\n * })\n * },\n * primitiveType : Cesium.PrimitiveType.LINE_LOOP\n * });\n *\n * @see Geometry\n */\nfunction GeometryAttribute(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n //>>includeStart('debug', pragmas.debug);\n if (!defined(options.componentDatatype)) {\n throw new DeveloperError(\"options.componentDatatype is required.\");\n }\n if (!defined(options.componentsPerAttribute)) {\n throw new DeveloperError(\"options.componentsPerAttribute is required.\");\n }\n if (\n options.componentsPerAttribute < 1 ||\n options.componentsPerAttribute > 4\n ) {\n throw new DeveloperError(\n \"options.componentsPerAttribute must be between 1 and 4.\"\n );\n }\n if (!defined(options.values)) {\n throw new DeveloperError(\"options.values is required.\");\n }\n //>>includeEnd('debug');\n\n /**\n * The datatype of each component in the attribute, e.g., individual elements in\n * {@link GeometryAttribute#values}.\n *\n * @type {ComponentDatatype}\n *\n * @default undefined\n */\n this.componentDatatype = options.componentDatatype;\n\n /**\n * A number between 1 and 4 that defines the number of components in an attributes.\n * For example, a position attribute with x, y, and z components would have 3 as\n * shown in the code example.\n *\n * @type {number}\n *\n * @default undefined\n *\n * @example\n * attribute.componentDatatype = Cesium.ComponentDatatype.FLOAT;\n * attribute.componentsPerAttribute = 3;\n * attribute.values = new Float32Array([\n * 0.0, 0.0, 0.0,\n * 7500000.0, 0.0, 0.0,\n * 0.0, 7500000.0, 0.0\n * ]);\n */\n this.componentsPerAttribute = options.componentsPerAttribute;\n\n /**\n * When true and componentDatatype is an integer format,\n * indicate that the components should be mapped to the range [0, 1] (unsigned)\n * or [-1, 1] (signed) when they are accessed as floating-point for rendering.\n *
\n * This is commonly used when storing colors using {@link ComponentDatatype.UNSIGNED_BYTE}.\n *
\n *\n * @type {boolean}\n *\n * @default false\n *\n * @example\n * attribute.componentDatatype = Cesium.ComponentDatatype.UNSIGNED_BYTE;\n * attribute.componentsPerAttribute = 4;\n * attribute.normalize = true;\n * attribute.values = new Uint8Array([\n * Cesium.Color.floatToByte(color.red),\n * Cesium.Color.floatToByte(color.green),\n * Cesium.Color.floatToByte(color.blue),\n * Cesium.Color.floatToByte(color.alpha)\n * ]);\n */\n this.normalize = defaultValue(options.normalize, false);\n\n /**\n * The values for the attributes stored in a typed array. In the code example,\n * every three elements in values defines one attributes since\n * componentsPerAttribute is 3.\n *\n * @type {number[]|Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array}\n *\n * @default undefined\n *\n * @example\n * attribute.componentDatatype = Cesium.ComponentDatatype.FLOAT;\n * attribute.componentsPerAttribute = 3;\n * attribute.values = new Float32Array([\n * 0.0, 0.0, 0.0,\n * 7500000.0, 0.0, 0.0,\n * 0.0, 7500000.0, 0.0\n * ]);\n */\n this.values = options.values;\n}\nexport default GeometryAttribute;\n", "import defined from \"./defined.js\";\n\n/**\n * Describes a compressed texture and contains a compressed texture buffer.\n * @alias CompressedTextureBuffer\n * @constructor\n *\n * @param {PixelFormat} internalFormat The pixel format of the compressed texture.\n * @param {PixelDatatype} pixelDatatype The pixel datatype of the compressed texture.\n * @param {number} width The width of the texture.\n * @param {number} height The height of the texture.\n * @param {Uint8Array} buffer The compressed texture buffer.\n */\nfunction CompressedTextureBuffer(\n internalFormat,\n pixelDatatype,\n width,\n height,\n buffer\n) {\n this._format = internalFormat;\n this._datatype = pixelDatatype;\n this._width = width;\n this._height = height;\n this._buffer = buffer;\n}\n\nObject.defineProperties(CompressedTextureBuffer.prototype, {\n /**\n * The format of the compressed texture.\n * @type {PixelFormat}\n * @readonly\n * @memberof CompressedTextureBuffer.prototype\n */\n internalFormat: {\n get: function () {\n return this._format;\n },\n },\n /**\n * The datatype of the compressed texture.\n * @type {PixelDatatype}\n * @readonly\n * @memberof CompressedTextureBuffer.prototype\n */\n pixelDatatype: {\n get: function () {\n return this._datatype;\n },\n },\n /**\n * The width of the texture.\n * @type {number}\n * @readonly\n * @memberof CompressedTextureBuffer.prototype\n */\n width: {\n get: function () {\n return this._width;\n },\n },\n /**\n * The height of the texture.\n * @type {number}\n * @readonly\n * @memberof CompressedTextureBuffer.prototype\n */\n height: {\n get: function () {\n return this._height;\n },\n },\n /**\n * The compressed texture buffer.\n * @type {Uint8Array}\n * @readonly\n * @memberof CompressedTextureBuffer.prototype\n */\n bufferView: {\n get: function () {\n return this._buffer;\n },\n },\n});\n\n/**\n * Creates a shallow clone of a compressed texture buffer.\n *\n * @param {CompressedTextureBuffer} object The compressed texture buffer to be cloned.\n * @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer.\n */\nCompressedTextureBuffer.clone = function (object) {\n if (!defined(object)) {\n return undefined;\n }\n\n return new CompressedTextureBuffer(\n object._format,\n object._datatype,\n object._width,\n object._height,\n object._buffer\n );\n};\n\n/**\n * Creates a shallow clone of this compressed texture buffer.\n *\n * @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer.\n */\nCompressedTextureBuffer.prototype.clone = function () {\n return CompressedTextureBuffer.clone(this);\n};\nexport default CompressedTextureBuffer;\n", "import Uri from \"urijs\";\nimport buildModuleUrl from \"./buildModuleUrl.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defer from \"./defer.js\";\nimport defined from \"./defined.js\";\nimport destroyObject from \"./destroyObject.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport Event from \"./Event.js\";\nimport FeatureDetection from \"./FeatureDetection.js\";\nimport isCrossOriginUrl from \"./isCrossOriginUrl.js\";\nimport Resource from \"./Resource.js\";\nimport RuntimeError from \"./RuntimeError.js\";\n\nfunction canTransferArrayBuffer() {\n if (!defined(TaskProcessor._canTransferArrayBuffer)) {\n const worker = new Worker(\n getWorkerUrl(\"Workers/transferTypedArrayTest.js\")\n );\n worker.postMessage = defaultValue(\n worker.webkitPostMessage,\n worker.postMessage\n );\n\n const value = 99;\n const array = new Int8Array([value]);\n\n try {\n // postMessage might fail with a DataCloneError\n // if transferring array buffers is not supported.\n worker.postMessage(\n {\n array: array,\n },\n [array.buffer]\n );\n } catch (e) {\n TaskProcessor._canTransferArrayBuffer = false;\n return TaskProcessor._canTransferArrayBuffer;\n }\n\n const deferred = defer();\n\n worker.onmessage = function (event) {\n const array = event.data.array;\n\n // some versions of Firefox silently fail to transfer typed arrays.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=841904\n // Check to make sure the value round-trips successfully.\n const result = defined(array) && array[0] === value;\n deferred.resolve(result);\n\n worker.terminate();\n\n TaskProcessor._canTransferArrayBuffer = result;\n };\n\n TaskProcessor._canTransferArrayBuffer = deferred.promise;\n }\n\n return TaskProcessor._canTransferArrayBuffer;\n}\n\nconst taskCompletedEvent = new Event();\n\nfunction completeTask(processor, data) {\n --processor._activeTasks;\n\n const id = data.id;\n if (!defined(id)) {\n // This is not one of ours.\n return;\n }\n\n const deferreds = processor._deferreds;\n const deferred = deferreds[id];\n\n if (defined(data.error)) {\n let error = data.error;\n if (error.name === \"RuntimeError\") {\n error = new RuntimeError(data.error.message);\n error.stack = data.error.stack;\n } else if (error.name === \"DeveloperError\") {\n error = new DeveloperError(data.error.message);\n error.stack = data.error.stack;\n }\n taskCompletedEvent.raiseEvent(error);\n deferred.reject(error);\n } else {\n taskCompletedEvent.raiseEvent();\n deferred.resolve(data.result);\n }\n\n delete deferreds[id];\n}\n\nfunction getWorkerUrl(moduleID) {\n let url = buildModuleUrl(moduleID);\n\n if (isCrossOriginUrl(url)) {\n //to load cross-origin, create a shim worker from a blob URL\n const script = `importScripts(\"${url}\");`;\n\n let blob;\n try {\n blob = new Blob([script], {\n type: \"application/javascript\",\n });\n } catch (e) {\n const BlobBuilder =\n window.BlobBuilder ||\n window.WebKitBlobBuilder ||\n window.MozBlobBuilder ||\n window.MSBlobBuilder;\n const blobBuilder = new BlobBuilder();\n blobBuilder.append(script);\n blob = blobBuilder.getBlob(\"application/javascript\");\n }\n\n const URL = window.URL || window.webkitURL;\n url = URL.createObjectURL(blob);\n }\n\n return url;\n}\n\nlet bootstrapperUrlResult;\nfunction getBootstrapperUrl() {\n if (!defined(bootstrapperUrlResult)) {\n bootstrapperUrlResult = getWorkerUrl(\"Workers/cesiumWorkerBootstrapper.js\");\n }\n return bootstrapperUrlResult;\n}\n\nfunction createWorker(processor) {\n const worker = new Worker(getBootstrapperUrl());\n worker.postMessage = defaultValue(\n worker.webkitPostMessage,\n worker.postMessage\n );\n\n const bootstrapMessage = {\n loaderConfig: {\n paths: {\n Workers: buildModuleUrl(\"Workers\"),\n },\n baseUrl: buildModuleUrl.getCesiumBaseUrl().url,\n },\n workerModule: processor._workerPath,\n };\n\n worker.postMessage(bootstrapMessage);\n worker.onmessage = function (event) {\n completeTask(processor, event.data);\n };\n\n return worker;\n}\n\nfunction getWebAssemblyLoaderConfig(processor, wasmOptions) {\n const config = {\n modulePath: undefined,\n wasmBinaryFile: undefined,\n wasmBinary: undefined,\n };\n\n // Web assembly not supported, use fallback js module if provided\n if (!FeatureDetection.supportsWebAssembly()) {\n if (!defined(wasmOptions.fallbackModulePath)) {\n throw new RuntimeError(\n `This browser does not support Web Assembly, and no backup module was provided for ${processor._workerPath}`\n );\n }\n\n config.modulePath = buildModuleUrl(wasmOptions.fallbackModulePath);\n return Promise.resolve(config);\n }\n\n config.modulePath = buildModuleUrl(wasmOptions.modulePath);\n config.wasmBinaryFile = buildModuleUrl(wasmOptions.wasmBinaryFile);\n\n return Resource.fetchArrayBuffer({\n url: config.wasmBinaryFile,\n }).then(function (arrayBuffer) {\n config.wasmBinary = arrayBuffer;\n return config;\n });\n}\n\n/**\n * A wrapper around a web worker that allows scheduling tasks for a given worker,\n * returning results asynchronously via a promise.\n *\n * The Worker is not constructed until a task is scheduled.\n *\n * @alias TaskProcessor\n * @constructor\n *\n * @param {string} workerPath The Url to the worker. This can either be an absolute path or relative to the Cesium Workers folder.\n * @param {number} [maximumActiveTasks=Number.POSITIVE_INFINITY] The maximum number of active tasks. Once exceeded,\n * scheduleTask will not queue any more tasks, allowing\n * work to be rescheduled in future frames.\n */\nfunction TaskProcessor(workerPath, maximumActiveTasks) {\n const uri = new Uri(workerPath);\n this._workerPath =\n uri.scheme().length !== 0 && uri.fragment().length === 0\n ? workerPath\n : TaskProcessor._workerModulePrefix + workerPath;\n this._maximumActiveTasks = defaultValue(\n maximumActiveTasks,\n Number.POSITIVE_INFINITY\n );\n this._activeTasks = 0;\n this._deferreds = {};\n this._nextID = 0;\n}\n\nconst emptyTransferableObjectArray = [];\n\n/**\n * Schedule a task to be processed by the web worker asynchronously. If there are currently more\n * tasks active than the maximum set by the constructor, will immediately return undefined.\n * Otherwise, returns a promise that will resolve to the result posted back by the worker when\n * finished.\n *\n * @param {object} parameters Any input data that will be posted to the worker.\n * @param {Object[]} [transferableObjects] An array of objects contained in parameters that should be\n * transferred to the worker instead of copied.\n * @returns {Promise