cesium-pocket 0.3.0-alpha → 0.3.1-alpha

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,4 +1,4 @@
1
- import { CustomDataSource as C, Cartesian3 as r, JulianDate as I, defined as l, ConstantPositionProperty as E, HeightReference as P, Color as u, EntityCollection as B, ScreenSpaceEventType as c, ScreenSpaceEventHandler as w, VerticalOrigin as R, PolylineDashMaterialProperty as M, CallbackProperty as A, PolygonHierarchy as m, Cartographic as y, Transforms as S, Matrix4 as g, EllipsoidGeodesic as k } from "cesium";
1
+ import { CustomDataSource as C, Cartesian3 as r, JulianDate as I, defined as l, ConstantPositionProperty as E, HeightReference as S, Color as u, EntityCollection as B, ScreenSpaceEventType as c, ScreenSpaceEventHandler as w, VerticalOrigin as R, PolylineDashMaterialProperty as M, CallbackProperty as A, PolygonHierarchy as P, Cartographic as y, Transforms as b, Matrix4 as g, EllipsoidGeodesic as k } from "cesium";
2
2
  import { toRaw as d } from "vue";
3
3
  const h = {
4
4
  STOPED: Symbol("STOPED"),
@@ -139,7 +139,7 @@ class L extends G {
139
139
  color: u.TRANSPARENT,
140
140
  outlineColor: u.YELLOW,
141
141
  outlineWidth: 2,
142
- heightReference: P.CLAMP_TO_GROUND
142
+ heightReference: S.CLAMP_TO_GROUND
143
143
  //贴地
144
144
  }, this.dataSource.entities.add({
145
145
  position: e,
@@ -163,22 +163,22 @@ class L extends G {
163
163
  });
164
164
  }
165
165
  }
