Cesium JS API
AppearanceArcGisMapServerImageryProviderArcGISTiledElevationTerrainProviderArcTypeAssociativeArrayAxisAxisAlignedBoundingBoxbarycentricCoordinatesBillboardBillboardCollectionBillboardGraphicsBillboardVisualizerbinarySearchbinarySearchComparatorBingMapsGeocoderServiceBingMapsImageryProviderBingMapsStyleBlendEquationBlendFunctionBlendingStateBlendOptionBoundingRectangleBoundingSphereBoxEmitterBoxGeometryBoxGeometryUpdaterBoxGraphicsBoxOutlineGeometrybuildModuleUrlCallbackPropertyCameraCameraEventAggregatorCameraEventTypeCartesian2Cartesian3Cartesian4CartographicCartographicGeocoderServiceCatmullRomSplineCesium3DTileCesium3DTileColorBlendModeCesium3DTileContentCesium3DTileFeatureCesium3DTilePointFeatureCesium3DTilesetCesium3DTilesetGraphicsCesium3DTilesetVisualizerCesium3DTileStyleCesium3DTilesVoxelProviderCesiumTerrainProviderCesiumWidgetCheckerboardMaterialPropertyCircleEmitterCircleGeometryCircleOutlineGeometryClassificationPrimitiveClassificationTypeClippingPlaneClippingPlaneCollectionClockClockRangeClockStepcloneCloudCollectionCloudTypeColorColorBlendModeColorGeometryInstanceAttributeColorMaterialPropertycombineComponentDatatypeCompositeEntityCollectionCompositeMaterialPropertyCompositePositionPropertyCompositePropertyCompressedTextureBufferConditionsExpressionConeEmitterConstantPositionPropertyConstantPropertyConstantSplineContextOptionsCoplanarPolygonGeometryCoplanarPolygonOutlineGeometryCornerTypeCorridorGeometryCorridorGeometryUpdaterCorridorGraphicsCorridorOutlineGeometrycreateElevationBandMaterialcreateElevationBandMaterialBandcreateElevationBandMaterialEntrycreateGuidcreateOsmBuildingscreateTangentSpaceDebugPrimitivecreateWorldImagerycreateWorldTerrainCreditCreditDisplayCubicRealPolynomialCullFaceCullingVolumeCumulusCloudCustomDataSourceCustomHeightmapTerrainProviderCustomShaderCustomShaderModeCustomShaderTranslucencyModeCylinderGeometryCylinderGeometryUpdaterCylinderGraphicsCylinderOutlineGeometryCzmlDataSourceDataSourceDataSourceClockDataSourceCollectionDataSourceDisplayDebugAppearanceDebugCameraPrimitiveDebugModelMatrixPrimitiveDefaultProxydefaultValuedefinedDepthFunctiondestroyObjectDeveloperErrorDirectionalLightDirectionUpDiscardEmptyTileImagePolicyDiscardMissingTileImagePolicyDistanceDisplayConditionDistanceDisplayConditionGeometryInstanceAttributeEasingFunctionEllipseGeometryEllipseGeometryUpdaterEllipseGraphicsEllipseOutlineGeometryEllipsoidEllipsoidGeodesicEllipsoidGeometryEllipsoidGeometryUpdaterEllipsoidGraphicsEllipsoidOutlineGeometryEllipsoidRhumbLineEllipsoidSurfaceAppearanceEllipsoidTangentPlaneEllipsoidTerrainProviderEntityEntityClusterEntityCollectionEntityViewEventEventHelperexcludesReverseAxisexportKmlexportKmlModelCallbackexportKmlResultKmlexportKmlResultKmzExpressionExtrapolationTypeFeatureDetectionFogformatErrorFrameRateMonitorFrustumGeometryFrustumOutlineGeometryFullscreenGeocoderServiceGeocodeTypeGeographicProjectionGeographicTilingSchemeGeoJsonDataSourceGeometryGeometryAttributeGeometryAttributesGeometryFactoryGeometryInstanceGeometryInstanceAttributeGeometryPipelineGeometryUpdaterGeometryVisualizergetAbsoluteUrigetBaseUrigetExtensionFromUriGetFeatureInfoFormatgetFilenameFromUrigetImagePixelsgetTimestampGlobeGlobeTranslucencyGoogleEarthEnterpriseImageryProviderGoogleEarthEnterpriseMapsProviderGoogleEarthEnterpriseMetadataGoogleEarthEnterpriseTerrainDataGoogleEarthEnterpriseTerrainProviderGpxDataSourceGregorianDateGridImageryProviderGridMaterialPropertyGroundGeometryUpdaterGroundPolylineGeometryGroundPolylinePrimitiveGroundPrimitiveHeadingPitchRangeHeadingPitchRollHeadingPitchRollValuesHeightmapEncodingHeightmapTerrainDataHeightReferenceHermitePolynomialApproximationHermiteSplineHilbertOrderHorizontalOriginI3SDataProviderI3SFeatureI3SFieldI3SGeometryI3SLayerI3SNodeImageBasedLightingImageMaterialPropertyImageryLayerImageryLayerCollectionImageryLayerFeatureInfoImageryProviderImageryTypesincludesReverseAxisIndexDatatypeIntersectIntersections2DIntersectionTestsIntervalIonIonGeocoderServiceIonImageryProviderIonResourceIonWorldImageryStyleisLeapYearIso8601JulianDateKeyboardEventModifierKmlCameraKmlDataSourceKmlFeatureDataKmlLookAtKmlTourKmlTourFlyToKmlTourWaitLabelLabelCollectionLabelGraphicsLabelStyleLabelVisualizerLagrangePolynomialApproximationLeapSecondLightLightingModelLinearApproximationLinearSplineMapboxImageryProviderMapboxStyleImageryProviderMapMode2DMapProjectionMaterialMaterialAppearanceMaterialSupportMaterialPropertyMathMatrix2Matrix3Matrix4mergeSortmergeSortComparatorMetadataClassMetadataClassPropertyMetadataComponentTypeMetadataEnumMetadataEnumValueMetadataSchemaMetadataTypeModelModelAnimationModelAnimationCollectionModelAnimationLoopModelFeatureModelGraphicsModelNodeModelVisualizerMoonMorphWeightSplineNearFarScalarNeverTileDiscardPolicyNodeTransformationPropertyobjectToQueryOccluderOpenCageGeocoderServiceOpenStreetMapImageryProviderOrientedBoundingBoxOrthographicFrustumOrthographicOffCenterFrustumPackableForInterpolationParticleParticleBurstParticleEmitterParticleSystemPathGraphicsPathVisualizerPeliasGeocoderServicePerInstanceColorAppearancePerspectiveFrustumPerspectiveOffCenterFrustumPinBuilderPixelDatatypePixelFormatPlanePlaneGeometryPlaneGeometryUpdaterPlaneGraphicsPlaneOutlineGeometryPointCloudShadingPointGraphicspointInsideTrianglePointPrimitivePointPrimitiveCollectionPointVisualizerPolygonGeometryPolygonGeometryUpdaterPolygonGraphicsPolygonHierarchyPolygonOutlineGeometryPolylinePolylineArrowMaterialPropertyPolylineCollectionPolylineColorAppearancePolylineDashMaterialPropertyPolylineGeometryPolylineGeometryUpdaterPolylineGlowMaterialPropertyPolylineGraphicsPolylineMaterialAppearancePolylineOutlineMaterialPropertyPolylineVisualizerPolylineVolumeGeometryPolylineVolumeGeometryUpdaterPolylineVolumeGraphicsPolylineVolumeOutlineGeometryPositionPropertyPositionPropertyArrayPostProcessStagePostProcessStageCollectionPostProcessStageCompositePostProcessStageLibraryPostProcessStageSampleModePrimitivePrimitiveCollectionPrimitiveTypePropertyPropertyArrayPropertyBagProxyQuadraticRealPolynomialQuantizedMeshTerrainDataQuarticRealPolynomialQuaternionQuaternionSplinequeryToObjectQueueRayreadyPromiseRectangleRectangleGeometryRectangleGeometryUpdaterRectangleGraphicsRectangleOutlineGeometryReferenceFrameReferencePropertyremoveExtensionRequestRequestErrorEventRequestSchedulerRequestStateRequestTypeResourceRuntimeErrorSampledPositionPropertySampledPropertysampleTerrainsampleTerrainMostDetailedSceneSceneModeSceneTransformsScreenSpaceCameraControllerScreenSpaceEventHandlerScreenSpaceEventTypeshaderDefinesshaderMaximumIntersectionsLengthshaderUniformsShadowMapShadowModeShowGeometryInstanceAttributeSimon1994PlanetaryPositionsSimplePolylineGeometrySingleTileImageryProviderSkyAtmosphereSkyBoxSphereEmitterSphereGeometrySphereOutlineGeometrySphericalSplineSplitDirectionStencilFunctionStencilOperationSteppedSplineStripeMaterialPropertyStripeOrientationStyleExpressionsubdivideArraySunSunLightTaskProcessorTerrainDataTerrainProviderTextureMagnificationFilterTextureMinificationFilterTextureUniformTileAvailabilityTileCoordinatesImageryProviderTileDiscardPolicyTileMapServiceImageryProviderTileProviderErrorTilingSchemeTimeDynamicImageryTimeDynamicPointCloudTimeIntervalTimeIntervalCollectionTimeIntervalCollectionPositionPropertyTimeIntervalCollectionPropertyTimeStandardTransformsTranslationRotationScaleTridiagonalSystemSolverTrustedServersUniformSpecifierUniformTypeUrlTemplateImageryProviderVaryingTypeVelocityOrientationPropertyVelocityVectorPropertyVertexFormatVerticalOriginVideoSynchronizerViewportQuadVisibilityVisualizerVoxelPrimitiveVoxelProviderVoxelShapeTypeVRTheWorldTerrainProviderWallGeometryWallGeometryUpdaterWallGraphicsWallOutlineGeometryWebGLConstantsWebGLOptionsWebMapServiceImageryProviderWebMapTileServiceImageryProviderWebMercatorProjectionWebMercatorTilingSchemeWindingOrderwriteTextToCanvasAnimationAnimationViewModelBaseLayerPickerBaseLayerPickerViewModelCesium3DTilesInspectorCesium3DTilesInspectorViewModelCesiumInspectorCesiumInspectorViewModelClockViewModelCommandcreateCommandFullscreenButtonFullscreenButtonViewModelGeocoderGeocoderViewModelHomeButtonHomeButtonViewModelInfoBoxInfoBoxViewModelNavigationHelpButtonNavigationHelpButtonViewModelPerformanceWatchdogPerformanceWatchdogViewModelProjectionPickerProjectionPickerViewModelProviderViewModelSceneModePickerSceneModePickerViewModelSelectionIndicatorSelectionIndicatorViewModelSvgPathBindingHandlerTimelineToggleButtonViewModelViewerviewerCesium3DTilesInspectorMixinviewerCesiumInspectorMixinviewerDragDropMixinviewerPerformanceWatchdogMixinviewerVoxelInspectorMixinVoxelInspectorVoxelInspectorViewModelVRButtonVRButtonViewModel

