easy-three-utils 0.0.365 → 0.0.367

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.
@@ -1,89 +0,0 @@
1
- import * as Cesium from 'cesium'
2
-
3
- export enum EMovementType {
4
- SPEED = 'speed',
5
- TIME = 'time'
6
- }
7
-
8
- export enum EControlAction {
9
- PLAY = 'play',
10
- PAUSE = 'pause'
11
- }
12
-
13
- export interface IPathType {
14
- modelParams: {
15
- id: string;
16
- name: string;
17
- url: string;
18
- };
19
- path: {
20
- duration: number;
21
- point: Cesium.Cartesian3;
22
- speed: number;
23
- }[];
24
- movementType: EMovementType;
25
- totalDuration: number;
26
- }
27
-
28
- const usePath = () => {
29
-
30
- const playAnimation = (viewer: Cesium.Viewer, path: IPathType[]) => {
31
- const startTime = Cesium.JulianDate.fromDate(new Date())
32
-
33
- path.forEach(item => {
34
- const property = new Cesium.SampledPositionProperty();
35
- item.totalDuration = 0
36
-
37
- item.path.forEach((value, i) => {
38
- if (i === 0) {
39
- property.addSample(Cesium.JulianDate.addSeconds(startTime, 0, new Cesium.JulianDate()), value.point);
40
- }
41
- if (i > 0) {
42
- const distance = Cesium.Cartesian3.distance(item.path[i - 1].point, value.point).toFixed();
43
- if (item.movementType === EMovementType.SPEED) {
44
- const time = Number(distance) / value.speed
45
- item.totalDuration = item.totalDuration + time
46
- property.addSample(Cesium.JulianDate.addSeconds(startTime, item.totalDuration, new Cesium.JulianDate()), value.point);
47
- } else if (item.movementType === EMovementType.TIME) {
48
- item.totalDuration = item.totalDuration + Number(value.duration)
49
- property.addSample(Cesium.JulianDate.addSeconds(startTime, item.totalDuration, new Cesium.JulianDate()), value.point);
50
- }
51
- }
52
- if (i === item.path.length - 1) {
53
- property.addSample(Cesium.JulianDate.fromDate(new Date(2099, 12, 31)), value.point);
54
- }
55
- })
56
-
57
- if (item.path.length) {
58
- viewer.entities.removeById(item.modelParams.id)
59
- viewer.entities.add({
60
- id: item.modelParams.id,
61
- name: item.modelParams.name,
62
- position: property,
63
- orientation: new Cesium.VelocityOrientationProperty(property),
64
- model: {
65
- uri: item.modelParams.url,
66
- heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
67
- }
68
- })
69
- }
70
- })
71
-
72
- path.sort((pre, cur) => cur.totalDuration - pre.totalDuration)
73
-
74
- viewer.clock.startTime = startTime.clone();
75
- viewer.clock.stopTime = Cesium.JulianDate.addSeconds(startTime, path[0].totalDuration, new Cesium.JulianDate())
76
-
77
- viewer.clock.currentTime = startTime.clone();
78
- viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
79
- viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
80
- }
81
-
82
- return {
83
- playAnimation,
84
- }
85
- }
86
-
87
- export {
88
- usePath
89
- }