casc-cesium
Version:
Vue 3.x components for CesiumJS.
1 lines • 6.74 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/datasources/custom/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2022-04-06 15:00:23\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\datasources\\custom\\index.ts\n */\nimport type { PropType, VNode } from 'vue'\nimport { createCommentVNode, defineComponent, getCurrentInstance, h } from 'vue'\nimport type { VcComponentInternalInstance, VcComponentPublicInstance, VcDatasource, VcPickEvent, VcReadyObject } from 'casc-cesium-utils/types'\nimport { useDatasources } from 'casc-cesium-composables'\nimport { kebabCase } from 'casc-cesium-utils/util'\nimport { hSlot } from 'casc-cesium-utils/private/render'\nimport { show, enableMouseEvent } from 'casc-cesium-utils/cesium-props'\nimport { VcEntityProps } from '../../entity'\nimport { datasourceEmits } from 'casc-cesium-utils/emits'\n\nexport const customDatasourceProps = {\n ...show,\n ...enableMouseEvent,\n entities: {\n type: Array as PropType<Array<VcEntityProps>>,\n default: () => []\n },\n name: String,\n destroy: {\n type: Boolean,\n default: false\n }\n}\nexport default defineComponent({\n name: 'VcDatasourceCustom',\n props: customDatasourceProps,\n emits: datasourceEmits,\n setup(props: VcDatasourceCustomProps, ctx) {\n // state\n const instance = getCurrentInstance() as VcComponentInternalInstance\n instance.cesiumClass = 'CustomDataSource'\n useDatasources(props, ctx, instance)\n\n instance.createCesiumObject = async () => {\n return new Cesium.CustomDataSource(props.name)\n }\n\n return () =>\n ctx.slots.default\n ? h(\n 'i',\n {\n class: kebabCase(instance.proxy?.$options.name || ''),\n style: { display: 'none !important' }\n },\n hSlot(ctx.slots.default)\n )\n : createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n }\n})\n\nexport type VcDatasourceCustomProps = {\n /**\n * Specify whether the data source is displayed.\n * Default value: true\n */\n show?: boolean\n /**\n * Specify whether to respond to mouse pick events.\n * Default value: true\n */\n enableMouseEvent?: boolean\n /**\n * Specify the collection of entities to be added to this data source.\n */\n entities?: Array<VcEntityProps>\n /**\n * A human-readable name for this instance.\n */\n name?: string\n /**\n * Whether to destroy the data source in addition to removing it.\n * Default value: false\n */\n destroy?: boolean\n /**\n * Triggers before the VcDatasourceCustom is loaded.\n */\n onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the VcDatasourceCustom 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 VcDatasourceCustom is destroyed.\n */\n onDestroyed?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the mouse is pressed on this datasource.\n */\n onMousedown?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse bounces up on this datasource.\n */\n onMouseup?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse clicks on this datasource.\n */\n onClick?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse clicks outside this datasource.\n */\n onClickout?: (evt: VcPickEvent) => void\n /**\n * Triggers when the left mouse button double-clicks this datasource.\n */\n onDblclick?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves on this datasource.\n */\n onMousemove?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves over to this datasource.\n */\n onMouseover?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves out of this datasource.\n */\n onMouseout?: (evt: VcPickEvent) => void\n /**\n * Triggers whenever a new property is assigned. datasource.clock.\n */\n onDefinitionChanged?: (property: Cesium.Property) => void\n /**\n * Triggers when a new cluster will be displayed. datasource.clustering.\n */\n onClusterEvent?: (\n entities: Array<Cesium.Entity>,\n cluster: { billboard: Cesium.Billboard; label: Cesium.Label; point: Cesium.PointPrimitive }\n ) => void\n /**\n * Triggers when entities are added or removed from the collection.datasource.entities\n */\n onCollectionChanged?: (\n collection: Cesium.EntityCollection,\n addedArray: Array<Cesium.Entity>,\n removedArray: Array<Cesium.Entity>,\n changedArray: Array<Cesium.Entity>\n ) => void\n /**\n * Triggerswhen the underlying data changes.\n */\n onChangedEvent?: (datasource: VcDatasource) => void\n /**\n * Triggers if an error is encountered during processing.\n */\n onErrorEvent?: (datasource: VcDatasource, error: any) => void\n /**\n * Triggers when the data source either starts or stops loading.\n */\n onLoadingEvent?: (datasource: VcDatasource, isLoading: boolean) => void\n}\n\nexport type VcDatasourceCustomRef = VcComponentPublicInstance<VcDatasourceCustomProps>\n\nexport interface VcDatasourceCustomSlots {\n /**\n * Slot for vc-entity.\n */\n default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;;AAMY,MAAC,qBAAqB,GAAG;AACrC,EAAE,GAAG,IAAI;AACT,EAAE,GAAG,gBAAgB;AACrB,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,KAAK;AACf,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE;AACF,uBAAe,eAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,oBAAoB;AAC5B,EAAE,KAAK,EAAE,qBAAqB;AAC9B,EAAE,KAAK,EAAE,eAAe;AACxB,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE;AACpB,IAAI,MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAC;AAC1C,IAAI,QAAQ,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAC9C,IAAI,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;AACzC,IAAI,QAAQ,CAAC,kBAAkB,GAAG,YAAY;AAC9C,MAAM,OAAO,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACrD,KAAK,CAAC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