Skip to content

Commit 83eb415

Browse files
committed
Reduces redundant clamping on labels
1 parent a158b2f commit 83eb415

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/engine/Source/Scene/LabelCollection.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import bitmapSDF from "bitmap-sdf";
1111
import BillboardCollection from "./BillboardCollection.js";
1212
import BillboardTexture from "./BillboardTexture.js";
1313
import BlendOption from "./BlendOption.js";
14-
import { isHeightReferenceClamp } from "./HeightReference.js";
14+
import HeightReference, { isHeightReferenceClamp } from "./HeightReference.js";
1515
import HorizontalOrigin from "./HorizontalOrigin.js";
1616
import Label from "./Label.js";
1717
import LabelStyle from "./LabelStyle.js";
@@ -306,7 +306,8 @@ function rebindAllGlyphs(labelCollection, label) {
306306
billboard.pixelOffset = label._pixelOffset;
307307
billboard.horizontalOrigin = HorizontalOrigin.LEFT;
308308
billboard.verticalOrigin = label._verticalOrigin;
309-
billboard.heightReference = label._heightReference;
309+
// To avoid excessive height update listeners, glyphs are not clamped. Their height values are updated manually by the owning label.
310+
billboard.heightReference = HeightReference.NONE;
310311
billboard.scale = label.totalScale;
311312
billboard.pickPrimitive = label;
312313
billboard.id = label._id;

packages/engine/Specs/Scene/LabelCollectionSpec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,8 @@ describe("Scene/LabelCollection", function () {
24462446
});
24472447

24482448
expect(l._clampedPosition).toBeDefined();
2449-
expect(l._glyphs[0].billboard._clampedPosition).toBeDefined();
2449+
// Glyphs are not truly clamped (to avoid excessive listeners and globe picks). They simply copy their owning label's clamped position.
2450+
expect(l._glyphs[0].billboard._clampedPosition).toBeUndefined();
24502451

24512452
l.heightReference = HeightReference.NONE;
24522453
expect(l._clampedPosition).toBeUndefined();
@@ -2459,13 +2460,14 @@ describe("Scene/LabelCollection", function () {
24592460
text: "t",
24602461
position: Cartesian3.fromDegrees(-72.0, 40.0),
24612462
});
2463+
l.showBackground = true;
24622464

24632465
await pollToPromise(() => {
24642466
scene.renderForSpecs();
24652467
return labelsWithHeight.ready;
24662468
});
24672469

2468-
const billboard = l._glyphs[0].billboard;
2470+
const billboard = l._backgroundBillboard;
24692471
expect(billboard._removeCallbackFunc).toBeDefined();
24702472
const spy = spyOn(billboard, "_removeCallbackFunc");
24712473
labelsWithHeight.remove(l);

0 commit comments

Comments
 (0)