easy-three-utils 0.0.354 → 0.0.355

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.
@@ -5,6 +5,9 @@ const useCloud = (viewer: Cesium.Viewer) => {
5
5
 
6
6
  let cloudsCollection = []
7
7
 
8
+ let globalClouds
9
+ let cloudData = []
10
+
8
11
  const getRandomPoints = (polygonCartesian: Cesium.Cartesian3[], numPoints: number, h: number) => {
9
12
 
10
13
  const polygon = polygonCartesian.map(cartesian => {
@@ -87,6 +90,7 @@ const useCloud = (viewer: Cesium.Viewer) => {
87
90
  const width = Math.max(...points.map(p => p.x)) - Math.min(...points.map(p => p.x))
88
91
  const length = Math.max(...points.map(p => p.y)) - Math.min(...points.map(p => p.y))
89
92
  const num = Math.floor(width * length / (options.cloudLength * options.cloudWidth)) * options.density
93
+
90
94
  const _points = getRandomPoints(points, num, 5000 + (options.cloudLength + options.cloudWidth) / 2)
91
95
 
92
96
  _points.forEach(point => {
@@ -120,6 +124,95 @@ const useCloud = (viewer: Cesium.Viewer) => {
120
124
  })
121
125
  }
122
126
 
127
+
128
+ let angle = 0
129
+ const speedDegPerSec = 0.1
130
+ const speed = Cesium.Math.toRadians(speedDegPerSec)
131
+ let prevTime = Cesium.JulianDate.clone(viewer.clock.currentTime)
132
+
133
+ const onTick = (clock) => {
134
+ const now = clock.currentTime;
135
+ const dt = Cesium.JulianDate.secondsDifference(now, prevTime)
136
+ prevTime = Cesium.JulianDate.clone(now)
137
+
138
+ if (dt <= 0) return
139
+
140
+ angle += speed * dt
141
+ const rot = Cesium.Matrix3.fromRotationZ(angle)
142
+
143
+ for (const d of cloudData) {
144
+ const rotated = new Cesium.Cartesian3()
145
+ Cesium.Matrix3.multiplyByVector(rot, d.orig, rotated)
146
+ d.cloud.position = rotated
147
+ }
148
+ }
149
+
150
+ const enabledGlobalCloud = (options?: {
151
+ color?: string;
152
+ number?: number;
153
+ }) => {
154
+
155
+ globalClouds = viewer.scene.primitives.add(new Cesium.CloudCollection())
156
+ const maxLength = 3000000
157
+ const minLength = 2000000
158
+
159
+ const coords = [
160
+ { lon: -180, lat: -90 },
161
+ { lon: 180, lat: -90 },
162
+ { lon: 180, lat: 90 },
163
+ { lon: -180, lat: 90 },
164
+ { lon: -180, lat: -90 },
165
+ ];
166
+
167
+ const points = coords.map(c =>
168
+ Cesium.Cartesian3.fromDegrees(c.lon, c.lat)
169
+ )
170
+
171
+ const _points = getRandomPoints(points, (options && options.number) ? options.number : 500, Math.floor(Math.random() * (900000 - 700000 + 1)) + 700000)
172
+ _points.forEach(point => {
173
+ const r = Math.random()
174
+ const cloud = globalClouds.add({
175
+ show: true,
176
+ position: point,
177
+ maximumSize: new Cesium.Cartesian3(
178
+ 5 + r * 15,
179
+ 4 + r * 10,
180
+ 3 + r * 5
181
+ ),
182
+ scale: new Cesium.Cartesian2(maxLength, Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength),
183
+ slice: 0.2 + Math.random() * 0.3,
184
+ brightness: 0.8 + Math.random() * 0.4,
185
+ color: Cesium.Color.fromCssColorString((options && options.color) ? options.color : 'rgba(255, 255, 255)'),
186
+ noiseDetail: 3.0 + Math.random(),
187
+ noiseOffset: new Cesium.Cartesian3(
188
+ Math.random() * 100,
189
+ Math.random() * 100,
190
+ Math.random() * 100
191
+ ),
192
+ orientation: Cesium.Quaternion.fromAxisAngle(
193
+ Cesium.Cartesian3.UNIT_Z,
194
+ Math.random() * Cesium.Math.TWO_PI
195
+ )
196
+ })
197
+
198
+ cloudData.push({
199
+ cloud,
200
+ orig: Cesium.Cartesian3.clone(point)
201
+ })
202
+ })
203
+
204
+ viewer.clock.onTick.addEventListener(onTick)
205
+ }
206
+
207
+ const disabledGlobalCloud = () => {
208
+ if (globalClouds) {
209
+ globalClouds.removeAll()
210
+ globalClouds = null
211
+ }
212
+ cloudData = []
213
+ viewer.clock.onTick.removeEventListener(onTick)
214
+ }
215
+
123
216
  const removeAll = () => {
124
217
  cloudsCollection.forEach(item => item.clouds.removeAll())
125
218
  viewer.scene.primitives.removeAll()
@@ -128,6 +221,8 @@ const useCloud = (viewer: Cesium.Viewer) => {
128
221
 
129
222
  return {
130
223
  draw,
224
+ enabledGlobalCloud,
225
+ disabledGlobalCloud,
131
226
  removeAll
132
227
  }
133
228
  }
@@ -20,7 +20,7 @@ const useSeawater = (viewer: Cesium.Viewer) => {
20
20
  fabric: {
21
21
  type: 'Water',
22
22
  uniforms: {
23
- specularMap: __POLT__URL__ + '/assets/image/earthspec.jpg',
23
+ specularMap: (window as any).__POLT__URL__ + '/assets/image/earthspec.jpg',
24
24
  normalMap: Cesium.buildModuleUrl('Assets/Textures/waterNormals.jpg'),
25
25
  frequency: 10000.0,
26
26
  animationSpeed: 0.01,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-three-utils",
3
- "version": "0.0.354",
3
+ "version": "0.0.355",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -8,5 +8,5 @@
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "types": "./index.d.ts",
11
- "description": "新增阳光控制器"
11
+ "description": "新增全球云"
12
12
  }