UNPKG

casc-cesium

Version:

Vue 3.x components for CesiumJS.

1 lines 7.9 kB
{"version":3,"file":"Feature.mjs","sources":["../../../../../../packages/components/controls/selection-indicator/Feature.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-10-27 15:54:13\n * @LastEditTime: 2022-09-10 21:29:53\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\controls\\selection-indicator\\Feature.ts\n */\n\nimport { makeCartesian3 } from 'casc-cesium-utils/cesium-helpers'\nimport type { VcCesiumObject } from 'casc-cesium-utils/types'\n\nclass Feature {\n id: string\n cesiumObject: VcCesiumObject\n pickedFeature: any\n name: any\n description: any\n properties: any\n data: any\n imageryLayer: Cesium.ImageryLayer\n position: Cesium.Cartesian3\n coords: any\n windowPosition: Cesium.Cartesian2\n constructor(options) {\n this.id = options.id || Cesium.createGuid()\n }\n\n static getBoundingSphere(cesiumObject, viewer: Cesium.Viewer) {\n const { Primitive, ClassificationPrimitive, GroundPolylinePrimitive, GroundPrimitive, Polyline } = Cesium\n let boundingSphere\n if (cesiumObject instanceof ClassificationPrimitive || cesiumObject instanceof GroundPolylinePrimitive) {\n boundingSphere = (cesiumObject as any)._primitive?._boundingSphereWC?.[0]\n } else if (cesiumObject instanceof Primitive) {\n boundingSphere = (cesiumObject as any)._boundingSphereWC?.[0]\n } else if (cesiumObject instanceof GroundPrimitive) {\n boundingSphere = (cesiumObject as any)._boundingVolumes?.[0]\n } else if (cesiumObject instanceof Polyline) {\n boundingSphere = (cesiumObject as any)._boundingVolumeWC\n } else if (cesiumObject instanceof Cesium.Entity) {\n boundingSphere = new Cesium.BoundingSphere()\n ;(viewer.dataSourceDisplay as any).getBoundingSphere(cesiumObject, true, boundingSphere)\n }\n\n return boundingSphere\n }\n static fromPickedFeature(cesiumObject, pickedFeature, viewer, screenPosition) {\n const feature = new Feature({ id: cesiumObject.id })\n\n if (cesiumObject.position) {\n feature.position = cesiumObject.position\n } else if (cesiumObject instanceof Cesium.Model) {\n feature.position = Cesium.Matrix4.getTranslation(cesiumObject.modelMatrix, new Cesium.Cartesian3())\n } else if (cesiumObject instanceof Cesium.Cesium3DTileset) {\n let position = pickedFeature.content.tile.boundingSphere.center\n let positionProperty = pickedFeature?.getProperty?.('position')\n if (Cesium.defined(positionProperty)) {\n if (typeof positionProperty === 'string') {\n positionProperty = JSON.parse(positionProperty)\n }\n\n position = makeCartesian3(positionProperty) as Cesium.Cartesian3\n }\n feature.position = position\n } else {\n feature.position = Feature.getBoundingSphere(cesiumObject, viewer)?.center\n }\n\n feature.cesiumObject = cesiumObject\n feature.pickedFeature = pickedFeature\n feature.windowPosition = screenPosition\n feature.description = cesiumObject?.description || cesiumObject?.description?.getValue()\n feature.properties = cesiumObject?.properties || cesiumObject?.properties?.getValue() || cesiumObject?.feature?.properties\n return feature\n }\n\n static fromImageryLayerFeature(imageryFeature, viewer: Cesium.Viewer) {\n const feature = new Feature({\n id: imageryFeature.name\n })\n feature.name = imageryFeature.name\n feature.description = imageryFeature.description // already defined by the new Entity\n feature.properties = imageryFeature.properties\n feature.data = imageryFeature.data\n\n feature.imageryLayer = imageryFeature.imageryLayer\n feature.position = viewer.scene.globe.ellipsoid.cartographicToCartesian(imageryFeature.position)\n feature.coords = imageryFeature.coords\n\n return feature\n }\n}\n\n// function addCustomFeatureProperties (entity) {\n// for (let i = 0; i < customProperties.length; i++) {\n// if (entity.propertyNames.indexOf(customProperties[i]) === -1) {\n// entity.addProperty(customProperties[i])\n// }\n// }\n// }\n\nexport default Feature\n"],"names":[],"mappings":";;AACA,MAAM,OAAO,CAAC;AACd,EAAE,WAAW,CAAC,OAAO,EAAE;AACvB,IAAI,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;AAChD,GAAG;AACH,EAAE,OAAO,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE;AACjD,IAAI,IAAI,EAAE,EAAE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