UNPKG

casc-cesium

Version:

Vue 3.x components for CesiumJS.

1 lines 8.38 kB
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/primitives/primitive/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2022-03-28 09:46:50\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\primitives\\primitive\\index.ts\n */\nimport { createCommentVNode, defineComponent, getCurrentInstance, h, Ref, VNode } from 'vue'\nimport type { VcAppearance, VcComponentInternalInstance, VcComponentPublicInstance, VcPickEvent, VcReadyObject } from 'casc-cesium-utils/types'\nimport { usePrimitives } from 'casc-cesium-composables'\nimport {\n geometryInstances,\n appearance,\n depthFailAppearance,\n show,\n modelMatrix,\n vertexCacheOptimize,\n interleave,\n compressVertices,\n releaseGeometryInstances,\n allowPicking,\n asynchronous,\n debugShowBoundingVolume,\n shadows,\n enableMouseEvent\n} from 'casc-cesium-utils/cesium-props'\nimport { kebabCase } from 'casc-cesium-utils/util'\nimport { hSlot } from 'casc-cesium-utils/private/render'\nimport { primitiveEmits } from 'casc-cesium-utils/emits'\n\nexport const primitiveProps = {\n ...geometryInstances,\n ...appearance,\n ...depthFailAppearance,\n ...show,\n ...modelMatrix,\n ...vertexCacheOptimize,\n ...interleave,\n ...compressVertices,\n ...releaseGeometryInstances,\n ...allowPicking,\n cull: {\n type: Boolean,\n default: true\n },\n ...asynchronous,\n ...debugShowBoundingVolume,\n ...shadows,\n ...enableMouseEvent\n}\nexport default defineComponent({\n name: 'VcPrimitive',\n props: primitiveProps,\n emits: primitiveEmits,\n setup(props, ctx) {\n // state\n const instance = getCurrentInstance() as VcComponentInternalInstance\n instance.cesiumClass = 'Primitive'\n usePrimitives(props, ctx, instance)\n\n const name = instance.proxy?.$options.name || ''\n return () =>\n ctx.slots.default\n ? h(\n 'i',\n {\n class: kebabCase(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 VcPrimitiveProps = {\n /**\n * The geometry instances - or a single geometry instance - to render.\n */\n geometryInstances?: Cesium.GeometryInstance | Array<Cesium.GeometryInstance>\n /**\n * The appearance used to render the primitive.\n */\n appearance?: VcAppearance\n /**\n * The appearance used to shade this primitive when it fails the depth test.\n */\n depthFailAppearance?: VcAppearance\n /**\n * Determines if this primitive will be shown.\n * Default value: true\n */\n show?: boolean\n /**\n * The 4x4 transformation matrix that transforms the primitive (all geometry instances) from model to world coordinates.\n */\n modelMatrix?: Cesium.Matrix4\n /**\n * When true, geometry vertices are optimized for the pre and post-vertex-shader caches.\n * Default value: false\n */\n vertexCacheOptimize?: boolean\n /**\n * When true, geometry vertex attributes are interleaved, which can slightly improve rendering performance but increases load time.\n * Default value: false\n */\n interleave?: boolean\n /**\n * When true, the geometry vertices are compressed, which will save memory.\n * Default value: true\n */\n compressVertices?: boolean\n /**\n * When true, the primitive does not keep a reference to the input geometryInstances to save memory.\n * Default value: true\n */\n releaseGeometryInstances?: boolean\n /**\n * When true, each geometry instance will only be pickable with Scene#pick. When false, GPU memory is saved.\n * Default value: true\n */\n allowPicking?: boolean\n /**\n * When true, the renderer frustum culls and horizon culls the primitive's commands based on their bounding volume. Set this to false for a small performance gain if you are manually culling the primitive.\n * Default value: true\n */\n cull?: boolean\n /**\n * Determines if the primitive will be created asynchronously or block until ready.\n * Default value: true\n */\n asynchronous?: boolean\n /**\n * For debugging only. Determines if this primitive's commands' bounding spheres are shown.\n */\n debugShowBoundingVolume?: boolean\n /**\n * Determines whether this primitive casts or receives shadows from light sources.\n */\n shadows?: number\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.Primitive, viewer: Cesium.Viewer, instance: VcComponentPublicInstance) => void\n 'onUpdate:geometryInstances'?: (instances: Array<Cesium.GeometryInstance>) => void\n}\n\nexport interface VcPrimitiveRef extends VcComponentPublicInstance<VcPrimitiveProps> {\n /**\n * private but needed by VcGeometryInstance\n * @param geometryInstance\n * @param index\n */\n __updateGeometryInstances?(geometryInstance: Cesium.GeometryInstance, index: number): boolean\n /**\n * private but needed by VcGeometryInstance\n * @param geometryInstance\n */\n __removeGeometryInstances?(geometryInstance: Cesium.GeometryInstance): boolean\n /**\n * private but needed by VcGeometryInstance\n */\n __childCount?: Ref<number>\n}\n\nexport interface VcPrimitiveSlots {\n /**\n * Slot for vc-geometry-instance.\n */\n default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;;AAqBY,MAAC,cAAc,GAAG;AAC9B,EAAE,GAAG,iBAAiB;AACtB,EAAE,GAAG,UAAU;AACf,EAAE,GAAG,mBAAmB;AAC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