@cesium/engine 14.0.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/Workers/{chunk-WVNLSTOF.js → chunk-2TQ64T4I.js} +2 -2
- package/Build/Workers/{chunk-ED6GLQTK.js → chunk-34EWMUFG.js} +1 -1
- package/Build/Workers/{chunk-HEZHXDYB.js → chunk-4LHK6E47.js} +1 -1
- package/Build/Workers/{chunk-7EO56M5R.js → chunk-5TN3LG2T.js} +2 -2
- package/Build/Workers/{chunk-7ZB2RVIQ.js → chunk-6B7KGA5P.js} +16 -19
- package/Build/Workers/{chunk-3QLSKXKF.js → chunk-B75OO2DU.js} +7 -10
- package/Build/Workers/{chunk-Q4ZVWJXX.js → chunk-COOLDICB.js} +9 -11
- package/Build/Workers/{chunk-3PIZQT3I.js → chunk-CQNYYX3N.js} +4 -4
- package/Build/Workers/{chunk-JPDKYBLF.js → chunk-CUJH7PS5.js} +27 -29
- package/Build/Workers/{chunk-CI2HEJFC.js → chunk-EAWYQ44R.js} +39 -41
- package/Build/Workers/{chunk-SDIDRZDG.js → chunk-EJJDBH5W.js} +7 -7
- package/Build/Workers/{chunk-5KWRW7YL.js → chunk-EO44CO62.js} +2 -2
- package/Build/Workers/{chunk-N2XAJBC6.js → chunk-EOIUWEAK.js} +26 -28
- package/Build/Workers/{chunk-YJX7X577.js → chunk-ERKJ7IWJ.js} +21 -23
- package/Build/Workers/{chunk-J7IH4EYI.js → chunk-ESED7XBA.js} +13 -16
- package/Build/Workers/{chunk-F4CUH4MR.js → chunk-FW2OX42E.js} +18 -21
- package/Build/Workers/{chunk-FX4R4MTH.js → chunk-GH6I7PBY.js} +6 -9
- package/Build/Workers/{chunk-FYGLNDKG.js → chunk-GQVSADCI.js} +19 -22
- package/Build/Workers/{chunk-TY4DKOWR.js → chunk-ICU72UPR.js} +4 -4
- package/Build/Workers/{chunk-DT5NFR5C.js → chunk-ILVAXLMC.js} +7 -7
- package/Build/Workers/{chunk-ZGFIT57T.js → chunk-KKV6XBF5.js} +27 -23
- package/Build/Workers/{chunk-HKHQ3EDR.js → chunk-KV6TEHXY.js} +4 -4
- package/Build/Workers/{chunk-B4GSRXE3.js → chunk-LCSH4ZOB.js} +7 -10
- package/Build/Workers/{chunk-LNSWJ43X.js → chunk-M5J3S3HY.js} +17 -26
- package/Build/Workers/{chunk-LJBJM6VI.js → chunk-NB6D74SQ.js} +6 -6
- package/Build/Workers/{chunk-4CHMVQTQ.js → chunk-NREPBWCX.js} +14 -14
- package/Build/Workers/{chunk-PWF4EY5P.js → chunk-OD4Q7HE5.js} +4 -4
- package/Build/Workers/{chunk-77XPS7ZA.js → chunk-OMFZ4IN6.js} +15 -24
- package/Build/Workers/{chunk-HUFQVUMY.js → chunk-OMZGZVHI.js} +12 -17
- package/Build/Workers/{chunk-LOZ4NKY3.js → chunk-ORIMMEHO.js} +18 -20
- package/Build/Workers/{chunk-5S5OOA6U.js → chunk-OWLBD6BL.js} +1 -1
- package/Build/Workers/{chunk-VCNOFQYH.js → chunk-PB6SE3SZ.js} +9 -12
- package/Build/Workers/{chunk-3JBEPBPL.js → chunk-PT6U7UNY.js} +25 -30
- package/Build/Workers/{chunk-G3BVMPWG.js → chunk-RWAFHSX3.js} +2 -2
- package/Build/Workers/{chunk-KHWLAQVA.js → chunk-S2NKKWYE.js} +1 -1
- package/Build/Workers/{chunk-FFBJDW4A.js → chunk-S3IQBSIB.js} +6 -6
- package/Build/Workers/{chunk-3LYROPON.js → chunk-SCUQTTCN.js} +16 -19
- package/Build/Workers/{chunk-ZMNLEL6W.js → chunk-TBSA4MNF.js} +5 -8
- package/Build/Workers/{chunk-EWDGNOJE.js → chunk-TEUGW455.js} +9 -12
- package/Build/Workers/{chunk-XK4OP6VA.js → chunk-TL5YKZJF.js} +33 -41
- package/Build/Workers/{chunk-KM6MITPF.js → chunk-V4Y7C25O.js} +46 -42
- package/Build/Workers/{chunk-OMXHEJTK.js → chunk-VNDECE6N.js} +2 -2
- package/Build/Workers/{chunk-LS3KVHYY.js → chunk-VVTAI2TN.js} +6 -9
- package/Build/Workers/{chunk-WEHZP4SE.js → chunk-VXAAIRJ7.js} +129 -146
- package/Build/Workers/{chunk-MVM4JV5U.js → chunk-WGIOUM2S.js} +9 -12
- package/Build/Workers/{chunk-JHBPC4LK.js → chunk-XF6EBVKV.js} +7 -7
- package/Build/Workers/{chunk-D7ZBZPHV.js → chunk-XMKE4XB2.js} +5 -5
- package/Build/Workers/{chunk-7UHKH6M3.js → chunk-YA4XALD5.js} +34 -36
- package/Build/Workers/{chunk-KSYBJA4M.js → chunk-YFXXUW6U.js} +6 -12
- package/Build/Workers/{chunk-Z3QWTHI7.js → chunk-YL26OJCG.js} +21 -23
- package/Build/Workers/{chunk-K4AH3TDT.js → chunk-ZLJDDRGB.js} +14 -17
- package/Build/Workers/combineGeometry.js +21 -22
- package/Build/Workers/createBoxGeometry.js +15 -16
- package/Build/Workers/createBoxOutlineGeometry.js +20 -25
- package/Build/Workers/createCircleGeometry.js +26 -28
- package/Build/Workers/createCircleOutlineGeometry.js +19 -21
- package/Build/Workers/createCoplanarPolygonGeometry.js +38 -42
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +34 -36
- package/Build/Workers/createCorridorGeometry.js +42 -49
- package/Build/Workers/createCorridorOutlineGeometry.js +36 -43
- package/Build/Workers/createCylinderGeometry.js +17 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +23 -25
- package/Build/Workers/createEllipseGeometry.js +23 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +16 -17
- package/Build/Workers/createEllipsoidGeometry.js +16 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -16
- package/Build/Workers/createFrustumGeometry.js +15 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -21
- package/Build/Workers/createGeometry.js +22 -25
- package/Build/Workers/createGroundPolylineGeometry.js +34 -42
- package/Build/Workers/createPlaneGeometry.js +19 -21
- package/Build/Workers/createPlaneOutlineGeometry.js +12 -13
- package/Build/Workers/createPolygonGeometry.js +45 -50
- package/Build/Workers/createPolygonOutlineGeometry.js +39 -44
- package/Build/Workers/createPolylineGeometry.js +33 -40
- package/Build/Workers/createPolylineVolumeGeometry.js +37 -44
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +32 -39
- package/Build/Workers/createRectangleGeometry.js +41 -51
- package/Build/Workers/createRectangleOutlineGeometry.js +28 -33
- package/Build/Workers/createSimplePolylineGeometry.js +29 -34
- package/Build/Workers/createSphereGeometry.js +17 -20
- package/Build/Workers/createSphereOutlineGeometry.js +16 -19
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +12 -13
- package/Build/Workers/createVectorTileGeometries.js +21 -22
- package/Build/Workers/createVectorTilePoints.js +11 -12
- package/Build/Workers/createVectorTilePolygons.js +19 -20
- package/Build/Workers/createVectorTilePolylines.js +12 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -23
- package/Build/Workers/createVerticesFromHeightmap.js +31 -58
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -18
- package/Build/Workers/createWallGeometry.js +30 -35
- package/Build/Workers/createWallOutlineGeometry.js +28 -33
- package/Build/Workers/decodeDraco.js +10 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -16
- package/Build/Workers/transcodeKTX2.js +50 -46
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -20
- package/Source/Core/ApproximateTerrainHeights.js +2 -3
- package/Source/Core/ArcGISTiledElevationTerrainProvider.js +6 -6
- package/Source/Core/AxisAlignedBoundingBox.js +2 -3
- package/Source/Core/BingMapsGeocoderService.js +2 -2
- package/Source/Core/BoundingRectangle.js +7 -8
- package/Source/Core/BoundingSphere.js +10 -11
- package/Source/Core/BoxGeometry.js +7 -7
- package/Source/Core/BoxOutlineGeometry.js +7 -9
- package/Source/Core/Cartesian2.js +4 -5
- package/Source/Core/Cartesian3.js +7 -8
- package/Source/Core/Cartesian4.js +6 -7
- package/Source/Core/Cartographic.js +5 -6
- package/Source/Core/CatmullRomSpline.js +2 -2
- package/Source/Core/CesiumTerrainProvider.js +11 -14
- package/Source/Core/CircleGeometry.js +2 -2
- package/Source/Core/CircleOutlineGeometry.js +2 -2
- package/Source/Core/Clock.js +7 -10
- package/Source/Core/Color.js +28 -28
- package/Source/Core/ColorGeometryInstanceAttribute.js +4 -5
- package/Source/Core/ComponentDatatype.js +4 -6
- package/Source/Core/CoplanarPolygonGeometry.js +8 -10
- package/Source/Core/CoplanarPolygonOutlineGeometry.js +5 -5
- package/Source/Core/CorridorGeometry.js +15 -20
- package/Source/Core/CorridorOutlineGeometry.js +10 -15
- package/Source/Core/Credit.js +1 -2
- package/Source/Core/CullingVolume.js +1 -2
- package/Source/Core/CustomHeightmapTerrainProvider.js +3 -3
- package/Source/Core/CylinderGeometry.js +7 -7
- package/Source/Core/CylinderOutlineGeometry.js +7 -7
- package/Source/Core/DistanceDisplayCondition.js +4 -5
- package/Source/Core/DistanceDisplayConditionGeometryInstanceAttribute.js +2 -3
- package/Source/Core/EarthOrientationParameters.js +4 -4
- package/Source/Core/EllipseGeometry.js +17 -23
- package/Source/Core/EllipseOutlineGeometry.js +12 -15
- package/Source/Core/Ellipsoid.js +7 -8
- package/Source/Core/EllipsoidGeodesic.js +1 -2
- package/Source/Core/EllipsoidGeometry.js +15 -15
- package/Source/Core/EllipsoidOutlineGeometry.js +15 -15
- package/Source/Core/EllipsoidRhumbLine.js +3 -4
- package/Source/Core/EllipsoidTangentPlane.js +1 -2
- package/Source/Core/EllipsoidTerrainProvider.js +4 -4
- package/Source/Core/EllipsoidalOccluder.js +2 -3
- package/Source/Core/FeatureDetection.js +1 -2
- package/Source/Core/Frozen.js +24 -0
- package/Source/Core/FrustumGeometry.js +7 -8
- package/Source/Core/FrustumOutlineGeometry.js +3 -4
- package/Source/Core/GeographicProjection.js +1 -2
- package/Source/Core/GeographicTilingScheme.js +6 -12
- package/Source/Core/Geometry.js +4 -7
- package/Source/Core/GeometryAttribute.js +3 -3
- package/Source/Core/GeometryAttributes.js +2 -2
- package/Source/Core/GeometryInstance.js +4 -6
- package/Source/Core/GeometryInstanceAttribute.js +3 -3
- package/Source/Core/GeometryPipeline.js +3 -4
- package/Source/Core/GoogleEarthEnterpriseMetadata.js +13 -24
- package/Source/Core/GoogleEarthEnterpriseTerrainData.js +9 -12
- package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +3 -3
- package/Source/Core/GoogleGeocoderService.js +2 -2
- package/Source/Core/GregorianDate.js +8 -9
- package/Source/Core/GroundPolylineGeometry.js +8 -8
- package/Source/Core/HeadingPitchRange.js +3 -4
- package/Source/Core/HeadingPitchRoll.js +3 -4
- package/Source/Core/Heap.js +3 -4
- package/Source/Core/HeightmapTerrainData.js +22 -38
- package/Source/Core/HeightmapTessellator.js +21 -37
- package/Source/Core/HermitePolynomialApproximation.js +1 -2
- package/Source/Core/HermiteSpline.js +5 -5
- package/Source/Core/ITwinPlatform.js +66 -12
- package/Source/Core/Iau2006XysData.js +8 -10
- package/Source/Core/IntersectionTests.js +1 -2
- package/Source/Core/Interval.js +2 -4
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocoderService.js +6 -10
- package/Source/Core/IonResource.js +6 -6
- package/Source/Core/JulianDate.js +11 -12
- package/Source/Core/LinearSpline.js +2 -2
- package/Source/Core/ManagedArray.js +2 -3
- package/Source/Core/Math.js +36 -27
- package/Source/Core/Matrix2.js +7 -8
- package/Source/Core/Matrix3.js +12 -13
- package/Source/Core/Matrix4.js +28 -28
- package/Source/Core/MorphWeightSpline.js +2 -2
- package/Source/Core/NearFarScalar.js +6 -7
- package/Source/Core/Occluder.js +1 -2
- package/Source/Core/OffsetGeometryInstanceAttribute.js +3 -4
- package/Source/Core/OpenCageGeocoderService.js +1 -2
- package/Source/Core/OrientedBoundingBox.js +7 -8
- package/Source/Core/OrthographicFrustum.js +6 -6
- package/Source/Core/OrthographicOffCenterFrustum.js +4 -4
- package/Source/Core/PerspectiveFrustum.js +8 -8
- package/Source/Core/PerspectiveOffCenterFrustum.js +4 -4
- package/Source/Core/PlaneGeometry.js +5 -5
- package/Source/Core/PolygonGeometry.js +16 -19
- package/Source/Core/PolygonGeometryLibrary.js +27 -6
- package/Source/Core/PolygonOutlineGeometry.js +11 -14
- package/Source/Core/PolygonPipeline.js +5 -6
- package/Source/Core/PolylineGeometry.js +10 -15
- package/Source/Core/PolylinePipeline.js +7 -14
- package/Source/Core/PolylineVolumeGeometry.js +8 -13
- package/Source/Core/PolylineVolumeOutlineGeometry.js +7 -12
- package/Source/Core/QuantizedMeshTerrainData.js +12 -16
- package/Source/Core/Quaternion.js +7 -8
- package/Source/Core/QuaternionSpline.js +2 -2
- package/Source/Core/Ray.js +2 -3
- package/Source/Core/Rectangle.js +18 -19
- package/Source/Core/RectangleGeometry.js +17 -25
- package/Source/Core/RectangleGeometryLibrary.js +1 -1
- package/Source/Core/RectangleOutlineGeometry.js +10 -13
- package/Source/Core/Request.js +6 -6
- package/Source/Core/RequestScheduler.js +4 -6
- package/Source/Core/Resource.js +13 -16
- package/Source/Core/S2Cell.js +2 -3
- package/Source/Core/ScreenSpaceEventHandler.js +1 -2
- package/Source/Core/ShowGeometryInstanceAttribute.js +1 -2
- package/Source/Core/Simon1994PlanetaryPositions.js +9 -9
- package/Source/Core/SimplePolylineGeometry.js +8 -11
- package/Source/Core/SphereGeometry.js +1 -2
- package/Source/Core/SphereOutlineGeometry.js +1 -2
- package/Source/Core/Spherical.js +4 -5
- package/Source/Core/Spline.js +1 -2
- package/Source/Core/SteppedSpline.js +2 -2
- package/Source/Core/TaskProcessor.js +2 -9
- package/Source/Core/TerrainData.js +1 -1
- package/Source/Core/TerrainEncoding.js +4 -11
- package/Source/Core/TerrainMesh.js +1 -3
- package/Source/Core/TerrainProvider.js +1 -1
- package/Source/Core/TexturePacker.js +166 -0
- package/Source/Core/TileProviderError.js +1 -2
- package/Source/Core/TimeInterval.js +7 -7
- package/Source/Core/TimeIntervalCollection.js +7 -7
- package/Source/Core/Tipsify.js +5 -5
- package/Source/Core/Transforms.js +10 -15
- package/Source/Core/TranslationRotationScale.js +3 -6
- package/Source/Core/VRTheWorldTerrainProvider.js +5 -5
- package/Source/Core/VertexFormat.js +10 -10
- package/Source/Core/VerticalExaggeration.js +1 -1
- package/Source/Core/VideoSynchronizer.js +6 -6
- package/Source/Core/WallGeometry.js +8 -11
- package/Source/Core/WallOutlineGeometry.js +7 -10
- package/Source/Core/WebMercatorProjection.js +1 -2
- package/Source/Core/WebMercatorTilingScheme.js +5 -11
- package/Source/Core/arrayRemoveDuplicates.js +1 -2
- package/Source/Core/clone.js +1 -3
- package/Source/Core/combine.js +1 -2
- package/Source/Core/createWorldBathymetryAsync.js +3 -3
- package/Source/Core/createWorldTerrainAsync.js +4 -4
- package/Source/Core/defaultValue.js +20 -1
- package/Source/Core/destroyObject.js +1 -5
- package/Source/Core/getAbsoluteUri.js +1 -2
- package/Source/Core/getMagic.js +1 -2
- package/Source/Core/getStringFromTypedArray.js +2 -3
- package/Source/Core/loadImageFromTypedArray.js +2 -6
- package/Source/Core/oneTimeWarning.js +1 -2
- package/Source/Core/writeTextToCanvas.js +10 -13
- package/Source/DataSources/BillboardGraphics.js +27 -53
- package/Source/DataSources/BillboardVisualizer.js +3 -3
- package/Source/DataSources/BoxGraphics.js +13 -18
- package/Source/DataSources/CallbackPositionProperty.js +1 -2
- package/Source/DataSources/Cesium3DTilesetGraphics.js +6 -8
- package/Source/DataSources/CheckerboardMaterialProperty.js +2 -2
- package/Source/DataSources/CompositePositionProperty.js +1 -2
- package/Source/DataSources/ConstantPositionProperty.js +1 -2
- package/Source/DataSources/CorridorGraphics.js +23 -35
- package/Source/DataSources/CylinderGraphics.js +18 -25
- package/Source/DataSources/CzmlDataSource.js +34 -60
- package/Source/DataSources/DataSourceClock.js +12 -13
- package/Source/DataSources/DataSourceCollection.js +2 -3
- package/Source/DataSources/DataSourceDisplay.js +2 -5
- package/Source/DataSources/EllipseGraphics.js +26 -40
- package/Source/DataSources/EllipsoidGeometryUpdater.js +1 -2
- package/Source/DataSources/EllipsoidGraphics.js +21 -32
- package/Source/DataSources/Entity.js +7 -9
- package/Source/DataSources/EntityCluster.js +53 -28
- package/Source/DataSources/EntityView.js +1 -2
- package/Source/DataSources/GeoJsonDataSource.js +12 -12
- package/Source/DataSources/GeometryUpdater.js +12 -17
- package/Source/DataSources/GeometryVisualizer.js +2 -3
- package/Source/DataSources/GpxDataSource.js +4 -7
- package/Source/DataSources/GridMaterialProperty.js +2 -2
- package/Source/DataSources/GroundGeometryUpdater.js +1 -2
- package/Source/DataSources/ImageMaterialProperty.js +2 -2
- package/Source/DataSources/KmlDataSource.js +84 -158
- package/Source/DataSources/LabelGraphics.js +27 -56
- package/Source/DataSources/LabelVisualizer.js +1 -2
- package/Source/DataSources/ModelGraphics.js +29 -63
- package/Source/DataSources/ModelVisualizer.js +1 -2
- package/Source/DataSources/NodeTransformationProperty.js +2 -2
- package/Source/DataSources/PathGraphics.js +10 -12
- package/Source/DataSources/PlaneGraphics.js +13 -15
- package/Source/DataSources/PointGraphics.js +17 -32
- package/Source/DataSources/PolygonGraphics.js +28 -45
- package/Source/DataSources/PolylineDashMaterialProperty.js +2 -2
- package/Source/DataSources/PolylineGeometryUpdater.js +9 -14
- package/Source/DataSources/PolylineGlowMaterialProperty.js +2 -2
- package/Source/DataSources/PolylineGraphics.js +16 -23
- package/Source/DataSources/PolylineOutlineMaterialProperty.js +2 -2
- package/Source/DataSources/PolylineVisualizer.js +2 -3
- package/Source/DataSources/PolylineVolumeGraphics.js +15 -17
- package/Source/DataSources/PositionPropertyArray.js +1 -2
- package/Source/DataSources/Property.js +1 -2
- package/Source/DataSources/PropertyBag.js +1 -2
- package/Source/DataSources/RectangleGraphics.js +23 -35
- package/Source/DataSources/Rotation.js +4 -5
- package/Source/DataSources/SampledPositionProperty.js +2 -3
- package/Source/DataSources/SampledProperty.js +6 -11
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -2
- package/Source/DataSources/StripeMaterialProperty.js +2 -2
- package/Source/DataSources/TimeIntervalCollectionPositionProperty.js +1 -2
- package/Source/DataSources/VelocityOrientationProperty.js +1 -2
- package/Source/DataSources/VelocityVectorProperty.js +1 -2
- package/Source/DataSources/WallGraphics.js +15 -23
- package/Source/DataSources/createPropertyDescriptor.js +2 -3
- package/Source/DataSources/exportKml.js +11 -14
- package/Source/Renderer/Buffer.js +5 -5
- package/Source/Renderer/ClearCommand.js +2 -2
- package/Source/Renderer/ComputeCommand.js +3 -3
- package/Source/Renderer/Context.js +22 -37
- package/Source/Renderer/CubeMap.js +6 -6
- package/Source/Renderer/CubeMapFace.js +11 -12
- package/Source/Renderer/DrawCommand.js +14 -25
- package/Source/Renderer/Framebuffer.js +3 -3
- package/Source/Renderer/FramebufferManager.js +25 -39
- package/Source/Renderer/MultisampleFramebuffer.js +2 -2
- package/Source/Renderer/RenderState.js +63 -92
- package/Source/Renderer/Renderbuffer.js +4 -4
- package/Source/Renderer/Sampler.js +2 -2
- package/Source/Renderer/ShaderBuilder.js +2 -3
- package/Source/Renderer/ShaderProgram.js +3 -3
- package/Source/Renderer/ShaderSource.js +3 -3
- package/Source/Renderer/Texture.js +16 -15
- package/Source/Renderer/TextureAtlas.js +802 -0
- package/Source/Renderer/UniformState.js +6 -11
- package/Source/Renderer/VertexArray.js +14 -23
- package/Source/Renderer/VertexArrayFacade.js +7 -11
- package/Source/Scene/Appearance.js +4 -4
- package/Source/Scene/ArcGisMapServerImageryProvider.js +23 -37
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/B3dmParser.js +2 -3
- package/Source/Scene/BatchTableHierarchy.js +6 -13
- package/Source/Scene/Billboard.js +105 -182
- package/Source/Scene/BillboardCollection.js +140 -224
- package/Source/Scene/BillboardLoadState.js +44 -0
- package/Source/Scene/BillboardTexture.js +348 -0
- package/Source/Scene/BingMapsImageryProvider.js +6 -6
- package/Source/Scene/BoxEmitter.js +1 -2
- package/Source/Scene/BufferLoader.js +2 -2
- package/Source/Scene/Camera.js +45 -64
- package/Source/Scene/CameraFlightPath.js +6 -6
- package/Source/Scene/Cesium3DContentGroup.js +2 -2
- package/Source/Scene/Cesium3DTile.js +3 -4
- package/Source/Scene/Cesium3DTileBatchTable.js +6 -49
- package/Source/Scene/Cesium3DTileFeatureTable.js +2 -3
- package/Source/Scene/Cesium3DTilePointFeature.js +10 -18
- package/Source/Scene/Cesium3DTileStyle.js +4 -7
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +419 -137
- package/Source/Scene/Cesium3DTileset.js +77 -143
- package/Source/Scene/Cesium3DTilesetMetadata.js +3 -3
- package/Source/Scene/Cesium3DTilesetStatistics.js +0 -1
- package/Source/Scene/CircleEmitter.js +2 -3
- package/Source/Scene/ClassificationPrimitive.js +15 -26
- package/Source/Scene/ClippingPlaneCollection.js +7 -12
- package/Source/Scene/ClippingPolygon.js +1 -2
- package/Source/Scene/ClippingPolygonCollection.js +4 -4
- package/Source/Scene/CloudCollection.js +9 -11
- package/Source/Scene/Composite3DTileContent.js +1 -2
- package/Source/Scene/ConeEmitter.js +1 -2
- package/Source/Scene/ContentMetadata.js +2 -2
- package/Source/Scene/CreditDisplay.js +5 -9
- package/Source/Scene/CumulusCloud.js +9 -15
- package/Source/Scene/DebugAppearance.js +7 -7
- package/Source/Scene/DebugCameraPrimitive.js +5 -5
- package/Source/Scene/DebugModelMatrixPrimitive.js +6 -8
- package/Source/Scene/DepthPlane.js +1 -2
- package/Source/Scene/DirectionalLight.js +2 -3
- package/Source/Scene/DiscardMissingTileImagePolicy.js +2 -2
- package/Source/Scene/DynamicEnvironmentMapManager.js +15 -24
- package/Source/Scene/EllipsoidPrimitive.js +11 -19
- package/Source/Scene/EllipsoidSurfaceAppearance.js +11 -15
- package/Source/Scene/Expression.js +1 -0
- package/Source/Scene/FrameRateMonitor.js +12 -21
- package/Source/Scene/FrustumCommands.js +2 -3
- package/Source/Scene/Geometry3DTileContent.js +9 -16
- package/Source/Scene/Globe.js +3 -4
- package/Source/Scene/GlobeSurfaceTileProvider.js +9 -18
- package/Source/Scene/GlobeTranslucencyState.js +12 -25
- package/Source/Scene/GltfBufferViewLoader.js +4 -4
- package/Source/Scene/GltfDracoLoader.js +2 -2
- package/Source/Scene/GltfImageLoader.js +2 -2
- package/Source/Scene/GltfIndexBufferLoader.js +5 -5
- package/Source/Scene/GltfJsonLoader.js +2 -2
- package/Source/Scene/GltfLoader.js +22 -37
- package/Source/Scene/GltfLoaderUtil.js +11 -11
- package/Source/Scene/GltfPipeline/addDefaults.js +37 -64
- package/Source/Scene/GltfPipeline/addToArray.js +1 -3
- package/Source/Scene/GltfPipeline/moveTechniqueRenderStates.js +2 -5
- package/Source/Scene/GltfPipeline/parseGlb.js +1 -5
- package/Source/Scene/GltfPipeline/removeUnusedElements.js +1 -2
- package/Source/Scene/GltfPipeline/updateVersion.js +28 -49
- package/Source/Scene/GltfStructuralMetadataLoader.js +5 -6
- package/Source/Scene/GltfTextureLoader.js +3 -3
- package/Source/Scene/GltfVertexBufferLoader.js +5 -5
- package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +2 -2
- package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +3 -4
- package/Source/Scene/GridImageryProvider.js +10 -13
- package/Source/Scene/GroundPolylinePrimitive.js +11 -22
- package/Source/Scene/GroundPrimitive.js +13 -24
- package/Source/Scene/GroupMetadata.js +2 -2
- package/Source/Scene/I3SDataProvider.js +10 -15
- package/Source/Scene/I3SNode.js +1 -6
- package/Source/Scene/I3SSublayer.js +1 -2
- package/Source/Scene/I3SSymbology.js +2 -3
- package/Source/Scene/I3dmParser.js +1 -2
- package/Source/Scene/ITwinData.js +11 -6
- package/Source/Scene/ImageBasedLighting.js +2 -2
- package/Source/Scene/ImageryLayer.js +42 -71
- package/Source/Scene/ImageryLayerCollection.js +2 -3
- package/Source/Scene/Implicit3DTileContent.js +3 -4
- package/Source/Scene/ImplicitAvailabilityBitstream.js +2 -5
- package/Source/Scene/ImplicitMetadataView.js +2 -2
- package/Source/Scene/ImplicitSubtree.js +10 -15
- package/Source/Scene/ImplicitSubtreeCache.js +3 -3
- package/Source/Scene/ImplicitSubtreeMetadata.js +2 -2
- package/Source/Scene/InstanceAttributeSemantic.js +1 -1
- package/Source/Scene/IonImageryProvider.js +3 -3
- package/Source/Scene/KeyframeNode.js +16 -2
- package/Source/Scene/Label.js +19 -36
- package/Source/Scene/LabelCollection.js +218 -196
- package/Source/Scene/MapboxImageryProvider.js +4 -4
- package/Source/Scene/MapboxStyleImageryProvider.js +5 -5
- package/Source/Scene/Material.js +14 -20
- package/Source/Scene/MaterialAppearance.js +12 -18
- package/Source/Scene/Megatexture.js +145 -82
- package/Source/Scene/MetadataClass.js +4 -4
- package/Source/Scene/MetadataClassProperty.js +11 -14
- package/Source/Scene/MetadataEnum.js +4 -7
- package/Source/Scene/MetadataEnumValue.js +2 -2
- package/Source/Scene/MetadataSchema.js +4 -4
- package/Source/Scene/MetadataSchemaLoader.js +2 -2
- package/Source/Scene/MetadataTable.js +2 -2
- package/Source/Scene/MetadataTableProperty.js +17 -31
- package/Source/Scene/Model/AlphaPipelineStage.js +1 -2
- package/Source/Scene/Model/B3dmLoader.js +15 -26
- package/Source/Scene/Model/BatchTexturePipelineStage.js +1 -2
- package/Source/Scene/Model/ClassificationModelDrawCommand.js +2 -2
- package/Source/Scene/Model/CustomShader.js +10 -14
- package/Source/Scene/Model/Extensions/Gpm/GltfMeshPrimitiveGpmLoader.js +3 -3
- package/Source/Scene/Model/FeatureIdPipelineStage.js +1 -5
- package/Source/Scene/Model/GeoJsonLoader.js +5 -8
- package/Source/Scene/Model/I3dmLoader.js +13 -21
- package/Source/Scene/Model/MaterialPipelineStage.js +1 -2
- package/Source/Scene/Model/Model.js +41 -63
- package/Source/Scene/Model/ModelAnimation.js +5 -6
- package/Source/Scene/Model/ModelAnimationChannel.js +2 -2
- package/Source/Scene/Model/ModelAnimationCollection.js +4 -4
- package/Source/Scene/Model/ModelArticulation.js +2 -2
- package/Source/Scene/Model/ModelArticulationStage.js +2 -2
- package/Source/Scene/Model/ModelDrawCommand.js +3 -3
- package/Source/Scene/Model/ModelFeatureTable.js +3 -9
- package/Source/Scene/Model/ModelLightingOptions.js +3 -3
- package/Source/Scene/Model/ModelNode.js +1 -1
- package/Source/Scene/Model/ModelRuntimeNode.js +2 -2
- package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -2
- package/Source/Scene/Model/ModelSceneGraph.js +2 -2
- package/Source/Scene/Model/ModelSkin.js +2 -2
- package/Source/Scene/Model/ModelUtility.js +5 -1
- package/Source/Scene/Model/PickingPipelineStage.js +1 -2
- package/Source/Scene/Model/PntsLoader.js +6 -6
- package/Source/Scene/Model/PointCloudStylingPipelineStage.js +1 -5
- package/Source/Scene/Model/PrimitiveOutlineGenerator.js +2 -2
- package/Source/Scene/Model/SelectedFeatureIdPipelineStage.js +2 -3
- package/Source/Scene/Model/TextureUniform.js +5 -8
- package/Source/Scene/Model/VaryingType.js +2 -2
- package/Source/Scene/Model/pickModel.js +4 -5
- package/Source/Scene/Moon.js +5 -5
- package/Source/Scene/OpenStreetMapImageryProvider.js +7 -7
- package/Source/Scene/OrderedGroundPrimitiveCollection.js +1 -2
- package/Source/Scene/Particle.js +11 -17
- package/Source/Scene/ParticleBurst.js +5 -5
- package/Source/Scene/ParticleSystem.js +24 -54
- package/Source/Scene/PerInstanceColorAppearance.js +8 -8
- package/Source/Scene/PerformanceDisplay.js +3 -3
- package/Source/Scene/PickFramebuffer.js +4 -5
- package/Source/Scene/Picking.js +3 -4
- package/Source/Scene/PntsParser.js +1 -2
- package/Source/Scene/PointCloud.js +6 -12
- package/Source/Scene/PointCloudShading.js +9 -18
- package/Source/Scene/PointPrimitive.js +11 -21
- package/Source/Scene/PointPrimitiveCollection.js +6 -14
- package/Source/Scene/Polyline.js +5 -5
- package/Source/Scene/PolylineCollection.js +5 -10
- package/Source/Scene/PolylineColorAppearance.js +7 -11
- package/Source/Scene/PolylineMaterialAppearance.js +7 -11
- package/Source/Scene/PostProcessStage.js +2 -2
- package/Source/Scene/PostProcessStageComposite.js +3 -6
- package/Source/Scene/Primitive.js +21 -42
- package/Source/Scene/PrimitiveCollection.js +4 -4
- package/Source/Scene/PrimitivePipeline.js +1 -2
- package/Source/Scene/PropertyAttribute.js +2 -2
- package/Source/Scene/PropertyAttributeProperty.js +4 -4
- package/Source/Scene/PropertyTable.js +2 -2
- package/Source/Scene/PropertyTexture.js +2 -2
- package/Source/Scene/PropertyTextureProperty.js +4 -4
- package/Source/Scene/QuadtreePrimitive.js +84 -66
- package/Source/Scene/QuadtreeTile.js +170 -0
- package/Source/Scene/ResourceCache.js +11 -11
- package/Source/Scene/ResourceCacheKey.js +11 -11
- package/Source/Scene/Scene.js +66 -40
- package/Source/Scene/ScreenSpaceCameraController.js +10 -20
- package/Source/Scene/ShadowMap.js +15 -15
- package/Source/Scene/ShadowVolumeAppearance.js +1 -2
- package/Source/Scene/SingleTileImageryProvider.js +4 -4
- package/Source/Scene/SkyAtmosphere.js +1 -2
- package/Source/Scene/SkyBox.js +1 -2
- package/Source/Scene/SpatialNode.js +4 -11
- package/Source/Scene/SphereEmitter.js +2 -3
- package/Source/Scene/StructuralMetadata.js +2 -2
- package/Source/Scene/SunLight.js +4 -4
- package/Source/Scene/SupportedImageFormats.js +4 -4
- package/Source/Scene/TileBoundingRegion.js +4 -5
- package/Source/Scene/TileBoundingS2Cell.js +3 -4
- package/Source/Scene/TileCoordinatesImageryProvider.js +5 -5
- package/Source/Scene/TileMapServiceImageryProvider.js +18 -27
- package/Source/Scene/TileMetadata.js +2 -2
- package/Source/Scene/TilesetMetadata.js +2 -2
- package/Source/Scene/TimeDynamicImagery.js +2 -2
- package/Source/Scene/TimeDynamicPointCloud.js +8 -10
- package/Source/Scene/TweenCollection.js +13 -16
- package/Source/Scene/UrlTemplateImageryProvider.js +11 -15
- package/Source/Scene/Vector3DTileClampedPolylines.js +1 -2
- package/Source/Scene/Vector3DTileContent.js +16 -20
- package/Source/Scene/Vector3DTileGeometry.js +1 -2
- package/Source/Scene/Vector3DTilePoints.js +2 -5
- package/Source/Scene/Vector3DTilePolygons.js +2 -3
- package/Source/Scene/Vector3DTilePolylines.js +1 -2
- package/Source/Scene/Vector3DTilePrimitive.js +9 -13
- package/Source/Scene/VoxelBoxShape.js +14 -8
- package/Source/Scene/VoxelCell.js +6 -5
- package/Source/Scene/VoxelContent.js +171 -107
- package/Source/Scene/VoxelCylinderShape.js +69 -69
- package/Source/Scene/VoxelEllipsoidShape.js +17 -8
- package/Source/Scene/VoxelMetadataOrder.js +24 -0
- package/Source/Scene/VoxelPrimitive.js +134 -79
- package/Source/Scene/VoxelProvider.js +22 -29
- package/Source/Scene/VoxelRenderResources.js +26 -7
- package/Source/Scene/VoxelShape.js +10 -3
- package/Source/Scene/VoxelTraversal.js +260 -180
- package/Source/Scene/WebMapServiceImageryProvider.js +17 -24
- package/Source/Scene/WebMapTileServiceImageryProvider.js +7 -10
- package/Source/Scene/createElevationBandMaterial.js +4 -4
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +8 -16
- package/Source/Scene/createOsmBuildingsAsync.js +3 -6
- package/Source/Scene/createTangentSpaceDebugPrimitive.js +4 -6
- package/Source/Scene/createWorldImageryAsync.js +3 -3
- package/Source/Scene/findContentMetadata.js +2 -5
- package/Source/Scene/findTileMetadata.js +2 -5
- package/Source/Scene/parseBatchTable.js +1 -5
- package/Source/Scene/parseFeatureMetadataLegacy.js +2 -2
- package/Source/Scene/parseStructuralMetadata.js +2 -2
- package/Source/Scene/processVoxelProperties.js +3 -0
- package/Source/Shaders/GlobeFS.glsl +10 -1
- package/Source/Shaders/GlobeFS.js +10 -1
- package/Source/Shaders/Voxels/Megatexture.glsl +4 -16
- package/Source/Shaders/Voxels/Megatexture.js +4 -16
- package/Source/Shaders/Voxels/Octree.glsl +44 -7
- package/Source/Shaders/Voxels/Octree.js +44 -7
- package/Source/Shaders/Voxels/VoxelFS.glsl +9 -15
- package/Source/Shaders/Voxels/VoxelFS.js +9 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +15 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.js +15 -15
- package/Source/Widget/CesiumWidget.js +17 -25
- package/Source/Workers/createGeometry.js +1 -2
- package/Source/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -2
- package/Source/Workers/decodeI3S.js +1 -5
- package/Source/Workers/transcodeKTX2.js +1 -2
- package/index.d.ts +231 -92
- package/index.js +315 -310
- package/package.json +3 -3
- package/Build/Workers/chunk-TVL3F7IU.js +0 -39
- package/Source/Scene/TextureAtlas.js +0 -558
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
import BoundingRectangle from "../Core/BoundingRectangle.js";
|
|
2
|
+
import Cartesian2 from "../Core/Cartesian2.js";
|
|
3
|
+
import Check from "../Core/Check.js";
|
|
4
|
+
import createGuid from "../Core/createGuid.js";
|
|
5
|
+
import Frozen from "../Core/Frozen.js";
|
|
6
|
+
import defined from "../Core/defined.js";
|
|
7
|
+
import destroyObject from "../Core/destroyObject.js";
|
|
8
|
+
import CesiumMath from "../Core/Math.js";
|
|
9
|
+
import PixelFormat from "../Core/PixelFormat.js";
|
|
10
|
+
import Resource from "../Core/Resource.js";
|
|
11
|
+
import RuntimeError from "../Core/RuntimeError.js";
|
|
12
|
+
import TexturePacker from "../Core/TexturePacker.js";
|
|
13
|
+
import Framebuffer from "./Framebuffer.js";
|
|
14
|
+
import Texture from "./Texture.js";
|
|
15
|
+
|
|
16
|
+
const defaultInitialDimensions = 16;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A TextureAtlas stores multiple images in one∂ texture and keeps
|
|
20
|
+
* track of the texture coordinates for each image. A TextureAtlas is dynamic,
|
|
21
|
+
* meaning new images can be added at any point in time.
|
|
22
|
+
* Texture coordinates are subject to change if the texture atlas resizes, so it's
|
|
23
|
+
* important to check {@link TextureAtlas#guid} before using old values.
|
|
24
|
+
*
|
|
25
|
+
* @alias TextureAtlas
|
|
26
|
+
* @constructor
|
|
27
|
+
*
|
|
28
|
+
* @param {object} options Object with the following properties:
|
|
29
|
+
* @param {PixelFormat} [options.pixelFormat=PixelFormat.RGBA] The pixel format of the texture.
|
|
30
|
+
* @param {Sampler} [options.sampler=new Sampler()] Information about how to sample the texture.
|
|
31
|
+
* @param {number} [options.borderWidthInPixels=1] The amount of spacing between adjacent images in pixels.
|
|
32
|
+
* @param {Cartesian2} [options.initialSize=new Cartesian2(16.0, 16.0)] The initial side lengths of the texture.
|
|
33
|
+
*
|
|
34
|
+
* @exception {DeveloperError} borderWidthInPixels must be greater than or equal to zero.
|
|
35
|
+
* @exception {DeveloperError} initialSize must be greater than zero.
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
function TextureAtlas(options) {
|
|
40
|
+
options = options ?? Frozen.EMPTY_OBJECT;
|
|
41
|
+
const borderWidthInPixels = options.borderWidthInPixels ?? 1.0;
|
|
42
|
+
const initialSize =
|
|
43
|
+
options.initialSize ??
|
|
44
|
+
new Cartesian2(defaultInitialDimensions, defaultInitialDimensions);
|
|
45
|
+
|
|
46
|
+
//>>includeStart('debug', pragmas.debug);
|
|
47
|
+
Check.typeOf.number.greaterThanOrEquals(
|
|
48
|
+
"options.borderWidthInPixels",
|
|
49
|
+
borderWidthInPixels,
|
|
50
|
+
0,
|
|
51
|
+
);
|
|
52
|
+
Check.typeOf.number.greaterThan("options.initialSize.x", initialSize.x, 0);
|
|
53
|
+
Check.typeOf.number.greaterThan("options.initialSize.y", initialSize.y, 0);
|
|
54
|
+
//>>includeEnd('debug');
|
|
55
|
+
|
|
56
|
+
this._pixelFormat = options.pixelFormat ?? PixelFormat.RGBA;
|
|
57
|
+
this._sampler = options.sampler;
|
|
58
|
+
this._borderWidthInPixels = borderWidthInPixels;
|
|
59
|
+
this._initialSize = initialSize;
|
|
60
|
+
|
|
61
|
+
this._texturePacker = undefined;
|
|
62
|
+
this._rectangles = [];
|
|
63
|
+
this._subRegions = new Map();
|
|
64
|
+
this._guid = createGuid();
|
|
65
|
+
|
|
66
|
+
this._imagesToAddQueue = [];
|
|
67
|
+
this._indexById = new Map();
|
|
68
|
+
this._indexPromiseById = new Map();
|
|
69
|
+
this._nextIndex = 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Object.defineProperties(TextureAtlas.prototype, {
|
|
73
|
+
/**
|
|
74
|
+
* The amount of spacing between adjacent images in pixels.
|
|
75
|
+
* @memberof TextureAtlas.prototype
|
|
76
|
+
* @type {number}
|
|
77
|
+
* @readonly
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
borderWidthInPixels: {
|
|
81
|
+
get: function () {
|
|
82
|
+
return this._borderWidthInPixels;
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* An array of {@link BoundingRectangle} pixel offset and dimensions for all the images in the texture atlas.
|
|
88
|
+
* The x and y values of the rectangle correspond to the bottom-left corner of the texture coordinate.
|
|
89
|
+
* If the index is a subregion of an existing image, thea and y values are specified as offsets relative to the parent.
|
|
90
|
+
* The coordinates are in the order that the corresponding images were added to the atlas.
|
|
91
|
+
* @memberof TextureAtlas.prototype
|
|
92
|
+
* @type {BoundingRectangle[]}
|
|
93
|
+
* @readonly
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
rectangles: {
|
|
97
|
+
get: function () {
|
|
98
|
+
return this._rectangles;
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The texture that all of the images are being written to. The value will be <code>undefined</code> until the first update.
|
|
104
|
+
* @memberof TextureAtlas.prototype
|
|
105
|
+
* @type {Texture|undefined}
|
|
106
|
+
* @readonly
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
texture: {
|
|
110
|
+
get: function () {
|
|
111
|
+
return this._texture;
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The pixel format of the texture.
|
|
117
|
+
* @memberof TextureAtlas.prototype
|
|
118
|
+
* @type {PixelFormat}
|
|
119
|
+
* @readonly
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
pixelFormat: {
|
|
123
|
+
get: function () {
|
|
124
|
+
return this._pixelFormat;
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The sampler to use when sampling this texture. If <code>undefined</code>, the default sampler is used.
|
|
130
|
+
* @memberof TextureAtlas.prototype
|
|
131
|
+
* @type {Sampler|undefined}
|
|
132
|
+
* @readonly
|
|
133
|
+
* @private
|
|
134
|
+
*/
|
|
135
|
+
sampler: {
|
|
136
|
+
get: function () {
|
|
137
|
+
return this._sampler;
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The number of images in the texture atlas. This value increases
|
|
143
|
+
* every time addImage or addImageSubRegion is called.
|
|
144
|
+
* Texture coordinates are subject to change if the texture atlas resizes, so it is
|
|
145
|
+
* important to check {@link TextureAtlas#guid} before using old values.
|
|
146
|
+
* @memberof TextureAtlas.prototype
|
|
147
|
+
* @type {number}
|
|
148
|
+
* @readonly
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
numberOfImages: {
|
|
152
|
+
get: function () {
|
|
153
|
+
return this._nextIndex;
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The atlas' globally unique identifier (GUID).
|
|
159
|
+
* The GUID changes whenever the texture atlas is modified.
|
|
160
|
+
* Classes that use a texture atlas should check if the GUID
|
|
161
|
+
* has changed before processing the atlas data.
|
|
162
|
+
* @memberof TextureAtlas.prototype
|
|
163
|
+
* @type {string}
|
|
164
|
+
* @readonly
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
guid: {
|
|
168
|
+
get: function () {
|
|
169
|
+
return this._guid;
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Returns the size in bytes of the texture.
|
|
175
|
+
* @memberof TextureAtlas.prototype
|
|
176
|
+
* @type {number}
|
|
177
|
+
* @readonly
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
180
|
+
sizeInBytes: {
|
|
181
|
+
get: function () {
|
|
182
|
+
if (!defined(this._texture)) {
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return this._texture.sizeInBytes;
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Get the texture coordinates for reading the associated image in shaders.
|
|
193
|
+
* @param {number} index The index of the image region.
|
|
194
|
+
* @param {BoundingRectangle} [result] The object into which to store the result.
|
|
195
|
+
* @return {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
|
|
196
|
+
* @private
|
|
197
|
+
* @example
|
|
198
|
+
* const index = await atlas.addImage("myImage", image);
|
|
199
|
+
* const rectangle = atlas.computeTextureCoordinates(index);
|
|
200
|
+
* BoundingRectangle.pack(rectangle, bufferView);
|
|
201
|
+
*/
|
|
202
|
+
TextureAtlas.prototype.computeTextureCoordinates = function (index, result) {
|
|
203
|
+
//>>includeStart('debug', pragmas.debug);
|
|
204
|
+
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
205
|
+
//>>includeEnd('debug');
|
|
206
|
+
|
|
207
|
+
const texture = this._texture;
|
|
208
|
+
const rectangle = this._rectangles[index];
|
|
209
|
+
|
|
210
|
+
if (!defined(result)) {
|
|
211
|
+
result = new BoundingRectangle();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!defined(rectangle)) {
|
|
215
|
+
result.x = 0;
|
|
216
|
+
result.y = 0;
|
|
217
|
+
result.width = 0;
|
|
218
|
+
result.height = 0;
|
|
219
|
+
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const atlasWidth = texture.width;
|
|
224
|
+
const atlasHeight = texture.height;
|
|
225
|
+
|
|
226
|
+
const width = rectangle.width;
|
|
227
|
+
const height = rectangle.height;
|
|
228
|
+
let x = rectangle.x;
|
|
229
|
+
let y = rectangle.y;
|
|
230
|
+
|
|
231
|
+
const parentIndex = this._subRegions.get(index);
|
|
232
|
+
if (defined(parentIndex)) {
|
|
233
|
+
const parentRectangle = this._rectangles[parentIndex];
|
|
234
|
+
|
|
235
|
+
x += parentRectangle.x;
|
|
236
|
+
y += parentRectangle.y;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
result.x = x / atlasWidth;
|
|
240
|
+
result.y = y / atlasHeight;
|
|
241
|
+
result.width = width / atlasWidth;
|
|
242
|
+
result.height = height / atlasHeight;
|
|
243
|
+
|
|
244
|
+
return result;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Perform a WebGL texture copy for each existing image from its previous packed position to its new packed position in the new texture.
|
|
249
|
+
* @param {Context} context The rendering context
|
|
250
|
+
* @param {number} width The pixel width of the texture
|
|
251
|
+
* @param {number} height The pixel height of the texture
|
|
252
|
+
* @param {BoundingRectangle[]} rectangles The packed bounding rectangles for the reszied texture
|
|
253
|
+
* @param {number} queueOffset Index of the last queued item that was successfully packed
|
|
254
|
+
* @private
|
|
255
|
+
*/
|
|
256
|
+
TextureAtlas.prototype._copyFromTexture = function (
|
|
257
|
+
context,
|
|
258
|
+
width,
|
|
259
|
+
height,
|
|
260
|
+
rectangles,
|
|
261
|
+
) {
|
|
262
|
+
const pixelFormat = this._pixelFormat;
|
|
263
|
+
const sampler = this._sampler;
|
|
264
|
+
const newTexture = new Texture({
|
|
265
|
+
context,
|
|
266
|
+
height,
|
|
267
|
+
width,
|
|
268
|
+
pixelFormat,
|
|
269
|
+
sampler,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const gl = context._gl;
|
|
273
|
+
const target = newTexture._textureTarget;
|
|
274
|
+
|
|
275
|
+
const oldTexture = this._texture;
|
|
276
|
+
const framebuffer = new Framebuffer({
|
|
277
|
+
context,
|
|
278
|
+
colorTextures: [oldTexture],
|
|
279
|
+
destroyAttachments: false,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
283
|
+
gl.bindTexture(target, newTexture._texture);
|
|
284
|
+
|
|
285
|
+
framebuffer._bind();
|
|
286
|
+
|
|
287
|
+
// Copy any textures from the old atlas to its new position in the new atlas
|
|
288
|
+
const oldRectangles = this.rectangles;
|
|
289
|
+
const subRegions = this._subRegions;
|
|
290
|
+
for (let index = 0; index < oldRectangles.length; ++index) {
|
|
291
|
+
const rectangle = rectangles[index];
|
|
292
|
+
const frameBufferOffset = oldRectangles[index];
|
|
293
|
+
|
|
294
|
+
if (
|
|
295
|
+
!defined(rectangle) ||
|
|
296
|
+
!defined(frameBufferOffset) ||
|
|
297
|
+
defined(subRegions.get(index)) // The rectangle corresponds to a subregion of a parent image
|
|
298
|
+
) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const { x, y, width, height } = rectangle;
|
|
303
|
+
gl.copyTexSubImage2D(
|
|
304
|
+
target,
|
|
305
|
+
0,
|
|
306
|
+
x,
|
|
307
|
+
y,
|
|
308
|
+
frameBufferOffset.x,
|
|
309
|
+
frameBufferOffset.y,
|
|
310
|
+
width,
|
|
311
|
+
height,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
gl.bindTexture(target, null);
|
|
316
|
+
newTexture._initialized = true;
|
|
317
|
+
|
|
318
|
+
framebuffer._unBind();
|
|
319
|
+
framebuffer.destroy();
|
|
320
|
+
|
|
321
|
+
return newTexture;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Recreates the texture atlas texture with new dimensions and repacks images as needed.
|
|
326
|
+
* @param {Context} context The rendering context
|
|
327
|
+
* @param {number} [queueOffset = 0] Index of the last queued item that was successfully packed
|
|
328
|
+
* @private
|
|
329
|
+
*/
|
|
330
|
+
TextureAtlas.prototype._resize = function (context, queueOffset = 0) {
|
|
331
|
+
const borderPadding = this._borderWidthInPixels;
|
|
332
|
+
const oldRectangles = this._rectangles;
|
|
333
|
+
const queue = this._imagesToAddQueue;
|
|
334
|
+
|
|
335
|
+
const oldTexture = this._texture;
|
|
336
|
+
let width = oldTexture.width;
|
|
337
|
+
let height = oldTexture.height;
|
|
338
|
+
|
|
339
|
+
// Get the rectangles (width and height) of the current set of images,
|
|
340
|
+
// ignoring the subregions, which don't get packed
|
|
341
|
+
const subRegions = this._subRegions;
|
|
342
|
+
const toPack = oldRectangles
|
|
343
|
+
.map((image, index) => {
|
|
344
|
+
return new AddImageRequest({ index, image });
|
|
345
|
+
})
|
|
346
|
+
.filter(
|
|
347
|
+
(request, index) =>
|
|
348
|
+
defined(request.image) && !defined(subRegions.get(index)),
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
// Add the new set of images
|
|
352
|
+
let maxWidth = 0;
|
|
353
|
+
let maxHeight = 0;
|
|
354
|
+
let areaQueued = 0;
|
|
355
|
+
for (let i = queueOffset; i < queue.length; ++i) {
|
|
356
|
+
const { width, height } = queue[i].image;
|
|
357
|
+
maxWidth = Math.max(maxWidth, width);
|
|
358
|
+
maxHeight = Math.max(maxHeight, height);
|
|
359
|
+
areaQueued += width * height;
|
|
360
|
+
toPack.push(queue[i]);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// At minimum, the texture will need to scale to accommodate the largest width and height
|
|
364
|
+
width = Math.max(maxWidth, width);
|
|
365
|
+
height = Math.max(maxHeight, height);
|
|
366
|
+
|
|
367
|
+
if (!context.webgl2) {
|
|
368
|
+
width = CesiumMath.nextPowerOfTwo(width);
|
|
369
|
+
height = CesiumMath.nextPowerOfTwo(height);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Determine by what factor the texture need to be scaled by at minimum
|
|
373
|
+
const areaDifference = areaQueued;
|
|
374
|
+
let scalingFactor = 1.0;
|
|
375
|
+
while (areaDifference / width / height >= 1.0) {
|
|
376
|
+
scalingFactor *= 2.0;
|
|
377
|
+
|
|
378
|
+
// Resize by one dimension
|
|
379
|
+
if (width > height) {
|
|
380
|
+
height *= scalingFactor;
|
|
381
|
+
} else {
|
|
382
|
+
width *= scalingFactor;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
toPack.sort(
|
|
387
|
+
({ image: imageA }, { image: imageB }) =>
|
|
388
|
+
imageB.height * imageB.width - imageA.height * imageA.width,
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
const newRectangles = new Array(this._nextIndex);
|
|
392
|
+
for (const index of this._subRegions.keys()) {
|
|
393
|
+
// Subregions are specified relative to their parents,
|
|
394
|
+
// so we can copy them directly
|
|
395
|
+
if (defined(subRegions.get(index))) {
|
|
396
|
+
newRectangles[index] = oldRectangles[index];
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
let texturePacker,
|
|
401
|
+
packed = false;
|
|
402
|
+
while (!packed) {
|
|
403
|
+
texturePacker = new TexturePacker({ height, width, borderPadding });
|
|
404
|
+
|
|
405
|
+
let i;
|
|
406
|
+
for (i = 0; i < toPack.length; ++i) {
|
|
407
|
+
const { index, image } = toPack[i];
|
|
408
|
+
if (!defined(image)) {
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const repackedNode = texturePacker.pack(index, image);
|
|
413
|
+
if (!defined(repackedNode)) {
|
|
414
|
+
// Could not fit everything into the new texture.
|
|
415
|
+
// Scale texture size and try again
|
|
416
|
+
if (width > height) {
|
|
417
|
+
// Resize height
|
|
418
|
+
height *= 2.0;
|
|
419
|
+
} else {
|
|
420
|
+
// Resize width
|
|
421
|
+
width *= 2.0;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
newRectangles[index] = repackedNode.rectangle;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
packed = i === toPack.length;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
this._texturePacker = texturePacker;
|
|
434
|
+
this._texture = this._copyFromTexture(context, width, height, newRectangles);
|
|
435
|
+
|
|
436
|
+
oldTexture.destroy();
|
|
437
|
+
|
|
438
|
+
this._rectangles = newRectangles;
|
|
439
|
+
this._guid = createGuid();
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Return the index of the image region for the specified ID. If the image is already in the atlas, the existing index is returned. Otherwise, the result is undefined.
|
|
444
|
+
* @param {string} id An identifier to detect whether the image already exists in the atlas.
|
|
445
|
+
* @returns {number|undefined} The image index, or undefined if the image does not exist in the atlas.
|
|
446
|
+
* @private
|
|
447
|
+
*/
|
|
448
|
+
TextureAtlas.prototype.getImageIndex = function (id) {
|
|
449
|
+
//>>includeStart('debug', pragmas.debug);
|
|
450
|
+
Check.typeOf.string("id", id);
|
|
451
|
+
//>>includeEnd('debug');
|
|
452
|
+
|
|
453
|
+
return this._indexById.get(id);
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Copy image data into the underlying texture atlas.
|
|
458
|
+
* @param {AddImageRequest} imageRequest The data needed to resolve the call to addImage in the queue
|
|
459
|
+
* @private
|
|
460
|
+
*/
|
|
461
|
+
TextureAtlas.prototype._copyImageToTexture = function ({
|
|
462
|
+
index,
|
|
463
|
+
image,
|
|
464
|
+
resolve,
|
|
465
|
+
reject,
|
|
466
|
+
}) {
|
|
467
|
+
const texture = this._texture;
|
|
468
|
+
const rectangle = this._rectangles[index];
|
|
469
|
+
|
|
470
|
+
try {
|
|
471
|
+
texture.copyFrom({
|
|
472
|
+
source: image,
|
|
473
|
+
xOffset: rectangle.x,
|
|
474
|
+
yOffset: rectangle.y,
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
if (defined(resolve)) {
|
|
478
|
+
resolve(index);
|
|
479
|
+
}
|
|
480
|
+
} catch (e) {
|
|
481
|
+
if (defined(reject)) {
|
|
482
|
+
reject(e);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Info needed to add a queued image to the texture atlas when update operatons are executed, typically at the end of a frame.
|
|
490
|
+
* @constructor
|
|
491
|
+
* @private
|
|
492
|
+
* @param {object} options Object with the following properties:
|
|
493
|
+
* @param {number} options.index An identifier
|
|
494
|
+
* @param {TexturePacker.PackableObject} options.image An object, such as an <code>Image</code> with <code>width</code> and <code>height</code> properties in pixels
|
|
495
|
+
* @param {function} [options.resolve] The promise resolver
|
|
496
|
+
* @param {function} [options.reject] The promise rejecter
|
|
497
|
+
*/
|
|
498
|
+
function AddImageRequest({ index, image, resolve, reject }) {
|
|
499
|
+
this.index = index;
|
|
500
|
+
this.image = image;
|
|
501
|
+
this.resolve = resolve;
|
|
502
|
+
this.reject = reject;
|
|
503
|
+
this.rectangle = undefined;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Adds an image to the queue for this frame.
|
|
508
|
+
* The image will be copied to the texture at the end of the frame, resizing the texture if needed.
|
|
509
|
+
*
|
|
510
|
+
* @private
|
|
511
|
+
* @param {number} index An identifier
|
|
512
|
+
* @param {TexturePacker.PackableObject} image An object, such as an <code>Image</code> with <code>width</code> and <code>height</code> properties in pixels
|
|
513
|
+
* @returns {Promise<number>} Promise which resolves to the image index once the image has been added, or rejects if there was an error. The promise resolves to <code>-1</code> if the texture atlas is destoyed in the interim.
|
|
514
|
+
*/
|
|
515
|
+
TextureAtlas.prototype._addImage = function (index, image) {
|
|
516
|
+
//>>includeStart('debug', pragmas.debug);
|
|
517
|
+
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
518
|
+
Check.defined("image", image);
|
|
519
|
+
//>>includeEnd('debug');
|
|
520
|
+
|
|
521
|
+
return new Promise((resolve, reject) => {
|
|
522
|
+
this._imagesToAddQueue.push(
|
|
523
|
+
new AddImageRequest({
|
|
524
|
+
index,
|
|
525
|
+
image,
|
|
526
|
+
resolve,
|
|
527
|
+
reject,
|
|
528
|
+
}),
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
this._imagesToAddQueue.sort(
|
|
532
|
+
({ image: imageA }, { image: imageB }) =>
|
|
533
|
+
imageB.height * imageB.width - imageA.height * imageA.width,
|
|
534
|
+
);
|
|
535
|
+
});
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Process the image queue for this frame, copying to the texture atlas and resizing the texture as needed.
|
|
540
|
+
* @private
|
|
541
|
+
* @param {Context} context The rendering context
|
|
542
|
+
* @return {boolean} true if the texture was updated this frame
|
|
543
|
+
*/
|
|
544
|
+
TextureAtlas.prototype._processImageQueue = function (context) {
|
|
545
|
+
const queue = this._imagesToAddQueue;
|
|
546
|
+
if (queue.length === 0) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
this._rectangles.length = this._nextIndex;
|
|
551
|
+
|
|
552
|
+
let i, error;
|
|
553
|
+
for (i = 0; i < queue.length; ++i) {
|
|
554
|
+
const imageRequest = queue[i];
|
|
555
|
+
const { image, index } = imageRequest;
|
|
556
|
+
const node = this._texturePacker.pack(index, image);
|
|
557
|
+
if (!defined(node)) {
|
|
558
|
+
// Atlas cannot fit all images in the queue
|
|
559
|
+
// Bail early and resize
|
|
560
|
+
try {
|
|
561
|
+
this._resize(context, i);
|
|
562
|
+
} catch (e) {
|
|
563
|
+
error = e;
|
|
564
|
+
|
|
565
|
+
if (defined(imageRequest.reject)) {
|
|
566
|
+
imageRequest.reject(error);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
this._rectangles[index] = node.rectangle;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if (defined(error)) {
|
|
575
|
+
for (i = i + 1; i < queue.length; ++i) {
|
|
576
|
+
const { resolve } = queue[i];
|
|
577
|
+
if (defined(resolve)) {
|
|
578
|
+
resolve(-1);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
queue.length = 0;
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
587
|
+
this._copyImageToTexture(queue[i]);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
queue.length = 0;
|
|
591
|
+
return true;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Processes any updates queued this frame, and updates rendering resources accordingly. Call before or after a frame has been rendered to avoid any race conditions for any dependant render commands.
|
|
596
|
+
* @private
|
|
597
|
+
* @param {Context} context The rendering context
|
|
598
|
+
* @return {boolean} true if rendering resources were updated.
|
|
599
|
+
*/
|
|
600
|
+
TextureAtlas.prototype.update = function (context) {
|
|
601
|
+
if (!defined(this._texture)) {
|
|
602
|
+
const width = this._initialSize.x;
|
|
603
|
+
const height = this._initialSize.y;
|
|
604
|
+
const pixelFormat = this._pixelFormat;
|
|
605
|
+
const sampler = this._sampler;
|
|
606
|
+
const borderPadding = this._borderWidthInPixels;
|
|
607
|
+
|
|
608
|
+
this._texture = new Texture({
|
|
609
|
+
context,
|
|
610
|
+
width,
|
|
611
|
+
height,
|
|
612
|
+
pixelFormat,
|
|
613
|
+
sampler,
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
this._texturePacker = new TexturePacker({
|
|
617
|
+
height,
|
|
618
|
+
width,
|
|
619
|
+
borderPadding,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return this._processImageQueue(context);
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
async function resolveImage(image, id) {
|
|
627
|
+
if (typeof image === "function") {
|
|
628
|
+
image = image(id);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (typeof image === "string" || image instanceof Resource) {
|
|
632
|
+
// Fetch the resource
|
|
633
|
+
const resource = Resource.createIfNeeded(image);
|
|
634
|
+
image = resource.fetchImage();
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
return image;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Adds an image to the atlas. If the image is already in the atlas, the atlas is unchanged and
|
|
642
|
+
* the existing index is used.
|
|
643
|
+
* @private
|
|
644
|
+
* @param {string} id An identifier to detect whether the image already exists in the atlas.
|
|
645
|
+
* @param {HTMLImageElement|HTMLCanvasElement|string|Resource|Promise|TextureAtlas.CreateImageCallback} image An image or canvas to add to the texture atlas,
|
|
646
|
+
* or a URL to an Image, or a Promise for an image, or a function that creates an image.
|
|
647
|
+
* @returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resouces are in the process of being destroyed.
|
|
648
|
+
*/
|
|
649
|
+
TextureAtlas.prototype.addImage = function (id, image) {
|
|
650
|
+
//>>includeStart('debug', pragmas.debug);
|
|
651
|
+
Check.typeOf.string("id", id);
|
|
652
|
+
Check.defined("image", image);
|
|
653
|
+
//>>includeEnd('debug');
|
|
654
|
+
|
|
655
|
+
let promise = this._indexPromiseById.get(id);
|
|
656
|
+
if (defined(promise)) {
|
|
657
|
+
// This image has already been added
|
|
658
|
+
return promise;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
const index = this._nextIndex++;
|
|
662
|
+
this._indexById.set(id, index);
|
|
663
|
+
|
|
664
|
+
const resolveAndAddImage = async () => {
|
|
665
|
+
image = await resolveImage(image, id);
|
|
666
|
+
//>>includeStart('debug', pragmas.debug);
|
|
667
|
+
Check.defined("image", image);
|
|
668
|
+
//>>includeEnd('debug');
|
|
669
|
+
|
|
670
|
+
if (this.isDestroyed() || !defined(image)) {
|
|
671
|
+
return -1;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return this._addImage(index, image);
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
promise = resolveAndAddImage();
|
|
678
|
+
this._indexPromiseById.set(id, promise);
|
|
679
|
+
return promise;
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Add a sub-region of an existing atlas image as additional image indices.
|
|
684
|
+
* @private
|
|
685
|
+
* @param {string} id The identifier of the existing image.
|
|
686
|
+
* @param {BoundingRectangle} subRegion An {@link BoundingRectangle} defining a region of an existing image, measured in pixels from the bottom-left of the image.
|
|
687
|
+
* @returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resouces are in the process of being destroyed.
|
|
688
|
+
*/
|
|
689
|
+
TextureAtlas.prototype.addImageSubRegion = function (id, subRegion) {
|
|
690
|
+
//>>includeStart('debug', pragmas.debug);
|
|
691
|
+
Check.typeOf.string("id", id);
|
|
692
|
+
Check.defined("subRegion", subRegion);
|
|
693
|
+
//>>includeEnd('debug');
|
|
694
|
+
|
|
695
|
+
const imageIndex = this._indexById.get(id);
|
|
696
|
+
if (!defined(imageIndex)) {
|
|
697
|
+
throw new RuntimeError(`image with id "${id}" not found in the atlas.`);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const indexPromise = this._indexPromiseById.get(id);
|
|
701
|
+
for (const [index, parentIndex] of this._subRegions.entries()) {
|
|
702
|
+
if (imageIndex === parentIndex) {
|
|
703
|
+
const boundingRegion = this._rectangles[index];
|
|
704
|
+
if (boundingRegion.equals(subRegion)) {
|
|
705
|
+
// The subregion is already being tracked
|
|
706
|
+
return indexPromise.then((resolvedImageIndex) => {
|
|
707
|
+
if (resolvedImageIndex === -1) {
|
|
708
|
+
// The atlas has been destroyed
|
|
709
|
+
return -1;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
return index;
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const index = this._nextIndex++;
|
|
719
|
+
this._subRegions.set(index, imageIndex);
|
|
720
|
+
this._rectangles[index] = subRegion.clone();
|
|
721
|
+
|
|
722
|
+
return indexPromise.then((imageIndex) => {
|
|
723
|
+
if (imageIndex === -1) {
|
|
724
|
+
// The atlas has been destroyed
|
|
725
|
+
return -1;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
const rectangle = this._rectangles[imageIndex];
|
|
729
|
+
|
|
730
|
+
//>>includeStart('debug', pragmas.debug);
|
|
731
|
+
Check.typeOf.number.lessThanOrEquals(
|
|
732
|
+
"subRegion.x",
|
|
733
|
+
subRegion.x,
|
|
734
|
+
rectangle.width,
|
|
735
|
+
);
|
|
736
|
+
Check.typeOf.number.lessThanOrEquals(
|
|
737
|
+
"subRegion.x + subRegion.width",
|
|
738
|
+
subRegion.x + subRegion.width,
|
|
739
|
+
rectangle.width,
|
|
740
|
+
);
|
|
741
|
+
Check.typeOf.number.lessThanOrEquals(
|
|
742
|
+
"subRegion.y",
|
|
743
|
+
subRegion.y,
|
|
744
|
+
rectangle.height,
|
|
745
|
+
);
|
|
746
|
+
Check.typeOf.number.lessThanOrEquals(
|
|
747
|
+
"subRegion.y + subRegion.height",
|
|
748
|
+
subRegion.y + subRegion.height,
|
|
749
|
+
rectangle.height,
|
|
750
|
+
);
|
|
751
|
+
//>>includeEnd('debug');
|
|
752
|
+
|
|
753
|
+
return index;
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Returns true if this object was destroyed; otherwise, false.
|
|
759
|
+
* <br /><br />
|
|
760
|
+
* If this object was destroyed, it should not be used; calling any function other than
|
|
761
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
|
|
762
|
+
* @private
|
|
763
|
+
* @returns {boolean} True if this object was destroyed; otherwise, false.
|
|
764
|
+
* @see TextureAtlas#destroy
|
|
765
|
+
*/
|
|
766
|
+
TextureAtlas.prototype.isDestroyed = function () {
|
|
767
|
+
return false;
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
|
|
772
|
+
* release of WebGL resources, instead of relying on the garbage collector to destroy this object.
|
|
773
|
+
* <br /><br />
|
|
774
|
+
* Once an object is destroyed, it should not be used; calling any function other than
|
|
775
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
|
|
776
|
+
* assign the return value (<code>undefined</code>) to the object as done in the example.
|
|
777
|
+
* @private
|
|
778
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
779
|
+
* @example
|
|
780
|
+
* atlas = atlas && atlas.destroy();
|
|
781
|
+
* @see TextureAtlas#isDestroyed
|
|
782
|
+
*/
|
|
783
|
+
TextureAtlas.prototype.destroy = function () {
|
|
784
|
+
this._texture = this._texture && this._texture.destroy();
|
|
785
|
+
this._imagesToAddQueue.forEach(({ resolve }) => {
|
|
786
|
+
if (defined(resolve)) {
|
|
787
|
+
resolve(-1);
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
return destroyObject(this);
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* A function that creates an image.
|
|
796
|
+
* @private
|
|
797
|
+
* @callback TextureAtlas.CreateImageCallback
|
|
798
|
+
* @param {string} id The identifier of the image to load.
|
|
799
|
+
* @returns {HTMLImageElement|Promise<HTMLImageElement>} The image, or a promise that will resolve to an image.
|
|
800
|
+
*/
|
|
801
|
+
|
|
802
|
+
export default TextureAtlas;
|