166
- class F extends L {
166
+ class T extends L {
167
167
  constructor(e, i = null) {
168
168
  super(e), this.handler = null, this.pointCollection = new B(), this.billboardCallbackFun = this.addBillboardCallback, this.point_L_ClickEvent = () => {
169
169
  var t;
170
170
  (t = this.handler) == null || t.setInputAction((a) => {
171
171
  if (h.DRAWABLE == super.getStatus()) {
172
- let n = this.viewer.camera.getPickRay(a.position), s = this.viewer.scene.globe.pick(n, this.viewer.scene);
173
- if (l(s)) {
174
- let v = this.billboardCallbackFun(s);
175
- this.mainData.push(s), this.pointCollection.add(v);
172
+ let s = this.viewer.camera.getPickRay(a.position), n = this.viewer.scene.globe.pick(s, this.viewer.scene);
173
+ if (l(n)) {
174
+ let v = this.billboardCallbackFun(n);
175
+ this.mainData.push(n), this.pointCollection.add(v);
176
176
  }
177
177
  } else if (h.DELETABLE == super.getStatus()) {
178
- const n = this.viewer.scene.pick(a.position);
179
- if (l(n) && l(n.id)) {
180
- const s = d(n.id);
181
- this.pointCollection.contains(s) && p.DEL_ENABLED == super.getDelStatus() && this.deleteBillboard(s);
178
+ const s = this.viewer.scene.pick(a.position);
179
+ if (l(s) && l(s.id)) {
180
+ const n = d(s.id);
181
+ this.pointCollection.contains(n) && p.DEL_ENABLED == super.getDelStatus() && this.deleteBillboard(n);
182
182
  }
183
183
  }
184
184
  }, c.LEFT_CLICK);
@@ -189,32 +189,35 @@ class F extends L {
189
189
  }, c.LEFT_DOWN);
190
190
  }, this.point_L_UpEvent = () => {
191
191
  var t;
192
- (t = this.handler) == null || t.setInputAction(() => {
193
- o.DRAGING == super.getEditStatus() && (this.editDragUnable(), this.currentDragPoint = null, this.viewer.scene.screenSpaceCameraController.enableRotate = !0);
192
+ (t = this.handler) == null || t.setInputAction((a) => {
193
+ if (o.DRAGING == super.getEditStatus()) {
194
+ const s = this.viewer.scene.pickPosition(a.endPosition);
195
+ l(s) && this.editCallbackFun && this.editCallbackFun(s), this.editDragUnable(), this.currentDragPoint = null, this.viewer.scene.screenSpaceCameraController.enableRotate = !0;
196
+ }
194
197
  }, c.LEFT_UP);
195
198
  }, this.point_moveEvent = () => {
196
199
  var t;
197
200
  (t = this.handler) == null || t.setInputAction((a) => {
198
201
  if (h.EDITABLE == super.getStatus())
199
202
  if (o.DRAG_UNABLED == super.getEditStatus()) {
200
- const n = this.viewer.scene.pick(a.endPosition);
201
- if (l(n) && l(n.id) && this.pointCollection.contains(d(n.id))) {
202
- let s = d(n.id);
203
- this.currentDragPoint = s, this.editDragEnable();
203
+ const s = this.viewer.scene.pick(a.endPosition);
204
+ if (l(s) && l(s.id) && this.pointCollection.contains(d(s.id))) {
205
+ let n = d(s.id);
206
+ this.currentDragPoint = n, this.editDragEnable();
204
207
  }
205
208
  } else if (o.DRAGING == super.getEditStatus()) {
206
- const n = this.viewer.scene.pickPosition(a.endPosition);
207
- l(n) && this.currentDragPoint && (this.currentDragPoint.position = new E(n));
209
+ const s = this.viewer.scene.pickPosition(a.endPosition);
210
+ l(s) && this.currentDragPoint && (this.currentDragPoint.position = new E(s));
208
211
  } else
209
212
  this.editDragUnable();
210
213
  else if (h.DELETABLE == super.getStatus())
211
214
  if (p.DEL_UNABLED == super.getDelStatus()) {
212
- const n = this.viewer.scene.pick(a.endPosition);
213
- l(n) && l(n.id) && this.pointCollection.contains(d(n.id)) && this.delEnable();
215
+ const s = this.viewer.scene.pick(a.endPosition);
216
+ l(s) && l(s.id) && this.pointCollection.contains(d(s.id)) && this.delEnable();
214
217
  } else
215
218
  this.delUnable();
216
219
  }, c.MOUSE_MOVE);
217
- }, i && (i.billboardCallbackFun && (this.billboardCallbackFun = i.billboardCallbackFun), i.delCallbackFun && (this.delCallbackFun = i.delCallbackFun));
220
+ }, i && (this.billboardCallbackFun = i.billboardCallbackFun ? i.billboardCallbackFun : this.addBillboardCallback, this.delCallbackFun = i.delCallbackFun ? i.delCallbackFun : this.delCallback, i.editCallbackFun && (this.editCallbackFun = i.editCallbackFun));
218
221
  }
219
222
  start() {
220
223
  super.drawableStatus(), this.handler || (this.handler = new w(this.viewer.scene.canvas)), this.point_L_ClickEvent(), this.point_L_DownEvent(), this.point_L_UpEvent(), this.point_moveEvent();
@@ -243,7 +246,7 @@ class F extends L {
243
246
  // 可选项:缩放倍数
244
247
  scale: 1,
245
248
  verticalOrigin: R.BOTTOM,
246
- heightReference: P.CLAMP_TO_GROUND
249
+ heightReference: S.CLAMP_TO_GROUND
247
250
  //贴地
248
251
  },
249
252
  show: !0
@@ -267,13 +270,13 @@ class O extends L {
267
270
  var t;
268
271
  (t = this.handler) == null || t.setInputAction((a) => {
269
272
  if (h.DRAWABLE == super.getStatus()) {
270
- let n = this.viewer.camera.getPickRay(a.position), s = this.viewer.scene.globe.pick(n, this.viewer.scene);
271
- l(s) && (this.addPoint(s), this.mainData.push(s), this.mainData.length > 0 && (this.mainLineEntity || this.createMainLine(), this.dashLineEntity || this.createDashline(), this.mainData.length > 2 && this.drawerMode === f.POLYGON && !this.mainPolygonEntity && this.createMainPolygon()));
273
+ let s = this.viewer.camera.getPickRay(a.position), n = this.viewer.scene.globe.pick(s, this.viewer.scene);
274
+ l(n) && (this.addPoint(n), this.mainData.push(n), this.mainData.length > 0 && (this.mainLineEntity || this.createMainLine(), this.dashLineEntity || this.createDashline(), this.mainData.length > 2 && this.drawerMode === f.POLYGON && !this.mainPolygonEntity && this.createMainPolygon()));
272
275
  } else if (h.DELETABLE == super.getStatus()) {
273
- const n = this.viewer.scene.pick(a.position);
274
- if (l(n) && l(n.id)) {
275
- const s = d(n.id);
276
- this.dataSource.entities.contains(s) && p.DEL_ENABLED == super.getDelStatus() && this.deletePoint(s);
276
+ const s = this.viewer.scene.pick(a.position);
277
+ if (l(s) && l(s.id)) {
278
+ const n = d(s.id);
279
+ this.dataSource.entities.contains(n) && p.DEL_ENABLED == super.getDelStatus() && this.deletePoint(n);
277
280
  }
278
281
  }
279
282
  }, c.LEFT_CLICK);
@@ -290,10 +293,10 @@ class O extends L {
290
293
  }, this.line_moveEvent = () => {
291
294
  var t;
292
295
  (t = this.handler) == null || t.setInputAction((a) => {
293
- const n = this.viewer.camera.getPickRay(a.endPosition);
294
- if (n) {
295
- const s = this.viewer.scene.globe.pick(n, this.viewer.scene);
296
- l(s) && (h.DRAWABLE == super.getStatus() ? this.dashEndData = s : h.EDITABLE == super.getStatus() ? (this.dashLineEntity.show = !1, this.editMoveFun(a, s)) : h.DELETABLE == super.getStatus() && (this.dashLineEntity.show = !1, this.deleteMoveFun(a)));
296
+ const s = this.viewer.camera.getPickRay(a.endPosition);
297
+ if (s) {
298
+ const n = this.viewer.scene.globe.pick(s, this.viewer.scene);
299
+ l(n) && (h.DRAWABLE == super.getStatus() ? this.dashEndData = n : h.EDITABLE == super.getStatus() ? (this.dashLineEntity.show = !1, this.editMoveFun(a, n)) : h.DELETABLE == super.getStatus() && (this.dashLineEntity.show = !1, this.deleteMoveFun(a)));
297
300
  }
298
301
  }, c.MOUSE_MOVE);
299
302
  }, this.createDashline = () => {
@@ -311,8 +314,8 @@ class O extends L {
311
314
  show: !0,
312
315
  clampToGround: !0
313
316
  }, t.positions = new A(() => {
314
- let a = this.mainData.length, n = this.mainData[a - 1];
315
- return n || (n = this.mainData[a - 2]), this.dashEndData || console.log("发生错误了dashEndData"), [n, this.dashEndData];
317
+ let a = this.mainData.length, s = this.mainData[a - 1];
318
+ return s || (s = this.mainData[a - 2]), this.dashEndData || console.log("发生错误了dashEndData"), [s, this.dashEndData];
316
319
  }, !1), this.dashLineEntity = this.viewer.entities.add({
317
320
  polyline: t,
318
321
  properties: {
@@ -359,7 +362,7 @@ class O extends L {
359
362
  hierarchy: [new r(), new r(), new r()],
360
363
  material: u.RED.withAlpha(0.4),
361
364
  outline: !1
362
- }, e.hierarchy = new A(() => new m(this.mainData), !1), this.mainPolygonEntity = this.viewer.entities.add({
365
+ }, e.hierarchy = new A(() => new P(this.mainData), !1), this.mainPolygonEntity = this.viewer.entities.add({
363
366
  polygon: e,
364
367
  properties: {
365
368
  entityType: "POLYGON"
@@ -374,8 +377,8 @@ class x extends L {
374
377
  var t;
375
378
  (t = this.handler) == null || t.setInputAction((a) => {
376
379
  if (h.DRAWABLE == super.getStatus()) {
377
- let n = this.viewer.camera.getPickRay(a.position), s = this.viewer.scene.globe.pick(n, this.viewer.scene);
378
- l(s) && (this.mainData.length === 0 ? (this.addPoint(s), this.firstPoint = s, this.mainData.push(s), this.createLine(), this.createPolygon()) : (this.addPoint(s), this.endPoint = s, this.stopStatus()));
380
+ let s = this.viewer.camera.getPickRay(a.position), n = this.viewer.scene.globe.pick(s, this.viewer.scene);
381
+ l(n) && (this.mainData.length === 0 ? (this.addPoint(n), this.firstPoint = n, this.mainData.push(n), this.createLine(), this.createPolygon()) : (this.addPoint(n), this.endPoint = n, this.stopStatus()));
379
382
  }
380
383
  }, c.LEFT_CLICK);
381
384
  }, this.rect_L_DownEvent = () => {
@@ -391,10 +394,10 @@ class x extends L {
391
394
  }, this.rect_moveEvent = () => {
392
395
  var t;
393
396
  (t = this.handler) == null || t.setInputAction((a) => {
394
- const n = this.viewer.camera.getPickRay(a.endPosition);
395
- if (n) {
396
- const s = this.viewer.scene.globe.pick(n, this.viewer.scene);
397
- l(s) && (h.DRAWABLE == super.getStatus() ? this.firstPoint && (this.endPoint = s, this.initMainData()) : h.EDITABLE == super.getStatus() && this.rectMove(a, s));
397
+ const s = this.viewer.camera.getPickRay(a.endPosition);
398
+ if (s) {
399
+ const n = this.viewer.scene.globe.pick(s, this.viewer.scene);
400
+ l(n) && (h.DRAWABLE == super.getStatus() ? this.firstPoint && (this.endPoint = n, this.initMainData()) : h.EDITABLE == super.getStatus() && this.rectMove(a, n));
398
401
  }
399
402
  }, c.MOUSE_MOVE);
400
403
  }, i && (this.point = i.point, this.polyline = i.polyline, this.polygon = i.polygon);
@@ -419,8 +422,8 @@ class x extends L {
419
422
  }
420
423
  initMainData() {
421
424
  if (this.firstPoint && this.endPoint) {
422
- const e = y.fromCartesian(this.firstPoint), i = e.longitude, t = e.latitude, a = y.fromCartesian(this.endPoint), n = a.longitude, s = a.latitude, v = r.fromRadians(i, s), b = r.fromRadians(n, t);
423
- this.mainData[0] = this.firstPoint, this.mainData[1] = v, this.mainData[2] = this.endPoint, this.mainData[3] = b;
425
+ const e = y.fromCartesian(this.firstPoint), i = e.longitude, t = e.latitude, a = y.fromCartesian(this.endPoint), s = a.longitude, n = a.latitude, v = r.fromRadians(i, n), m = r.fromRadians(s, t);
426
+ this.mainData[0] = this.firstPoint, this.mainData[1] = v, this.mainData[2] = this.endPoint, this.mainData[3] = m;
424
427
  }
425
428
  }
426
429
  //创建主线数据
@@ -449,7 +452,7 @@ class x extends L {
449
452
  hierarchy: [new r(), new r(), new r()],
450
453
  material: u.RED.withAlpha(0.4),
451
454
  outline: !1
452
- }, e.hierarchy = new A(() => new m(this.mainData), !1), this.polygonEntity = this.viewer.entities.add({
455
+ }, e.hierarchy = new A(() => new P(this.mainData), !1), this.polygonEntity = this.viewer.entities.add({
453
456
  polygon: e,
454
457
  properties: {
455
458
  entityType: "POLYGON"
@@ -464,8 +467,8 @@ class Q extends L {
464
467
  var t;
465
468
  (t = this.handler) == null || t.setInputAction((a) => {
466
469
  if (h.DRAWABLE == super.getStatus()) {
467
- let n = this.viewer.camera.getPickRay(a.position), s = this.viewer.scene.globe.pick(n, this.viewer.scene);
468
- l(s) && (this.mainData.length === 0 ? (this.addPoint(s), this.mainData.push(s), this.firstPoint = s, this.createCircle()) : (this.endPoint = s, this.mainData.push(s), this.endPointEntity = this.addPoint(s), this.getAngle(), this.stopStatus()));
470
+ let s = this.viewer.camera.getPickRay(a.position), n = this.viewer.scene.globe.pick(s, this.viewer.scene);
471
+ l(n) && (this.mainData.length === 0 ? (this.addPoint(n), this.mainData.push(n), this.firstPoint = n, this.createCircle()) : (this.endPoint = n, this.mainData.push(n), this.endPointEntity = this.addPoint(n), this.getAngle(), this.stopStatus()));
469
472
  }
470
473
  }, c.LEFT_CLICK);
471
474
  }, this.circle_L_DownEvent = () => {
@@ -481,10 +484,10 @@ class Q extends L {
481
484
  }, this.circle_moveEvent = () => {
482
485
  var t;
483
486
  (t = this.handler) == null || t.setInputAction((a) => {
484
- const n = this.viewer.camera.getPickRay(a.endPosition);
485
- if (n) {
486
- const s = this.viewer.scene.globe.pick(n, this.viewer.scene);
487
- l(s) && (h.DRAWABLE == super.getStatus() ? this.mainData.length > 0 && (this.endPoint = s, this.countDistance()) : h.EDITABLE == super.getStatus() && this.circleMove(a, s));
487
+ const s = this.viewer.camera.getPickRay(a.endPosition);
488
+ if (s) {
489
+ const n = this.viewer.scene.globe.pick(s, this.viewer.scene);
490
+ l(n) && (h.DRAWABLE == super.getStatus() ? this.mainData.length > 0 && (this.endPoint = n, this.countDistance()) : h.EDITABLE == super.getStatus() && this.circleMove(a, n));
488
491
  }
489
492
  }, c.MOUSE_MOVE);
490
493
  }, i && (this.point = i.point, this.ellipse = i.ellipse);
@@ -499,7 +502,7 @@ class Q extends L {
499
502
  this.clearAllData(), this.firstPoint = new r(), this.endPoint = new r(), this.handler && (this.handler = null), this.ellipseEntity && this.viewer.entities.removeById(this.ellipseEntity.id);
500
503
  }
501
504
  getAngle() {
502
- const e = S.eastNorthUpToFixedFrame(this.firstPoint.clone()), i = g.inverse(e, new g()), t = g.multiplyByPoint(i, this.endPoint.clone(), new r());
505
+ const e = b.eastNorthUpToFixedFrame(this.firstPoint.clone()), i = g.inverse(e, new g()), t = g.multiplyByPoint(i, this.endPoint.clone(), new r());
503
506
  this.angle = Math.atan2(t.x, t.y);
504
507
  }
505
508
  circleMove(e, i) {
@@ -517,7 +520,7 @@ class Q extends L {
517
520
  this.distance * Math.cos(this.angle),
518
521
  0
519
522
  // 保持水平,如果希望保持高度则设为 localEdge.z
520
- ), i = S.eastNorthUpToFixedFrame(this.firstPoint), t = g.multiplyByPointAsVector(i, e, new r());
523
+ ), i = b.eastNorthUpToFixedFrame(this.firstPoint), t = g.multiplyByPointAsVector(i, e, new r());
521
524
  this.endPoint = r.add(this.firstPoint, t, new r());
522
525
  }
523
526
  countDistance() {
@@ -555,7 +558,7 @@ class Q extends L {
555
558
  export {
556
559
  O as C,
557
560
  h as D,
558
- F as P,
561
+ T as P,
559
562
  x as R,
560
563
  Q as a,
561
564
  f as b
package/drawer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as D, a as e, b as s, D as R, P as w, R as o } from "./CircleDrawer-1f9OEOcZ.js";
1
+ import { C as D, a as e, b as s, D as R, P as w, R as o } from "./CircleDrawer-DbOS8_ZI.js";
2
2
  export {
3
3
  D as CP2dDrawer,
4
4
  e as CircleDrawer,
package/index.js CHANGED
@@ -3,7 +3,7 @@ import * as PA from "three";
3
3
  import { TrianglesDrawMode as tP, TriangleFanDrawMode as EA, TriangleStripDrawMode as SA, Loader as sP, LoaderUtils as F, FileLoader as qA, Color as S, LinearSRGBColorSpace as H, SpotLight as BP, PointLight as rP, DirectionalLight as vP, MeshBasicMaterial as W, SRGBColorSpace as R, MeshPhysicalMaterial as y, Vector2 as VA, Matrix4 as tA, Vector3 as K, Quaternion as hA, InstancedMesh as gP, InstancedBufferAttribute as CP, Object3D as JA, TextureLoader as DP, ImageBitmapLoader as wP, BufferAttribute as BA, InterleavedBuffer as QP, InterleavedBufferAttribute as cP, LinearMipmapLinearFilter as YA, NearestMipmapLinearFilter as IP, LinearMipmapNearestFilter as EP, NearestMipmapNearestFilter as zP, LinearFilter as zA, NearestFilter as NA, RepeatWrapping as TA, MirroredRepeatWrapping as TP, ClampToEdgeWrapping as lP, PointsMaterial as oP, Material as rA, LineBasicMaterial as aP, MeshStandardMaterial as KA, DoubleSide as MP, PropertyBinding as uP, BufferGeometry as pP, SkinnedMesh as bP, Mesh as iP, LineSegments as fP, Line as UP, LineLoop as yP, Points as dP, Group as vA, PerspectiveCamera as jP, MathUtils as HP, OrthographicCamera as mP, Skeleton as kP, AnimationClip as LP, Bone as OP, InterpolateDiscrete as SP, InterpolateLinear as XA, ColorManagement as MA, Texture as uA, VectorKeyframeTrack as pA, NumberKeyframeTrack as bA, QuaternionKeyframeTrack as iA, FrontSide as qP, Interpolant as VP, Box3 as hP, Sphere as JP } from "three";
4
4
  import { Viewer as h, Math as _, Cartesian2 as eA, Cartesian3 as L, Cartographic as ZA, SceneTransforms as YP, Ray as NP, Color as KP, ScreenSpaceEventType as gA, ScreenSpaceEventHandler as XP, createWorldTerrainAsync as ZP, EllipsoidTerrainProvider as GP, WebMapTileServiceImageryProvider as Y, Credit as N } from "cesium";
5
5
  import { P as G, a as fA, b as xP, c as WP, d as FP, C as UA } from "./index-CcaLwHv1.js";
6
- import { C as Mn, a as un, b as pn, D as bn, P as fn, R as Un } from "./CircleDrawer-1f9OEOcZ.js";
6
+ import { C as Mn, a as un, b as pn, D as bn, P as fn, R as Un } from "./CircleDrawer-DbOS8_ZI.js";
7
7
  function yA(D, A) {
8
8
  if (A === tP)
9
9
  return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cesium-pocket",
3
- "version": "0.3.0-alpha",
3
+ "version": "0.3.1-alpha",
4
4
  "description": "cesium的插件库;基于vue3的开发",
5
5
  "module": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -1,14 +1,17 @@
1
1
  import { Cartesian3, Viewer, Entity } from 'cesium';
2
2
  import { DataCenter, DelCallbackFn } from './DataCenter.ts';
3
+ export type EditCallbackFn = (cartesian: Cartesian3) => void;
3
4
  export type EntityCallbackFn = (cartesian: Cartesian3) => Entity;
4
5
  export type PointOptions = {
5
6
  billboardCallbackFun?: EntityCallbackFn;
7
+ editCallbackFun?: EditCallbackFn;
6
8
  delCallbackFun?: DelCallbackFn;
7
9
  } | null;
8
10
  export declare class PointDrawer extends DataCenter {
9
11
  private handler;
10
12
  private pointCollection;
11
13
  private billboardCallbackFun;
14
+ private editCallbackFun;
12
15
  constructor(viewer: Viewer, options?: PointOptions);
13
16
  start(): void;
14
17
  getEntity(): EntityCollection;