vue-cesium
Version:
Vue 3.x components for CesiumJS.
1 lines • 12.9 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/primitives/model/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2023-07-28 00:41:06\n * @LastEditors: zouyaoji 370681295@qq.com\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\primitives\\model\\index.ts\n */\nimport { createCommentVNode, defineComponent, getCurrentInstance, PropType, VNode } from 'vue'\nimport type {\n VcCartesian2,\n VcCartesian3Array,\n VcColor,\n VcComponentInternalInstance,\n VcComponentPublicInstance,\n VcDistanceDisplayCondition,\n VcPickEvent,\n VcReadyObject\n} from '@vue-cesium/utils/types'\nimport { usePrimitives } from '@vue-cesium/composables'\nimport {\n url,\n show,\n modelMatrix,\n scale,\n minimumPixelSize,\n maximumScale,\n id,\n allowPicking,\n incrementallyLoadTextures,\n asynchronous,\n clampAnimations,\n shadows,\n debugShowBoundingVolume,\n debugWireframe,\n heightReference,\n scene,\n distanceDisplayCondition,\n color,\n colorBlendMode,\n colorBlendAmount,\n silhouetteColor,\n silhouetteSize,\n clippingPlanes,\n imageBasedLightingFactor,\n lightColor,\n luminanceAtZenith,\n sphericalHarmonicCoefficients,\n specularEnvironmentMaps,\n credit,\n backFaceCulling,\n enableMouseEvent\n} from '@vue-cesium/utils/cesium-props'\nimport { kebabCase } from '@vue-cesium/utils/util'\nimport { primitiveEmits } from '@vue-cesium/utils/emits'\nimport { compareCesiumVersion } from '@vue-cesium/utils/cesium-helpers'\n\nexport const modelPrimitiveProps = {\n ...url,\n basePath: String as PropType<string | Cesium.Resource>,\n ...show,\n ...modelMatrix,\n ...scale,\n ...minimumPixelSize,\n ...maximumScale,\n ...id,\n ...allowPicking,\n ...incrementallyLoadTextures,\n ...asynchronous,\n ...clampAnimations,\n ...shadows,\n ...debugShowBoundingVolume,\n ...debugWireframe,\n ...heightReference,\n ...scene,\n ...distanceDisplayCondition,\n ...color,\n ...colorBlendMode,\n ...colorBlendAmount,\n ...silhouetteColor,\n ...silhouetteSize,\n ...clippingPlanes,\n dequantizeInShader: {\n type: Boolean,\n default: true\n },\n ...imageBasedLightingFactor,\n ...lightColor,\n ...luminanceAtZenith,\n ...sphericalHarmonicCoefficients,\n ...specularEnvironmentMaps,\n ...credit,\n ...backFaceCulling,\n showOutline: {\n type: Boolean,\n default: true\n },\n ...enableMouseEvent\n}\nexport default defineComponent({\n name: 'VcPrimitiveModel',\n props: modelPrimitiveProps,\n emits: {\n ...primitiveEmits,\n readyEvent: (evt: Cesium.Model) => true,\n texturesReadyEvent: (evt: Cesium.Model) => true,\n errorEvent: (evt: Error) => true\n },\n setup(props, ctx) {\n // state\n const instance = getCurrentInstance() as VcComponentInternalInstance\n instance.cesiumClass = 'Model'\n instance.cesiumEvents = ['readyEvent', 'texturesReadyEvent', 'errorEvent']\n const primitivesState = usePrimitives(props, ctx, instance)\n // methods\n instance.createCesiumObject = async () => {\n const options: any = primitivesState?.transformProps(props)\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return compareCesiumVersion(Cesium.VERSION, '1.104') ? await Cesium.Model.fromGltfAsync(options) : Cesium.Model.fromGltf(options)\n }\n return () => createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n }\n})\n\nexport type VcPrimitiveModelProps = {\n /**\n * The url to the .gltf file.\n */\n url: string | Cesium.Resource\n /**\n * The base path that paths in the glTF JSON are relative to.\n */\n basePath?: string | Cesium.Resource\n /**\n * Determines if the model primitive will be shown.\n * Default value: true\n */\n show?: boolean\n /**\n * The 4x4 transformation matrix that transforms the model from model to world coordinates.\n */\n modelMatrix: Cesium.Matrix4\n /**\n * A uniform scale applied to this model.\n * Default value: 1.0\n */\n scale?: number\n /**\n * The approximate minimum pixel size of the model regardless of zoom.\n * Default value: 0.0\n */\n minimumPixelSize?: number\n /**\n * The maximum scale for the model.\n */\n maximumScale?: number\n /**\n * A user-defined object to return when the model is picked with Scene#pick.\n */\n id?: any\n /**\n * When true, each glTF mesh and primitive is pickable with Scene#pick.\n * Default value: true\n */\n allowPicking?: boolean\n /**\n * Determine if textures may continue to stream in after the model is loaded.\n * Default value: true\n */\n incrementallyLoadTextures?: boolean\n /**\n * Determines if model WebGL resource creation will be spread out over several frames or block until completion once all glTF files are loaded.\n * Default value: true\n */\n asynchronous?: boolean\n /**\n * Determines if the model's animations should hold a pose over frames where no keyframes are specified.\n * Default value: true\n */\n clampAnimations?: boolean\n /**\n * Determines whether the model casts or receives shadows from light sources.\n */\n shadows?: number | Cesium.ShadowMode\n /**\n * For debugging only. Draws the bounding sphere for each draw command in the model.\n * Default value: false\n */\n debugShowBoundingVolume?: boolean\n /**\n * For debugging only. Draws the model in wireframe.\n * Default value: false\n */\n debugWireframe?: boolean\n /**\n * Determines how the model is drawn relative to terrain.\n */\n heightReference?: number | Cesium.HeightReference\n /**\n * Must be passed in for models that use the height reference property.\n */\n scene?: Cesium.Scene\n /**\n * The condition specifying at what distance from the camera that this model will be displayed.\n */\n distanceDisplayCondition?: VcDistanceDisplayCondition\n /**\n * A color that blends with the model's rendered color.\n * Default value: white\n */\n color?: VcColor\n /**\n * Defines how the color blends with the model.\n */\n colorBlendMode?: number | Cesium.ColorBlendMode\n /**\n * Value used to determine the color strength when the colorBlendMode is MIX. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.\n * Default value: 0.5\n */\n colorBlendAmount?: number\n /**\n * The silhouette color. If more than 256 models have silhouettes enabled, there is a small chance that overlapping models will have minor artifacts.\n */\n silhouetteColor?: VcColor\n /**\n * The size of the silhouette in pixels.\n * Default value: 0.0\n */\n silhouetteSize?: number\n /**\n * The ClippingPlaneCollection used to selectively disable rendering the model.\n */\n clippingPlanes?: Cesium.ClippingPlaneCollection\n /**\n * Determines if a Draco encoded model is dequantized on the GPU. This decreases total memory usage for encoded models.\n * Default value: true\n */\n dequantizeInShader?: boolean\n /**\n * Scales diffuse and specular image-based lighting from the earth, sky, atmosphere and star skybox.\n * Default value: { x: 1.0, y: 1.0 }\n */\n imageBasedLightingFactor?: VcCartesian2\n /**\n * The light color when shading the model. When undefined the scene's light color is used instead.\n */\n lightColor?: VcColor\n /**\n * The sun's luminance at the zenith in kilo candela per meter squared to use for this model's procedural environment map.\n * Default value: 0.2\n */\n luminanceAtZenith?: number\n /**\n * The third order spherical harmonic coefficients used for the diffuse color of image-based lighting.\n */\n sphericalHarmonicCoefficients?: VcCartesian3Array\n /**\n * A URL to a KTX2 file that contains a cube map of the specular lighting and the convoluted specular mipmaps.\n */\n specularEnvironmentMaps?: string\n /**\n * A credit for the model, which is displayed on the canvas.\n */\n credit?: string | Cesium.Credit\n /**\n * Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if Model#color is translucent or Model#silhouetteSize is greater than 0.0.\n * Default value: true\n */\n backFaceCulling?: boolean\n /**\n * Whether to display the outline for models using the CESIUM_primitive_outline extension. When true, outlines are displayed. When false, outlines are not displayed.\n * Default value: true\n */\n showOutline?: boolean\n /**\n * Specifies whether to respond to mouse pick events.\n * Default Value: true\n */\n enableMouseEvent?: boolean\n /**\n * Triggers before the component is loaded.\n */\n onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the component 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 component is destroyed.\n */\n onDestroyed?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the mouse is pressed on this primitive.\n */\n onMousedown?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse bounces up on this primitive.\n */\n onMouseup?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse clicks on this primitive.\n */\n onClick?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse clicks outside this primitive.\n */\n onClickout?: (evt: VcPickEvent) => void\n /**\n * Triggers when the left mouse button double-clicks this primitive.\n */\n onDblclick?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves on this primitive.\n */\n onMousemove?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves over to this primitive.\n */\n onMouseover?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves out of this primitive.\n */\n onMouseout?: (evt: VcPickEvent) => void\n /**\n * Triggers when the primitive is ready to render.\n */\n onReadyPromise?: (primitive: Cesium.ClassificationPrimitive, viewer: Cesium.Viewer, instance: VcComponentPublicInstance) => void\n /**\n * Triggers when the model is loaded and ready for rendering.\n */\n onReadyEvent?: (evt: Cesium.Model) => void\n /**\n * Triggers when the model textures are loaded and ready for rendering.\n */\n onTexturesReadyEvent?: (evt: Cesium.Model) => void\n /**\n * Triggers when the model encounters an asynchronous rendering error.\n */\n onErrorEvent?: (evt: Error) => void\n}\n\nexport type VcPrimitiveModelRef = VcComponentPublicInstance<VcPrimitiveModelProps>\n\nexport interface VcPrimitiveModelSlots {\n /**\n * Slot for vc-geometry-instance.\n */\n default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;;;AAyDO,MAAM,mBAAsB,GAAA;AAAA,EACjC,GAAG,GAAA;AAAA,EACH,QAAU,EAAA,MAAA;AAAA,EACV,GAAG,IAAA;AAAA,EACH,GAAG,WAAA;AAAA,EACH,GAAG,KAAA;AAAA,EACH,GAAG,gBAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,GAAG,EAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,GAAG,yBAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,OAAA;AAAA,EACH,GAAG,uBAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,KAAA;AAAA,EACH,GAAG,wBAAA;AAAA,EACH,GAAG,KAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG,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