@jorgmoritz/gis-manager 0.1.54 → 0.1.56

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/dist/index.cjs CHANGED
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13
13
  // package.json
14
14
  var package_default = {
15
15
  name: "@jorgmoritz/gis-manager",
16
- version: "0.1.54"};
16
+ version: "0.1.56"};
17
17
 
18
18
  // src/utils/version.ts
19
19
  var version = package_default.version;
@@ -2815,24 +2815,6 @@ var HeightMarker = class {
2815
2815
  },
2816
2816
  properties: { _type: "height-marker" }
2817
2817
  });
2818
- this.labelEntity = this.layer.entities.add({
2819
- position: C.Cartesian3.ZERO,
2820
- label: {
2821
- text: "",
2822
- font: "10px sans-serif",
2823
- // 字体改小
2824
- style: C.LabelStyle.FILL_AND_OUTLINE,
2825
- fillColor: C.Color.BLACK,
2826
- outlineColor: C.Color.WHITE,
2827
- outlineWidth: 2,
2828
- pixelOffset: new C.Cartesian2(0, -4),
2829
- showBackground: false,
2830
- horizontalOrigin: C.HorizontalOrigin.CENTER,
2831
- verticalOrigin: C.VerticalOrigin.BOTTOM,
2832
- disableDepthTestDistance: Number.POSITIVE_INFINITY
2833
- },
2834
- properties: { _type: "height-marker-label" }
2835
- });
2836
2818
  }
2837
2819
  /** Compute ground point directly under the given world position. */
2838
2820
  computeGroundPoint(top) {
@@ -4333,14 +4315,16 @@ var TriangleShape = class {
4333
4315
  * @param positionCallback - Callback function that returns current position
4334
4316
  * @param headingCallback - Callback function that returns current heading in degrees
4335
4317
  * @param properties - Additional properties for entities
4318
+ * @param scaleCallback - Optional callback function that returns current scale factor (default 1)
4336
4319
  * @returns Array of created entities [bottom faces, side faces]
4337
4320
  */
4338
- createEntities(layer, positionCallback, headingCallback, properties) {
4321
+ createEntities(layer, positionCallback, headingCallback, properties, scaleCallback) {
4339
4322
  const C = this.CesiumNS;
4340
4323
  const entities = [];
4341
4324
  const computeVertices = () => {
4342
4325
  const position = positionCallback();
4343
4326
  const heading = headingCallback();
4327
+ const scale = scaleCallback?.() ?? 1;
4344
4328
  const enu = C.Transforms.eastNorthUpToFixedFrame(position);
4345
4329
  const east4 = C.Matrix4.getColumn(enu, 0, new C.Cartesian4());
4346
4330
  const north4 = C.Matrix4.getColumn(enu, 1, new C.Cartesian4());
@@ -4352,9 +4336,12 @@ var TriangleShape = class {
4352
4336
  const sin = Math.sin(theta);
4353
4337
  const cos = Math.cos(theta);
4354
4338
  const toWorld = (x, y, z) => {
4355
- const ex = C.Cartesian3.multiplyByScalar(east, x * cos + y * sin, new C.Cartesian3());
4356
- const ny = C.Cartesian3.multiplyByScalar(north, -x * sin + y * cos, new C.Cartesian3());
4357
- const uz = C.Cartesian3.multiplyByScalar(up, z, new C.Cartesian3());
4339
+ const sx = x * scale;
4340
+ const sy = y * scale;
4341
+ const sz = z * scale;
4342
+ const ex = C.Cartesian3.multiplyByScalar(east, sx * cos + sy * sin, new C.Cartesian3());
4343
+ const ny = C.Cartesian3.multiplyByScalar(north, -sx * sin + sy * cos, new C.Cartesian3());
4344
+ const uz = C.Cartesian3.multiplyByScalar(up, sz, new C.Cartesian3());
4358
4345
  const offset = C.Cartesian3.add(ex, ny, new C.Cartesian3());
4359
4346
  C.Cartesian3.add(offset, uz, offset);
4360
4347
  return C.Cartesian3.add(position, offset, new C.Cartesian3());
@@ -4635,6 +4622,28 @@ var AirplaneCursor = class {
4635
4622
  * 创建三角形标记游标
4636
4623
  */
4637
4624
  createTriangleCursor(_color) {
4625
+ const C = this.CesiumNS;
4626
+ const baseScale = 1;
4627
+ const minScale = 0.1;
4628
+ const maxScale = 3;
4629
+ const referenceDistance = 800;
4630
+ const computeScaleFactor = () => {
4631
+ try {
4632
+ const cameraPos = this.viewer.camera.positionWC;
4633
+ const modelPos = this.pose.position;
4634
+ const distance = C.Cartesian3.distance(cameraPos, modelPos);
4635
+ const rawScale = baseScale * (distance / referenceDistance);
4636
+ const clampedScale = Math.max(minScale, Math.min(maxScale, rawScale));
4637
+ return clampedScale / baseScale;
4638
+ } catch {
4639
+ return 1;
4640
+ }
4641
+ };
4642
+ this.cachedScaleFactor = computeScaleFactor();
4643
+ this.cameraChangedListener = this.viewer.camera.changed.addEventListener(() => {
4644
+ this.cachedScaleFactor = computeScaleFactor();
4645
+ this.viewer.scene?.requestRender?.();
4646
+ });
4638
4647
  this.triangleShape = new TriangleShape(this.CesiumNS, {
4639
4648
  baseSize: 15,
4640
4649
  pyramidHeight: 25,
@@ -4644,7 +4653,9 @@ var AirplaneCursor = class {
4644
4653
  this.pyramidLayer,
4645
4654
  () => this.pose.position,
4646
4655
  () => this.pose.heading,
4647
- { _type: "airplane-cursor" }
4656
+ { _type: "airplane-cursor" },
4657
+ () => this.cachedScaleFactor
4658
+ // 传入缩放因子回调
4648
4659
  );
4649
4660
  triangleEntities.forEach((entity) => {
4650
4661
  entity.show = this.visible;
@@ -5445,7 +5456,7 @@ function calculatePathDistance(CesiumNS, positions, targetIndex, hiddenClimbInde
5445
5456
  const C = CesiumNS;
5446
5457
  let totalDistance = 0;
5447
5458
  const startIndex = 1;
5448
- if (targetIndex <= startIndex) return 0;
5459
+ if (targetIndex < startIndex) return 0;
5449
5460
  for (let i = startIndex; i <= targetIndex; i++) {
5450
5461
  try {
5451
5462
  const prevPos = positions[i - 1];