UNPKG

casc-cesium

Version:

Vue 3.x components for CesiumJS.

1 lines 11.8 kB
{"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: 2022-03-28 09:45:36\n * @LastEditors: zouyaoji\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 'casc-cesium-utils/types'\nimport { usePrimitives } from 'casc-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 'casc-cesium-utils/cesium-props'\nimport { kebabCase } from 'casc-cesium-utils/util'\nimport { primitiveEmits } from 'casc-cesium-utils/emits'\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: primitiveEmits,\n setup(props, ctx) {\n // state\n const instance = getCurrentInstance() as VcComponentInternalInstance\n instance.cesiumClass = 'Model'\n const primitivesState = usePrimitives(props, ctx, instance)\n // methods\n instance.createCesiumObject = async () => {\n const options: any = primitivesState?.transformProps(props)\n return 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\nexport type VcPrimitiveModelRef = VcComponentPublicInstance<VcPrimitiveModelProps>\n\nexport interface VcPrimitiveModelSlots {\n /**\n * Slot for vc-geometry-instance.\n */\n default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;AAqCY,MAAC,mBAAmB,GAAG;AACnC,EAAE,GAAG,GAAG;AACR,EAAE,QAAQ,EAAE,MAAM;AAClB,EAAE,GAAG,IAAI;AACT,EAAE,GAAG,WAAW;AAChB,EAAE,GAAG,KAAK;AACV,EAAE,GAAG,gBAAgB;AACrB,EAAE,GAAG,YAAY;AACjB,EAAE,GAAG,EAAE;AACP,EAAE,GAAG,YAAY;AACjB,EAAE,GAAG,yBAAyB;AAC9B,EAAE,GAAG,YAAY;AACjB,EAAE,GAAG,eAAe;AACpB,EAAE,GAAG,OAAO;AACZ,EAAE,GAAG,uBAAuB;AAC5B,EAAE,GAAG,cAAc;AACnB,EAAE,GAAG,eAAe;AACpB,EAAE,GAAG,KAAK;AACV,EAAE,GAAG,wBAAwB;AAC7B,EAAE,GAAG,KAAK;AACV,EAAE,GAAG,cAAc;AACnB,EAAE,GAAG,gBAAgB;AACrB,EAAE,GAAG,eAAe;AACpB,EAAE,GAAG,cAAc;AACnB,EAAE,GAAG,cAAc;AACnB,EAAE,kBAAkB,EAAE;AACtB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,GAAG,wBAAwB;AAC7B,EAAE,GAAG,UAAU;AACf,EAAE,GAAG,iBAAiB;AACtB,EAAE,GAAG,6BAA6B;AAClC,EAAE,GAAG,uBAAuB;AAC5B,EAAE,GAAG,MAAM;AACX,EAAE,GAAG,eAAe;AACpB,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,GAAG,gBAAgB;AACrB,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