MorphWeightSpline

MorphWeightSpline是一个用于从一个几何体到另一个几何体过渡(morph)的类。该效果通常用于动画或实时图形。

构造函数

MorphWeightSpline(positions, weights)
  • positionsCartesian3数组,用于定义过渡的几何形状。通常应该是两个几何体之间的顶点。
  • weights:数字数组,与每个位置点对应的权重。数组长度应与positions相同。

属性

length

表示类中的过渡路径段的数量。

minimumTime

返回最小可用时间(路程/Easing函数)。

maximumTime

返回最大可用时间(路程/Easing函数)。

方法

evaluate(time)
  • time:浮点数,指定过渡的时间。在minimumTimemaximumTime之间。

返回值:Cartesian3,给定时间的几何体。

findTimeInterval(time)
  • time:浮点数,指定过渡的时间。在minimumTimemaximumTime之间。

返回值:对象,包含以下属性:

  • index:整数,最靠近给定时间的路径段的索引。
  • time:浮点数,路径段开始的时间。
getSplinePoints(count, callback)

返回值:Cartesian3分配的数组,定义路径的曲线点数。

  • count:曲线点数。
  • callback:可选参数,用于每个路径段的额外应用。
getSplinePointsInRange(startTime, stopTime, callback)

返回值:Cartesian3分配的数组,定义路径的曲线点数,指定起始时间和结束时间。

  • startTime:起始时间。
  • stopTime:结束时间。
  • callback:可选参数,用于每个路径段的额外应用。
