@vesium/shared 1.0.1-beta.26 → 1.0.1-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +58 -1
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.iife.js +12 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +9 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Xiankq <https://github.com/xiankq>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
# @vesium/shared [](https://www.npmjs.com/package/@vesium/shared)
|
|
2
|
+
|
|
3
|
+
> This is an additional library to [Vesium](https://github.com/GeoVueJS/vesium).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<img src="./assets/logo.svg" align="center" width="15%" />
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<h1 align="center">Vesium</h1>
|
|
13
|
+
|
|
14
|
+
<p align="center">Vue component and composition-api library for Cesium.</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://www.npmjs.com/package/@vesium/core" target="__blank"><img src="https://img.shields.io/npm/v/@vesium/core?color=a1b858&label=" alt="NPM version"></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@vesium/core" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@vesium/core?color=50a36f&label="></a>
|
|
19
|
+
<a href="https://github.com/GeoVueJS/vesium" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/GeoVueJS/vesium?style=social"></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
> 🚧 This project is under development, and the API may change frequently.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- 🎯 **Intuitive** - VueUse-style API design, familiar to Vue developers
|
|
27
|
+
- 💪 **Type Strong** - Written in TypeScript, with full TS support
|
|
28
|
+
- 🏪 **Modular** - Tree-shakeable ESM modules
|
|
29
|
+
- 🌐 **Full Featured** - Comprehensive Cesium functionality support
|
|
30
|
+
- 🎮 **Interactive** - Rich interactive capabilities with map elements
|
|
31
|
+
- ⚡️ **Lightweight** - No bloated dependencies
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# npm
|
|
37
|
+
npm i cesium @vueuse/core vesium
|
|
38
|
+
|
|
39
|
+
# yarn
|
|
40
|
+
yarn add cesium @vueuse/core vesium
|
|
41
|
+
|
|
42
|
+
# pnpm
|
|
43
|
+
pnpm add cesium @vueuse/core vesium
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<div ref="cesiumContainer" style="width: 100%; height: 100%" />
|
|
48
|
+
</template>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 🌸 Credits
|
|
52
|
+
|
|
53
|
+
- [VueUse](https://github.com/vueuse/vueuse) - Collection of Vue Composition Utilities
|
|
54
|
+
- [Cesium](https://github.com/CesiumGS/cesium) - An open-source JavaScript library for world-class 3D globes and maps
|
|
55
|
+
|
|
56
|
+
## 📄 License
|
|
57
|
+
|
|
58
|
+
[MIT](./LICENSE) License © 2025 [GeoVueJS](https://github.com/GeoVueJS)
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const cesium = require("cesium");
|
|
4
|
-
const shared = require("@vueuse/shared");
|
|
5
4
|
const toString = Object.prototype.toString;
|
|
6
5
|
function isDef(val) {
|
|
7
6
|
return typeof val !== "undefined";
|
|
@@ -191,6 +190,12 @@ function pickHitGraphic(pick, graphic) {
|
|
|
191
190
|
}
|
|
192
191
|
return elements.some((element) => graphic.includes(element));
|
|
193
192
|
}
|
|
193
|
+
function promiseTimeout(ms) {
|
|
194
|
+
ms < 0 && (ms = 0);
|
|
195
|
+
return new Promise((resolve) => {
|
|
196
|
+
setTimeout(resolve, ms);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
194
199
|
function isProperty(value) {
|
|
195
200
|
return value && isFunction(value.getValue);
|
|
196
201
|
}
|
|
@@ -292,7 +297,7 @@ function throttle(callback, delay = 100, trailing = true, leading = false) {
|
|
|
292
297
|
const restList = [];
|
|
293
298
|
let tracked = false;
|
|
294
299
|
const trigger = async () => {
|
|
295
|
-
await
|
|
300
|
+
await promiseTimeout(delay);
|
|
296
301
|
tracked = false;
|
|
297
302
|
if (leading) {
|
|
298
303
|
try {
|
|
@@ -350,7 +355,7 @@ function toCartographic(position) {
|
|
|
350
355
|
return cesium.Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
|
|
351
356
|
}
|
|
352
357
|
}
|
|
353
|
-
function
|
|
358
|
+
function arrayDiff(list, oldList) {
|
|
354
359
|
const oldListSet = new Set(oldList);
|
|
355
360
|
const added = list.filter((obj) => !oldListSet.has(obj));
|
|
356
361
|
const newListSet = new Set(list);
|
|
@@ -359,7 +364,7 @@ function arrayDifference(list, oldList) {
|
|
|
359
364
|
}
|
|
360
365
|
exports.CesiumMaterial = CesiumMaterial;
|
|
361
366
|
exports.addMaterialCache = addMaterialCache;
|
|
362
|
-
exports.
|
|
367
|
+
exports.arrayDiff = arrayDiff;
|
|
363
368
|
exports.assertError = assertError;
|
|
364
369
|
exports.canvasCoordToCartesian = canvasCoordToCartesian;
|
|
365
370
|
exports.cartesianToCanvasCoord = cartesianToCanvasCoord;
|
|
@@ -386,6 +391,7 @@ exports.isProperty = isProperty;
|
|
|
386
391
|
exports.isString = isString;
|
|
387
392
|
exports.isWindow = isWindow;
|
|
388
393
|
exports.pickHitGraphic = pickHitGraphic;
|
|
394
|
+
exports.promiseTimeout = promiseTimeout;
|
|
389
395
|
exports.resolvePick = resolvePick;
|
|
390
396
|
exports.throttle = throttle;
|
|
391
397
|
exports.toCartesian3 = toCartesian3;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/is.ts","../src/cesiumUtils.ts","../src/convertCoord.ts","../src/toCoord.ts","../src/convertDMS.ts","../src/material.ts","../src/pick.ts","../src/property.ts","../src/throttle.ts","../src/toCartesian3.ts","../src/toCartographic.ts","../src/utils.ts"],"sourcesContent":["import type { AnyFn } from './types';\n\nconst toString = Object.prototype.toString;\n\nexport function isDef<T = any>(val?: T): val is T {\n return typeof val !== 'undefined';\n}\n\nexport function isBoolean(val: any): val is boolean {\n return typeof val === 'boolean';\n}\n\nexport function isFunction<T extends AnyFn>(val: any): val is T {\n return typeof val === 'function';\n}\n\nexport function isNumber(val: any): val is number {\n return typeof val === 'number';\n}\n\nexport function isString(val: unknown): val is string {\n return typeof val === 'string';\n}\n\nexport function isObject(val: any): val is object {\n return toString.call(val) === '[object Object]';\n}\n\nexport function isWindow(val: any): val is Window {\n return typeof window !== 'undefined' && toString.call(val) === '[object Window]';\n}\n\nexport function isPromise<T extends Promise<any>>(val: any): val is T {\n return !!val && (typeof val === 'object' || typeof val === 'function') && typeof (val as any).then === 'function';\n}\n\nexport function isElement<T extends Element>(val: any): val is T {\n return !!(val && val.nodeName && val.nodeType === 1);\n}\n\nexport const isArray = Array.isArray;\n\nexport function isBase64(val: string): boolean {\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking\n const reg = /^\\s*data:([a-z]+\\/[\\d+.a-z-]+(;[a-z-]+=[\\da-z-]+)?)?(;base64)?,([\\s\\w!$%&'()*+,./:;=?@~-]*?)\\s*$/i;\n return reg.test(val);\n}\n\nexport function assertError(condition: boolean, error: any) {\n if (condition) {\n throw new Error(error);\n }\n}\n","import type { MaybeProperty } from './property';\nimport { defined } from 'cesium';\nimport { isFunction } from './is';\n\n/**\n * Determines if two Cesium objects are equal.\n *\n * This function not only judges whether the instances are equal,\n * but also judges the equals method in the example.\n *\n * @param left The first Cesium object\n * @param right The second Cesium object\n * @returns Returns true if the two Cesium objects are equal, otherwise false\n */\nexport function cesiumEquals(left: any, right: any): boolean {\n return left === right || (isFunction(left?.equals) && left.equals(right)) || (isFunction(right?.equals) && right.equals(left));\n}\n\n/**\n * Determines if the Cesium property is a constant.\n *\n * @param value Cesium property\n */\nexport function isCesiumConstant(value: MaybeProperty): boolean {\n return !defined(value) || !!value.isConstant;\n}\n","import type { Cartesian2, Cartesian3, Scene } from 'cesium';\nimport { Ellipsoid } from 'cesium';\n\n/**\n * Convert canvas coordinates to Cartesian coordinates\n *\n * @param canvasCoord Canvas coordinates\n * @param scene Cesium.Scene instance\n * @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'\n *\n * `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.\n * However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur\n *\n * `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,\n * but can be used for picking terrain. If terrain does not exist, the picked elevation is 0\n *\n * `auto`: Automatically determine which picking content to return\n *\n * Calculation speed comparison: globePick > auto >= pickPosition\n */\nexport function canvasCoordToCartesian(\n canvasCoord: Cartesian2,\n scene: Scene,\n mode: 'pickPosition' | 'globePick' | 'auto' = 'auto',\n): Cartesian3 | undefined {\n if (mode === 'pickPosition') {\n return scene.pickPosition(canvasCoord);\n }\n else if (mode === 'globePick') {\n const ray = scene.camera.getPickRay(canvasCoord);\n return ray && scene.globe.pick(ray, scene);\n }\n else {\n // depth test\n if (scene.globe.depthTestAgainstTerrain) {\n return scene.pickPosition(canvasCoord);\n }\n const position1 = scene.pickPosition(canvasCoord);\n const ray = scene.camera.getPickRay(canvasCoord);\n const position2 = ray && scene.globe.pick(ray, scene);\n if (!position1) {\n return position2;\n }\n const height1 = (position1 && Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;\n const height2 = (position2 && Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;\n return height1 < height2 ? position1 : position2;\n }\n}\n\n/**\n * Convert Cartesian coordinates to canvas coordinates\n *\n * @param position Cartesian coordinates\n * @param scene Cesium.Scene instance\n */\nexport function cartesianToCanvasCoord(position: Cartesian3, scene: Scene): Cartesian2 {\n return scene.cartesianToCanvasCoordinates(position);\n}\n","import type { CommonCoord, CoordArray, CoordArray_ALT, CoordObject, CoordObject_ALT } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid, Math } from 'cesium';\n\ninterface ToCoordOptions<T extends 'Array' | 'Object', Alt extends boolean> {\n /**\n * Return type\n * @default 'Array'\n */\n type?: T;\n\n /**\n * Whether to return altitude information\n */\n alt?: Alt;\n\n}\n\nexport type ToCoordReturn<T extends 'Array' | 'Object', Alt extends boolean> =\n T extends 'Array' ?\n Alt extends true ?\n CoordArray_ALT :\n CoordArray\n : Alt extends true ?\n CoordObject_ALT\n : CoordObject;\n\n/**\n * Converts coordinates to an array or object in the specified format.\n *\n * @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.\n * @param options Conversion options, including conversion type and whether to include altitude information.\n * @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.\n *\n * @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.\n * @template Alt Whether to include altitude information, default is false\n */\nexport function toCoord<T extends 'Array' | 'Object' = 'Array', Alt extends boolean = false>(\n position?: CommonCoord,\n options: ToCoordOptions<T, Alt> = {},\n): ToCoordReturn<T, Alt> | undefined {\n if (!position) {\n return undefined;\n }\n\n const { type = 'Array', alt = false } = options;\n\n let longitude: number, latitude: number, height: number | undefined;\n\n if (position instanceof Cartesian3) {\n const cartographic = Ellipsoid.WGS84.cartesianToCartographic(position);\n longitude = Math.toDegrees(cartographic.longitude);\n latitude = Math.toDegrees(cartographic.latitude);\n height = cartographic.height;\n }\n else if (position instanceof Cartographic) {\n const cartographic = position;\n longitude = Math.toDegrees(cartographic.longitude);\n latitude = Math.toDegrees(cartographic.latitude);\n height = cartographic.height;\n }\n else if (Array.isArray(position)) {\n longitude = Math.toDegrees(position[0]);\n latitude = Math.toDegrees(position[1]);\n height = position[2];\n }\n else {\n longitude = (position.longitude);\n latitude = (position.latitude);\n height = (position as any).height;\n }\n\n if (type === 'Array') {\n return alt ? [longitude, latitude, height] : [longitude, latitude] as any;\n }\n else {\n return alt ? { longitude, latitude, height } : { longitude, latitude } as any;\n }\n}\n","import type { CommonCoord, CoordArray_ALT } from './types';\nimport { toCoord } from './toCoord';\n\nexport type DMSCoord = [longitude: string, latitude: string, height?: number];\n\n/**\n * Convert degrees to DMS (Degrees Minutes Seconds) format string\n *\n * @param degrees The angle value\n * @param precision The number of decimal places to retain for the seconds, defaults to 3\n * @returns A DMS formatted string in the format: degrees° minutes′ seconds″\n */\nexport function dmsEncode(degrees: number, precision = 3): string {\n const str = `${degrees}`;\n let i = str.indexOf('.');\n const d = i < 0 ? str : str.slice(0, Math.max(0, i));\n let m = '0';\n let s = '0';\n if (i > 0) {\n m = `0${str.slice(Math.max(0, i))}`;\n m = `${+m * 60}`;\n i = m.indexOf('.');\n if (i > 0) {\n s = `0${m.slice(Math.max(0, i))}`;\n m = m.slice(0, Math.max(0, i));\n s = `${+s * 60}`;\n i = s.indexOf('.');\n s = s.slice(0, Math.max(0, i + 4));\n s = (+s).toFixed(precision);\n }\n }\n return `${Math.abs(+d)}°${+m}′${+s}″`;\n}\n\n/**\n * Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value\n *\n * @param dmsCode DMS formatted string, e.g. \"120°30′45″N\"\n * @returns The decoded decimal angle value, or 0 if decoding fails\n */\nexport function dmsDecode(dmsCode: string) {\n const [dd, msStr] = dmsCode.split('°') ?? [];\n const [mm, sStr] = msStr?.split('′') ?? [];\n const ss = sStr?.split('″')[0];\n\n const d = Number(dd) || 0;\n const m = (Number(mm) || 0) / 60;\n const s = (Number(ss) || 0) / 60 / 60;\n const degrees = d + m + s;\n if (degrees === 0) {\n return 0;\n }\n else {\n let res = degrees;\n // South, West are negative numbers\n if (['W', 'w', 'S', 's'].includes(dmsCode[dmsCode.length - 1]!)) {\n res = -res;\n }\n return res;\n }\n}\n\n/**\n * Convert latitude and longitude coordinates to degrees-minutes-seconds format\n *\n * @param position The latitude and longitude coordinates\n * @param precision The number of decimal places to retain for 'seconds', default is 3\n * @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails\n */\nexport function degreesToDms(position: CommonCoord, precision = 3): DMSCoord | undefined {\n const coord = toCoord(position, { alt: true });\n if (!coord) {\n return;\n }\n const [longitude, latitude, height] = coord;\n const x = dmsEncode(longitude, precision);\n const y = dmsEncode(latitude, precision);\n return [`${x}${longitude > 0 ? 'E' : 'W'}`, `${y}${latitude > 0 ? 'N' : 'S'}`, height];\n}\n\n/**\n * Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates\n *\n * @param dms The latitude or longitude coordinate in DMS format\n * @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails\n */\nexport function dmsToDegrees(dms: DMSCoord): CoordArray_ALT | undefined {\n const [x, y, height] = dms;\n const longitude = dmsDecode(x);\n const latitude = dmsDecode(y);\n return [longitude, latitude, (Number(height)) || 0];\n}\n","import type { Event, JulianDate, MaterialProperty, TextureMagnificationFilter, TextureMinificationFilter } from 'cesium';\n\nimport { Material } from 'cesium';\n\n/**\n * Cesium.Material.fabric参数\n */\nexport interface CesiumMaterialFabricOptions<U> {\n /**\n * 用于声明 fabric 对象最终会生成什么材质,如果是官方内置的,直接用官方内置的,否则则创建自定义的材质并缓存。\n */\n type: string;\n /**\n * 可再塞进去一层子级的 fabric,构成复合材质\n */\n materials?: Material;\n /**\n * glsl代码\n */\n source?: string;\n components?: {\n diffuse?: string;\n alpha?: string;\n };\n /**\n * 传glsl代码的变量\n */\n uniforms?: U & Record<string, any>;\n}\n\n/**\n * Cesium.Material参数\n */\nexport interface CesiumMaterialConstructorOptions<U> {\n /**\n * 严格模式\n */\n strict?: boolean;\n /**\n * translucent\n */\n translucent?: boolean | ((...params: any[]) => any);\n /**\n * 缩小滤镜\n */\n minificationFilter?: TextureMinificationFilter;\n /**\n * 放大滤镜\n */\n magnificationFilter?: TextureMagnificationFilter;\n /**\n * 矩阵配置\n */\n fabric: CesiumMaterialFabricOptions<U>;\n}\n\n/**\n * 仅作为`Cesium.Material`的类型修复\n */\nexport class CesiumMaterial<U> extends Material {\n constructor(options: CesiumMaterialConstructorOptions<U>) {\n super(options);\n }\n\n /**\n * 矩阵配置\n */\n declare fabric: CesiumMaterialFabricOptions<U>;\n}\n\n/**\n * 仅作为`Cesium.MaterialProperty`的类型修复\n */\nexport interface CesiumMaterialProperty<V> extends MaterialProperty {\n get isConstant(): boolean;\n\n get definitionChanged(): Event<(scope: this, field: string, value: any, previous: any) => void>;\n\n getType: (time: JulianDate) => string;\n\n getValue: (time: JulianDate, result?: V) => V;\n\n equals: (other?: any) => boolean;\n}\n\n/**\n * Get material from cache, alias of `Material._materialCache.getMaterial`\n */\nexport function getMaterialCache<T extends Material = CesiumMaterial<any>>(type: string): T | undefined {\n return (Material as any)._materialCache.getMaterial(type);\n}\n\n/**\n * Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`\n */\nexport function addMaterialCache(type: string, material: CesiumMaterialConstructorOptions<any>): void {\n return (Material as any)._materialCache.addMaterial(type, material);\n}\n","/**\n * Analyze the result of Cesium's `scene.pick` and convert it to an array format\n */\nexport function resolvePick(pick: any = {}): any[] {\n const { primitive, id, primitiveCollection, collection } = pick;\n const entityCollection = (id && id.entityCollection) || null;\n const dataSource = (entityCollection && entityCollection.owner) || null;\n const ids = Array.isArray(id) ? id : [id].filter(Boolean); // When aggregating entities, ensure id is an array and filter out falsy values\n return [\n ...ids,\n primitive,\n primitiveCollection,\n collection,\n entityCollection,\n dataSource,\n ].filter(e => !!e);\n}\n\n/**\n * Determine if the given array of graphics is hit by Cesium's `scene.pick`\n *\n * @param pick The `scene.pick` object used for matching\n * @param graphic An array of graphics to check for hits\n */\nexport function pickHitGraphic(pick: any, graphic: any | any[]): boolean {\n if (!Array.isArray(graphic) || !graphic.length) {\n return false;\n }\n const elements = resolvePick(pick);\n if (!elements.length) {\n return false;\n }\n return elements.some(element => graphic.includes(element));\n}\n","import type { Event, JulianDate, Property } from 'cesium';\nimport { CallbackProperty, ConstantProperty, defined } from 'cesium';\nimport { isFunction } from './is';\n\nexport type MaybeProperty<T = any> = T | { getValue: (time?: JulianDate) => T };\n\nexport type MaybePropertyOrGetter<T = any> = MaybeProperty<T> | (() => T);\n\n/**\n * Is Cesium.Property\n * @param value - The target object\n */\nexport function isProperty(value: any): value is Property {\n return value && isFunction(value.getValue);\n}\n\n/**\n * Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation\n * ```typescript\n * toPropertyValue('val') //=> 'val'\n * toPropertyValue(new ConstantProperty('val')) //=> 'val'\n * toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'\n * ```\n *\n * @param value - The value to convert\n */\nexport function toPropertyValue<T = unknown>(value: MaybeProperty<T>, time?: JulianDate): T {\n return isProperty(value) ? value.getValue(time as any) : value;\n}\n\nexport type PropertyCallback<T = any> = (time: JulianDate, result?: T) => T;\n\n/**\n * Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation\n *\n * @param value - The property value or getter to convert, can be undefined or null\n * @param isConstant - The second parameter for converting to CallbackProperty\n * @returns Returns the converted Property object, if value is undefined or null, returns undefined\n */\nexport function toProperty<T>(value?: MaybePropertyOrGetter<T>, isConstant = false): Property {\n return isProperty(value)\n ? value\n : isFunction(value)\n ? (new CallbackProperty(value, isConstant) as any)\n : new ConstantProperty(value);\n}\n\n/**\n * Create a Cesium property key\n *\n * @param scope The host object\n * @param field The property name\n * @param maybeProperty Optional property or getter\n * @param readonly Whether the property is read-only\n */\nexport function createPropertyField<T>(\n scope: any,\n field: string,\n maybeProperty?: MaybePropertyOrGetter<T>,\n readonly?: boolean,\n) {\n let removeOwnerListener: VoidFunction | undefined;\n // 自身内部变化时也触发载体的`definitionChanged`\n // Trigger the carrier's `definitionChanged` when its own internal state changes\n const ownerBinding = (value: any) => {\n removeOwnerListener?.();\n if (defined(value?.definitionChanged)) {\n removeOwnerListener = value?.definitionChanged?.addEventListener(() => {\n scope.definitionChanged.raiseEvent(scope, field, value, value);\n });\n }\n };\n\n const privateField = `_${field}`;\n const property = toProperty(maybeProperty);\n scope[privateField] = property;\n ownerBinding(property);\n\n if (readonly) {\n Object.defineProperty(scope, field, {\n get() {\n return scope[privateField];\n },\n });\n }\n else {\n Object.defineProperty(scope, field, {\n get() {\n return scope[privateField];\n },\n set(value) {\n const previous = scope[privateField];\n if (scope[privateField] !== value) {\n scope[privateField] = value;\n ownerBinding(value);\n if (defined(scope.definitionChanged)) {\n scope.definitionChanged.raiseEvent(scope, field, value, previous);\n }\n }\n },\n });\n }\n}\n\nexport interface CreateCesiumAttributeOptions {\n readonly?: boolean;\n toProperty?: boolean;\n /**\n * The event name that triggers the change\n * @default 'definitionChanged'\n */\n changedEventKey?: string;\n\n shallowClone?: boolean;\n}\n\nexport function createCesiumAttribute<Scope extends object>(\n scope: Scope,\n key: keyof Scope,\n value: any,\n options: CreateCesiumAttributeOptions = {},\n) {\n const allowToProperty = !!options.toProperty;\n const shallowClone = !!options.shallowClone;\n const changedEventKey = options.changedEventKey || 'definitionChanged';\n const changedEvent = Reflect.get(scope, changedEventKey) as Event;\n const privateKey = `_${String(key)}`;\n const attribute = allowToProperty ? toProperty(value) : value;\n Reflect.set(scope, privateKey, attribute);\n\n const obj: any = {\n get() {\n const value = Reflect.get(scope, privateKey);\n if (shallowClone) {\n return Array.isArray(value) ? [...value] : { ...value };\n }\n else {\n return value;\n }\n },\n };\n\n let previousListener: VoidFunction | undefined;\n\n const serial = (property: Property, previous?: any) => {\n previousListener?.();\n previousListener = property?.definitionChanged?.addEventListener(() => {\n changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);\n });\n };\n\n if (!options.readonly) {\n // 初始化是父子级绑定监听\n if (allowToProperty && isProperty(value)) {\n serial(value);\n }\n\n obj.set = (value: any) => {\n if (allowToProperty && !isProperty(value)) {\n throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);\n }\n const previous = Reflect.get(scope, privateKey);\n\n if (previous !== value) {\n Reflect.set(scope, privateKey, value);\n changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value, previous);\n if (allowToProperty) {\n // 重新绑定监听\n serial(value);\n }\n }\n };\n }\n\n Object.defineProperty(scope, key, obj);\n}\n\nexport interface CreateCesiumPropertyOptions {\n readonly?: boolean;\n /**\n * The event name that triggers the change\n * @default 'definitionChanged'\n */\n changedEventKey?: string;\n}\nexport function createCesiumProperty<Scope extends object>(\n scope: Scope,\n key: keyof Scope,\n value: any,\n options: CreateCesiumPropertyOptions = {},\n) {\n return createCesiumAttribute(scope, key, value, { ...options, toProperty: true });\n}\n","import { promiseTimeout } from '@vueuse/shared';\n\nexport type ThrottleCallback<T extends any[]> = (...rest: T) => void;\n\n/**\n * Throttle function, which limits the frequency of execution of the function\n *\n * @param callback raw function\n * @param delay Throttled delay duration (ms)\n * @param trailing Trigger callback function after last call @default true\n * @param leading Trigger the callback function immediately on the first call @default false\n * @returns Throttle function\n */\nexport function throttle<T extends any[]>(\n callback: ThrottleCallback<T>,\n delay = 100,\n trailing = true,\n leading = false,\n): ThrottleCallback<T> {\n const restList: T[] = [];\n let tracked = false;\n const trigger = async () => {\n await promiseTimeout(delay);\n tracked = false;\n if (leading) {\n try {\n callback(...restList[0]);\n }\n catch (error) {\n console.error(error);\n }\n }\n if (trailing && (!leading || restList.length > 1)) {\n try {\n callback(...restList[restList.length - 1]!);\n }\n catch (error) {\n console.error(error);\n }\n }\n restList.length = 0;\n };\n\n return (...rest: T) => {\n if (restList.length < 2) {\n restList.push(rest);\n }\n else {\n restList[1] = rest;\n }\n\n if (!tracked) {\n tracked = true;\n trigger();\n }\n };\n}\n","import type { CommonCoord } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid } from 'cesium';\n\n/**\n * Converts position to a coordinate point in the Cartesian coordinate system\n *\n * @param position Position information, which can be a Cartesian coordinate point (Cartesian3), a geographic coordinate point (Cartographic), an array, or an object containing WGS84 latitude, longitude, and height information\n * @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned\n */\nexport function toCartesian3(position?: CommonCoord): Cartesian3 | undefined {\n if (!position) {\n return undefined;\n }\n if (position instanceof Cartesian3) {\n return position.clone();\n }\n else if (position instanceof Cartographic) {\n return Ellipsoid.WGS84.cartographicToCartesian(position);\n }\n else if (Array.isArray(position)) {\n return Cartesian3.fromDegrees(position[0], position[1], position[2]);\n }\n else {\n return Cartesian3.fromDegrees(position.longitude, position.latitude, (position as any).height);\n }\n}\n","import type { CommonCoord } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid } from 'cesium';\n\n/**\n * Converts a position to a Cartographic coordinate point\n *\n * @param position Position information, which can be a Cartesian3 coordinate point, a Cartographic coordinate point, an array, or an object containing WGS84 longitude, latitude, and height information\n * @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid\n */\nexport function toCartographic(position?: CommonCoord): Cartographic | undefined {\n if (!position) {\n return undefined;\n }\n if (position instanceof Cartesian3) {\n return Ellipsoid.WGS84.cartesianToCartographic(position);\n }\n else if (position instanceof Cartographic) {\n return position.clone();\n }\n else if (Array.isArray(position)) {\n return Cartographic.fromDegrees(position[0], position[1], position[2]);\n }\n else {\n return Cartographic.fromDegrees(position.longitude, position.latitude, (position as any).height);\n }\n}\n","export interface ArrayDifferenceRetrun<T> {\n added: T[];\n removed: T[];\n}\n\n/**\n * 计算两个数组的差异,返回新增和删除的元素\n */\nexport function arrayDifference<T>(\n list: T[],\n oldList: T[] | undefined,\n): ArrayDifferenceRetrun<T> {\n const oldListSet = new Set(oldList);\n const added: T[] = list.filter(obj => !oldListSet.has(obj));\n const newListSet = new Set(list);\n const removed = oldList?.filter(obj => !newListSet.has(obj)) ?? [];\n return { added, removed };\n}\n"],"names":["defined","Ellipsoid","Cartesian3","Math","Cartographic","Material","CallbackProperty","ConstantProperty","value","promiseTimeout"],"mappings":";;;;AAEA,MAAM,WAAW,OAAO,UAAU;AAE3B,SAAS,MAAe,KAAmB;AAChD,SAAO,OAAO,QAAQ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WAAOA,oBAAa,YAAY,SAAS,WAAW,SAAS,UAAW,SAAiB,MAAM;AAAA,EAAA;AAEnG;ACjBgB,SAAA,gBACd,MACA,SAC0B;AACpB,QAAA,aAAa,IAAI,IAAI,OAAO;AAC5B,QAAA,QAAa,KAAK,OAAO,CAAA,QAAO,CAAC,WAAW,IAAI,GAAG,CAAC;AACpD,QAAA,aAAa,IAAI,IAAI,IAAI;AACzB,QAAA,WAAU,mCAAS,OAAO,CAAO,QAAA,CAAC,WAAW,IAAI,GAAG,OAAM,CAAC;AAC1D,SAAA,EAAE,OAAO,QAAQ;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/is.ts","../src/cesiumUtils.ts","../src/convertCoord.ts","../src/toCoord.ts","../src/convertDMS.ts","../src/material.ts","../src/pick.ts","../src/promiseTimeout.ts","../src/property.ts","../src/throttle.ts","../src/toCartesian3.ts","../src/toCartographic.ts","../src/utils.ts"],"sourcesContent":["import type { AnyFn } from './types';\n\nconst toString = Object.prototype.toString;\n\nexport function isDef<T = any>(val?: T): val is T {\n return typeof val !== 'undefined';\n}\n\nexport function isBoolean(val: any): val is boolean {\n return typeof val === 'boolean';\n}\n\nexport function isFunction<T extends AnyFn>(val: any): val is T {\n return typeof val === 'function';\n}\n\nexport function isNumber(val: any): val is number {\n return typeof val === 'number';\n}\n\nexport function isString(val: unknown): val is string {\n return typeof val === 'string';\n}\n\nexport function isObject(val: any): val is object {\n return toString.call(val) === '[object Object]';\n}\n\nexport function isWindow(val: any): val is Window {\n return typeof window !== 'undefined' && toString.call(val) === '[object Window]';\n}\n\nexport function isPromise<T extends Promise<any>>(val: any): val is T {\n return !!val && (typeof val === 'object' || typeof val === 'function') && typeof (val as any).then === 'function';\n}\n\nexport function isElement<T extends Element>(val: any): val is T {\n return !!(val && val.nodeName && val.nodeType === 1);\n}\n\nexport const isArray = Array.isArray;\n\nexport function isBase64(val: string): boolean {\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking\n const reg = /^\\s*data:([a-z]+\\/[\\d+.a-z-]+(;[a-z-]+=[\\da-z-]+)?)?(;base64)?,([\\s\\w!$%&'()*+,./:;=?@~-]*?)\\s*$/i;\n return reg.test(val);\n}\n\nexport function assertError(condition: boolean, error: any) {\n if (condition) {\n throw new Error(error);\n }\n}\n","import type { MaybeProperty } from './property';\nimport { defined } from 'cesium';\nimport { isFunction } from './is';\n\n/**\n * Determines if two Cesium objects are equal.\n *\n * This function not only judges whether the instances are equal,\n * but also judges the equals method in the example.\n *\n * @param left The first Cesium object\n * @param right The second Cesium object\n * @returns Returns true if the two Cesium objects are equal, otherwise false\n */\nexport function cesiumEquals(left: any, right: any): boolean {\n return left === right || (isFunction(left?.equals) && left.equals(right)) || (isFunction(right?.equals) && right.equals(left));\n}\n\n/**\n * Determines if the Cesium property is a constant.\n *\n * @param value Cesium property\n */\nexport function isCesiumConstant(value: MaybeProperty): boolean {\n return !defined(value) || !!value.isConstant;\n}\n","import type { Cartesian2, Cartesian3, Scene } from 'cesium';\nimport { Ellipsoid } from 'cesium';\n\n/**\n * Convert canvas coordinates to Cartesian coordinates\n *\n * @param canvasCoord Canvas coordinates\n * @param scene Cesium.Scene instance\n * @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'\n *\n * `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.\n * However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur\n *\n * `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,\n * but can be used for picking terrain. If terrain does not exist, the picked elevation is 0\n *\n * `auto`: Automatically determine which picking content to return\n *\n * Calculation speed comparison: globePick > auto >= pickPosition\n */\nexport function canvasCoordToCartesian(\n canvasCoord: Cartesian2,\n scene: Scene,\n mode: 'pickPosition' | 'globePick' | 'auto' = 'auto',\n): Cartesian3 | undefined {\n if (mode === 'pickPosition') {\n return scene.pickPosition(canvasCoord);\n }\n else if (mode === 'globePick') {\n const ray = scene.camera.getPickRay(canvasCoord);\n return ray && scene.globe.pick(ray, scene);\n }\n else {\n // depth test\n if (scene.globe.depthTestAgainstTerrain) {\n return scene.pickPosition(canvasCoord);\n }\n const position1 = scene.pickPosition(canvasCoord);\n const ray = scene.camera.getPickRay(canvasCoord);\n const position2 = ray && scene.globe.pick(ray, scene);\n if (!position1) {\n return position2;\n }\n const height1 = (position1 && Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;\n const height2 = (position2 && Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;\n return height1 < height2 ? position1 : position2;\n }\n}\n\n/**\n * Convert Cartesian coordinates to canvas coordinates\n *\n * @param position Cartesian coordinates\n * @param scene Cesium.Scene instance\n */\nexport function cartesianToCanvasCoord(position: Cartesian3, scene: Scene): Cartesian2 {\n return scene.cartesianToCanvasCoordinates(position);\n}\n","import type { CommonCoord, CoordArray, CoordArray_ALT, CoordObject, CoordObject_ALT } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid, Math } from 'cesium';\n\ninterface ToCoordOptions<T extends 'Array' | 'Object', Alt extends boolean> {\n /**\n * Return type\n * @default 'Array'\n */\n type?: T;\n\n /**\n * Whether to return altitude information\n */\n alt?: Alt;\n\n}\n\nexport type ToCoordReturn<T extends 'Array' | 'Object', Alt extends boolean> =\n T extends 'Array' ?\n Alt extends true ?\n CoordArray_ALT :\n CoordArray\n : Alt extends true ?\n CoordObject_ALT\n : CoordObject;\n\n/**\n * Converts coordinates to an array or object in the specified format.\n *\n * @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.\n * @param options Conversion options, including conversion type and whether to include altitude information.\n * @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.\n *\n * @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.\n * @template Alt Whether to include altitude information, default is false\n */\nexport function toCoord<T extends 'Array' | 'Object' = 'Array', Alt extends boolean = false>(\n position?: CommonCoord,\n options: ToCoordOptions<T, Alt> = {},\n): ToCoordReturn<T, Alt> | undefined {\n if (!position) {\n return undefined;\n }\n\n const { type = 'Array', alt = false } = options;\n\n let longitude: number, latitude: number, height: number | undefined;\n\n if (position instanceof Cartesian3) {\n const cartographic = Ellipsoid.WGS84.cartesianToCartographic(position);\n longitude = Math.toDegrees(cartographic.longitude);\n latitude = Math.toDegrees(cartographic.latitude);\n height = cartographic.height;\n }\n else if (position instanceof Cartographic) {\n const cartographic = position;\n longitude = Math.toDegrees(cartographic.longitude);\n latitude = Math.toDegrees(cartographic.latitude);\n height = cartographic.height;\n }\n else if (Array.isArray(position)) {\n longitude = Math.toDegrees(position[0]);\n latitude = Math.toDegrees(position[1]);\n height = position[2];\n }\n else {\n longitude = (position.longitude);\n latitude = (position.latitude);\n height = (position as any).height;\n }\n\n if (type === 'Array') {\n return alt ? [longitude, latitude, height] : [longitude, latitude] as any;\n }\n else {\n return alt ? { longitude, latitude, height } : { longitude, latitude } as any;\n }\n}\n","import type { CommonCoord, CoordArray_ALT } from './types';\nimport { toCoord } from './toCoord';\n\nexport type DMSCoord = [longitude: string, latitude: string, height?: number];\n\n/**\n * Convert degrees to DMS (Degrees Minutes Seconds) format string\n *\n * @param degrees The angle value\n * @param precision The number of decimal places to retain for the seconds, defaults to 3\n * @returns A DMS formatted string in the format: degrees° minutes′ seconds″\n */\nexport function dmsEncode(degrees: number, precision = 3): string {\n const str = `${degrees}`;\n let i = str.indexOf('.');\n const d = i < 0 ? str : str.slice(0, Math.max(0, i));\n let m = '0';\n let s = '0';\n if (i > 0) {\n m = `0${str.slice(Math.max(0, i))}`;\n m = `${+m * 60}`;\n i = m.indexOf('.');\n if (i > 0) {\n s = `0${m.slice(Math.max(0, i))}`;\n m = m.slice(0, Math.max(0, i));\n s = `${+s * 60}`;\n i = s.indexOf('.');\n s = s.slice(0, Math.max(0, i + 4));\n s = (+s).toFixed(precision);\n }\n }\n return `${Math.abs(+d)}°${+m}′${+s}″`;\n}\n\n/**\n * Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value\n *\n * @param dmsCode DMS formatted string, e.g. \"120°30′45″N\"\n * @returns The decoded decimal angle value, or 0 if decoding fails\n */\nexport function dmsDecode(dmsCode: string) {\n const [dd, msStr] = dmsCode.split('°') ?? [];\n const [mm, sStr] = msStr?.split('′') ?? [];\n const ss = sStr?.split('″')[0];\n\n const d = Number(dd) || 0;\n const m = (Number(mm) || 0) / 60;\n const s = (Number(ss) || 0) / 60 / 60;\n const degrees = d + m + s;\n if (degrees === 0) {\n return 0;\n }\n else {\n let res = degrees;\n // South, West are negative numbers\n if (['W', 'w', 'S', 's'].includes(dmsCode[dmsCode.length - 1]!)) {\n res = -res;\n }\n return res;\n }\n}\n\n/**\n * Convert latitude and longitude coordinates to degrees-minutes-seconds format\n *\n * @param position The latitude and longitude coordinates\n * @param precision The number of decimal places to retain for 'seconds', default is 3\n * @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails\n */\nexport function degreesToDms(position: CommonCoord, precision = 3): DMSCoord | undefined {\n const coord = toCoord(position, { alt: true });\n if (!coord) {\n return;\n }\n const [longitude, latitude, height] = coord;\n const x = dmsEncode(longitude, precision);\n const y = dmsEncode(latitude, precision);\n return [`${x}${longitude > 0 ? 'E' : 'W'}`, `${y}${latitude > 0 ? 'N' : 'S'}`, height];\n}\n\n/**\n * Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates\n *\n * @param dms The latitude or longitude coordinate in DMS format\n * @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails\n */\nexport function dmsToDegrees(dms: DMSCoord): CoordArray_ALT | undefined {\n const [x, y, height] = dms;\n const longitude = dmsDecode(x);\n const latitude = dmsDecode(y);\n return [longitude, latitude, (Number(height)) || 0];\n}\n","import type { Event, JulianDate, MaterialProperty, TextureMagnificationFilter, TextureMinificationFilter } from 'cesium';\n\nimport { Material } from 'cesium';\n\n/**\n * Cesium.Material.fabric parameters\n */\nexport interface CesiumMaterialFabricOptions<U> {\n /**\n * Used to declare what material the fabric object will ultimately generate. If it's an official built-in one, use the official built-in one directly; otherwise, create a custom material and cache it.\n */\n type: string;\n /**\n * Can nest another level of child fabric to form a composite material\n */\n materials?: Material;\n /**\n * glsl code\n */\n source?: string;\n components?: {\n diffuse?: string;\n alpha?: string;\n };\n /**\n * Pass variables to glsl code\n */\n uniforms?: U & Record<string, any>;\n}\n\n/**\n * Cesium.Material parameters\n */\nexport interface CesiumMaterialConstructorOptions<U> {\n /**\n * Strict mode\n */\n strict?: boolean;\n /**\n * translucent\n */\n translucent?: boolean | ((...params: any[]) => any);\n /**\n * Minification filter\n */\n minificationFilter?: TextureMinificationFilter;\n /**\n * Magnification filter\n */\n magnificationFilter?: TextureMagnificationFilter;\n /**\n * Matrix configuration\n */\n fabric: CesiumMaterialFabricOptions<U>;\n}\n\n/**\n * Only as a type fix for `Cesium.Material`\n */\nexport class CesiumMaterial<U> extends Material {\n constructor(options: CesiumMaterialConstructorOptions<U>) {\n super(options);\n }\n\n /**\n * Matrix configuration\n */\n declare fabric: CesiumMaterialFabricOptions<U>;\n}\n\n/**\n * Only as a type fix for `Cesium.MaterialProperty`\n */\nexport interface CesiumMaterialProperty<V> extends MaterialProperty {\n get isConstant(): boolean;\n\n get definitionChanged(): Event<(scope: this, field: string, value: any, previous: any) => void>;\n\n getType: (time: JulianDate) => string;\n\n getValue: (time: JulianDate, result?: V) => V;\n\n equals: (other?: any) => boolean;\n}\n\n/**\n * Get material from cache, alias of `Material._materialCache.getMaterial`\n */\nexport function getMaterialCache<T extends Material = CesiumMaterial<any>>(type: string): T | undefined {\n return (Material as any)._materialCache.getMaterial(type);\n}\n\n/**\n * Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`\n */\nexport function addMaterialCache(type: string, material: CesiumMaterialConstructorOptions<any>): void {\n return (Material as any)._materialCache.addMaterial(type, material);\n}\n","/**\n * Analyze the result of Cesium's `scene.pick` and convert it to an array format\n */\nexport function resolvePick(pick: any = {}): any[] {\n const { primitive, id, primitiveCollection, collection } = pick;\n const entityCollection = (id && id.entityCollection) || null;\n const dataSource = (entityCollection && entityCollection.owner) || null;\n const ids = Array.isArray(id) ? id : [id].filter(Boolean); // When aggregating entities, ensure id is an array and filter out falsy values\n return [\n ...ids,\n primitive,\n primitiveCollection,\n collection,\n entityCollection,\n dataSource,\n ].filter(e => !!e);\n}\n\n/**\n * Determine if the given array of graphics is hit by Cesium's `scene.pick`\n *\n * @param pick The `scene.pick` object used for matching\n * @param graphic An array of graphics to check for hits\n */\nexport function pickHitGraphic(pick: any, graphic: any | any[]): boolean {\n if (!Array.isArray(graphic) || !graphic.length) {\n return false;\n }\n const elements = resolvePick(pick);\n if (!elements.length) {\n return false;\n }\n return elements.some(element => graphic.includes(element));\n}\n","/**\n * 使用将setTimeout转换成Promise\n */\nexport function promiseTimeout(ms: number): Promise<void> {\n ms < 0 && (ms = 0);\n return new Promise<void>((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n","import type { Event, JulianDate, Property } from 'cesium';\nimport { CallbackProperty, ConstantProperty, defined } from 'cesium';\nimport { isFunction } from './is';\n\nexport type MaybeProperty<T = any> = T | { getValue: (time?: JulianDate) => T };\n\nexport type MaybePropertyOrGetter<T = any> = MaybeProperty<T> | (() => T);\n\n/**\n * Is Cesium.Property\n * @param value - The target object\n */\nexport function isProperty(value: any): value is Property {\n return value && isFunction(value.getValue);\n}\n\n/**\n * Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation\n * ```typescript\n * toPropertyValue('val') //=> 'val'\n * toPropertyValue(new ConstantProperty('val')) //=> 'val'\n * toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'\n * ```\n *\n * @param value - The value to convert\n */\nexport function toPropertyValue<T = unknown>(value: MaybeProperty<T>, time?: JulianDate): T {\n return isProperty(value) ? value.getValue(time as any) : value;\n}\n\nexport type PropertyCallback<T = any> = (time: JulianDate, result?: T) => T;\n\n/**\n * Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation\n *\n * @param value - The property value or getter to convert, can be undefined or null\n * @param isConstant - The second parameter for converting to CallbackProperty\n * @returns Returns the converted Property object, if value is undefined or null, returns undefined\n */\nexport function toProperty<T>(value?: MaybePropertyOrGetter<T>, isConstant = false): Property {\n return isProperty(value)\n ? value\n : isFunction(value)\n ? (new CallbackProperty(value, isConstant) as any)\n : new ConstantProperty(value);\n}\n\n/**\n * Create a Cesium property key\n *\n * @param scope The host object\n * @param field The property name\n * @param maybeProperty Optional property or getter\n * @param readonly Whether the property is read-only\n */\nexport function createPropertyField<T>(\n scope: any,\n field: string,\n maybeProperty?: MaybePropertyOrGetter<T>,\n readonly?: boolean,\n) {\n let removeOwnerListener: VoidFunction | undefined;\n // 自身内部变化时也触发载体的`definitionChanged`\n // Trigger the carrier's `definitionChanged` when its own internal state changes\n const ownerBinding = (value: any) => {\n removeOwnerListener?.();\n if (defined(value?.definitionChanged)) {\n removeOwnerListener = value?.definitionChanged?.addEventListener(() => {\n scope.definitionChanged.raiseEvent(scope, field, value, value);\n });\n }\n };\n\n const privateField = `_${field}`;\n const property = toProperty(maybeProperty);\n scope[privateField] = property;\n ownerBinding(property);\n\n if (readonly) {\n Object.defineProperty(scope, field, {\n get() {\n return scope[privateField];\n },\n });\n }\n else {\n Object.defineProperty(scope, field, {\n get() {\n return scope[privateField];\n },\n set(value) {\n const previous = scope[privateField];\n if (scope[privateField] !== value) {\n scope[privateField] = value;\n ownerBinding(value);\n if (defined(scope.definitionChanged)) {\n scope.definitionChanged.raiseEvent(scope, field, value, previous);\n }\n }\n },\n });\n }\n}\n\nexport interface CreateCesiumAttributeOptions {\n readonly?: boolean;\n toProperty?: boolean;\n /**\n * The event name that triggers the change\n * @default 'definitionChanged'\n */\n changedEventKey?: string;\n\n shallowClone?: boolean;\n}\n\nexport function createCesiumAttribute<Scope extends object>(\n scope: Scope,\n key: keyof Scope,\n value: any,\n options: CreateCesiumAttributeOptions = {},\n) {\n const allowToProperty = !!options.toProperty;\n const shallowClone = !!options.shallowClone;\n const changedEventKey = options.changedEventKey || 'definitionChanged';\n const changedEvent = Reflect.get(scope, changedEventKey) as Event;\n const privateKey = `_${String(key)}`;\n const attribute = allowToProperty ? toProperty(value) : value;\n Reflect.set(scope, privateKey, attribute);\n\n const obj: any = {\n get() {\n const value = Reflect.get(scope, privateKey);\n if (shallowClone) {\n return Array.isArray(value) ? [...value] : { ...value };\n }\n else {\n return value;\n }\n },\n };\n\n let previousListener: VoidFunction | undefined;\n\n const serial = (property: Property, previous?: any) => {\n previousListener?.();\n previousListener = property?.definitionChanged?.addEventListener(() => {\n changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);\n });\n };\n\n if (!options.readonly) {\n // 初始化是父子级绑定监听\n if (allowToProperty && isProperty(value)) {\n serial(value);\n }\n\n obj.set = (value: any) => {\n if (allowToProperty && !isProperty(value)) {\n throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);\n }\n const previous = Reflect.get(scope, privateKey);\n\n if (previous !== value) {\n Reflect.set(scope, privateKey, value);\n changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value, previous);\n if (allowToProperty) {\n // 重新绑定监听\n serial(value);\n }\n }\n };\n }\n\n Object.defineProperty(scope, key, obj);\n}\n\nexport interface CreateCesiumPropertyOptions {\n readonly?: boolean;\n /**\n * The event name that triggers the change\n * @default 'definitionChanged'\n */\n changedEventKey?: string;\n}\nexport function createCesiumProperty<Scope extends object>(\n scope: Scope,\n key: keyof Scope,\n value: any,\n options: CreateCesiumPropertyOptions = {},\n) {\n return createCesiumAttribute(scope, key, value, { ...options, toProperty: true });\n}\n","import { promiseTimeout } from './promiseTimeout';\n\nexport type ThrottleCallback<T extends any[]> = (...rest: T) => void;\n\n/**\n * Throttle function, which limits the frequency of execution of the function\n *\n * @param callback raw function\n * @param delay Throttled delay duration (ms)\n * @param trailing Trigger callback function after last call @default true\n * @param leading Trigger the callback function immediately on the first call @default false\n * @returns Throttle function\n */\nexport function throttle<T extends any[]>(\n callback: ThrottleCallback<T>,\n delay = 100,\n trailing = true,\n leading = false,\n): ThrottleCallback<T> {\n const restList: T[] = [];\n let tracked = false;\n const trigger = async () => {\n await promiseTimeout(delay);\n tracked = false;\n if (leading) {\n try {\n callback(...restList[0]);\n }\n catch (error) {\n console.error(error);\n }\n }\n if (trailing && (!leading || restList.length > 1)) {\n try {\n callback(...restList[restList.length - 1]!);\n }\n catch (error) {\n console.error(error);\n }\n }\n restList.length = 0;\n };\n\n return (...rest: T) => {\n if (restList.length < 2) {\n restList.push(rest);\n }\n else {\n restList[1] = rest;\n }\n\n if (!tracked) {\n tracked = true;\n trigger();\n }\n };\n}\n","import type { CommonCoord } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid } from 'cesium';\n\n/**\n * Converts position to a coordinate point in the Cartesian coordinate system\n *\n * @param position Position information, which can be a Cartesian coordinate point (Cartesian3), a geographic coordinate point (Cartographic), an array, or an object containing WGS84 latitude, longitude, and height information\n * @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned\n */\nexport function toCartesian3(position?: CommonCoord): Cartesian3 | undefined {\n if (!position) {\n return undefined;\n }\n if (position instanceof Cartesian3) {\n return position.clone();\n }\n else if (position instanceof Cartographic) {\n return Ellipsoid.WGS84.cartographicToCartesian(position);\n }\n else if (Array.isArray(position)) {\n return Cartesian3.fromDegrees(position[0], position[1], position[2]);\n }\n else {\n return Cartesian3.fromDegrees(position.longitude, position.latitude, (position as any).height);\n }\n}\n","import type { CommonCoord } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid } from 'cesium';\n\n/**\n * Converts a position to a Cartographic coordinate point\n *\n * @param position Position information, which can be a Cartesian3 coordinate point, a Cartographic coordinate point, an array, or an object containing WGS84 longitude, latitude, and height information\n * @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid\n */\nexport function toCartographic(position?: CommonCoord): Cartographic | undefined {\n if (!position) {\n return undefined;\n }\n if (position instanceof Cartesian3) {\n return Ellipsoid.WGS84.cartesianToCartographic(position);\n }\n else if (position instanceof Cartographic) {\n return position.clone();\n }\n else if (Array.isArray(position)) {\n return Cartographic.fromDegrees(position[0], position[1], position[2]);\n }\n else {\n return Cartographic.fromDegrees(position.longitude, position.latitude, (position as any).height);\n }\n}\n","export interface ArrayDiffRetrun<T> {\n added: T[];\n removed: T[];\n}\n\n/**\n * 计算两个数组的差异,返回新增和删除的元素\n */\nexport function arrayDiff<T>(\n list: T[],\n oldList: T[] | undefined,\n): ArrayDiffRetrun<T> {\n const oldListSet = new Set(oldList);\n const added: T[] = list.filter(obj => !oldListSet.has(obj));\n const newListSet = new Set(list);\n const removed = oldList?.filter(obj => !newListSet.has(obj)) ?? [];\n return { added, removed };\n}\n"],"names":["defined","Ellipsoid","Cartesian3","Math","Cartographic","Material","CallbackProperty","ConstantProperty","value"],"mappings":";;;AAEA,MAAM,WAAW,OAAO,UAAU;AAE3B,SAAS,MAAe,KAAmB;AAChD,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,UAAU,KAA0B;AAClD,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,WAA4B,KAAoB;AAC9D,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,SAAS,KAAyB;AAChD,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,SAAS,KAA6B;AACpD,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,SAAS,KAAyB;AACzC,SAAA,SAAS,KAAK,GAAG,MAAM;AAChC;AAEO,SAAS,SAAS,KAAyB;AAChD,SAAO,OAAO,WAAW,eAAe,SAAS,KAAK,GAAG,MAAM;AACjE;AAEO,SAAS,UAAkC,KAAoB;AAC7D,SAAA,CAAC,CAAC,QAAQ,OAAO,QAAQ,YAAY,OAAO,QAAQ,eAAe,OAAQ,IAAY,SAAS;AACzG;AAEO,SAAS,UAA6B,KAAoB;AAC/D,SAAO,CAAC,EAAE,OAAO,IAAI,YAAY,IAAI,aAAa;AACpD;AAEO,MAAM,U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from 'cesium';
|
|
2
2
|
import { Cartesian3 } from 'cesium';
|
|
3
3
|
import { Cartographic } from 'cesium';
|
|
4
|
-
import { Cesium3DTileset } from 'cesium';
|
|
5
4
|
import { CustomDataSource } from 'cesium';
|
|
6
5
|
import { CzmlDataSource } from 'cesium';
|
|
7
6
|
import { DataSource } from 'cesium';
|
|
@@ -12,8 +11,6 @@ import { JulianDate } from 'cesium';
|
|
|
12
11
|
import { KmlDataSource } from 'cesium';
|
|
13
12
|
import { Material } from 'cesium';
|
|
14
13
|
import { MaterialProperty } from 'cesium';
|
|
15
|
-
import { Primitive } from 'cesium';
|
|
16
|
-
import { PrimitiveCollection } from 'cesium';
|
|
17
14
|
import { Property } from 'cesium';
|
|
18
15
|
import { Scene } from 'cesium';
|
|
19
16
|
import { TextureMagnificationFilter } from 'cesium';
|
|
@@ -31,9 +28,9 @@ export declare type ArgsFn<Args extends any[] = any[], Return = void> = (...args
|
|
|
31
28
|
/**
|
|
32
29
|
* 计算两个数组的差异,返回新增和删除的元素
|
|
33
30
|
*/
|
|
34
|
-
export declare function
|
|
31
|
+
export declare function arrayDiff<T>(list: T[], oldList: T[] | undefined): ArrayDiffRetrun<T>;
|
|
35
32
|
|
|
36
|
-
export declare interface
|
|
33
|
+
export declare interface ArrayDiffRetrun<T> {
|
|
37
34
|
added: T[];
|
|
38
35
|
removed: T[];
|
|
39
36
|
}
|
|
@@ -87,22 +84,22 @@ export declare type CesiumDataSource = DataSource | CustomDataSource | CzmlDataS
|
|
|
87
84
|
export declare function cesiumEquals(left: any, right: any): boolean;
|
|
88
85
|
|
|
89
86
|
/**
|
|
90
|
-
*
|
|
87
|
+
* Only as a type fix for `Cesium.Material`
|
|
91
88
|
*/
|
|
92
89
|
export declare class CesiumMaterial<U> extends Material {
|
|
93
90
|
constructor(options: CesiumMaterialConstructorOptions<U>);
|
|
94
91
|
/**
|
|
95
|
-
*
|
|
92
|
+
* Matrix configuration
|
|
96
93
|
*/
|
|
97
94
|
fabric: CesiumMaterialFabricOptions<U>;
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
/**
|
|
101
|
-
* Cesium.Material
|
|
98
|
+
* Cesium.Material parameters
|
|
102
99
|
*/
|
|
103
100
|
export declare interface CesiumMaterialConstructorOptions<U> {
|
|
104
101
|
/**
|
|
105
|
-
*
|
|
102
|
+
* Strict mode
|
|
106
103
|
*/
|
|
107
104
|
strict?: boolean;
|
|
108
105
|
/**
|
|
@@ -110,33 +107,33 @@ export declare interface CesiumMaterialConstructorOptions<U> {
|
|
|
110
107
|
*/
|
|
111
108
|
translucent?: boolean | ((...params: any[]) => any);
|
|
112
109
|
/**
|
|
113
|
-
*
|
|
110
|
+
* Minification filter
|
|
114
111
|
*/
|
|
115
112
|
minificationFilter?: TextureMinificationFilter;
|
|
116
113
|
/**
|
|
117
|
-
*
|
|
114
|
+
* Magnification filter
|
|
118
115
|
*/
|
|
119
116
|
magnificationFilter?: TextureMagnificationFilter;
|
|
120
117
|
/**
|
|
121
|
-
*
|
|
118
|
+
* Matrix configuration
|
|
122
119
|
*/
|
|
123
120
|
fabric: CesiumMaterialFabricOptions<U>;
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
/**
|
|
127
|
-
* Cesium.Material.fabric
|
|
124
|
+
* Cesium.Material.fabric parameters
|
|
128
125
|
*/
|
|
129
126
|
export declare interface CesiumMaterialFabricOptions<U> {
|
|
130
127
|
/**
|
|
131
|
-
*
|
|
128
|
+
* Used to declare what material the fabric object will ultimately generate. If it's an official built-in one, use the official built-in one directly; otherwise, create a custom material and cache it.
|
|
132
129
|
*/
|
|
133
130
|
type: string;
|
|
134
131
|
/**
|
|
135
|
-
*
|
|
132
|
+
* Can nest another level of child fabric to form a composite material
|
|
136
133
|
*/
|
|
137
134
|
materials?: Material;
|
|
138
135
|
/**
|
|
139
|
-
* glsl
|
|
136
|
+
* glsl code
|
|
140
137
|
*/
|
|
141
138
|
source?: string;
|
|
142
139
|
components?: {
|
|
@@ -144,13 +141,13 @@ export declare interface CesiumMaterialFabricOptions<U> {
|
|
|
144
141
|
alpha?: string;
|
|
145
142
|
};
|
|
146
143
|
/**
|
|
147
|
-
*
|
|
144
|
+
* Pass variables to glsl code
|
|
148
145
|
*/
|
|
149
146
|
uniforms?: U & Record<string, any>;
|
|
150
147
|
}
|
|
151
148
|
|
|
152
149
|
/**
|
|
153
|
-
*
|
|
150
|
+
* Only as a type fix for `Cesium.MaterialProperty`
|
|
154
151
|
*/
|
|
155
152
|
export declare interface CesiumMaterialProperty<V> extends MaterialProperty {
|
|
156
153
|
get isConstant(): boolean;
|
|
@@ -160,8 +157,6 @@ export declare interface CesiumMaterialProperty<V> extends MaterialProperty {
|
|
|
160
157
|
equals: (other?: any) => boolean;
|
|
161
158
|
}
|
|
162
159
|
|
|
163
|
-
export declare type CesiumPrimitive = Primitive | PrimitiveCollection | Cesium3DTileset | any;
|
|
164
|
-
|
|
165
160
|
/**
|
|
166
161
|
* Common Coordinate
|
|
167
162
|
* Can be a Cartesian3 point, a Cartographic point, an array, or an object containing longitude, latitude, and optional height information
|
|
@@ -323,6 +318,11 @@ export declare type Nullable<T> = T | null | undefined;
|
|
|
323
318
|
*/
|
|
324
319
|
export declare function pickHitGraphic(pick: any, graphic: any | any[]): boolean;
|
|
325
320
|
|
|
321
|
+
/**
|
|
322
|
+
* 使用将setTimeout转换成Promise
|
|
323
|
+
*/
|
|
324
|
+
export declare function promiseTimeout(ms: number): Promise<void>;
|
|
325
|
+
|
|
326
326
|
export declare type PropertyCallback<T = any> = (time: JulianDate, result?: T) => T;
|
|
327
327
|
|
|
328
328
|
/**
|
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var VesiumShared = function(exports, cesium
|
|
1
|
+
var VesiumShared = function(exports, cesium) {
|
|
2
2
|
"use strict";
|
|
3
3
|
const toString = Object.prototype.toString;
|
|
4
4
|
function isDef(val) {
|
|
@@ -189,6 +189,12 @@ var VesiumShared = function(exports, cesium, shared) {
|
|
|
189
189
|
}
|
|
190
190
|
return elements.some((element) => graphic.includes(element));
|
|
191
191
|
}
|
|
192
|
+
function promiseTimeout(ms) {
|
|
193
|
+
ms < 0 && (ms = 0);
|
|
194
|
+
return new Promise((resolve) => {
|
|
195
|
+
setTimeout(resolve, ms);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
192
198
|
function isProperty(value) {
|
|
193
199
|
return value && isFunction(value.getValue);
|
|
194
200
|
}
|
|
@@ -290,7 +296,7 @@ var VesiumShared = function(exports, cesium, shared) {
|
|
|
290
296
|
const restList = [];
|
|
291
297
|
let tracked = false;
|
|
292
298
|
const trigger = async () => {
|
|
293
|
-
await
|
|
299
|
+
await promiseTimeout(delay);
|
|
294
300
|
tracked = false;
|
|
295
301
|
if (leading) {
|
|
296
302
|
try {
|
|
@@ -348,7 +354,7 @@ var VesiumShared = function(exports, cesium, shared) {
|
|
|
348
354
|
return cesium.Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
|
-
function
|
|
357
|
+
function arrayDiff(list, oldList) {
|
|
352
358
|
const oldListSet = new Set(oldList);
|
|
353
359
|
const added = list.filter((obj) => !oldListSet.has(obj));
|
|
354
360
|
const newListSet = new Set(list);
|
|
@@ -357,7 +363,7 @@ var VesiumShared = function(exports, cesium, shared) {
|
|
|
357
363
|
}
|
|
358
364
|
exports.CesiumMaterial = CesiumMaterial;
|
|
359
365
|
exports.addMaterialCache = addMaterialCache;
|
|
360
|
-
exports.
|
|
366
|
+
exports.arrayDiff = arrayDiff;
|
|
361
367
|
exports.assertError = assertError;
|
|
362
368
|
exports.canvasCoordToCartesian = canvasCoordToCartesian;
|
|
363
369
|
exports.cartesianToCanvasCoord = cartesianToCanvasCoord;
|
|
@@ -384,6 +390,7 @@ var VesiumShared = function(exports, cesium, shared) {
|
|
|
384
390
|
exports.isString = isString;
|
|
385
391
|
exports.isWindow = isWindow;
|
|
386
392
|
exports.pickHitGraphic = pickHitGraphic;
|
|
393
|
+
exports.promiseTimeout = promiseTimeout;
|
|
387
394
|
exports.resolvePick = resolvePick;
|
|
388
395
|
exports.throttle = throttle;
|
|
389
396
|
exports.toCartesian3 = toCartesian3;
|
|
@@ -393,5 +400,5 @@ var VesiumShared = function(exports, cesium, shared) {
|
|
|
393
400
|
exports.toPropertyValue = toPropertyValue;
|
|
394
401
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
395
402
|
return exports;
|
|
396
|
-
}({}, Cesium
|
|
403
|
+
}({}, Cesium);
|
|
397
404
|
//# sourceMappingURL=index.iife.js.map
|