@cesium/engine 24.0.0 → 26.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-6WLHJFD3.js → chunk-3VFEWOBI.js} +59 -32
- package/Build/Workers/{chunk-UQU4RXLT.js → chunk-424RNO3D.js} +50 -45
- package/Build/Workers/chunk-4MGMYHOO.js +147 -0
- package/Build/Workers/{chunk-AMIHNSST.js → chunk-4S7IE3LB.js} +2 -2
- package/Build/Workers/{chunk-J6AW5YHS.js → chunk-52JDLOEM.js} +14 -14
- package/Build/Workers/{chunk-6RMS4S72.js → chunk-54I6Y66F.js} +6 -6
- package/Build/Workers/{chunk-C6P4IG5P.js → chunk-6YEE6JDR.js} +6 -6
- package/Build/Workers/{chunk-72VYSVEW.js → chunk-7J2HKPRH.js} +11 -10
- package/Build/Workers/{chunk-7O5XJTVE.js → chunk-7WM2PX4V.js} +5 -5
- package/Build/Workers/{chunk-5A2SW66E.js → chunk-ACXQXN46.js} +16 -16
- package/Build/Workers/{chunk-VLDEUTOP.js → chunk-AYKR4VBR.js} +2 -2
- package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-C6J67V5A.js} +3 -2
- package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-C6KNZ7T4.js} +17 -17
- package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-CFQP6LYM.js} +4 -4
- package/Build/Workers/{chunk-YAOZMOFL.js → chunk-CXOYE2WM.js} +5 -5
- package/Build/Workers/{chunk-B6SCUUFP.js → chunk-CZEYZU4N.js} +10 -10
- package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DBOEKL43.js} +7 -7
- package/Build/Workers/{chunk-44EMEGKW.js → chunk-DDWSZVMY.js} +5 -5
- package/Build/Workers/{chunk-7X322WP2.js → chunk-DOBXCNC3.js} +13 -13
- package/Build/Workers/{chunk-JCI63T3K.js → chunk-E7VQ76KE.js} +6 -6
- package/Build/Workers/{chunk-7TYLCBGK.js → chunk-EBSIOBXY.js} +12 -10
- package/Build/Workers/{chunk-GQUNK2XC.js → chunk-EF2QYXGA.js} +14 -14
- package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-EPYXRCDB.js} +12 -12
- package/Build/Workers/{chunk-63SIWPLS.js → chunk-F6QDY6HU.js} +13 -13
- package/Build/Workers/{chunk-XY6HMDGI.js → chunk-FRQZECAO.js} +5 -5
- package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-G7PXZRVF.js} +7 -7
- package/Build/Workers/{chunk-N65BAKSH.js → chunk-INUEEEQA.js} +8 -8
- package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-IRBKFCEJ.js} +2 -2
- package/Build/Workers/{chunk-UIGVOKKI.js → chunk-IYOUHCZB.js} +3 -2
- package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-J6BWOHUF.js} +3 -3
- package/Build/Workers/{chunk-A47HVBC5.js → chunk-KFSTQKNM.js} +7 -7
- package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-KKOSKAZB.js} +17 -17
- package/Build/Workers/{chunk-6MPGQEHA.js → chunk-KSSWJIZW.js} +2 -2
- package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-M3B5JKSM.js} +3 -2
- package/Build/Workers/chunk-MPZHGZU6.js +2342 -0
- package/Build/Workers/{chunk-YJZGW74L.js → chunk-MYP774IS.js} +2213 -1349
- package/Build/Workers/{chunk-LIB2H534.js → chunk-O3EA5HS7.js} +12 -11
- package/Build/Workers/{chunk-ILMFADZA.js → chunk-P3CK7MCY.js} +27 -5
- package/Build/Workers/chunk-Q3PY526V.js +3201 -0
- package/Build/Workers/chunk-QN67VG36.js +973 -0
- package/Build/Workers/{chunk-XJRBB253.js → chunk-QRWGUWI6.js} +11 -11
- package/Build/Workers/{chunk-AF3MU2RL.js → chunk-S4MCOY6I.js} +7 -6
- package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-SMQZZOW6.js} +10 -10
- package/Build/Workers/{chunk-PVV64VFW.js → chunk-TKKIREQ6.js} +3 -2
- package/Build/Workers/{chunk-MKM27KGV.js → chunk-U3ZA64U7.js} +2 -2
- package/Build/Workers/{chunk-2N4KDHS3.js → chunk-UA25D5MX.js} +12 -11
- package/Build/Workers/{chunk-RQNJD3O4.js → chunk-UOOIQ3KX.js} +12 -12
- package/Build/Workers/{chunk-GOQBUCXH.js → chunk-V7VQKN6N.js} +709 -431
- package/Build/Workers/{chunk-LXMCPFFS.js → chunk-VQYETPWC.js} +4 -4
- package/Build/Workers/{chunk-NKT5K3K3.js → chunk-VWV2IJRB.js} +13 -12
- package/Build/Workers/chunk-XZMBNNDX.js +1287 -0
- package/Build/Workers/{chunk-ISY4EZCA.js → chunk-Y57HREW5.js} +4 -4
- package/Build/Workers/{chunk-EDXL4W76.js → chunk-Y5BF6AFU.js} +2 -2
- package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-YLY7NKAB.js} +4 -4
- package/Build/Workers/{chunk-4TIG36AW.js → chunk-ZK3CF7ZD.js} +12 -12
- package/Build/Workers/{chunk-AJLTU6PF.js → chunk-ZP7JMQV4.js} +4 -1
- package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-ZZ46LWL6.js} +1 -1
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +175 -118
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +24 -23
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +12 -9
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/ArcType.js +6 -1
- package/Source/Core/ArticulationStageType.js +5 -1
- package/Source/Core/AssociativeArray.js +100 -94
- package/Source/Core/BoundingSphere.js +1296 -1300
- package/Source/Core/Cartesian2.js +1 -1
- package/Source/Core/Cartesian3.js +2 -3
- package/Source/Core/Cartesian4.js +1 -1
- package/Source/Core/Cartographic.js +257 -249
- package/Source/Core/ClockRange.js +6 -1
- package/Source/Core/ClockStep.js +6 -1
- package/Source/Core/Color.js +844 -835
- package/Source/Core/ComponentDatatype.js +39 -1
- package/Source/Core/CornerType.js +6 -1
- package/Source/Core/Credit.js +121 -124
- package/Source/Core/Ellipsoid.js +637 -660
- package/Source/Core/ExtrapolationType.js +6 -1
- package/Source/Core/GeocodeType.js +6 -1
- package/Source/Core/GeographicProjection.js +74 -74
- package/Source/Core/GeographicTilingScheme.js +179 -198
- package/Source/Core/GeometryOffsetAttribute.js +7 -1
- package/Source/Core/GeometryType.js +7 -1
- package/Source/Core/HeightmapEncoding.js +6 -1
- package/Source/Core/Iau2006XysData.js +24 -13
- package/Source/Core/IndexDatatype.js +3 -1
- package/Source/Core/InterpolationType.js +5 -1
- package/Source/Core/Intersect.js +6 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocodeProviderType.js +5 -1
- package/Source/Core/JulianDate.js +850 -848
- package/Source/Core/KeyboardEventModifier.js +6 -1
- package/Source/Core/MapProjection.js +40 -44
- package/Source/Core/Matrix2.js +906 -893
- package/Source/Core/Matrix3.js +1643 -1575
- package/Source/Core/Matrix4.js +2903 -2872
- package/Source/Core/PixelFormat.js +3 -1
- package/Source/Core/PrimitiveType.js +11 -1
- package/Source/Core/Ray.js +62 -60
- package/Source/Core/Rectangle.js +913 -904
- package/Source/Core/ReferenceFrame.js +6 -1
- package/Source/Core/RequestScheduler.js +8 -3
- package/Source/Core/RequestState.js +6 -1
- package/Source/Core/RequestType.js +6 -1
- package/Source/Core/Resource.js +1 -1
- package/Source/Core/ScreenSpaceEventHandler.js +51 -41
- package/Source/Core/ScreenSpaceEventType.js +6 -1
- package/Source/Core/TerrainQuantization.js +6 -1
- package/Source/Core/TilingScheme.js +100 -98
- package/Source/Core/TimeConstants.js +6 -1
- package/Source/Core/TimeStandard.js +6 -1
- package/Source/Core/TrackingReferenceFrame.js +6 -1
- package/Source/Core/Visibility.js +6 -1
- package/Source/Core/VulkanConstants.js +6 -1
- package/Source/Core/WebGLConstants.js +6 -1
- package/Source/Core/WebMercatorProjection.js +108 -109
- package/Source/Core/WebMercatorTilingScheme.js +246 -242
- package/Source/Core/WindingOrder.js +3 -1
- package/Source/Core/createColorRamp.js +37 -0
- package/Source/Core/globalTypes.js +25 -0
- package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +1 -0
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -0
- package/Source/DataSources/StripeOrientation.js +6 -1
- package/Source/Renderer/BufferUsage.js +20 -9
- package/Source/Renderer/Context.js +2 -29
- package/Source/Renderer/DrawCommand.js +435 -403
- package/Source/Renderer/MipmapHint.js +5 -1
- package/Source/Renderer/Pass.js +10 -3
- package/Source/Renderer/PickId.js +44 -0
- package/Source/Renderer/PixelDatatype.js +3 -1
- package/Source/Renderer/RenderbufferFormat.js +5 -1
- package/Source/Renderer/ShaderDestination.js +4 -1
- package/Source/Renderer/TextureMagnificationFilter.js +3 -1
- package/Source/Renderer/TextureMinificationFilter.js +3 -1
- package/Source/Renderer/TextureWrap.js +5 -1
- package/Source/Renderer/createUniform.js +346 -239
- package/Source/Renderer/createUniformArray.js +494 -381
- package/Source/Scene/AlphaMode.js +5 -1
- package/Source/Scene/ArcGisBaseMapType.js +6 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/AttributeType.js +3 -1
- package/Source/Scene/Axis.js +3 -1
- package/Source/Scene/BingMapsStyle.js +6 -1
- package/Source/Scene/BlendEquation.js +6 -1
- package/Source/Scene/BlendFunction.js +6 -1
- package/Source/Scene/BlendOption.js +6 -1
- package/Source/Scene/BlendingState.js +6 -1
- package/Source/Scene/BufferLoader.js +0 -2
- package/Source/Scene/BufferPoint.js +1 -0
- package/Source/Scene/BufferPointCollection.js +17 -1
- package/Source/Scene/BufferPolygon.js +3 -2
- package/Source/Scene/BufferPolygonCollection.js +13 -1
- package/Source/Scene/BufferPolyline.js +1 -0
- package/Source/Scene/BufferPolylineCollection.js +5 -1
- package/Source/Scene/BufferPrimitiveCollection.js +210 -43
- package/Source/Scene/CameraEventAggregator.js +30 -18
- package/Source/Scene/CameraEventType.js +6 -1
- package/Source/Scene/Cesium3DTile.js +54 -1
- package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
- package/Source/Scene/Cesium3DTileContent.js +195 -254
- package/Source/Scene/Cesium3DTileContentFactory.js +10 -2
- package/Source/Scene/Cesium3DTileContentState.js +6 -1
- package/Source/Scene/Cesium3DTileContentType.js +3 -1
- package/Source/Scene/Cesium3DTileFeature.js +289 -306
- package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
- package/Source/Scene/Cesium3DTilePass.js +5 -1
- package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
- package/Source/Scene/Cesium3DTileRefine.js +6 -1
- package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
- package/Source/Scene/Cesium3DTileset.js +46 -6
- package/Source/Scene/ClassificationType.js +3 -1
- package/Source/Scene/CloudType.js +3 -1
- package/Source/Scene/ColorBlendMode.js +4 -1
- package/Source/Scene/Composite3DTileContent.js +254 -292
- package/Source/Scene/CullFace.js +6 -1
- package/Source/Scene/DepthFunction.js +6 -1
- package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
- package/Source/Scene/EdgeDisplayMode.js +50 -0
- package/Source/Scene/Empty3DTileContent.js +100 -132
- package/Source/Scene/EquirectangularPanorama.js +1 -0
- package/Source/Scene/ExpressionNodeType.js +6 -1
- package/Source/Scene/GaussianSplat3DTileContent.js +436 -478
- package/Source/Scene/GeoJsonPrimitive.js +874 -0
- package/Source/Scene/Geometry3DTileContent.js +151 -185
- package/Source/Scene/GltfBufferViewLoader.js +0 -2
- package/Source/Scene/GltfDracoLoader.js +0 -2
- package/Source/Scene/GltfImageLoader.js +0 -3
- package/Source/Scene/GltfIndexBufferLoader.js +0 -4
- package/Source/Scene/GltfJsonLoader.js +0 -2
- package/Source/Scene/GltfLoader.js +109 -5
- package/Source/Scene/GltfLoaderUtil.js +14 -0
- package/Source/Scene/GltfSpzLoader.js +0 -2
- package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
- package/Source/Scene/GltfTextureLoader.js +0 -2
- package/Source/Scene/GltfVertexBufferLoader.js +0 -4
- package/Source/Scene/HeightReference.js +5 -1
- package/Source/Scene/HorizontalOrigin.js +6 -1
- package/Source/Scene/ImageryProvider.js +1 -1
- package/Source/Scene/ImageryState.js +6 -1
- package/Source/Scene/Implicit3DTileContent.js +179 -214
- package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
- package/Source/Scene/InstanceAttributeSemantic.js +3 -1
- package/Source/Scene/IonWorldImageryStyle.js +6 -1
- package/Source/Scene/JobType.js +6 -1
- package/Source/Scene/LabelStyle.js +6 -1
- package/Source/Scene/MVTDataProvider.js +147 -0
- package/Source/Scene/MapMode2D.js +6 -1
- package/Source/Scene/MetadataComponentType.js +3 -1
- package/Source/Scene/MetadataSchemaLoader.js +0 -2
- package/Source/Scene/MetadataSemantic.js +6 -2
- package/Source/Scene/MetadataType.js +3 -1
- package/Source/Scene/Model/B3dmLoader.js +0 -3
- package/Source/Scene/Model/CustomShaderMode.js +3 -1
- package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +78 -337
- package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
- package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
- package/Source/Scene/Model/GeoJsonLoader.js +0 -2
- package/Source/Scene/Model/I3dmLoader.js +0 -3
- package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
- package/Source/Scene/Model/LightingModel.js +5 -1
- package/Source/Scene/Model/MaterialPipelineStage.js +184 -3
- package/Source/Scene/Model/Model.js +34 -0
- package/Source/Scene/Model/Model3DTileContent.js +424 -458
- package/Source/Scene/Model/ModelDrawCommand.js +31 -3
- package/Source/Scene/Model/ModelReader.js +474 -3
- package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
- package/Source/Scene/Model/ModelType.js +3 -1
- package/Source/Scene/Model/ModelUtility.js +4 -0
- package/Source/Scene/Model/PntsLoader.js +4 -3
- package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
- package/Source/Scene/Model/UniformType.js +5 -1
- package/Source/Scene/Model/VaryingType.js +5 -1
- package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +500 -139
- package/Source/Scene/Model/pickModel.js +94 -299
- package/Source/Scene/ModelAnimationLoop.js +6 -1
- package/Source/Scene/ModelAnimationState.js +6 -1
- package/Source/Scene/ModelComponents.js +47 -2
- package/Source/Scene/Multiple3DTileContent.js +291 -334
- package/Source/Scene/PrimitiveState.js +7 -1
- package/Source/Scene/QuadtreeOccluders.js +20 -15
- package/Source/Scene/QuadtreeTile.js +547 -541
- package/Source/Scene/QuadtreeTileLoadState.js +6 -1
- package/Source/Scene/QuadtreeTileProvider.js +159 -175
- package/Source/Scene/ResourceLoader.js +0 -1
- package/Source/Scene/ResourceLoaderState.js +7 -1
- package/Source/Scene/Scene.js +26 -0
- package/Source/Scene/SceneMode.js +4 -1
- package/Source/Scene/ShadowMode.js +3 -1
- package/Source/Scene/SkyBox.js +1 -1
- package/Source/Scene/SplitDirection.js +6 -1
- package/Source/Scene/StencilFunction.js +6 -1
- package/Source/Scene/StencilOperation.js +6 -1
- package/Source/Scene/TerrainState.js +7 -1
- package/Source/Scene/TileState.js +7 -1
- package/Source/Scene/Tileset3DTileContent.js +113 -146
- package/Source/Scene/Tonemapper.js +5 -1
- package/Source/Scene/UrlTemplate3DTilesDataProvider.js +499 -0
- package/Source/Scene/Vector3DTileContent.js +205 -234
- package/Source/Scene/VectorGltf3DTileContent.js +131 -61
- package/Source/Scene/VertexAttributeSemantic.js +3 -1
- package/Source/Scene/VerticalOrigin.js +6 -1
- package/Source/Scene/VoxelBoxShape.js +12 -6
- package/Source/Scene/VoxelContent.js +2 -0
- package/Source/Scene/VoxelCylinderShape.js +39 -38
- package/Source/Scene/VoxelEllipsoidShape.js +46 -96
- package/Source/Scene/VoxelMetadataOrder.js +6 -1
- package/Source/Scene/VoxelPrimitive.js +159 -175
- package/Source/Scene/VoxelProvider.js +64 -90
- package/Source/Scene/VoxelShapeType.js +3 -1
- package/Source/Scene/buildVectorGltfFromMVT.js +1059 -0
- package/Source/Scene/buildVoxelCustomShader.js +199 -0
- package/Source/Scene/decodeMVT.js +634 -0
- package/Source/Scene/renderBufferPointCollection.js +124 -127
- package/Source/Scene/renderBufferPolygonCollection.js +122 -122
- package/Source/Scene/renderBufferPolylineCollection.js +386 -238
- package/Source/Shaders/BufferPointMaterialFS.glsl +1 -0
- package/Source/Shaders/BufferPointMaterialFS.js +1 -0
- package/Source/Shaders/BufferPointMaterialVS.glsl +19 -9
- package/Source/Shaders/BufferPointMaterialVS.js +20 -10
- package/Source/Shaders/BufferPolygonMaterialVS.glsl +13 -4
- package/Source/Shaders/BufferPolygonMaterialVS.js +14 -5
- package/Source/Shaders/BufferPolylineMaterialVS.glsl +16 -2
- package/Source/Shaders/BufferPolylineMaterialVS.js +17 -3
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.glsl +9 -0
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
- package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
- package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
- package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
- package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
- package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
- package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +0 -1
- package/Source/Shaders/Model/EdgeVisibilityStageVS.js +0 -1
- package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
- package/Source/Shaders/Model/MaterialStageFS.js +46 -20
- package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
- package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
- package/Source/Widget/CesiumWidget.js +11 -4
- package/index.d.ts +595 -343
- package/index.js +392 -378
- package/package.json +3 -3
- package/Build/Workers/chunk-DVB56LG7.js +0 -114
- package/Build/Workers/chunk-HKUES6UG.js +0 -2357
- package/Build/Workers/chunk-HRHRYFHS.js +0 -940
- package/Build/Workers/chunk-KLPGTXS3.js +0 -642
- package/Build/Workers/chunk-ZBZRTRJB.js +0 -1829
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import Cartesian3 from "./Cartesian3.js";
|
|
2
4
|
import Cartographic from "./Cartographic.js";
|
|
3
5
|
import Check from "./Check.js";
|
|
@@ -11,1246 +13,1479 @@ import Matrix3 from "./Matrix3.js";
|
|
|
11
13
|
import Matrix4 from "./Matrix4.js";
|
|
12
14
|
import Rectangle from "./Rectangle.js";
|
|
13
15
|
|
|
16
|
+
/** @import {TypedArray} from "./globalTypes.js"; */
|
|
17
|
+
/** @import OrientedBoundingBox from "./OrientedBoundingBox.js"; */
|
|
18
|
+
/** @import Plane from "./Plane.js"; */
|
|
19
|
+
/** @import MapProjection from "./MapProjection.js"; */
|
|
20
|
+
/** @import Occluder from "./Occluder.js"; */
|
|
21
|
+
|
|
14
22
|
/**
|
|
15
23
|
* A bounding sphere with a center and a radius.
|
|
16
|
-
* @alias BoundingSphere
|
|
17
|
-
* @constructor
|
|
18
|
-
*
|
|
19
|
-
* @param {Cartesian3} [center=Cartesian3.ZERO] The center of the bounding sphere.
|
|
20
|
-
* @param {number} [radius=0.0] The radius of the bounding sphere.
|
|
21
24
|
*
|
|
22
25
|
* @see AxisAlignedBoundingBox
|
|
23
26
|
* @see BoundingRectangle
|
|
24
27
|
* @see Packable
|
|
25
28
|
*/
|
|
26
|
-
|
|
29
|
+
class BoundingSphere {
|
|
27
30
|
/**
|
|
28
|
-
* The center
|
|
29
|
-
* @
|
|
30
|
-
* @default {@link Cartesian3.ZERO}
|
|
31
|
+
* @param {Cartesian3} [center=Cartesian3.ZERO] The center of the bounding sphere.
|
|
32
|
+
* @param {number} [radius=0.0] The radius of the bounding sphere.
|
|
31
33
|
*/
|
|
32
|
-
|
|
34
|
+
constructor(center, radius) {
|
|
35
|
+
/**
|
|
36
|
+
* The center point of the sphere.
|
|
37
|
+
* @type {Cartesian3}
|
|
38
|
+
* @default {@link Cartesian3.ZERO}
|
|
39
|
+
*/
|
|
40
|
+
this.center = Cartesian3.clone(center ?? Cartesian3.ZERO);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The radius of the sphere.
|
|
44
|
+
* @type {number}
|
|
45
|
+
* @default 0.0
|
|
46
|
+
*/
|
|
47
|
+
this.radius = radius ?? 0.0;
|
|
48
|
+
}
|
|
33
49
|
|
|
34
50
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
51
|
+
* Computes a tight-fitting bounding sphere enclosing a list of 3D Cartesian points.
|
|
52
|
+
* The bounding sphere is computed by running two algorithms, a naive algorithm and
|
|
53
|
+
* Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.
|
|
54
|
+
*
|
|
55
|
+
* @param {Cartesian3[]} [positions] An array of points that the bounding sphere will enclose. Each point must have <code>x</code>, <code>y</code>, and <code>z</code> properties.
|
|
56
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
57
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
58
|
+
*
|
|
59
|
+
* @see {@link http://help.agi.com/AGIComponents/html/BlogBoundingSphere.htm|Bounding Sphere computation article}
|
|
38
60
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
static fromPoints(positions, result) {
|
|
62
|
+
if (!defined(result)) {
|
|
63
|
+
result = new BoundingSphere();
|
|
64
|
+
}
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const fromPointsZMax = new Cartesian3();
|
|
48
|
-
const fromPointsCurrentPos = new Cartesian3();
|
|
49
|
-
const fromPointsScratch = new Cartesian3();
|
|
50
|
-
const fromPointsRitterCenter = new Cartesian3();
|
|
51
|
-
const fromPointsMinBoxPt = new Cartesian3();
|
|
52
|
-
const fromPointsMaxBoxPt = new Cartesian3();
|
|
53
|
-
const fromPointsNaiveCenterScratch = new Cartesian3();
|
|
54
|
-
const volumeConstant = (4.0 / 3.0) * CesiumMath.PI;
|
|
66
|
+
if (!defined(positions) || positions.length === 0) {
|
|
67
|
+
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
68
|
+
result.radius = 0.0;
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
* Computes a tight-fitting bounding sphere enclosing a list of 3D Cartesian points.
|
|
58
|
-
* The bounding sphere is computed by running two algorithms, a naive algorithm and
|
|
59
|
-
* Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.
|
|
60
|
-
*
|
|
61
|
-
* @param {Cartesian3[]} [positions] An array of points that the bounding sphere will enclose. Each point must have <code>x</code>, <code>y</code>, and <code>z</code> properties.
|
|
62
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
63
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
64
|
-
*
|
|
65
|
-
* @see {@link http://help.agi.com/AGIComponents/html/BlogBoundingSphere.htm|Bounding Sphere computation article}
|
|
66
|
-
*/
|
|
67
|
-
BoundingSphere.fromPoints = function (positions, result) {
|
|
68
|
-
if (!defined(result)) {
|
|
69
|
-
result = new BoundingSphere();
|
|
70
|
-
}
|
|
72
|
+
const currentPos = Cartesian3.clone(positions[0], fromPointsCurrentPos);
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
74
|
+
const xMin = Cartesian3.clone(currentPos, fromPointsXMin);
|
|
75
|
+
const yMin = Cartesian3.clone(currentPos, fromPointsYMin);
|
|
76
|
+
const zMin = Cartesian3.clone(currentPos, fromPointsZMin);
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
const xMax = Cartesian3.clone(currentPos, fromPointsXMax);
|
|
79
|
+
const yMax = Cartesian3.clone(currentPos, fromPointsYMax);
|
|
80
|
+
const zMax = Cartesian3.clone(currentPos, fromPointsZMax);
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const numPositions = positions.length;
|
|
83
|
+
let i;
|
|
84
|
+
for (i = 1; i < numPositions; i++) {
|
|
85
|
+
Cartesian3.clone(positions[i], currentPos);
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
const x = currentPos.x;
|
|
88
|
+
const y = currentPos.y;
|
|
89
|
+
const z = currentPos.z;
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
// Store points containing the the smallest and largest components
|
|
92
|
+
if (x < xMin.x) {
|
|
93
|
+
Cartesian3.clone(currentPos, xMin);
|
|
94
|
+
}
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
if (x > xMax.x) {
|
|
97
|
+
Cartesian3.clone(currentPos, xMax);
|
|
98
|
+
}
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
100
|
+
if (y < yMin.y) {
|
|
101
|
+
Cartesian3.clone(currentPos, yMin);
|
|
102
|
+
}
|
|
101
103
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (y > yMax.y) {
|
|
105
|
+
Cartesian3.clone(currentPos, yMax);
|
|
106
|
+
}
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
if (z < zMin.z) {
|
|
109
|
+
Cartesian3.clone(currentPos, zMin);
|
|
110
|
+
}
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
if (z > zMax.z) {
|
|
113
|
+
Cartesian3.clone(currentPos, zMax);
|
|
114
|
+
}
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
// Compute x-, y-, and z-spans (Squared distances b/n each component's min. and max.).
|
|
118
|
+
const xSpan = Cartesian3.magnitudeSquared(
|
|
119
|
+
Cartesian3.subtract(xMax, xMin, fromPointsScratch),
|
|
120
|
+
);
|
|
121
|
+
const ySpan = Cartesian3.magnitudeSquared(
|
|
122
|
+
Cartesian3.subtract(yMax, yMin, fromPointsScratch),
|
|
123
|
+
);
|
|
124
|
+
const zSpan = Cartesian3.magnitudeSquared(
|
|
125
|
+
Cartesian3.subtract(zMax, zMin, fromPointsScratch),
|
|
126
|
+
);
|
|
117
127
|
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
// Set the diameter endpoints to the largest span.
|
|
129
|
+
let diameter1 = xMin;
|
|
130
|
+
let diameter2 = xMax;
|
|
131
|
+
let maxSpan = xSpan;
|
|
132
|
+
if (ySpan > maxSpan) {
|
|
133
|
+
maxSpan = ySpan;
|
|
134
|
+
diameter1 = yMin;
|
|
135
|
+
diameter2 = yMax;
|
|
136
|
+
}
|
|
137
|
+
if (zSpan > maxSpan) {
|
|
138
|
+
maxSpan = zSpan;
|
|
139
|
+
diameter1 = zMin;
|
|
140
|
+
diameter2 = zMax;
|
|
120
141
|
}
|
|
121
|
-
}
|
|
122
142
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Cartesian3.subtract(yMax, yMin, fromPointsScratch),
|
|
129
|
-
);
|
|
130
|
-
const zSpan = Cartesian3.magnitudeSquared(
|
|
131
|
-
Cartesian3.subtract(zMax, zMin, fromPointsScratch),
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
// Set the diameter endpoints to the largest span.
|
|
135
|
-
let diameter1 = xMin;
|
|
136
|
-
let diameter2 = xMax;
|
|
137
|
-
let maxSpan = xSpan;
|
|
138
|
-
if (ySpan > maxSpan) {
|
|
139
|
-
maxSpan = ySpan;
|
|
140
|
-
diameter1 = yMin;
|
|
141
|
-
diameter2 = yMax;
|
|
142
|
-
}
|
|
143
|
-
if (zSpan > maxSpan) {
|
|
144
|
-
maxSpan = zSpan;
|
|
145
|
-
diameter1 = zMin;
|
|
146
|
-
diameter2 = zMax;
|
|
147
|
-
}
|
|
143
|
+
// Calculate the center of the initial sphere found by Ritter's algorithm
|
|
144
|
+
const ritterCenter = fromPointsRitterCenter;
|
|
145
|
+
ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
|
|
146
|
+
ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
|
|
147
|
+
ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
maxBoxPt.z = zMax.z;
|
|
171
|
-
|
|
172
|
-
const naiveCenter = Cartesian3.midpoint(
|
|
173
|
-
minBoxPt,
|
|
174
|
-
maxBoxPt,
|
|
175
|
-
fromPointsNaiveCenterScratch,
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
// Begin 2nd pass to find naive radius and modify the ritter sphere.
|
|
179
|
-
let naiveRadius = 0;
|
|
180
|
-
for (i = 0; i < numPositions; i++) {
|
|
181
|
-
Cartesian3.clone(positions[i], currentPos);
|
|
182
|
-
|
|
183
|
-
// Find the furthest point from the naive center to calculate the naive radius.
|
|
184
|
-
const r = Cartesian3.magnitude(
|
|
185
|
-
Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch),
|
|
149
|
+
// Calculate the radius of the initial sphere found by Ritter's algorithm
|
|
150
|
+
let radiusSquared = Cartesian3.magnitudeSquared(
|
|
151
|
+
Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch),
|
|
152
|
+
);
|
|
153
|
+
let ritterRadius = Math.sqrt(radiusSquared);
|
|
154
|
+
|
|
155
|
+
// Find the center of the sphere found using the Naive method.
|
|
156
|
+
const minBoxPt = fromPointsMinBoxPt;
|
|
157
|
+
minBoxPt.x = xMin.x;
|
|
158
|
+
minBoxPt.y = yMin.y;
|
|
159
|
+
minBoxPt.z = zMin.z;
|
|
160
|
+
|
|
161
|
+
const maxBoxPt = fromPointsMaxBoxPt;
|
|
162
|
+
maxBoxPt.x = xMax.x;
|
|
163
|
+
maxBoxPt.y = yMax.y;
|
|
164
|
+
maxBoxPt.z = zMax.z;
|
|
165
|
+
|
|
166
|
+
const naiveCenter = Cartesian3.midpoint(
|
|
167
|
+
minBoxPt,
|
|
168
|
+
maxBoxPt,
|
|
169
|
+
fromPointsNaiveCenterScratch,
|
|
186
170
|
);
|
|
187
|
-
|
|
188
|
-
|
|
171
|
+
|
|
172
|
+
// Begin 2nd pass to find naive radius and modify the ritter sphere.
|
|
173
|
+
let naiveRadius = 0;
|
|
174
|
+
for (i = 0; i < numPositions; i++) {
|
|
175
|
+
Cartesian3.clone(positions[i], currentPos);
|
|
176
|
+
|
|
177
|
+
// Find the furthest point from the naive center to calculate the naive radius.
|
|
178
|
+
const r = Cartesian3.magnitude(
|
|
179
|
+
Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch),
|
|
180
|
+
);
|
|
181
|
+
if (r > naiveRadius) {
|
|
182
|
+
naiveRadius = r;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Make adjustments to the Ritter Sphere to include all points.
|
|
186
|
+
const oldCenterToPointSquared = Cartesian3.magnitudeSquared(
|
|
187
|
+
Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch),
|
|
188
|
+
);
|
|
189
|
+
if (oldCenterToPointSquared > radiusSquared) {
|
|
190
|
+
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
|
|
191
|
+
// Calculate new radius to include the point that lies outside
|
|
192
|
+
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
|
|
193
|
+
radiusSquared = ritterRadius * ritterRadius;
|
|
194
|
+
// Calculate center of new Ritter sphere
|
|
195
|
+
const oldToNew = oldCenterToPoint - ritterRadius;
|
|
196
|
+
ritterCenter.x =
|
|
197
|
+
(ritterRadius * ritterCenter.x + oldToNew * currentPos.x) /
|
|
198
|
+
oldCenterToPoint;
|
|
199
|
+
ritterCenter.y =
|
|
200
|
+
(ritterRadius * ritterCenter.y + oldToNew * currentPos.y) /
|
|
201
|
+
oldCenterToPoint;
|
|
202
|
+
ritterCenter.z =
|
|
203
|
+
(ritterRadius * ritterCenter.z + oldToNew * currentPos.z) /
|
|
204
|
+
oldCenterToPoint;
|
|
205
|
+
}
|
|
189
206
|
}
|
|
190
207
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// Calculate new radius to include the point that lies outside
|
|
198
|
-
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
|
|
199
|
-
radiusSquared = ritterRadius * ritterRadius;
|
|
200
|
-
// Calculate center of new Ritter sphere
|
|
201
|
-
const oldToNew = oldCenterToPoint - ritterRadius;
|
|
202
|
-
ritterCenter.x =
|
|
203
|
-
(ritterRadius * ritterCenter.x + oldToNew * currentPos.x) /
|
|
204
|
-
oldCenterToPoint;
|
|
205
|
-
ritterCenter.y =
|
|
206
|
-
(ritterRadius * ritterCenter.y + oldToNew * currentPos.y) /
|
|
207
|
-
oldCenterToPoint;
|
|
208
|
-
ritterCenter.z =
|
|
209
|
-
(ritterRadius * ritterCenter.z + oldToNew * currentPos.z) /
|
|
210
|
-
oldCenterToPoint;
|
|
208
|
+
if (ritterRadius < naiveRadius) {
|
|
209
|
+
Cartesian3.clone(ritterCenter, result.center);
|
|
210
|
+
result.radius = ritterRadius;
|
|
211
|
+
} else {
|
|
212
|
+
Cartesian3.clone(naiveCenter, result.center);
|
|
213
|
+
result.radius = naiveRadius;
|
|
211
214
|
}
|
|
212
|
-
}
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
Cartesian3.clone(ritterCenter, result.center);
|
|
216
|
-
result.radius = ritterRadius;
|
|
217
|
-
} else {
|
|
218
|
-
Cartesian3.clone(naiveCenter, result.center);
|
|
219
|
-
result.radius = naiveRadius;
|
|
216
|
+
return result;
|
|
220
217
|
}
|
|
221
218
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
219
|
+
/**
|
|
220
|
+
* Computes a bounding sphere from a rectangle projected in 2D.
|
|
221
|
+
*
|
|
222
|
+
* @param {Rectangle} [rectangle] The rectangle around which to create a bounding sphere.
|
|
223
|
+
* @param {MapProjection} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
|
|
224
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
225
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
226
|
+
*/
|
|
227
|
+
static fromRectangle2D(rectangle, projection, result) {
|
|
228
|
+
return BoundingSphere.fromRectangleWithHeights2D(
|
|
229
|
+
rectangle,
|
|
230
|
+
projection,
|
|
231
|
+
0.0,
|
|
232
|
+
0.0,
|
|
233
|
+
result,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
230
236
|
|
|
231
|
-
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
BoundingSphere
|
|
240
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Computes a bounding sphere from a rectangle projected in 2D. The bounding sphere accounts for the
|
|
239
|
+
* object's minimum and maximum heights over the rectangle.
|
|
240
|
+
*
|
|
241
|
+
* @param {Rectangle} [rectangle] The rectangle around which to create a bounding sphere.
|
|
242
|
+
* @param {MapProjection} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
|
|
243
|
+
* @param {number} [minimumHeight=0.0] The minimum height over the rectangle.
|
|
244
|
+
* @param {number} [maximumHeight=0.0] The maximum height over the rectangle.
|
|
245
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
246
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
247
|
+
*/
|
|
248
|
+
static fromRectangleWithHeights2D(
|
|
241
249
|
rectangle,
|
|
242
250
|
projection,
|
|
243
|
-
|
|
244
|
-
|
|
251
|
+
minimumHeight,
|
|
252
|
+
maximumHeight,
|
|
245
253
|
result,
|
|
246
|
-
)
|
|
247
|
-
|
|
254
|
+
) {
|
|
255
|
+
if (!defined(result)) {
|
|
256
|
+
result = new BoundingSphere();
|
|
257
|
+
}
|
|
248
258
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* @param {object} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
|
|
255
|
-
* @param {number} [minimumHeight=0.0] The minimum height over the rectangle.
|
|
256
|
-
* @param {number} [maximumHeight=0.0] The maximum height over the rectangle.
|
|
257
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
258
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
259
|
-
*/
|
|
260
|
-
BoundingSphere.fromRectangleWithHeights2D = function (
|
|
261
|
-
rectangle,
|
|
262
|
-
projection,
|
|
263
|
-
minimumHeight,
|
|
264
|
-
maximumHeight,
|
|
265
|
-
result,
|
|
266
|
-
) {
|
|
267
|
-
if (!defined(result)) {
|
|
268
|
-
result = new BoundingSphere();
|
|
269
|
-
}
|
|
259
|
+
if (!defined(rectangle)) {
|
|
260
|
+
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
261
|
+
result.radius = 0.0;
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
270
264
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
result.radius = 0.0;
|
|
274
|
-
return result;
|
|
275
|
-
}
|
|
265
|
+
defaultProjection._ellipsoid = Ellipsoid.default;
|
|
266
|
+
projection = projection ?? defaultProjection;
|
|
276
267
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
fromRectangle2DSouthwest.height = minimumHeight;
|
|
282
|
-
Rectangle.northeast(rectangle, fromRectangle2DNortheast);
|
|
283
|
-
fromRectangle2DNortheast.height = maximumHeight;
|
|
284
|
-
|
|
285
|
-
const lowerLeft = projection.project(
|
|
286
|
-
fromRectangle2DSouthwest,
|
|
287
|
-
fromRectangle2DLowerLeft,
|
|
288
|
-
);
|
|
289
|
-
const upperRight = projection.project(
|
|
290
|
-
fromRectangle2DNortheast,
|
|
291
|
-
fromRectangle2DUpperRight,
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
const width = upperRight.x - lowerLeft.x;
|
|
295
|
-
const height = upperRight.y - lowerLeft.y;
|
|
296
|
-
const elevation = upperRight.z - lowerLeft.z;
|
|
297
|
-
|
|
298
|
-
result.radius =
|
|
299
|
-
Math.sqrt(width * width + height * height + elevation * elevation) * 0.5;
|
|
300
|
-
const center = result.center;
|
|
301
|
-
center.x = lowerLeft.x + width * 0.5;
|
|
302
|
-
center.y = lowerLeft.y + height * 0.5;
|
|
303
|
-
center.z = lowerLeft.z + elevation * 0.5;
|
|
304
|
-
return result;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const fromRectangle3DScratch = [];
|
|
268
|
+
Rectangle.southwest(rectangle, fromRectangle2DSouthwest);
|
|
269
|
+
fromRectangle2DSouthwest.height = minimumHeight;
|
|
270
|
+
Rectangle.northeast(rectangle, fromRectangle2DNortheast);
|
|
271
|
+
fromRectangle2DNortheast.height = maximumHeight;
|
|
308
272
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
ellipsoid,
|
|
322
|
-
surfaceHeight,
|
|
323
|
-
result,
|
|
324
|
-
) {
|
|
325
|
-
ellipsoid = ellipsoid ?? Ellipsoid.default;
|
|
326
|
-
surfaceHeight = surfaceHeight ?? 0.0;
|
|
327
|
-
|
|
328
|
-
if (!defined(result)) {
|
|
329
|
-
result = new BoundingSphere();
|
|
330
|
-
}
|
|
273
|
+
const lowerLeft = projection.project(
|
|
274
|
+
fromRectangle2DSouthwest,
|
|
275
|
+
fromRectangle2DLowerLeft,
|
|
276
|
+
);
|
|
277
|
+
const upperRight = projection.project(
|
|
278
|
+
fromRectangle2DNortheast,
|
|
279
|
+
fromRectangle2DUpperRight,
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const width = upperRight.x - lowerLeft.x;
|
|
283
|
+
const height = upperRight.y - lowerLeft.y;
|
|
284
|
+
const elevation = upperRight.z - lowerLeft.z;
|
|
331
285
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
286
|
+
result.radius =
|
|
287
|
+
Math.sqrt(width * width + height * height + elevation * elevation) * 0.5;
|
|
288
|
+
const center = result.center;
|
|
289
|
+
center.x = lowerLeft.x + width * 0.5;
|
|
290
|
+
center.y = lowerLeft.y + height * 0.5;
|
|
291
|
+
center.z = lowerLeft.z + elevation * 0.5;
|
|
335
292
|
return result;
|
|
336
293
|
}
|
|
337
294
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
295
|
+
/**
|
|
296
|
+
* Computes a bounding sphere from a rectangle in 3D. The bounding sphere is created using a subsample of points
|
|
297
|
+
* on the ellipsoid and contained in the rectangle. It may not be accurate for all rectangles on all types of ellipsoids.
|
|
298
|
+
*
|
|
299
|
+
* @param {Rectangle} [rectangle] The valid rectangle used to create a bounding sphere.
|
|
300
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid used to determine positions of the rectangle.
|
|
301
|
+
* @param {number} [surfaceHeight=0.0] The height above the surface of the ellipsoid.
|
|
302
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
303
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
304
|
+
*/
|
|
305
|
+
static fromRectangle3D(rectangle, ellipsoid, surfaceHeight, result) {
|
|
306
|
+
ellipsoid = ellipsoid ?? Ellipsoid.default;
|
|
307
|
+
surfaceHeight = surfaceHeight ?? 0.0;
|
|
346
308
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
* algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to
|
|
351
|
-
* ensure a tight fit.
|
|
352
|
-
*
|
|
353
|
-
* @param {number[]|TypedArray} [positions] An array of points that the bounding sphere will enclose. Each point
|
|
354
|
-
* is formed from three elements in the array in the order X, Y, Z.
|
|
355
|
-
* @param {Cartesian3} [center=Cartesian3.ZERO] The position to which the positions are relative, which need not be the
|
|
356
|
-
* origin of the coordinate system. This is useful when the positions are to be used for
|
|
357
|
-
* relative-to-center (RTC) rendering.
|
|
358
|
-
* @param {number} [stride=3] The number of array elements per vertex. It must be at least 3, but it may
|
|
359
|
-
* be higher. Regardless of the value of this parameter, the X coordinate of the first position
|
|
360
|
-
* is at array index 0, the Y coordinate is at array index 1, and the Z coordinate is at array index
|
|
361
|
-
* 2. When stride is 3, the X coordinate of the next position then begins at array index 3. If
|
|
362
|
-
* the stride is 5, however, two array elements are skipped and the next position begins at array
|
|
363
|
-
* index 5.
|
|
364
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
365
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
* // Compute the bounding sphere from 3 positions, each specified relative to a center.
|
|
369
|
-
* // In addition to the X, Y, and Z coordinates, the points array contains two additional
|
|
370
|
-
* // elements per point which are ignored for the purpose of computing the bounding sphere.
|
|
371
|
-
* const center = new Cesium.Cartesian3(1.0, 2.0, 3.0);
|
|
372
|
-
* const points = [1.0, 2.0, 3.0, 0.1, 0.2,
|
|
373
|
-
* 4.0, 5.0, 6.0, 0.1, 0.2,
|
|
374
|
-
* 7.0, 8.0, 9.0, 0.1, 0.2];
|
|
375
|
-
* const sphere = Cesium.BoundingSphere.fromVertices(points, center, 5);
|
|
376
|
-
*
|
|
377
|
-
* @see {@link http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding/|Bounding Sphere computation article}
|
|
378
|
-
*/
|
|
379
|
-
BoundingSphere.fromVertices = function (positions, center, stride, result) {
|
|
380
|
-
if (!defined(result)) {
|
|
381
|
-
result = new BoundingSphere();
|
|
382
|
-
}
|
|
309
|
+
if (!defined(result)) {
|
|
310
|
+
result = new BoundingSphere();
|
|
311
|
+
}
|
|
383
312
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
313
|
+
if (!defined(rectangle)) {
|
|
314
|
+
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
315
|
+
result.radius = 0.0;
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const positions = Rectangle.subsample(
|
|
320
|
+
rectangle,
|
|
321
|
+
ellipsoid,
|
|
322
|
+
surfaceHeight,
|
|
323
|
+
fromRectangle3DScratch,
|
|
324
|
+
);
|
|
325
|
+
return BoundingSphere.fromPoints(positions, result);
|
|
388
326
|
}
|
|
389
327
|
|
|
390
|
-
|
|
328
|
+
/**
|
|
329
|
+
* Computes a tight-fitting bounding sphere enclosing a list of 3D points, where the points are
|
|
330
|
+
* stored in a flat array in X, Y, Z, order. The bounding sphere is computed by running two
|
|
331
|
+
* algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to
|
|
332
|
+
* ensure a tight fit.
|
|
333
|
+
*
|
|
334
|
+
* @param {number[]|TypedArray} [positions] An array of points that the bounding sphere will enclose. Each point
|
|
335
|
+
* is formed from three elements in the array in the order X, Y, Z.
|
|
336
|
+
* @param {Cartesian3} [center=Cartesian3.ZERO] The position to which the positions are relative, which need not be the
|
|
337
|
+
* origin of the coordinate system. This is useful when the positions are to be used for
|
|
338
|
+
* relative-to-center (RTC) rendering.
|
|
339
|
+
* @param {number} [stride=3] The number of array elements per vertex. It must be at least 3, but it may
|
|
340
|
+
* be higher. Regardless of the value of this parameter, the X coordinate of the first position
|
|
341
|
+
* is at array index 0, the Y coordinate is at array index 1, and the Z coordinate is at array index
|
|
342
|
+
* 2. When stride is 3, the X coordinate of the next position then begins at array index 3. If
|
|
343
|
+
* the stride is 5, however, two array elements are skipped and the next position begins at array
|
|
344
|
+
* index 5.
|
|
345
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
346
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* // Compute the bounding sphere from 3 positions, each specified relative to a center.
|
|
350
|
+
* // In addition to the X, Y, and Z coordinates, the points array contains two additional
|
|
351
|
+
* // elements per point which are ignored for the purpose of computing the bounding sphere.
|
|
352
|
+
* const center = new Cesium.Cartesian3(1.0, 2.0, 3.0);
|
|
353
|
+
* const points = [1.0, 2.0, 3.0, 0.1, 0.2,
|
|
354
|
+
* 4.0, 5.0, 6.0, 0.1, 0.2,
|
|
355
|
+
* 7.0, 8.0, 9.0, 0.1, 0.2];
|
|
356
|
+
* const sphere = Cesium.BoundingSphere.fromVertices(points, center, 5);
|
|
357
|
+
*
|
|
358
|
+
* @see {@link http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding/|Bounding Sphere computation article}
|
|
359
|
+
*/
|
|
360
|
+
static fromVertices(positions, center, stride, result) {
|
|
361
|
+
if (!defined(result)) {
|
|
362
|
+
result = new BoundingSphere();
|
|
363
|
+
}
|
|
391
364
|
|
|
392
|
-
|
|
365
|
+
if (!defined(positions) || positions.length === 0) {
|
|
366
|
+
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
367
|
+
result.radius = 0.0;
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
center = center ?? Cartesian3.ZERO;
|
|
372
|
+
|
|
373
|
+
stride = stride ?? 3;
|
|
374
|
+
|
|
375
|
+
//>>includeStart('debug', pragmas.debug);
|
|
376
|
+
Check.typeOf.number.greaterThanOrEquals("stride", stride, 3);
|
|
377
|
+
//>>includeEnd('debug');
|
|
378
|
+
|
|
379
|
+
const currentPos = fromPointsCurrentPos;
|
|
380
|
+
currentPos.x = positions[0] + center.x;
|
|
381
|
+
currentPos.y = positions[1] + center.y;
|
|
382
|
+
currentPos.z = positions[2] + center.z;
|
|
383
|
+
|
|
384
|
+
const xMin = Cartesian3.clone(currentPos, fromPointsXMin);
|
|
385
|
+
const yMin = Cartesian3.clone(currentPos, fromPointsYMin);
|
|
386
|
+
const zMin = Cartesian3.clone(currentPos, fromPointsZMin);
|
|
393
387
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
388
|
+
const xMax = Cartesian3.clone(currentPos, fromPointsXMax);
|
|
389
|
+
const yMax = Cartesian3.clone(currentPos, fromPointsYMax);
|
|
390
|
+
const zMax = Cartesian3.clone(currentPos, fromPointsZMax);
|
|
397
391
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
392
|
+
const numElements = positions.length;
|
|
393
|
+
let i;
|
|
394
|
+
for (i = 0; i < numElements; i += stride) {
|
|
395
|
+
const x = positions[i] + center.x;
|
|
396
|
+
const y = positions[i + 1] + center.y;
|
|
397
|
+
const z = positions[i + 2] + center.z;
|
|
402
398
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
399
|
+
currentPos.x = x;
|
|
400
|
+
currentPos.y = y;
|
|
401
|
+
currentPos.z = z;
|
|
406
402
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
403
|
+
// Store points containing the the smallest and largest components
|
|
404
|
+
if (x < xMin.x) {
|
|
405
|
+
Cartesian3.clone(currentPos, xMin);
|
|
406
|
+
}
|
|
410
407
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const x = positions[i] + center.x;
|
|
415
|
-
const y = positions[i + 1] + center.y;
|
|
416
|
-
const z = positions[i + 2] + center.z;
|
|
408
|
+
if (x > xMax.x) {
|
|
409
|
+
Cartesian3.clone(currentPos, xMax);
|
|
410
|
+
}
|
|
417
411
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
412
|
+
if (y < yMin.y) {
|
|
413
|
+
Cartesian3.clone(currentPos, yMin);
|
|
414
|
+
}
|
|
421
415
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
416
|
+
if (y > yMax.y) {
|
|
417
|
+
Cartesian3.clone(currentPos, yMax);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (z < zMin.z) {
|
|
421
|
+
Cartesian3.clone(currentPos, zMin);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (z > zMax.z) {
|
|
425
|
+
Cartesian3.clone(currentPos, zMax);
|
|
426
|
+
}
|
|
425
427
|
}
|
|
426
428
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
// Compute x-, y-, and z-spans (Squared distances b/n each component's min. and max.).
|
|
430
|
+
const xSpan = Cartesian3.magnitudeSquared(
|
|
431
|
+
Cartesian3.subtract(xMax, xMin, fromPointsScratch),
|
|
432
|
+
);
|
|
433
|
+
const ySpan = Cartesian3.magnitudeSquared(
|
|
434
|
+
Cartesian3.subtract(yMax, yMin, fromPointsScratch),
|
|
435
|
+
);
|
|
436
|
+
const zSpan = Cartesian3.magnitudeSquared(
|
|
437
|
+
Cartesian3.subtract(zMax, zMin, fromPointsScratch),
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
// Set the diameter endpoints to the largest span.
|
|
441
|
+
let diameter1 = xMin;
|
|
442
|
+
let diameter2 = xMax;
|
|
443
|
+
let maxSpan = xSpan;
|
|
444
|
+
if (ySpan > maxSpan) {
|
|
445
|
+
maxSpan = ySpan;
|
|
446
|
+
diameter1 = yMin;
|
|
447
|
+
diameter2 = yMax;
|
|
429
448
|
}
|
|
449
|
+
if (zSpan > maxSpan) {
|
|
450
|
+
maxSpan = zSpan;
|
|
451
|
+
diameter1 = zMin;
|
|
452
|
+
diameter2 = zMax;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// Calculate the center of the initial sphere found by Ritter's algorithm
|
|
456
|
+
const ritterCenter = fromPointsRitterCenter;
|
|
457
|
+
ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
|
|
458
|
+
ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
|
|
459
|
+
ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
|
|
430
460
|
|
|
431
|
-
|
|
432
|
-
|
|
461
|
+
// Calculate the radius of the initial sphere found by Ritter's algorithm
|
|
462
|
+
let radiusSquared = Cartesian3.magnitudeSquared(
|
|
463
|
+
Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch),
|
|
464
|
+
);
|
|
465
|
+
let ritterRadius = Math.sqrt(radiusSquared);
|
|
466
|
+
|
|
467
|
+
// Find the center of the sphere found using the Naive method.
|
|
468
|
+
const minBoxPt = fromPointsMinBoxPt;
|
|
469
|
+
minBoxPt.x = xMin.x;
|
|
470
|
+
minBoxPt.y = yMin.y;
|
|
471
|
+
minBoxPt.z = zMin.z;
|
|
472
|
+
|
|
473
|
+
const maxBoxPt = fromPointsMaxBoxPt;
|
|
474
|
+
maxBoxPt.x = xMax.x;
|
|
475
|
+
maxBoxPt.y = yMax.y;
|
|
476
|
+
maxBoxPt.z = zMax.z;
|
|
477
|
+
|
|
478
|
+
const naiveCenter = Cartesian3.midpoint(
|
|
479
|
+
minBoxPt,
|
|
480
|
+
maxBoxPt,
|
|
481
|
+
fromPointsNaiveCenterScratch,
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
// Begin 2nd pass to find naive radius and modify the ritter sphere.
|
|
485
|
+
let naiveRadius = 0;
|
|
486
|
+
for (i = 0; i < numElements; i += stride) {
|
|
487
|
+
currentPos.x = positions[i] + center.x;
|
|
488
|
+
currentPos.y = positions[i + 1] + center.y;
|
|
489
|
+
currentPos.z = positions[i + 2] + center.z;
|
|
490
|
+
|
|
491
|
+
// Find the furthest point from the naive center to calculate the naive radius.
|
|
492
|
+
const r = Cartesian3.magnitude(
|
|
493
|
+
Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch),
|
|
494
|
+
);
|
|
495
|
+
if (r > naiveRadius) {
|
|
496
|
+
naiveRadius = r;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Make adjustments to the Ritter Sphere to include all points.
|
|
500
|
+
const oldCenterToPointSquared = Cartesian3.magnitudeSquared(
|
|
501
|
+
Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch),
|
|
502
|
+
);
|
|
503
|
+
if (oldCenterToPointSquared > radiusSquared) {
|
|
504
|
+
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
|
|
505
|
+
// Calculate new radius to include the point that lies outside
|
|
506
|
+
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
|
|
507
|
+
radiusSquared = ritterRadius * ritterRadius;
|
|
508
|
+
// Calculate center of new Ritter sphere
|
|
509
|
+
const oldToNew = oldCenterToPoint - ritterRadius;
|
|
510
|
+
ritterCenter.x =
|
|
511
|
+
(ritterRadius * ritterCenter.x + oldToNew * currentPos.x) /
|
|
512
|
+
oldCenterToPoint;
|
|
513
|
+
ritterCenter.y =
|
|
514
|
+
(ritterRadius * ritterCenter.y + oldToNew * currentPos.y) /
|
|
515
|
+
oldCenterToPoint;
|
|
516
|
+
ritterCenter.z =
|
|
517
|
+
(ritterRadius * ritterCenter.z + oldToNew * currentPos.z) /
|
|
518
|
+
oldCenterToPoint;
|
|
519
|
+
}
|
|
433
520
|
}
|
|
434
521
|
|
|
435
|
-
if (
|
|
436
|
-
Cartesian3.clone(
|
|
522
|
+
if (ritterRadius < naiveRadius) {
|
|
523
|
+
Cartesian3.clone(ritterCenter, result.center);
|
|
524
|
+
result.radius = ritterRadius;
|
|
525
|
+
} else {
|
|
526
|
+
Cartesian3.clone(naiveCenter, result.center);
|
|
527
|
+
result.radius = naiveRadius;
|
|
437
528
|
}
|
|
438
529
|
|
|
439
|
-
|
|
440
|
-
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Computes a tight-fitting bounding sphere enclosing a list of EncodedCartesian3s, where the points are
|
|
535
|
+
* stored in parallel flat arrays in X, Y, Z, order. The bounding sphere is computed by running two
|
|
536
|
+
* algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to
|
|
537
|
+
* ensure a tight fit.
|
|
538
|
+
*
|
|
539
|
+
* @param {number[]} [positionsHigh] An array of high bits of the encoded cartesians that the bounding sphere will enclose. Each point
|
|
540
|
+
* is formed from three elements in the array in the order X, Y, Z.
|
|
541
|
+
* @param {number[]} [positionsLow] An array of low bits of the encoded cartesians that the bounding sphere will enclose. Each point
|
|
542
|
+
* is formed from three elements in the array in the order X, Y, Z.
|
|
543
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
544
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
545
|
+
*
|
|
546
|
+
* @see {@link http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding/|Bounding Sphere computation article}
|
|
547
|
+
*/
|
|
548
|
+
static fromEncodedCartesianVertices(positionsHigh, positionsLow, result) {
|
|
549
|
+
if (!defined(result)) {
|
|
550
|
+
result = new BoundingSphere();
|
|
441
551
|
}
|
|
442
552
|
|
|
443
|
-
if (
|
|
444
|
-
|
|
553
|
+
if (
|
|
554
|
+
!defined(positionsHigh) ||
|
|
555
|
+
!defined(positionsLow) ||
|
|
556
|
+
positionsHigh.length !== positionsLow.length ||
|
|
557
|
+
positionsHigh.length === 0
|
|
558
|
+
) {
|
|
559
|
+
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
560
|
+
result.radius = 0.0;
|
|
561
|
+
return result;
|
|
445
562
|
}
|
|
446
|
-
}
|
|
447
563
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
Cartesian3.
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
564
|
+
const currentPos = fromPointsCurrentPos;
|
|
565
|
+
currentPos.x = positionsHigh[0] + positionsLow[0];
|
|
566
|
+
currentPos.y = positionsHigh[1] + positionsLow[1];
|
|
567
|
+
currentPos.z = positionsHigh[2] + positionsLow[2];
|
|
568
|
+
|
|
569
|
+
const xMin = Cartesian3.clone(currentPos, fromPointsXMin);
|
|
570
|
+
const yMin = Cartesian3.clone(currentPos, fromPointsYMin);
|
|
571
|
+
const zMin = Cartesian3.clone(currentPos, fromPointsZMin);
|
|
572
|
+
|
|
573
|
+
const xMax = Cartesian3.clone(currentPos, fromPointsXMax);
|
|
574
|
+
const yMax = Cartesian3.clone(currentPos, fromPointsYMax);
|
|
575
|
+
const zMax = Cartesian3.clone(currentPos, fromPointsZMax);
|
|
576
|
+
|
|
577
|
+
const numElements = positionsHigh.length;
|
|
578
|
+
let i;
|
|
579
|
+
for (i = 0; i < numElements; i += 3) {
|
|
580
|
+
const x = positionsHigh[i] + positionsLow[i];
|
|
581
|
+
const y = positionsHigh[i + 1] + positionsLow[i + 1];
|
|
582
|
+
const z = positionsHigh[i + 2] + positionsLow[i + 2];
|
|
583
|
+
|
|
584
|
+
currentPos.x = x;
|
|
585
|
+
currentPos.y = y;
|
|
586
|
+
currentPos.z = z;
|
|
587
|
+
|
|
588
|
+
// Store points containing the the smallest and largest components
|
|
589
|
+
if (x < xMin.x) {
|
|
590
|
+
Cartesian3.clone(currentPos, xMin);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (x > xMax.x) {
|
|
594
|
+
Cartesian3.clone(currentPos, xMax);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (y < yMin.y) {
|
|
598
|
+
Cartesian3.clone(currentPos, yMin);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (y > yMax.y) {
|
|
602
|
+
Cartesian3.clone(currentPos, yMax);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
if (z < zMin.z) {
|
|
606
|
+
Cartesian3.clone(currentPos, zMin);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (z > zMax.z) {
|
|
610
|
+
Cartesian3.clone(currentPos, zMax);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
473
613
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
// Calculate the radius of the initial sphere found by Ritter's algorithm
|
|
481
|
-
let radiusSquared = Cartesian3.magnitudeSquared(
|
|
482
|
-
Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch),
|
|
483
|
-
);
|
|
484
|
-
let ritterRadius = Math.sqrt(radiusSquared);
|
|
485
|
-
|
|
486
|
-
// Find the center of the sphere found using the Naive method.
|
|
487
|
-
const minBoxPt = fromPointsMinBoxPt;
|
|
488
|
-
minBoxPt.x = xMin.x;
|
|
489
|
-
minBoxPt.y = yMin.y;
|
|
490
|
-
minBoxPt.z = zMin.z;
|
|
491
|
-
|
|
492
|
-
const maxBoxPt = fromPointsMaxBoxPt;
|
|
493
|
-
maxBoxPt.x = xMax.x;
|
|
494
|
-
maxBoxPt.y = yMax.y;
|
|
495
|
-
maxBoxPt.z = zMax.z;
|
|
496
|
-
|
|
497
|
-
const naiveCenter = Cartesian3.midpoint(
|
|
498
|
-
minBoxPt,
|
|
499
|
-
maxBoxPt,
|
|
500
|
-
fromPointsNaiveCenterScratch,
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
// Begin 2nd pass to find naive radius and modify the ritter sphere.
|
|
504
|
-
let naiveRadius = 0;
|
|
505
|
-
for (i = 0; i < numElements; i += stride) {
|
|
506
|
-
currentPos.x = positions[i] + center.x;
|
|
507
|
-
currentPos.y = positions[i + 1] + center.y;
|
|
508
|
-
currentPos.z = positions[i + 2] + center.z;
|
|
509
|
-
|
|
510
|
-
// Find the furthest point from the naive center to calculate the naive radius.
|
|
511
|
-
const r = Cartesian3.magnitude(
|
|
512
|
-
Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch),
|
|
614
|
+
// Compute x-, y-, and z-spans (Squared distances b/n each component's min. and max.).
|
|
615
|
+
const xSpan = Cartesian3.magnitudeSquared(
|
|
616
|
+
Cartesian3.subtract(xMax, xMin, fromPointsScratch),
|
|
617
|
+
);
|
|
618
|
+
const ySpan = Cartesian3.magnitudeSquared(
|
|
619
|
+
Cartesian3.subtract(yMax, yMin, fromPointsScratch),
|
|
513
620
|
);
|
|
514
|
-
|
|
515
|
-
|
|
621
|
+
const zSpan = Cartesian3.magnitudeSquared(
|
|
622
|
+
Cartesian3.subtract(zMax, zMin, fromPointsScratch),
|
|
623
|
+
);
|
|
624
|
+
|
|
625
|
+
// Set the diameter endpoints to the largest span.
|
|
626
|
+
let diameter1 = xMin;
|
|
627
|
+
let diameter2 = xMax;
|
|
628
|
+
let maxSpan = xSpan;
|
|
629
|
+
if (ySpan > maxSpan) {
|
|
630
|
+
maxSpan = ySpan;
|
|
631
|
+
diameter1 = yMin;
|
|
632
|
+
diameter2 = yMax;
|
|
516
633
|
}
|
|
634
|
+
if (zSpan > maxSpan) {
|
|
635
|
+
maxSpan = zSpan;
|
|
636
|
+
diameter1 = zMin;
|
|
637
|
+
diameter2 = zMax;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Calculate the center of the initial sphere found by Ritter's algorithm
|
|
641
|
+
const ritterCenter = fromPointsRitterCenter;
|
|
642
|
+
ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
|
|
643
|
+
ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
|
|
644
|
+
ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
|
|
517
645
|
|
|
518
|
-
//
|
|
519
|
-
|
|
520
|
-
Cartesian3.subtract(
|
|
646
|
+
// Calculate the radius of the initial sphere found by Ritter's algorithm
|
|
647
|
+
let radiusSquared = Cartesian3.magnitudeSquared(
|
|
648
|
+
Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch),
|
|
649
|
+
);
|
|
650
|
+
let ritterRadius = Math.sqrt(radiusSquared);
|
|
651
|
+
|
|
652
|
+
// Find the center of the sphere found using the Naive method.
|
|
653
|
+
const minBoxPt = fromPointsMinBoxPt;
|
|
654
|
+
minBoxPt.x = xMin.x;
|
|
655
|
+
minBoxPt.y = yMin.y;
|
|
656
|
+
minBoxPt.z = zMin.z;
|
|
657
|
+
|
|
658
|
+
const maxBoxPt = fromPointsMaxBoxPt;
|
|
659
|
+
maxBoxPt.x = xMax.x;
|
|
660
|
+
maxBoxPt.y = yMax.y;
|
|
661
|
+
maxBoxPt.z = zMax.z;
|
|
662
|
+
|
|
663
|
+
const naiveCenter = Cartesian3.midpoint(
|
|
664
|
+
minBoxPt,
|
|
665
|
+
maxBoxPt,
|
|
666
|
+
fromPointsNaiveCenterScratch,
|
|
521
667
|
);
|
|
522
|
-
if (oldCenterToPointSquared > radiusSquared) {
|
|
523
|
-
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
|
|
524
|
-
// Calculate new radius to include the point that lies outside
|
|
525
|
-
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
|
|
526
|
-
radiusSquared = ritterRadius * ritterRadius;
|
|
527
|
-
// Calculate center of new Ritter sphere
|
|
528
|
-
const oldToNew = oldCenterToPoint - ritterRadius;
|
|
529
|
-
ritterCenter.x =
|
|
530
|
-
(ritterRadius * ritterCenter.x + oldToNew * currentPos.x) /
|
|
531
|
-
oldCenterToPoint;
|
|
532
|
-
ritterCenter.y =
|
|
533
|
-
(ritterRadius * ritterCenter.y + oldToNew * currentPos.y) /
|
|
534
|
-
oldCenterToPoint;
|
|
535
|
-
ritterCenter.z =
|
|
536
|
-
(ritterRadius * ritterCenter.z + oldToNew * currentPos.z) /
|
|
537
|
-
oldCenterToPoint;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
668
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
669
|
+
// Begin 2nd pass to find naive radius and modify the ritter sphere.
|
|
670
|
+
let naiveRadius = 0;
|
|
671
|
+
for (i = 0; i < numElements; i += 3) {
|
|
672
|
+
currentPos.x = positionsHigh[i] + positionsLow[i];
|
|
673
|
+
currentPos.y = positionsHigh[i + 1] + positionsLow[i + 1];
|
|
674
|
+
currentPos.z = positionsHigh[i + 2] + positionsLow[i + 2];
|
|
675
|
+
|
|
676
|
+
// Find the furthest point from the naive center to calculate the naive radius.
|
|
677
|
+
const r = Cartesian3.magnitude(
|
|
678
|
+
Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch),
|
|
679
|
+
);
|
|
680
|
+
if (r > naiveRadius) {
|
|
681
|
+
naiveRadius = r;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// Make adjustments to the Ritter Sphere to include all points.
|
|
685
|
+
const oldCenterToPointSquared = Cartesian3.magnitudeSquared(
|
|
686
|
+
Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch),
|
|
687
|
+
);
|
|
688
|
+
if (oldCenterToPointSquared > radiusSquared) {
|
|
689
|
+
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
|
|
690
|
+
// Calculate new radius to include the point that lies outside
|
|
691
|
+
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
|
|
692
|
+
radiusSquared = ritterRadius * ritterRadius;
|
|
693
|
+
// Calculate center of new Ritter sphere
|
|
694
|
+
const oldToNew = oldCenterToPoint - ritterRadius;
|
|
695
|
+
ritterCenter.x =
|
|
696
|
+
(ritterRadius * ritterCenter.x + oldToNew * currentPos.x) /
|
|
697
|
+
oldCenterToPoint;
|
|
698
|
+
ritterCenter.y =
|
|
699
|
+
(ritterRadius * ritterCenter.y + oldToNew * currentPos.y) /
|
|
700
|
+
oldCenterToPoint;
|
|
701
|
+
ritterCenter.z =
|
|
702
|
+
(ritterRadius * ritterCenter.z + oldToNew * currentPos.z) /
|
|
703
|
+
oldCenterToPoint;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
548
706
|
|
|
549
|
-
|
|
550
|
-
|
|
707
|
+
if (ritterRadius < naiveRadius) {
|
|
708
|
+
Cartesian3.clone(ritterCenter, result.center);
|
|
709
|
+
result.radius = ritterRadius;
|
|
710
|
+
} else {
|
|
711
|
+
Cartesian3.clone(naiveCenter, result.center);
|
|
712
|
+
result.radius = naiveRadius;
|
|
713
|
+
}
|
|
551
714
|
|
|
552
|
-
|
|
553
|
-
* Computes a tight-fitting bounding sphere enclosing a list of EncodedCartesian3s, where the points are
|
|
554
|
-
* stored in parallel flat arrays in X, Y, Z, order. The bounding sphere is computed by running two
|
|
555
|
-
* algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to
|
|
556
|
-
* ensure a tight fit.
|
|
557
|
-
*
|
|
558
|
-
* @param {number[]} [positionsHigh] An array of high bits of the encoded cartesians that the bounding sphere will enclose. Each point
|
|
559
|
-
* is formed from three elements in the array in the order X, Y, Z.
|
|
560
|
-
* @param {number[]} [positionsLow] An array of low bits of the encoded cartesians that the bounding sphere will enclose. Each point
|
|
561
|
-
* is formed from three elements in the array in the order X, Y, Z.
|
|
562
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
563
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
564
|
-
*
|
|
565
|
-
* @see {@link http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding/|Bounding Sphere computation article}
|
|
566
|
-
*/
|
|
567
|
-
BoundingSphere.fromEncodedCartesianVertices = function (
|
|
568
|
-
positionsHigh,
|
|
569
|
-
positionsLow,
|
|
570
|
-
result,
|
|
571
|
-
) {
|
|
572
|
-
if (!defined(result)) {
|
|
573
|
-
result = new BoundingSphere();
|
|
715
|
+
return result;
|
|
574
716
|
}
|
|
575
717
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
718
|
+
/**
|
|
719
|
+
* Computes a bounding sphere from the corner points of an axis-aligned bounding box. The sphere
|
|
720
|
+
* tightly and fully encompasses the box.
|
|
721
|
+
*
|
|
722
|
+
* @param {Cartesian3} [corner] The minimum height over the rectangle.
|
|
723
|
+
* @param {Cartesian3} [oppositeCorner] The maximum height over the rectangle.
|
|
724
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
725
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* // Create a bounding sphere around the unit cube
|
|
729
|
+
* const sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5));
|
|
730
|
+
*/
|
|
731
|
+
static fromCornerPoints(corner, oppositeCorner, result) {
|
|
732
|
+
//>>includeStart('debug', pragmas.debug);
|
|
733
|
+
Check.typeOf.object("corner", corner);
|
|
734
|
+
Check.typeOf.object("oppositeCorner", oppositeCorner);
|
|
735
|
+
//>>includeEnd('debug');
|
|
736
|
+
|
|
737
|
+
if (!defined(result)) {
|
|
738
|
+
result = new BoundingSphere();
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
const center = Cartesian3.midpoint(corner, oppositeCorner, result.center);
|
|
742
|
+
result.radius = Cartesian3.distance(center, oppositeCorner);
|
|
584
743
|
return result;
|
|
585
744
|
}
|
|
586
745
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
const y = positionsHigh[i + 1] + positionsLow[i + 1];
|
|
605
|
-
const z = positionsHigh[i + 2] + positionsLow[i + 2];
|
|
606
|
-
|
|
607
|
-
currentPos.x = x;
|
|
608
|
-
currentPos.y = y;
|
|
609
|
-
currentPos.z = z;
|
|
610
|
-
|
|
611
|
-
// Store points containing the the smallest and largest components
|
|
612
|
-
if (x < xMin.x) {
|
|
613
|
-
Cartesian3.clone(currentPos, xMin);
|
|
746
|
+
/**
|
|
747
|
+
* Creates a bounding sphere encompassing an ellipsoid.
|
|
748
|
+
*
|
|
749
|
+
* @param {Ellipsoid} ellipsoid The ellipsoid around which to create a bounding sphere.
|
|
750
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
751
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* const boundingSphere = Cesium.BoundingSphere.fromEllipsoid(ellipsoid);
|
|
755
|
+
*/
|
|
756
|
+
static fromEllipsoid(ellipsoid, result) {
|
|
757
|
+
//>>includeStart('debug', pragmas.debug);
|
|
758
|
+
Check.typeOf.object("ellipsoid", ellipsoid);
|
|
759
|
+
//>>includeEnd('debug');
|
|
760
|
+
|
|
761
|
+
if (!defined(result)) {
|
|
762
|
+
result = new BoundingSphere();
|
|
614
763
|
}
|
|
615
764
|
|
|
616
|
-
|
|
617
|
-
|
|
765
|
+
Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
766
|
+
result.radius = ellipsoid.maximumRadius;
|
|
767
|
+
return result;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Computes a tight-fitting bounding sphere enclosing the provided array of bounding spheres.
|
|
772
|
+
*
|
|
773
|
+
* @param {BoundingSphere[]} [boundingSpheres] The array of bounding spheres.
|
|
774
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
775
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
776
|
+
*/
|
|
777
|
+
static fromBoundingSpheres(boundingSpheres, result) {
|
|
778
|
+
if (!defined(result)) {
|
|
779
|
+
result = new BoundingSphere();
|
|
618
780
|
}
|
|
619
781
|
|
|
620
|
-
if (
|
|
621
|
-
Cartesian3.clone(
|
|
782
|
+
if (!defined(boundingSpheres) || boundingSpheres.length === 0) {
|
|
783
|
+
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
784
|
+
result.radius = 0.0;
|
|
785
|
+
return result;
|
|
622
786
|
}
|
|
623
787
|
|
|
624
|
-
|
|
625
|
-
|
|
788
|
+
const length = boundingSpheres.length;
|
|
789
|
+
if (length === 1) {
|
|
790
|
+
return BoundingSphere.clone(boundingSpheres[0], result);
|
|
626
791
|
}
|
|
627
792
|
|
|
628
|
-
if (
|
|
629
|
-
|
|
793
|
+
if (length === 2) {
|
|
794
|
+
return BoundingSphere.union(
|
|
795
|
+
boundingSpheres[0],
|
|
796
|
+
boundingSpheres[1],
|
|
797
|
+
result,
|
|
798
|
+
);
|
|
630
799
|
}
|
|
631
800
|
|
|
632
|
-
|
|
633
|
-
|
|
801
|
+
const positions = [];
|
|
802
|
+
let i;
|
|
803
|
+
for (i = 0; i < length; i++) {
|
|
804
|
+
positions.push(boundingSpheres[i].center);
|
|
634
805
|
}
|
|
635
|
-
}
|
|
636
806
|
|
|
637
|
-
|
|
638
|
-
const xSpan = Cartesian3.magnitudeSquared(
|
|
639
|
-
Cartesian3.subtract(xMax, xMin, fromPointsScratch),
|
|
640
|
-
);
|
|
641
|
-
const ySpan = Cartesian3.magnitudeSquared(
|
|
642
|
-
Cartesian3.subtract(yMax, yMin, fromPointsScratch),
|
|
643
|
-
);
|
|
644
|
-
const zSpan = Cartesian3.magnitudeSquared(
|
|
645
|
-
Cartesian3.subtract(zMax, zMin, fromPointsScratch),
|
|
646
|
-
);
|
|
647
|
-
|
|
648
|
-
// Set the diameter endpoints to the largest span.
|
|
649
|
-
let diameter1 = xMin;
|
|
650
|
-
let diameter2 = xMax;
|
|
651
|
-
let maxSpan = xSpan;
|
|
652
|
-
if (ySpan > maxSpan) {
|
|
653
|
-
maxSpan = ySpan;
|
|
654
|
-
diameter1 = yMin;
|
|
655
|
-
diameter2 = yMax;
|
|
656
|
-
}
|
|
657
|
-
if (zSpan > maxSpan) {
|
|
658
|
-
maxSpan = zSpan;
|
|
659
|
-
diameter1 = zMin;
|
|
660
|
-
diameter2 = zMax;
|
|
661
|
-
}
|
|
807
|
+
result = BoundingSphere.fromPoints(positions, result);
|
|
662
808
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
Cartesian3.subtract(diameter2, ritterCenter, fromPointsScratch),
|
|
672
|
-
);
|
|
673
|
-
let ritterRadius = Math.sqrt(radiusSquared);
|
|
674
|
-
|
|
675
|
-
// Find the center of the sphere found using the Naive method.
|
|
676
|
-
const minBoxPt = fromPointsMinBoxPt;
|
|
677
|
-
minBoxPt.x = xMin.x;
|
|
678
|
-
minBoxPt.y = yMin.y;
|
|
679
|
-
minBoxPt.z = zMin.z;
|
|
680
|
-
|
|
681
|
-
const maxBoxPt = fromPointsMaxBoxPt;
|
|
682
|
-
maxBoxPt.x = xMax.x;
|
|
683
|
-
maxBoxPt.y = yMax.y;
|
|
684
|
-
maxBoxPt.z = zMax.z;
|
|
685
|
-
|
|
686
|
-
const naiveCenter = Cartesian3.midpoint(
|
|
687
|
-
minBoxPt,
|
|
688
|
-
maxBoxPt,
|
|
689
|
-
fromPointsNaiveCenterScratch,
|
|
690
|
-
);
|
|
691
|
-
|
|
692
|
-
// Begin 2nd pass to find naive radius and modify the ritter sphere.
|
|
693
|
-
let naiveRadius = 0;
|
|
694
|
-
for (i = 0; i < numElements; i += 3) {
|
|
695
|
-
currentPos.x = positionsHigh[i] + positionsLow[i];
|
|
696
|
-
currentPos.y = positionsHigh[i + 1] + positionsLow[i + 1];
|
|
697
|
-
currentPos.z = positionsHigh[i + 2] + positionsLow[i + 2];
|
|
698
|
-
|
|
699
|
-
// Find the furthest point from the naive center to calculate the naive radius.
|
|
700
|
-
const r = Cartesian3.magnitude(
|
|
701
|
-
Cartesian3.subtract(currentPos, naiveCenter, fromPointsScratch),
|
|
702
|
-
);
|
|
703
|
-
if (r > naiveRadius) {
|
|
704
|
-
naiveRadius = r;
|
|
809
|
+
const center = result.center;
|
|
810
|
+
let radius = result.radius;
|
|
811
|
+
for (i = 0; i < length; i++) {
|
|
812
|
+
const tmp = boundingSpheres[i];
|
|
813
|
+
radius = Math.max(
|
|
814
|
+
radius,
|
|
815
|
+
Cartesian3.distance(center, tmp.center) + tmp.radius,
|
|
816
|
+
);
|
|
705
817
|
}
|
|
818
|
+
result.radius = radius;
|
|
706
819
|
|
|
707
|
-
|
|
708
|
-
const oldCenterToPointSquared = Cartesian3.magnitudeSquared(
|
|
709
|
-
Cartesian3.subtract(currentPos, ritterCenter, fromPointsScratch),
|
|
710
|
-
);
|
|
711
|
-
if (oldCenterToPointSquared > radiusSquared) {
|
|
712
|
-
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
|
|
713
|
-
// Calculate new radius to include the point that lies outside
|
|
714
|
-
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
|
|
715
|
-
radiusSquared = ritterRadius * ritterRadius;
|
|
716
|
-
// Calculate center of new Ritter sphere
|
|
717
|
-
const oldToNew = oldCenterToPoint - ritterRadius;
|
|
718
|
-
ritterCenter.x =
|
|
719
|
-
(ritterRadius * ritterCenter.x + oldToNew * currentPos.x) /
|
|
720
|
-
oldCenterToPoint;
|
|
721
|
-
ritterCenter.y =
|
|
722
|
-
(ritterRadius * ritterCenter.y + oldToNew * currentPos.y) /
|
|
723
|
-
oldCenterToPoint;
|
|
724
|
-
ritterCenter.z =
|
|
725
|
-
(ritterRadius * ritterCenter.z + oldToNew * currentPos.z) /
|
|
726
|
-
oldCenterToPoint;
|
|
727
|
-
}
|
|
820
|
+
return result;
|
|
728
821
|
}
|
|
729
822
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
823
|
+
/**
|
|
824
|
+
* Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box.
|
|
825
|
+
*
|
|
826
|
+
* @param {OrientedBoundingBox} orientedBoundingBox The oriented bounding box.
|
|
827
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
828
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
829
|
+
*/
|
|
830
|
+
static fromOrientedBoundingBox(orientedBoundingBox, result) {
|
|
831
|
+
//>>includeStart('debug', pragmas.debug);
|
|
832
|
+
Check.defined("orientedBoundingBox", orientedBoundingBox);
|
|
833
|
+
//>>includeEnd('debug');
|
|
737
834
|
|
|
738
|
-
|
|
739
|
-
|
|
835
|
+
if (!defined(result)) {
|
|
836
|
+
result = new BoundingSphere();
|
|
837
|
+
}
|
|
740
838
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
* @param {Cartesian3} [corner] The minimum height over the rectangle.
|
|
746
|
-
* @param {Cartesian3} [oppositeCorner] The maximum height over the rectangle.
|
|
747
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
748
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
749
|
-
*
|
|
750
|
-
* @example
|
|
751
|
-
* // Create a bounding sphere around the unit cube
|
|
752
|
-
* const sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5));
|
|
753
|
-
*/
|
|
754
|
-
BoundingSphere.fromCornerPoints = function (corner, oppositeCorner, result) {
|
|
755
|
-
//>>includeStart('debug', pragmas.debug);
|
|
756
|
-
Check.typeOf.object("corner", corner);
|
|
757
|
-
Check.typeOf.object("oppositeCorner", oppositeCorner);
|
|
758
|
-
//>>includeEnd('debug');
|
|
759
|
-
|
|
760
|
-
if (!defined(result)) {
|
|
761
|
-
result = new BoundingSphere();
|
|
762
|
-
}
|
|
839
|
+
const halfAxes = orientedBoundingBox.halfAxes;
|
|
840
|
+
const u = Matrix3.getColumn(halfAxes, 0, fromOrientedBoundingBoxScratchU);
|
|
841
|
+
const v = Matrix3.getColumn(halfAxes, 1, fromOrientedBoundingBoxScratchV);
|
|
842
|
+
const w = Matrix3.getColumn(halfAxes, 2, fromOrientedBoundingBoxScratchW);
|
|
763
843
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
return result;
|
|
767
|
-
};
|
|
844
|
+
Cartesian3.add(u, v, u);
|
|
845
|
+
Cartesian3.add(u, w, u);
|
|
768
846
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
*
|
|
772
|
-
* @param {Ellipsoid} ellipsoid The ellipsoid around which to create a bounding sphere.
|
|
773
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
774
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
775
|
-
*
|
|
776
|
-
* @example
|
|
777
|
-
* const boundingSphere = Cesium.BoundingSphere.fromEllipsoid(ellipsoid);
|
|
778
|
-
*/
|
|
779
|
-
BoundingSphere.fromEllipsoid = function (ellipsoid, result) {
|
|
780
|
-
//>>includeStart('debug', pragmas.debug);
|
|
781
|
-
Check.typeOf.object("ellipsoid", ellipsoid);
|
|
782
|
-
//>>includeEnd('debug');
|
|
847
|
+
result.center = Cartesian3.clone(orientedBoundingBox.center, result.center);
|
|
848
|
+
result.radius = Cartesian3.magnitude(u);
|
|
783
849
|
|
|
784
|
-
|
|
785
|
-
result = new BoundingSphere();
|
|
850
|
+
return result;
|
|
786
851
|
}
|
|
787
852
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
853
|
+
/**
|
|
854
|
+
* Computes a tight-fitting bounding sphere enclosing the provided affine transformation.
|
|
855
|
+
*
|
|
856
|
+
* @param {Matrix4} transformation The affine transformation.
|
|
857
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
858
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
859
|
+
*/
|
|
860
|
+
static fromTransformation(transformation, result) {
|
|
861
|
+
//>>includeStart('debug', pragmas.debug);
|
|
862
|
+
Check.typeOf.object("transformation", transformation);
|
|
863
|
+
//>>includeEnd('debug');
|
|
792
864
|
|
|
793
|
-
|
|
865
|
+
if (!defined(result)) {
|
|
866
|
+
result = new BoundingSphere();
|
|
867
|
+
}
|
|
794
868
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
result =
|
|
805
|
-
|
|
869
|
+
const center = Matrix4.getTranslation(
|
|
870
|
+
transformation,
|
|
871
|
+
scratchFromTransformationCenter,
|
|
872
|
+
);
|
|
873
|
+
const scale = Matrix4.getScale(
|
|
874
|
+
transformation,
|
|
875
|
+
scratchFromTransformationScale,
|
|
876
|
+
);
|
|
877
|
+
const radius = 0.5 * Cartesian3.magnitude(scale);
|
|
878
|
+
result.center = Cartesian3.clone(center, result.center);
|
|
879
|
+
result.radius = radius;
|
|
806
880
|
|
|
807
|
-
if (!defined(boundingSpheres) || boundingSpheres.length === 0) {
|
|
808
|
-
result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);
|
|
809
|
-
result.radius = 0.0;
|
|
810
881
|
return result;
|
|
811
882
|
}
|
|
812
883
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
884
|
+
/**
|
|
885
|
+
* Duplicates a BoundingSphere instance.
|
|
886
|
+
*
|
|
887
|
+
* @param {BoundingSphere} sphere The bounding sphere to duplicate.
|
|
888
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
889
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided. (Returns undefined if sphere is undefined)
|
|
890
|
+
*/
|
|
891
|
+
static clone(sphere, result) {
|
|
892
|
+
if (!defined(sphere)) {
|
|
893
|
+
return undefined;
|
|
894
|
+
}
|
|
817
895
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
896
|
+
if (!defined(result)) {
|
|
897
|
+
return new BoundingSphere(sphere.center, sphere.radius);
|
|
898
|
+
}
|
|
821
899
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
positions.push(boundingSpheres[i].center);
|
|
900
|
+
result.center = Cartesian3.clone(sphere.center, result.center);
|
|
901
|
+
result.radius = sphere.radius;
|
|
902
|
+
return result;
|
|
826
903
|
}
|
|
827
904
|
|
|
828
|
-
|
|
905
|
+
/**
|
|
906
|
+
* Stores the provided instance into the provided array.
|
|
907
|
+
*
|
|
908
|
+
* @param {BoundingSphere} value The value to pack.
|
|
909
|
+
* @param {number[]} array The array to pack into.
|
|
910
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
911
|
+
*
|
|
912
|
+
* @returns {number[]} The array that was packed into
|
|
913
|
+
*/
|
|
914
|
+
static pack(value, array, startingIndex) {
|
|
915
|
+
//>>includeStart('debug', pragmas.debug);
|
|
916
|
+
Check.typeOf.object("value", value);
|
|
917
|
+
Check.defined("array", array);
|
|
918
|
+
//>>includeEnd('debug');
|
|
829
919
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
920
|
+
startingIndex = startingIndex ?? 0;
|
|
921
|
+
|
|
922
|
+
const center = value.center;
|
|
923
|
+
array[startingIndex++] = center.x;
|
|
924
|
+
array[startingIndex++] = center.y;
|
|
925
|
+
array[startingIndex++] = center.z;
|
|
926
|
+
array[startingIndex] = value.radius;
|
|
927
|
+
|
|
928
|
+
return array;
|
|
839
929
|
}
|
|
840
|
-
result.radius = radius;
|
|
841
930
|
|
|
842
|
-
|
|
843
|
-
|
|
931
|
+
/**
|
|
932
|
+
* Retrieves an instance from a packed array.
|
|
933
|
+
*
|
|
934
|
+
* @param {number[]} array The packed array.
|
|
935
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
936
|
+
* @param {BoundingSphere} [result] The object into which to store the result.
|
|
937
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
|
|
938
|
+
*/
|
|
939
|
+
static unpack(array, startingIndex, result) {
|
|
940
|
+
//>>includeStart('debug', pragmas.debug);
|
|
941
|
+
Check.defined("array", array);
|
|
942
|
+
//>>includeEnd('debug');
|
|
844
943
|
|
|
845
|
-
|
|
846
|
-
const fromOrientedBoundingBoxScratchV = new Cartesian3();
|
|
847
|
-
const fromOrientedBoundingBoxScratchW = new Cartesian3();
|
|
944
|
+
startingIndex = startingIndex ?? 0;
|
|
848
945
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
) {
|
|
860
|
-
//>>includeStart('debug', pragmas.debug);
|
|
861
|
-
Check.defined("orientedBoundingBox", orientedBoundingBox);
|
|
862
|
-
//>>includeEnd('debug');
|
|
863
|
-
|
|
864
|
-
if (!defined(result)) {
|
|
865
|
-
result = new BoundingSphere();
|
|
946
|
+
if (!defined(result)) {
|
|
947
|
+
result = new BoundingSphere();
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
const center = result.center;
|
|
951
|
+
center.x = array[startingIndex++];
|
|
952
|
+
center.y = array[startingIndex++];
|
|
953
|
+
center.z = array[startingIndex++];
|
|
954
|
+
result.radius = array[startingIndex];
|
|
955
|
+
return result;
|
|
866
956
|
}
|
|
867
957
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
958
|
+
/**
|
|
959
|
+
* Computes a bounding sphere that contains both the left and right bounding spheres.
|
|
960
|
+
*
|
|
961
|
+
* @param {BoundingSphere} left A sphere to enclose in a bounding sphere.
|
|
962
|
+
* @param {BoundingSphere} right A sphere to enclose in a bounding sphere.
|
|
963
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
964
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
965
|
+
*/
|
|
966
|
+
static union(left, right, result) {
|
|
967
|
+
//>>includeStart('debug', pragmas.debug);
|
|
968
|
+
Check.typeOf.object("left", left);
|
|
969
|
+
Check.typeOf.object("right", right);
|
|
970
|
+
//>>includeEnd('debug');
|
|
971
|
+
|
|
972
|
+
if (!defined(result)) {
|
|
973
|
+
result = new BoundingSphere();
|
|
974
|
+
}
|
|
872
975
|
|
|
873
|
-
|
|
874
|
-
|
|
976
|
+
const leftCenter = left.center;
|
|
977
|
+
const leftRadius = left.radius;
|
|
978
|
+
const rightCenter = right.center;
|
|
979
|
+
const rightRadius = right.radius;
|
|
875
980
|
|
|
876
|
-
|
|
877
|
-
|
|
981
|
+
const toRightCenter = Cartesian3.subtract(
|
|
982
|
+
rightCenter,
|
|
983
|
+
leftCenter,
|
|
984
|
+
unionScratch,
|
|
985
|
+
);
|
|
986
|
+
const centerSeparation = Cartesian3.magnitude(toRightCenter);
|
|
878
987
|
|
|
879
|
-
|
|
880
|
-
|
|
988
|
+
if (leftRadius >= centerSeparation + rightRadius) {
|
|
989
|
+
// Left sphere wins.
|
|
990
|
+
left.clone(result);
|
|
991
|
+
return result;
|
|
992
|
+
}
|
|
881
993
|
|
|
882
|
-
|
|
883
|
-
|
|
994
|
+
if (rightRadius >= centerSeparation + leftRadius) {
|
|
995
|
+
// Right sphere wins.
|
|
996
|
+
right.clone(result);
|
|
997
|
+
return result;
|
|
998
|
+
}
|
|
884
999
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
*
|
|
888
|
-
* @param {Matrix4} transformation The affine transformation.
|
|
889
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
890
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
891
|
-
*/
|
|
892
|
-
BoundingSphere.fromTransformation = function (transformation, result) {
|
|
893
|
-
//>>includeStart('debug', pragmas.debug);
|
|
894
|
-
Check.typeOf.object("transformation", transformation);
|
|
895
|
-
//>>includeEnd('debug');
|
|
1000
|
+
// There are two tangent points, one on far side of each sphere.
|
|
1001
|
+
const halfDistanceBetweenTangentPoints =
|
|
1002
|
+
(leftRadius + centerSeparation + rightRadius) * 0.5;
|
|
896
1003
|
|
|
897
|
-
|
|
898
|
-
|
|
1004
|
+
// Compute the center point halfway between the two tangent points.
|
|
1005
|
+
const center = Cartesian3.multiplyByScalar(
|
|
1006
|
+
toRightCenter,
|
|
1007
|
+
(-leftRadius + halfDistanceBetweenTangentPoints) / centerSeparation,
|
|
1008
|
+
unionScratchCenter,
|
|
1009
|
+
);
|
|
1010
|
+
Cartesian3.add(center, leftCenter, center);
|
|
1011
|
+
Cartesian3.clone(center, result.center);
|
|
1012
|
+
result.radius = halfDistanceBetweenTangentPoints;
|
|
1013
|
+
|
|
1014
|
+
return result;
|
|
899
1015
|
}
|
|
900
1016
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Computes a bounding sphere by enlarging the provided sphere to contain the provided point.
|
|
1019
|
+
*
|
|
1020
|
+
* @param {BoundingSphere} sphere A sphere to expand.
|
|
1021
|
+
* @param {Cartesian3} point A point to enclose in a bounding sphere.
|
|
1022
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1023
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1024
|
+
*/
|
|
1025
|
+
static expand(sphere, point, result) {
|
|
1026
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1027
|
+
Check.typeOf.object("sphere", sphere);
|
|
1028
|
+
Check.typeOf.object("point", point);
|
|
1029
|
+
//>>includeEnd('debug');
|
|
915
1030
|
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
return
|
|
1031
|
+
result = BoundingSphere.clone(sphere, result);
|
|
1032
|
+
|
|
1033
|
+
const radius = Cartesian3.magnitude(
|
|
1034
|
+
Cartesian3.subtract(point, result.center, expandScratch),
|
|
1035
|
+
);
|
|
1036
|
+
if (radius > result.radius) {
|
|
1037
|
+
result.radius = radius;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
return result;
|
|
926
1041
|
}
|
|
927
1042
|
|
|
928
|
-
|
|
929
|
-
|
|
1043
|
+
/**
|
|
1044
|
+
* Determines which side of a plane a sphere is located.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {BoundingSphere} sphere The bounding sphere to test.
|
|
1047
|
+
* @param {Plane} plane The plane to test against.
|
|
1048
|
+
* @returns {Intersect} {@link Intersect.INSIDE} if the entire sphere is on the side of the plane
|
|
1049
|
+
* the normal is pointing, {@link Intersect.OUTSIDE} if the entire sphere is
|
|
1050
|
+
* on the opposite side, and {@link Intersect.INTERSECTING} if the sphere
|
|
1051
|
+
* intersects the plane.
|
|
1052
|
+
*/
|
|
1053
|
+
static intersectPlane(sphere, plane) {
|
|
1054
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1055
|
+
Check.typeOf.object("sphere", sphere);
|
|
1056
|
+
Check.typeOf.object("plane", plane);
|
|
1057
|
+
//>>includeEnd('debug');
|
|
1058
|
+
|
|
1059
|
+
const center = sphere.center;
|
|
1060
|
+
const radius = sphere.radius;
|
|
1061
|
+
const normal = plane.normal;
|
|
1062
|
+
const distanceToPlane = Cartesian3.dot(normal, center) + plane.distance;
|
|
1063
|
+
|
|
1064
|
+
if (distanceToPlane < -radius) {
|
|
1065
|
+
// The center point is negative side of the plane normal
|
|
1066
|
+
return Intersect.OUTSIDE;
|
|
1067
|
+
} else if (distanceToPlane < radius) {
|
|
1068
|
+
// The center point is positive side of the plane, but radius extends beyond it; partial overlap
|
|
1069
|
+
return Intersect.INTERSECTING;
|
|
1070
|
+
}
|
|
1071
|
+
return Intersect.INSIDE;
|
|
930
1072
|
}
|
|
931
1073
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Applies a 4x4 affine transformation matrix to a bounding sphere.
|
|
1076
|
+
*
|
|
1077
|
+
* @param {BoundingSphere} sphere The bounding sphere to apply the transformation to.
|
|
1078
|
+
* @param {Matrix4} transform The transformation matrix to apply to the bounding sphere.
|
|
1079
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1080
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1081
|
+
*/
|
|
1082
|
+
static transform(sphere, transform, result) {
|
|
1083
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1084
|
+
Check.typeOf.object("sphere", sphere);
|
|
1085
|
+
Check.typeOf.object("transform", transform);
|
|
1086
|
+
//>>includeEnd('debug');
|
|
1087
|
+
|
|
1088
|
+
if (!defined(result)) {
|
|
1089
|
+
result = new BoundingSphere();
|
|
1090
|
+
}
|
|
936
1091
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1092
|
+
result.center = Matrix4.multiplyByPoint(
|
|
1093
|
+
transform,
|
|
1094
|
+
sphere.center,
|
|
1095
|
+
result.center,
|
|
1096
|
+
);
|
|
1097
|
+
result.radius = Matrix4.getMaximumScale(transform) * sphere.radius;
|
|
942
1098
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
*
|
|
946
|
-
* @param {BoundingSphere} value The value to pack.
|
|
947
|
-
* @param {number[]} array The array to pack into.
|
|
948
|
-
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
949
|
-
*
|
|
950
|
-
* @returns {number[]} The array that was packed into
|
|
951
|
-
*/
|
|
952
|
-
BoundingSphere.pack = function (value, array, startingIndex) {
|
|
953
|
-
//>>includeStart('debug', pragmas.debug);
|
|
954
|
-
Check.typeOf.object("value", value);
|
|
955
|
-
Check.defined("array", array);
|
|
956
|
-
//>>includeEnd('debug');
|
|
1099
|
+
return result;
|
|
1100
|
+
}
|
|
957
1101
|
|
|
958
|
-
|
|
1102
|
+
/**
|
|
1103
|
+
* Computes the estimated distance squared from the closest point on a bounding sphere to a point.
|
|
1104
|
+
*
|
|
1105
|
+
* @param {BoundingSphere} sphere The sphere.
|
|
1106
|
+
* @param {Cartesian3} cartesian The point
|
|
1107
|
+
* @returns {number} The distance squared from the bounding sphere to the point. Returns 0 if the point is inside the sphere.
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* // Sort bounding spheres from back to front
|
|
1111
|
+
* spheres.sort(function(a, b) {
|
|
1112
|
+
* return Cesium.BoundingSphere.distanceSquaredTo(b, camera.positionWC) - Cesium.BoundingSphere.distanceSquaredTo(a, camera.positionWC);
|
|
1113
|
+
* });
|
|
1114
|
+
*/
|
|
1115
|
+
static distanceSquaredTo(sphere, cartesian) {
|
|
1116
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1117
|
+
Check.typeOf.object("sphere", sphere);
|
|
1118
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
1119
|
+
//>>includeEnd('debug');
|
|
1120
|
+
|
|
1121
|
+
const diff = Cartesian3.subtract(
|
|
1122
|
+
sphere.center,
|
|
1123
|
+
cartesian,
|
|
1124
|
+
distanceSquaredToScratch,
|
|
1125
|
+
);
|
|
959
1126
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
array[startingIndex] = value.radius;
|
|
1127
|
+
const distance = Cartesian3.magnitude(diff) - sphere.radius;
|
|
1128
|
+
if (distance <= 0.0) {
|
|
1129
|
+
return 0.0;
|
|
1130
|
+
}
|
|
965
1131
|
|
|
966
|
-
|
|
967
|
-
}
|
|
1132
|
+
return distance * distance;
|
|
1133
|
+
}
|
|
968
1134
|
|
|
969
|
-
/**
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1135
|
+
/**
|
|
1136
|
+
* Applies a 4x4 affine transformation matrix to a bounding sphere where there is no scale
|
|
1137
|
+
* The transformation matrix is not verified to have a uniform scale of 1.
|
|
1138
|
+
* This method is faster than computing the general bounding sphere transform using {@link BoundingSphere.transform}.
|
|
1139
|
+
*
|
|
1140
|
+
* @param {BoundingSphere} sphere The bounding sphere to apply the transformation to.
|
|
1141
|
+
* @param {Matrix4} transform The transformation matrix to apply to the bounding sphere.
|
|
1142
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1143
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid);
|
|
1147
|
+
* const boundingSphere = new Cesium.BoundingSphere();
|
|
1148
|
+
* const newBoundingSphere = Cesium.BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix);
|
|
1149
|
+
*/
|
|
1150
|
+
static transformWithoutScale(sphere, transform, result) {
|
|
1151
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1152
|
+
Check.typeOf.object("sphere", sphere);
|
|
1153
|
+
Check.typeOf.object("transform", transform);
|
|
1154
|
+
//>>includeEnd('debug');
|
|
1155
|
+
|
|
1156
|
+
if (!defined(result)) {
|
|
1157
|
+
result = new BoundingSphere();
|
|
1158
|
+
}
|
|
981
1159
|
|
|
982
|
-
|
|
1160
|
+
result.center = Matrix4.multiplyByPoint(
|
|
1161
|
+
transform,
|
|
1162
|
+
sphere.center,
|
|
1163
|
+
result.center,
|
|
1164
|
+
);
|
|
1165
|
+
result.radius = sphere.radius;
|
|
983
1166
|
|
|
984
|
-
|
|
985
|
-
result = new BoundingSphere();
|
|
1167
|
+
return result;
|
|
986
1168
|
}
|
|
987
1169
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1170
|
+
/**
|
|
1171
|
+
* The distances calculated by the vector from the center of the bounding sphere to position projected onto direction
|
|
1172
|
+
* plus/minus the radius of the bounding sphere.
|
|
1173
|
+
* <br>
|
|
1174
|
+
* If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the
|
|
1175
|
+
* closest and farthest planes from position that intersect the bounding sphere.
|
|
1176
|
+
*
|
|
1177
|
+
* @param {BoundingSphere} sphere The bounding sphere to calculate the distance to.
|
|
1178
|
+
* @param {Cartesian3} position The position to calculate the distance from.
|
|
1179
|
+
* @param {Cartesian3} direction The direction from position.
|
|
1180
|
+
* @param {Interval} [result] A Interval to store the nearest and farthest distances.
|
|
1181
|
+
* @returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction.
|
|
1182
|
+
*/
|
|
1183
|
+
static computePlaneDistances(sphere, position, direction, result) {
|
|
1184
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1185
|
+
Check.typeOf.object("sphere", sphere);
|
|
1186
|
+
Check.typeOf.object("position", position);
|
|
1187
|
+
Check.typeOf.object("direction", direction);
|
|
1188
|
+
//>>includeEnd('debug');
|
|
1189
|
+
|
|
1190
|
+
if (!defined(result)) {
|
|
1191
|
+
result = new Interval();
|
|
1192
|
+
}
|
|
995
1193
|
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
* @param {BoundingSphere} right A sphere to enclose in a bounding sphere.
|
|
1003
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1004
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1005
|
-
*/
|
|
1006
|
-
BoundingSphere.union = function (left, right, result) {
|
|
1007
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1008
|
-
Check.typeOf.object("left", left);
|
|
1009
|
-
Check.typeOf.object("right", right);
|
|
1010
|
-
//>>includeEnd('debug');
|
|
1011
|
-
|
|
1012
|
-
if (!defined(result)) {
|
|
1013
|
-
result = new BoundingSphere();
|
|
1014
|
-
}
|
|
1194
|
+
const toCenter = Cartesian3.subtract(
|
|
1195
|
+
sphere.center,
|
|
1196
|
+
position,
|
|
1197
|
+
scratchCartesian3,
|
|
1198
|
+
);
|
|
1199
|
+
const mag = Cartesian3.dot(direction, toCenter);
|
|
1015
1200
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
const rightCenter = right.center;
|
|
1019
|
-
const rightRadius = right.radius;
|
|
1020
|
-
|
|
1021
|
-
const toRightCenter = Cartesian3.subtract(
|
|
1022
|
-
rightCenter,
|
|
1023
|
-
leftCenter,
|
|
1024
|
-
unionScratch,
|
|
1025
|
-
);
|
|
1026
|
-
const centerSeparation = Cartesian3.magnitude(toRightCenter);
|
|
1027
|
-
|
|
1028
|
-
if (leftRadius >= centerSeparation + rightRadius) {
|
|
1029
|
-
// Left sphere wins.
|
|
1030
|
-
left.clone(result);
|
|
1201
|
+
result.start = mag - sphere.radius;
|
|
1202
|
+
result.stop = mag + sphere.radius;
|
|
1031
1203
|
return result;
|
|
1032
1204
|
}
|
|
1033
1205
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1206
|
+
/**
|
|
1207
|
+
* Creates a bounding sphere in 2D from a bounding sphere in 3D world coordinates.
|
|
1208
|
+
*
|
|
1209
|
+
* @param {BoundingSphere} sphere The bounding sphere to transform to 2D.
|
|
1210
|
+
* @param {MapProjection} [projection=GeographicProjection] The projection to 2D.
|
|
1211
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1212
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1213
|
+
*/
|
|
1214
|
+
static projectTo2D(sphere, projection, result) {
|
|
1215
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1216
|
+
Check.typeOf.object("sphere", sphere);
|
|
1217
|
+
//>>includeEnd('debug');
|
|
1218
|
+
|
|
1219
|
+
projectTo2DProjection._ellipsoid = Ellipsoid.default;
|
|
1220
|
+
projection = projection ?? projectTo2DProjection;
|
|
1221
|
+
|
|
1222
|
+
const ellipsoid = projection.ellipsoid;
|
|
1223
|
+
let center = sphere.center;
|
|
1224
|
+
const radius = sphere.radius;
|
|
1225
|
+
|
|
1226
|
+
let normal;
|
|
1227
|
+
if (Cartesian3.equals(center, Cartesian3.ZERO)) {
|
|
1228
|
+
// Bounding sphere is at the center. The geodetic surface normal is not
|
|
1229
|
+
// defined here so pick the x-axis as a fallback.
|
|
1230
|
+
normal = Cartesian3.clone(Cartesian3.UNIT_X, projectTo2DNormalScratch);
|
|
1231
|
+
} else {
|
|
1232
|
+
normal = ellipsoid.geodeticSurfaceNormal(
|
|
1233
|
+
center,
|
|
1234
|
+
projectTo2DNormalScratch,
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
const east = Cartesian3.cross(
|
|
1238
|
+
Cartesian3.UNIT_Z,
|
|
1239
|
+
normal,
|
|
1240
|
+
projectTo2DEastScratch,
|
|
1241
|
+
);
|
|
1242
|
+
Cartesian3.normalize(east, east);
|
|
1243
|
+
const north = Cartesian3.cross(normal, east, projectTo2DNorthScratch);
|
|
1244
|
+
Cartesian3.normalize(north, north);
|
|
1245
|
+
|
|
1246
|
+
Cartesian3.multiplyByScalar(normal, radius, normal);
|
|
1247
|
+
Cartesian3.multiplyByScalar(north, radius, north);
|
|
1248
|
+
Cartesian3.multiplyByScalar(east, radius, east);
|
|
1249
|
+
|
|
1250
|
+
const south = Cartesian3.negate(north, projectTo2DSouthScratch);
|
|
1251
|
+
const west = Cartesian3.negate(east, projectTo2DWestScratch);
|
|
1252
|
+
|
|
1253
|
+
const positions = projectTo2DPositionsScratch;
|
|
1254
|
+
|
|
1255
|
+
// top NE corner
|
|
1256
|
+
let corner = positions[0];
|
|
1257
|
+
Cartesian3.add(normal, north, corner);
|
|
1258
|
+
Cartesian3.add(corner, east, corner);
|
|
1259
|
+
|
|
1260
|
+
// top NW corner
|
|
1261
|
+
corner = positions[1];
|
|
1262
|
+
Cartesian3.add(normal, north, corner);
|
|
1263
|
+
Cartesian3.add(corner, west, corner);
|
|
1264
|
+
|
|
1265
|
+
// top SW corner
|
|
1266
|
+
corner = positions[2];
|
|
1267
|
+
Cartesian3.add(normal, south, corner);
|
|
1268
|
+
Cartesian3.add(corner, west, corner);
|
|
1269
|
+
|
|
1270
|
+
// top SE corner
|
|
1271
|
+
corner = positions[3];
|
|
1272
|
+
Cartesian3.add(normal, south, corner);
|
|
1273
|
+
Cartesian3.add(corner, east, corner);
|
|
1274
|
+
|
|
1275
|
+
Cartesian3.negate(normal, normal);
|
|
1276
|
+
|
|
1277
|
+
// bottom NE corner
|
|
1278
|
+
corner = positions[4];
|
|
1279
|
+
Cartesian3.add(normal, north, corner);
|
|
1280
|
+
Cartesian3.add(corner, east, corner);
|
|
1281
|
+
|
|
1282
|
+
// bottom NW corner
|
|
1283
|
+
corner = positions[5];
|
|
1284
|
+
Cartesian3.add(normal, north, corner);
|
|
1285
|
+
Cartesian3.add(corner, west, corner);
|
|
1286
|
+
|
|
1287
|
+
// bottom SW corner
|
|
1288
|
+
corner = positions[6];
|
|
1289
|
+
Cartesian3.add(normal, south, corner);
|
|
1290
|
+
Cartesian3.add(corner, west, corner);
|
|
1291
|
+
|
|
1292
|
+
// bottom SE corner
|
|
1293
|
+
corner = positions[7];
|
|
1294
|
+
Cartesian3.add(normal, south, corner);
|
|
1295
|
+
Cartesian3.add(corner, east, corner);
|
|
1296
|
+
|
|
1297
|
+
const length = positions.length;
|
|
1298
|
+
for (let i = 0; i < length; ++i) {
|
|
1299
|
+
const position = positions[i];
|
|
1300
|
+
Cartesian3.add(center, position, position);
|
|
1301
|
+
const cartographic = ellipsoid.cartesianToCartographic(
|
|
1302
|
+
position,
|
|
1303
|
+
projectTo2DCartographicScratch,
|
|
1304
|
+
);
|
|
1305
|
+
projection.project(cartographic, position);
|
|
1306
|
+
}
|
|
1039
1307
|
|
|
1040
|
-
|
|
1041
|
-
const halfDistanceBetweenTangentPoints =
|
|
1042
|
-
(leftRadius + centerSeparation + rightRadius) * 0.5;
|
|
1308
|
+
result = BoundingSphere.fromPoints(positions, result);
|
|
1043
1309
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
result.radius = halfDistanceBetweenTangentPoints;
|
|
1310
|
+
// swizzle center components
|
|
1311
|
+
center = result.center;
|
|
1312
|
+
const x = center.x;
|
|
1313
|
+
const y = center.y;
|
|
1314
|
+
const z = center.z;
|
|
1315
|
+
center.x = z;
|
|
1316
|
+
center.y = x;
|
|
1317
|
+
center.z = y;
|
|
1053
1318
|
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1319
|
+
return result;
|
|
1320
|
+
}
|
|
1056
1321
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
//>>includeEnd('debug');
|
|
1071
|
-
|
|
1072
|
-
result = BoundingSphere.clone(sphere, result);
|
|
1073
|
-
|
|
1074
|
-
const radius = Cartesian3.magnitude(
|
|
1075
|
-
Cartesian3.subtract(point, result.center, expandScratch),
|
|
1076
|
-
);
|
|
1077
|
-
if (radius > result.radius) {
|
|
1078
|
-
result.radius = radius;
|
|
1322
|
+
/**
|
|
1323
|
+
* Determines whether or not a sphere is hidden from view by the occluder.
|
|
1324
|
+
*
|
|
1325
|
+
* @param {BoundingSphere} sphere The bounding sphere surrounding the occluded object.
|
|
1326
|
+
* @param {Occluder} occluder The occluder.
|
|
1327
|
+
* @returns {boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
|
|
1328
|
+
*/
|
|
1329
|
+
static isOccluded(sphere, occluder) {
|
|
1330
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1331
|
+
Check.typeOf.object("sphere", sphere);
|
|
1332
|
+
Check.typeOf.object("occluder", occluder);
|
|
1333
|
+
//>>includeEnd('debug');
|
|
1334
|
+
return !occluder.isBoundingSphereVisible(sphere);
|
|
1079
1335
|
}
|
|
1080
1336
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1337
|
+
/**
|
|
1338
|
+
* Compares the provided BoundingSphere componentwise and returns
|
|
1339
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1340
|
+
*
|
|
1341
|
+
* @param {BoundingSphere} [left] The first BoundingSphere.
|
|
1342
|
+
* @param {BoundingSphere} [right] The second BoundingSphere.
|
|
1343
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
1344
|
+
*/
|
|
1345
|
+
static equals(left, right) {
|
|
1346
|
+
return (
|
|
1347
|
+
left === right ||
|
|
1348
|
+
(defined(left) &&
|
|
1349
|
+
defined(right) &&
|
|
1350
|
+
Cartesian3.equals(left.center, right.center) &&
|
|
1351
|
+
left.radius === right.radius)
|
|
1352
|
+
);
|
|
1353
|
+
}
|
|
1083
1354
|
|
|
1084
|
-
/**
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
BoundingSphere.intersectPlane
|
|
1095
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1096
|
-
Check.typeOf.object("sphere", sphere);
|
|
1097
|
-
Check.typeOf.object("plane", plane);
|
|
1098
|
-
//>>includeEnd('debug');
|
|
1099
|
-
|
|
1100
|
-
const center = sphere.center;
|
|
1101
|
-
const radius = sphere.radius;
|
|
1102
|
-
const normal = plane.normal;
|
|
1103
|
-
const distanceToPlane = Cartesian3.dot(normal, center) + plane.distance;
|
|
1104
|
-
|
|
1105
|
-
if (distanceToPlane < -radius) {
|
|
1106
|
-
// The center point is negative side of the plane normal
|
|
1107
|
-
return Intersect.OUTSIDE;
|
|
1108
|
-
} else if (distanceToPlane < radius) {
|
|
1109
|
-
// The center point is positive side of the plane, but radius extends beyond it; partial overlap
|
|
1110
|
-
return Intersect.INTERSECTING;
|
|
1355
|
+
/**
|
|
1356
|
+
* Determines which side of a plane the sphere is located.
|
|
1357
|
+
*
|
|
1358
|
+
* @param {Plane} plane The plane to test against.
|
|
1359
|
+
* @returns {Intersect} {@link Intersect.INSIDE} if the entire sphere is on the side of the plane
|
|
1360
|
+
* the normal is pointing, {@link Intersect.OUTSIDE} if the entire sphere is
|
|
1361
|
+
* on the opposite side, and {@link Intersect.INTERSECTING} if the sphere
|
|
1362
|
+
* intersects the plane.
|
|
1363
|
+
*/
|
|
1364
|
+
intersectPlane(plane) {
|
|
1365
|
+
return BoundingSphere.intersectPlane(this, plane);
|
|
1111
1366
|
}
|
|
1112
|
-
return Intersect.INSIDE;
|
|
1113
|
-
};
|
|
1114
1367
|
|
|
1115
|
-
/**
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
if (!defined(result)) {
|
|
1130
|
-
result = new BoundingSphere();
|
|
1368
|
+
/**
|
|
1369
|
+
* Computes the estimated distance squared from the closest point on a bounding sphere to a point.
|
|
1370
|
+
*
|
|
1371
|
+
* @param {Cartesian3} cartesian The point
|
|
1372
|
+
* @returns {number} The estimated distance squared from the bounding sphere to the point.
|
|
1373
|
+
*
|
|
1374
|
+
* @example
|
|
1375
|
+
* // Sort bounding spheres from back to front
|
|
1376
|
+
* spheres.sort(function(a, b) {
|
|
1377
|
+
* return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
|
|
1378
|
+
* });
|
|
1379
|
+
*/
|
|
1380
|
+
distanceSquaredTo(cartesian) {
|
|
1381
|
+
return BoundingSphere.distanceSquaredTo(this, cartesian);
|
|
1131
1382
|
}
|
|
1132
1383
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1384
|
+
/**
|
|
1385
|
+
* The distances calculated by the vector from the center of the bounding sphere to position projected onto direction
|
|
1386
|
+
* plus/minus the radius of the bounding sphere.
|
|
1387
|
+
* <br>
|
|
1388
|
+
* If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the
|
|
1389
|
+
* closest and farthest planes from position that intersect the bounding sphere.
|
|
1390
|
+
*
|
|
1391
|
+
* @param {Cartesian3} position The position to calculate the distance from.
|
|
1392
|
+
* @param {Cartesian3} direction The direction from position.
|
|
1393
|
+
* @param {Interval} [result] A Interval to store the nearest and farthest distances.
|
|
1394
|
+
* @returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction.
|
|
1395
|
+
*/
|
|
1396
|
+
computePlaneDistances(position, direction, result) {
|
|
1397
|
+
return BoundingSphere.computePlaneDistances(
|
|
1398
|
+
this,
|
|
1399
|
+
position,
|
|
1400
|
+
direction,
|
|
1401
|
+
result,
|
|
1402
|
+
);
|
|
1403
|
+
}
|
|
1139
1404
|
|
|
1140
|
-
|
|
1141
|
-
|
|
1405
|
+
/**
|
|
1406
|
+
* Determines whether or not a sphere is hidden from view by the occluder.
|
|
1407
|
+
*
|
|
1408
|
+
* @param {Occluder} occluder The occluder.
|
|
1409
|
+
* @returns {boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
|
|
1410
|
+
*/
|
|
1411
|
+
isOccluded(occluder) {
|
|
1412
|
+
return BoundingSphere.isOccluded(this, occluder);
|
|
1413
|
+
}
|
|
1142
1414
|
|
|
1143
|
-
|
|
1415
|
+
/**
|
|
1416
|
+
* Compares this BoundingSphere against the provided BoundingSphere componentwise and returns
|
|
1417
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {BoundingSphere} [right] The right hand side BoundingSphere.
|
|
1420
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1421
|
+
*/
|
|
1422
|
+
equals(right) {
|
|
1423
|
+
return BoundingSphere.equals(this, right);
|
|
1424
|
+
}
|
|
1144
1425
|
|
|
1145
|
-
/**
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
* // Sort bounding spheres from back to front
|
|
1154
|
-
* spheres.sort(function(a, b) {
|
|
1155
|
-
* return Cesium.BoundingSphere.distanceSquaredTo(b, camera.positionWC) - Cesium.BoundingSphere.distanceSquaredTo(a, camera.positionWC);
|
|
1156
|
-
* });
|
|
1157
|
-
*/
|
|
1158
|
-
BoundingSphere.distanceSquaredTo = function (sphere, cartesian) {
|
|
1159
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1160
|
-
Check.typeOf.object("sphere", sphere);
|
|
1161
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
1162
|
-
//>>includeEnd('debug');
|
|
1163
|
-
|
|
1164
|
-
const diff = Cartesian3.subtract(
|
|
1165
|
-
sphere.center,
|
|
1166
|
-
cartesian,
|
|
1167
|
-
distanceSquaredToScratch,
|
|
1168
|
-
);
|
|
1169
|
-
|
|
1170
|
-
const distance = Cartesian3.magnitude(diff) - sphere.radius;
|
|
1171
|
-
if (distance <= 0.0) {
|
|
1172
|
-
return 0.0;
|
|
1426
|
+
/**
|
|
1427
|
+
* Duplicates this BoundingSphere instance.
|
|
1428
|
+
*
|
|
1429
|
+
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1430
|
+
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1431
|
+
*/
|
|
1432
|
+
clone(result) {
|
|
1433
|
+
return BoundingSphere.clone(this, result);
|
|
1173
1434
|
}
|
|
1174
1435
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1436
|
+
/**
|
|
1437
|
+
* Computes the radius of the BoundingSphere.
|
|
1438
|
+
* @returns {number} The radius of the BoundingSphere.
|
|
1439
|
+
*/
|
|
1440
|
+
volume() {
|
|
1441
|
+
const radius = this.radius;
|
|
1442
|
+
return volumeConstant * radius * radius * radius;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1177
1445
|
|
|
1178
1446
|
/**
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
* This method is faster than computing the general bounding sphere transform using {@link BoundingSphere.transform}.
|
|
1182
|
-
*
|
|
1183
|
-
* @param {BoundingSphere} sphere The bounding sphere to apply the transformation to.
|
|
1184
|
-
* @param {Matrix4} transform The transformation matrix to apply to the bounding sphere.
|
|
1185
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1186
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1187
|
-
*
|
|
1188
|
-
* @example
|
|
1189
|
-
* const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid);
|
|
1190
|
-
* const boundingSphere = new Cesium.BoundingSphere();
|
|
1191
|
-
* const newBoundingSphere = Cesium.BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix);
|
|
1447
|
+
* The number of elements used to pack the object into an array.
|
|
1448
|
+
* @type {number}
|
|
1192
1449
|
*/
|
|
1193
|
-
BoundingSphere.
|
|
1194
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1195
|
-
Check.typeOf.object("sphere", sphere);
|
|
1196
|
-
Check.typeOf.object("transform", transform);
|
|
1197
|
-
//>>includeEnd('debug');
|
|
1198
|
-
|
|
1199
|
-
if (!defined(result)) {
|
|
1200
|
-
result = new BoundingSphere();
|
|
1201
|
-
}
|
|
1450
|
+
BoundingSphere.packedLength = 4;
|
|
1202
1451
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1452
|
+
const fromPointsXMin = new Cartesian3();
|
|
1453
|
+
const fromPointsYMin = new Cartesian3();
|
|
1454
|
+
const fromPointsZMin = new Cartesian3();
|
|
1455
|
+
const fromPointsXMax = new Cartesian3();
|
|
1456
|
+
const fromPointsYMax = new Cartesian3();
|
|
1457
|
+
const fromPointsZMax = new Cartesian3();
|
|
1458
|
+
const fromPointsCurrentPos = new Cartesian3();
|
|
1459
|
+
const fromPointsScratch = new Cartesian3();
|
|
1460
|
+
const fromPointsRitterCenter = new Cartesian3();
|
|
1461
|
+
const fromPointsMinBoxPt = new Cartesian3();
|
|
1462
|
+
const fromPointsMaxBoxPt = new Cartesian3();
|
|
1463
|
+
const fromPointsNaiveCenterScratch = new Cartesian3();
|
|
1464
|
+
const volumeConstant = (4.0 / 3.0) * CesiumMath.PI;
|
|
1209
1465
|
|
|
1210
|
-
|
|
1211
|
-
|
|
1466
|
+
const defaultProjection = new GeographicProjection();
|
|
1467
|
+
const fromRectangle2DLowerLeft = new Cartesian3();
|
|
1468
|
+
const fromRectangle2DUpperRight = new Cartesian3();
|
|
1469
|
+
const fromRectangle2DSouthwest = new Cartographic();
|
|
1470
|
+
const fromRectangle2DNortheast = new Cartographic();
|
|
1212
1471
|
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
* @param {Interval} [result] A Interval to store the nearest and farthest distances.
|
|
1225
|
-
* @returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction.
|
|
1226
|
-
*/
|
|
1227
|
-
BoundingSphere.computePlaneDistances = function (
|
|
1228
|
-
sphere,
|
|
1229
|
-
position,
|
|
1230
|
-
direction,
|
|
1231
|
-
result,
|
|
1232
|
-
) {
|
|
1233
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1234
|
-
Check.typeOf.object("sphere", sphere);
|
|
1235
|
-
Check.typeOf.object("position", position);
|
|
1236
|
-
Check.typeOf.object("direction", direction);
|
|
1237
|
-
//>>includeEnd('debug');
|
|
1238
|
-
|
|
1239
|
-
if (!defined(result)) {
|
|
1240
|
-
result = new Interval();
|
|
1241
|
-
}
|
|
1472
|
+
const fromRectangle3DScratch = /** @type {Cartesian3[]} */ ([]);
|
|
1473
|
+
|
|
1474
|
+
const fromOrientedBoundingBoxScratchU = new Cartesian3();
|
|
1475
|
+
const fromOrientedBoundingBoxScratchV = new Cartesian3();
|
|
1476
|
+
const fromOrientedBoundingBoxScratchW = new Cartesian3();
|
|
1477
|
+
|
|
1478
|
+
const scratchFromTransformationCenter = new Cartesian3();
|
|
1479
|
+
const scratchFromTransformationScale = new Cartesian3();
|
|
1480
|
+
|
|
1481
|
+
const unionScratch = new Cartesian3();
|
|
1482
|
+
const unionScratchCenter = new Cartesian3();
|
|
1242
1483
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
scratchCartesian3,
|
|
1247
|
-
);
|
|
1248
|
-
const mag = Cartesian3.dot(direction, toCenter);
|
|
1484
|
+
const expandScratch = new Cartesian3();
|
|
1485
|
+
|
|
1486
|
+
const distanceSquaredToScratch = new Cartesian3();
|
|
1249
1487
|
|
|
1250
|
-
|
|
1251
|
-
result.stop = mag + sphere.radius;
|
|
1252
|
-
return result;
|
|
1253
|
-
};
|
|
1488
|
+
const scratchCartesian3 = new Cartesian3();
|
|
1254
1489
|
|
|
1255
1490
|
const projectTo2DNormalScratch = new Cartesian3();
|
|
1256
1491
|
const projectTo2DEastScratch = new Cartesian3();
|
|
@@ -1264,243 +1499,4 @@ for (let n = 0; n < 8; ++n) {
|
|
|
1264
1499
|
}
|
|
1265
1500
|
|
|
1266
1501
|
const projectTo2DProjection = new GeographicProjection();
|
|
1267
|
-
/**
|
|
1268
|
-
* Creates a bounding sphere in 2D from a bounding sphere in 3D world coordinates.
|
|
1269
|
-
*
|
|
1270
|
-
* @param {BoundingSphere} sphere The bounding sphere to transform to 2D.
|
|
1271
|
-
* @param {object} [projection=GeographicProjection] The projection to 2D.
|
|
1272
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1273
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1274
|
-
*/
|
|
1275
|
-
BoundingSphere.projectTo2D = function (sphere, projection, result) {
|
|
1276
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1277
|
-
Check.typeOf.object("sphere", sphere);
|
|
1278
|
-
//>>includeEnd('debug');
|
|
1279
|
-
|
|
1280
|
-
projectTo2DProjection._ellipsoid = Ellipsoid.default;
|
|
1281
|
-
projection = projection ?? projectTo2DProjection;
|
|
1282
|
-
|
|
1283
|
-
const ellipsoid = projection.ellipsoid;
|
|
1284
|
-
let center = sphere.center;
|
|
1285
|
-
const radius = sphere.radius;
|
|
1286
|
-
|
|
1287
|
-
let normal;
|
|
1288
|
-
if (Cartesian3.equals(center, Cartesian3.ZERO)) {
|
|
1289
|
-
// Bounding sphere is at the center. The geodetic surface normal is not
|
|
1290
|
-
// defined here so pick the x-axis as a fallback.
|
|
1291
|
-
normal = Cartesian3.clone(Cartesian3.UNIT_X, projectTo2DNormalScratch);
|
|
1292
|
-
} else {
|
|
1293
|
-
normal = ellipsoid.geodeticSurfaceNormal(center, projectTo2DNormalScratch);
|
|
1294
|
-
}
|
|
1295
|
-
const east = Cartesian3.cross(
|
|
1296
|
-
Cartesian3.UNIT_Z,
|
|
1297
|
-
normal,
|
|
1298
|
-
projectTo2DEastScratch,
|
|
1299
|
-
);
|
|
1300
|
-
Cartesian3.normalize(east, east);
|
|
1301
|
-
const north = Cartesian3.cross(normal, east, projectTo2DNorthScratch);
|
|
1302
|
-
Cartesian3.normalize(north, north);
|
|
1303
|
-
|
|
1304
|
-
Cartesian3.multiplyByScalar(normal, radius, normal);
|
|
1305
|
-
Cartesian3.multiplyByScalar(north, radius, north);
|
|
1306
|
-
Cartesian3.multiplyByScalar(east, radius, east);
|
|
1307
|
-
|
|
1308
|
-
const south = Cartesian3.negate(north, projectTo2DSouthScratch);
|
|
1309
|
-
const west = Cartesian3.negate(east, projectTo2DWestScratch);
|
|
1310
|
-
|
|
1311
|
-
const positions = projectTo2DPositionsScratch;
|
|
1312
|
-
|
|
1313
|
-
// top NE corner
|
|
1314
|
-
let corner = positions[0];
|
|
1315
|
-
Cartesian3.add(normal, north, corner);
|
|
1316
|
-
Cartesian3.add(corner, east, corner);
|
|
1317
|
-
|
|
1318
|
-
// top NW corner
|
|
1319
|
-
corner = positions[1];
|
|
1320
|
-
Cartesian3.add(normal, north, corner);
|
|
1321
|
-
Cartesian3.add(corner, west, corner);
|
|
1322
|
-
|
|
1323
|
-
// top SW corner
|
|
1324
|
-
corner = positions[2];
|
|
1325
|
-
Cartesian3.add(normal, south, corner);
|
|
1326
|
-
Cartesian3.add(corner, west, corner);
|
|
1327
|
-
|
|
1328
|
-
// top SE corner
|
|
1329
|
-
corner = positions[3];
|
|
1330
|
-
Cartesian3.add(normal, south, corner);
|
|
1331
|
-
Cartesian3.add(corner, east, corner);
|
|
1332
|
-
|
|
1333
|
-
Cartesian3.negate(normal, normal);
|
|
1334
|
-
|
|
1335
|
-
// bottom NE corner
|
|
1336
|
-
corner = positions[4];
|
|
1337
|
-
Cartesian3.add(normal, north, corner);
|
|
1338
|
-
Cartesian3.add(corner, east, corner);
|
|
1339
|
-
|
|
1340
|
-
// bottom NW corner
|
|
1341
|
-
corner = positions[5];
|
|
1342
|
-
Cartesian3.add(normal, north, corner);
|
|
1343
|
-
Cartesian3.add(corner, west, corner);
|
|
1344
|
-
|
|
1345
|
-
// bottom SW corner
|
|
1346
|
-
corner = positions[6];
|
|
1347
|
-
Cartesian3.add(normal, south, corner);
|
|
1348
|
-
Cartesian3.add(corner, west, corner);
|
|
1349
|
-
|
|
1350
|
-
// bottom SE corner
|
|
1351
|
-
corner = positions[7];
|
|
1352
|
-
Cartesian3.add(normal, south, corner);
|
|
1353
|
-
Cartesian3.add(corner, east, corner);
|
|
1354
|
-
|
|
1355
|
-
const length = positions.length;
|
|
1356
|
-
for (let i = 0; i < length; ++i) {
|
|
1357
|
-
const position = positions[i];
|
|
1358
|
-
Cartesian3.add(center, position, position);
|
|
1359
|
-
const cartographic = ellipsoid.cartesianToCartographic(
|
|
1360
|
-
position,
|
|
1361
|
-
projectTo2DCartographicScratch,
|
|
1362
|
-
);
|
|
1363
|
-
projection.project(cartographic, position);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
result = BoundingSphere.fromPoints(positions, result);
|
|
1367
|
-
|
|
1368
|
-
// swizzle center components
|
|
1369
|
-
center = result.center;
|
|
1370
|
-
const x = center.x;
|
|
1371
|
-
const y = center.y;
|
|
1372
|
-
const z = center.z;
|
|
1373
|
-
center.x = z;
|
|
1374
|
-
center.y = x;
|
|
1375
|
-
center.z = y;
|
|
1376
|
-
|
|
1377
|
-
return result;
|
|
1378
|
-
};
|
|
1379
|
-
|
|
1380
|
-
/**
|
|
1381
|
-
* Determines whether or not a sphere is hidden from view by the occluder.
|
|
1382
|
-
*
|
|
1383
|
-
* @param {BoundingSphere} sphere The bounding sphere surrounding the occluded object.
|
|
1384
|
-
* @param {Occluder} occluder The occluder.
|
|
1385
|
-
* @returns {boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
|
|
1386
|
-
*/
|
|
1387
|
-
BoundingSphere.isOccluded = function (sphere, occluder) {
|
|
1388
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1389
|
-
Check.typeOf.object("sphere", sphere);
|
|
1390
|
-
Check.typeOf.object("occluder", occluder);
|
|
1391
|
-
//>>includeEnd('debug');
|
|
1392
|
-
return !occluder.isBoundingSphereVisible(sphere);
|
|
1393
|
-
};
|
|
1394
|
-
|
|
1395
|
-
/**
|
|
1396
|
-
* Compares the provided BoundingSphere componentwise and returns
|
|
1397
|
-
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1398
|
-
*
|
|
1399
|
-
* @param {BoundingSphere} [left] The first BoundingSphere.
|
|
1400
|
-
* @param {BoundingSphere} [right] The second BoundingSphere.
|
|
1401
|
-
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
1402
|
-
*/
|
|
1403
|
-
BoundingSphere.equals = function (left, right) {
|
|
1404
|
-
return (
|
|
1405
|
-
left === right ||
|
|
1406
|
-
(defined(left) &&
|
|
1407
|
-
defined(right) &&
|
|
1408
|
-
Cartesian3.equals(left.center, right.center) &&
|
|
1409
|
-
left.radius === right.radius)
|
|
1410
|
-
);
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
/**
|
|
1414
|
-
* Determines which side of a plane the sphere is located.
|
|
1415
|
-
*
|
|
1416
|
-
* @param {Plane} plane The plane to test against.
|
|
1417
|
-
* @returns {Intersect} {@link Intersect.INSIDE} if the entire sphere is on the side of the plane
|
|
1418
|
-
* the normal is pointing, {@link Intersect.OUTSIDE} if the entire sphere is
|
|
1419
|
-
* on the opposite side, and {@link Intersect.INTERSECTING} if the sphere
|
|
1420
|
-
* intersects the plane.
|
|
1421
|
-
*/
|
|
1422
|
-
BoundingSphere.prototype.intersectPlane = function (plane) {
|
|
1423
|
-
return BoundingSphere.intersectPlane(this, plane);
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
/**
|
|
1427
|
-
* Computes the estimated distance squared from the closest point on a bounding sphere to a point.
|
|
1428
|
-
*
|
|
1429
|
-
* @param {Cartesian3} cartesian The point
|
|
1430
|
-
* @returns {number} The estimated distance squared from the bounding sphere to the point.
|
|
1431
|
-
*
|
|
1432
|
-
* @example
|
|
1433
|
-
* // Sort bounding spheres from back to front
|
|
1434
|
-
* spheres.sort(function(a, b) {
|
|
1435
|
-
* return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
|
|
1436
|
-
* });
|
|
1437
|
-
*/
|
|
1438
|
-
BoundingSphere.prototype.distanceSquaredTo = function (cartesian) {
|
|
1439
|
-
return BoundingSphere.distanceSquaredTo(this, cartesian);
|
|
1440
|
-
};
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* The distances calculated by the vector from the center of the bounding sphere to position projected onto direction
|
|
1444
|
-
* plus/minus the radius of the bounding sphere.
|
|
1445
|
-
* <br>
|
|
1446
|
-
* If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the
|
|
1447
|
-
* closest and farthest planes from position that intersect the bounding sphere.
|
|
1448
|
-
*
|
|
1449
|
-
* @param {Cartesian3} position The position to calculate the distance from.
|
|
1450
|
-
* @param {Cartesian3} direction The direction from position.
|
|
1451
|
-
* @param {Interval} [result] A Interval to store the nearest and farthest distances.
|
|
1452
|
-
* @returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction.
|
|
1453
|
-
*/
|
|
1454
|
-
BoundingSphere.prototype.computePlaneDistances = function (
|
|
1455
|
-
position,
|
|
1456
|
-
direction,
|
|
1457
|
-
result,
|
|
1458
|
-
) {
|
|
1459
|
-
return BoundingSphere.computePlaneDistances(
|
|
1460
|
-
this,
|
|
1461
|
-
position,
|
|
1462
|
-
direction,
|
|
1463
|
-
result,
|
|
1464
|
-
);
|
|
1465
|
-
};
|
|
1466
|
-
|
|
1467
|
-
/**
|
|
1468
|
-
* Determines whether or not a sphere is hidden from view by the occluder.
|
|
1469
|
-
*
|
|
1470
|
-
* @param {Occluder} occluder The occluder.
|
|
1471
|
-
* @returns {boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
|
|
1472
|
-
*/
|
|
1473
|
-
BoundingSphere.prototype.isOccluded = function (occluder) {
|
|
1474
|
-
return BoundingSphere.isOccluded(this, occluder);
|
|
1475
|
-
};
|
|
1476
|
-
|
|
1477
|
-
/**
|
|
1478
|
-
* Compares this BoundingSphere against the provided BoundingSphere componentwise and returns
|
|
1479
|
-
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1480
|
-
*
|
|
1481
|
-
* @param {BoundingSphere} [right] The right hand side BoundingSphere.
|
|
1482
|
-
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1483
|
-
*/
|
|
1484
|
-
BoundingSphere.prototype.equals = function (right) {
|
|
1485
|
-
return BoundingSphere.equals(this, right);
|
|
1486
|
-
};
|
|
1487
|
-
|
|
1488
|
-
/**
|
|
1489
|
-
* Duplicates this BoundingSphere instance.
|
|
1490
|
-
*
|
|
1491
|
-
* @param {BoundingSphere} [result] The object onto which to store the result.
|
|
1492
|
-
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
|
|
1493
|
-
*/
|
|
1494
|
-
BoundingSphere.prototype.clone = function (result) {
|
|
1495
|
-
return BoundingSphere.clone(this, result);
|
|
1496
|
-
};
|
|
1497
|
-
|
|
1498
|
-
/**
|
|
1499
|
-
* Computes the radius of the BoundingSphere.
|
|
1500
|
-
* @returns {number} The radius of the BoundingSphere.
|
|
1501
|
-
*/
|
|
1502
|
-
BoundingSphere.prototype.volume = function () {
|
|
1503
|
-
const radius = this.radius;
|
|
1504
|
-
return volumeConstant * radius * radius * radius;
|
|
1505
|
-
};
|
|
1506
1502
|
export default BoundingSphere;
|