getPointParameters(count, callback)

返回值:包含以下属性的对象:

  • pointsCartesian3分配的数组,定义路径的曲线点数。

  • time:浮点数数组,与每个曲线点对应的时间。

  • distance:浮点数数组,与每个曲线点对应的距离。

  • count:曲线点数。

  • callback:可选参数,用于每个路径段的额外应用。

getPointAtDistance(distance, time)
  • distance:开始位置到所需点的距离。
  • time:要在路径上搜索的起始时间。

返回值:包含以下属性的对象:

  • pointCartesian3,路径上给定距离的点。
  • time:浮点数,到给定距离的时间。
  • index:整数,最接近路径的段。
getParametersAtDistance(distance, time)
  • distance:开始位置到所需点的距离。
  • time:要在路径上搜索的起始时间。

返回值:包含以下属性的对象:

  • positionCartesian3,路径上给定距离的点。
  • time:浮点数,到给定距离的时间。
  • index:整数,最接近路径的段。
  • weighted:布尔值,指示如果权重被省略是否返回。
getDirection(time, forward, result)
  • time:查找方向的时间。
  • forward:布尔值,为true时返回方向向前的向量,否则向后。
  • result:可选参数,存储结果的向量。

返回值:Cartesian3,路径的方向。

getDerivative(time, result)
  • time:查找导数的时间。
  • result:可选参数,存储结果的向量。

