{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/providers/cesium-terrain/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2022-04-08 13:38:10\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\providers\\cesium-terrain\\index.ts\n */\nimport { createCommentVNode, defineComponent, getCurrentInstance } from 'vue'\nimport type { PropType } from 'vue'\nimport type { VcComponentInternalInstance, VcComponentPublicInstance, VcReadyObject } from 'casc-cesium-utils/types'\nimport { useProviders } from 'casc-cesium-composables'\nimport { ellipsoid, credit } from 'casc-cesium-utils/cesium-props'\nimport { kebabCase } from 'casc-cesium-utils/util'\nimport { providerEmits } from 'casc-cesium-utils/emits'\n\nexport const cesiumTerrainProviderProps = {\n  url: [String, Object] as PropType<string | Promise<string> | Promise<Cesium.Resource> | Cesium.Resource>,\n  requestVertexNormals: {\n    type: Boolean,\n    default: false\n  },\n  requestWaterMask: {\n    type: Boolean,\n    default: false\n  },\n  requestMetadata: {\n    type: Boolean,\n    default: true\n  },\n  ...ellipsoid,\n  ...credit\n}\n\nexport default defineComponent({\n  name: 'VcTerrainProviderCesium',\n  props: cesiumTerrainProviderProps,\n  emits: providerEmits,\n  setup(props, ctx) {\n    // state\n    const instance = getCurrentInstance() as VcComponentInternalInstance\n    instance.cesiumClass = 'CesiumTerrainProvider'\n    const providersState = useProviders(props, ctx, instance)\n\n    if (undefined === providersState) {\n      return\n    }\n    // methods\n    instance.createCesiumObject = async () => {\n      if (providersState.unwatchFns.length === 0) {\n        providersState.setPropsWatcher(true)\n      }\n      const options = providersState.transformProps(props)\n      return Cesium.defined(options.url)\n        ? new Cesium.CesiumTerrainProvider(options as any)\n        : Cesium.createWorldTerrain({ requestVertexNormals: options.requestVertexNormals, requestWaterMask: options.requestWaterMask })\n    }\n    return () => createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n  }\n})\n\nexport type VcTerrainProviderCesiumProps = {\n  /**\n   * The URL of the Cesium terrain server.\n   */\n  url?: string\n  /**\n   * Flag that indicates if the client should request additional lighting information from the server, in the form of per vertex normals if available.\n   * Default value: false\n   */\n  requestVertexNormals?: boolean\n  /**\n   * Flag that indicates if the client should request per tile water masks from the server, if available.\n   * Default value: false\n   */\n  requestWaterMask?: boolean\n  /**\n   * Flag that indicates if the client should request per tile metadata from the server, if available.\n   * Default value: true\n   */\n  requestMetadata?: boolean\n  /**\n   * The ellipsoid. If not specified, the WGS84 ellipsoid is used.\n   */\n  ellipsoid?: Cesium.Ellipsoid\n  /**\n   * A credit for the data source, which is displayed on the canvas.\n   */\n  credit?: string\n  /**\n   * Triggers before the VcTerrainProviderCesium is loaded.\n   */\n  onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n  /**\n   * Triggers when the VcTerrainProviderCesium is successfully loaded.\n   */\n  onReady?: (readyObject: VcReadyObject) => void\n  /**\n   * Triggers when the component load failed.\n   */\n  onUnready?: (e: any) => void\n  /**\n   * Triggers when the VcTerrainProviderCesium is destroyed.\n   */\n  onDestroyed?: (instance: VcComponentInternalInstance) => void\n  /**\n   * Triggers when the terrain provider encounters an asynchronous error.\n   */\n  onErrorEvent?: (evt: Cesium.TileProviderError) => void\n  /**\n   * Triggers when the provider is ready for use.\n   */\n  onReadyPromise?: (evt: boolean, viewer: Cesium.Viewer, instance: VcComponentPublicInstance) => void\n}\n\nexport type VcTerrainProviderCesiumRef = VcComponentPublicInstance<VcTerrainProviderCesiumProps>\n"],"names":[],"mappings":";;;;;;;AAKY,MAAC,0BAA0B,GAAG;AAC1C,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AACvB,EAAE,oBAAoB,EAAE;AACxB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,gBAAgB,EAAE;AACpB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAA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