返回值:Cartesian3,路径的导数。

getPoint(time, result)
  • time:查找路径上的点的时间。
  • result:可选参数,存储结果的向量。

返回值:Cartesian3,路径上给定时间的点。

getWeight(time, index)
  • time:查找权重的时间。
  • index:权重的索引。

返回值:权重在给定时间的值。

setWeight(time, index, weight)
  • time:查找权重的时间。
  • index:权重的索引。
  • weight:新权重。

返回值:undefined

getWeightsAtTime(time, result)
  • time:查找权重的时间。
  • result:可选参数,存储结果的数组。

返回值:给定时间的权重数组。

setWeightAtTime(time, weights)
  • time:要设置权重的时间。
  • weights:要设置的新权重。

返回值:undefined

getTimes(result)
  • result:可选参数,存储结果的数组。

返回值:时间数组。

getWeights(result)
  • result:可选参数,存储结果的数组。

返回值:权重数组。

equals(right, left)
  • right:比较的对象之一。
  • left:比较的对象之二。

返回值:如果两个对象相等,则为true,否则为false

clone(result)
  • result:可选参数,指定将克隆复制到的对象。

返回值:与此对象相同的新对象。

equalsEpsilon(right, left, epsilon)
  • right:比较的对象之一。
  • left:比较的对象之二。
  • epsilon:查找等效的阈值。

返回值:如果两个值之间的距离小于epsilon,则为true。否则为false

findTimeIntervalForPosition(position, startIndex)
  • position:位置。
  • startIndex:查找位置的开始时间。

返回值:对象,包含以下属性:

  • index:整数,最靠近给定位置的路径段的索引。
  • time:与最靠近给定位置的路径段的开始时间相对应的时间。

示例

以下示例演示了如何在两个几何体之间过渡。

var positions = [
  new Cesium.Cartesian3(-4806070.978045533, 5631675.149991115, 2840851.5874214114),
  new Cesium.Cartesian3(-4879901.418869056, 5721868.879421465, 3048850.388971803),
  new Cesium.Cartesian3(-4989449.630462545, 5751857.395557718, 2854315.049967946),
];

var weights = [0.0, 0.5, 1.0];

var morph = new Cesium.MorphWeightSpline(positions, weights);

viewer.scene.preUpdate.addEventListener(function(scene, time) {
  var terrain = viewer.scene.globe.terrainProvider;
  if (!(terrain instanceof Cesium.EllipsoidTerrainProvider)) {
    for (var i = 0; i < positions.length; ++i) {
      positions[i] = Cesium.Cartographic.toCartesian(terrain.getRectangle().getCenter(), positions[i]);
    }
  }

  var morphTime = Cesium.JulianDate.secondsDifference(time, startTime) / length;
  morphTime = Cesium.Math.clamp(morphTime, 0, 1);

  Cesium.Cartesian3.lerp(positions[0], positions[1], morphTime, scratchPosition);

  if (morphTime !== 0 && morphTime !== 1) {
    morph.setWeight(morphTime, 1, (1 / (1 - morphTime)));
    morph.setWeight(morphTime, 2, (1 / morphTime));
  }

  scratchCartographic = Cesium.Cartographic.fromCartesian(scratchPosition);
  scratchCartographic.height += altitude;
  scratchPosition = Cesium.Ellipsoid.WGS84.cartographicToCartesian(
    scratchCartographic, scratchPosition);

  entity.position = scratchPosition;
});