Skip to content

Commit 8872bd6

Browse files
authored
Merge branch 'main' into patch-release-guide
2 parents 6ebd634 + 1dcf973 commit 8872bd6

File tree

16 files changed

+220
-164
lines changed

16 files changed

+220
-164
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
### @cesium/engine
66

7+
#### Breaking Changes :mega:
8+
9+
- `scene.drillPick` now uses a breadth-first search strategy instead of depth-first. This may change which entities are picked when
10+
using large values of `width` and `height` when providing a `limit`, prioritizing entities closer to the camera.
11+
712
#### Fixes :wrench:
813

914
- Fixes an event bug following recent changes, where adding a new listener during an event callback caused an infinite loop. [#12955](https://github.com/CesiumGS/cesium/pull/12955)
1015
- Fix issues with label background when updating properties while `label.show` is `false`. [#12138](https://github.com/CesiumGS/cesium/issues/12138)
16+
- Improved performance of `scene.drillPick`. [#12916](https://github.com/CesiumGS/cesium/pull/12916)
17+
- Improved performance when removing primitives. [#3018](https://github.com/CesiumGS/cesium/pull/3018)
1118

1219
## 1.134 - 2025-10-01
1320

Specs/TypeScript/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"noEmit": true,
44
"types": [],
55
"strict": true,
6-
"isolatedModules": true
6+
"isolatedModules": true,
7+
"lib": ["ES2020", "DOM"]
78
},
89
"include": [
910
"index.ts",

Tools/jsdoc/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {
3-
"noEmit": true,
4-
"types": []
3+
"noEmit": true,
4+
"types": [],
5+
"lib": ["ES2020", "DOM"]
56
},
67
"files": [
78
"../../Source/Cesium.d.ts"

gulpfile.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,6 @@ export async function buildDocsWatch() {
425425
return gulp.watch(sourceFiles, buildDocs);
426426
}
427427

428-
function combineForSandcastle() {
429-
const outputDirectory = join("Build", "Sandcastle", "CesiumUnminified");
430-
return buildCesium({
431-
development: false,
432-
minify: false,
433-
removePragmas: false,
434-
node: false,
435-
outputDirectory: outputDirectory,
436-
});
437-
}
438-
439428
export const websiteRelease = gulp.series(
440429
buildEngine,
441430
buildWidgets,
@@ -447,14 +436,23 @@ export const websiteRelease = gulp.series(
447436
node: false,
448437
});
449438
},
450-
function () {
439+
function websiteReleaseBuildMinified() {
451440
return buildCesium({
452441
minify: true,
453442
removePragmas: true,
454443
node: false,
455444
});
456445
},
457-
combineForSandcastle,
446+
function combineForSandcastle() {
447+
const outputDirectory = join("Build", "Sandcastle", "CesiumUnminified");
448+
return buildCesium({
449+
development: false,
450+
minify: false,
451+
removePragmas: false,
452+
node: false,
453+
outputDirectory: outputDirectory,
454+
});
455+
},
458456
buildDocs,
459457
);
460458

@@ -712,17 +710,21 @@ export async function deploySetVersion() {
712710
export async function deployStatus() {
713711
const status = argv.status;
714712
const message = argv.message;
715-
716713
const deployUrl = `${devDeployUrl}`;
717714
const zipUrl = `${deployUrl}Cesium-${version}.zip`;
718715
const npmUrl = `${deployUrl}cesium-${version}.tgz`;
719-
const coverageUrl = `${devDeployUrl}Build/Coverage/index.html`;
716+
const coverageUrl = `${deployUrl}Build/Coverage/index.html`;
720717

721718
return Promise.all([
722-
setStatus(status, deployUrl, message, "deployment"),
723-
setStatus(status, zipUrl, message, "zip file"),
724-
setStatus(status, npmUrl, message, "npm package"),
725-
setStatus(status, coverageUrl, message, "coverage results"),
719+
setStatus(status, deployUrl, message, "deploy / artifact: deployment"),
720+
setStatus(status, zipUrl, message, "deploy / artifact: zip file"),
721+
setStatus(status, npmUrl, message, "deploy / artifact: npm package"),
722+
setStatus(
723+
status,
724+
coverageUrl,
725+
message,
726+
"deploy / artifact: coverage results",
727+
),
726728
]);
727729
}
728730

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@
6363
"esbuild": "^0.25.8",
6464
"eslint": "^9.32.0",
6565
"eslint-plugin-html": "^8.1.1",
66-
"eslint-plugin-react-hooks": "^5.2.0",
66+
"eslint-plugin-react-hooks": "^7.0.0",
6767
"eslint-plugin-react-refresh": "^0.4.19",
6868
"express": "^5.1.0",
6969
"globals": "^16.0.0",
70-
"globby": "^14.0.0",
70+
"globby": "^15.0.0",
7171
"glsl-strip-comments": "^1.0.0",
7272
"gulp": "^5.0.0",
7373
"gulp-clean-css": "^4.3.0",
@@ -101,7 +101,7 @@
101101
"prismjs": "^1.28.0",
102102
"rimraf": "^6.0.1",
103103
"tsd-jsdoc": "^2.5.0",
104-
"typescript": "~5.8.3",
104+
"typescript": "^5.9.3",
105105
"typescript-eslint": "^8.30.1",
106106
"yargs": "^18.0.0"
107107
},

packages/engine/Source/Core/Color.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,23 @@ Color.prototype.toBytes = function (result) {
679679
return result;
680680
};
681681

682+
/**
683+
* Converts RGBA values in bytes to a single numeric unsigned 32-bit RGBA value, using the endianness
684+
* of the system.
685+
*
686+
* @returns {number} A single numeric unsigned 32-bit RGBA value.
687+
*
688+
* @see Color.toRgba
689+
*/
690+
Color.bytesToRgba = function (red, green, blue, alpha) {
691+
// scratchUint32Array and scratchUint8Array share an underlying array buffer
692+
scratchUint8Array[0] = red;
693+
scratchUint8Array[1] = green;
694+
scratchUint8Array[2] = blue;
695+
scratchUint8Array[3] = alpha;
696+
return scratchUint32Array[0];
697+
};
698+
682699
/**
683700
* Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness
684701
* of the system.
@@ -692,12 +709,12 @@ Color.prototype.toBytes = function (result) {
692709
* @see Color.fromRgba
693710
*/
694711
Color.prototype.toRgba = function () {
695-
// scratchUint32Array and scratchUint8Array share an underlying array buffer
696-
scratchUint8Array[0] = Color.floatToByte(this.red);
697-
scratchUint8Array[1] = Color.floatToByte(this.green);
698-
scratchUint8Array[2] = Color.floatToByte(this.blue);
699-
scratchUint8Array[3] = Color.floatToByte(this.alpha);
700-
return scratchUint32Array[0];
712+
return Color.bytesToRgba(
713+
Color.floatToByte(this.red),
714+
Color.floatToByte(this.green),
715+
Color.floatToByte(this.blue),
716+
Color.floatToByte(this.alpha),
717+
);
701718
};
702719

703720
/**

packages/engine/Source/Renderer/Context.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function Context(canvas, options) {
356356
this._vertexAttribDivisors.push(0);
357357
}
358358

359-
this._pickObjects = {};
359+
this._pickObjects = new Map();
360360
this._nextPickColor = new Uint32Array(1);
361361

362362
/**
@@ -1562,7 +1562,7 @@ Context.prototype.createViewportQuadCommand = function (
15621562
/**
15631563
* Gets the object associated with a pick color.
15641564
*
1565-
* @param {Color} pickColor The pick color.
1565+
* @param {number} pickColor The unsigned 32-bit RGBA pick color
15661566
* @returns {object} The object associated with the pick color, or undefined if no object is associated with that color.
15671567
*
15681568
* @example
@@ -1575,9 +1575,15 @@ Context.prototype.getObjectByPickColor = function (pickColor) {
15751575
Check.defined("pickColor", pickColor);
15761576
//>>includeEnd('debug');
15771577

1578-
return this._pickObjects[pickColor.toRgba()];
1578+
return this._pickObjects.get(pickColor);
15791579
};
15801580

1581+
/**
1582+
*
1583+
* @param {Map<number, object>} pickObjects
1584+
* @param {number} key
1585+
* @param {Color} color
1586+
*/
15811587
function PickId(pickObjects, key, color) {
15821588
this._pickObjects = pickObjects;
15831589
this.key = key;
@@ -1587,16 +1593,16 @@ function PickId(pickObjects, key, color) {
15871593
Object.defineProperties(PickId.prototype, {
15881594
object: {
15891595
get: function () {
1590-
return this._pickObjects[this.key];
1596+
return this._pickObjects.get(this.key);
15911597
},
15921598
set: function (value) {
1593-
this._pickObjects[this.key] = value;
1599+
this._pickObjects.set(this.key, value);
15941600
},
15951601
},
15961602
});
15971603

15981604
PickId.prototype.destroy = function () {
1599-
delete this._pickObjects[this.key];
1605+
this._pickObjects.delete(this.key);
16001606
return undefined;
16011607
};
16021608

@@ -1633,7 +1639,7 @@ Context.prototype.createPickId = function (object) {
16331639
throw new RuntimeError("Out of unique Pick IDs.");
16341640
}
16351641

1636-
this._pickObjects[key] = object;
1642+
this._pickObjects.set(key, object);
16371643
return new PickId(this._pickObjects, key, Color.fromRgba(key));
16381644
};
16391645

packages/engine/Source/Scene/PickFramebuffer.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ PickFramebuffer.prototype.begin = function (screenSpaceRectangle, viewport) {
4848
return this._passState;
4949
};
5050

51-
const colorScratchForPickFramebuffer = new Color();
52-
5351
/**
54-
* Return the picked object rendered within a given rectangle.
52+
* Return the picked objects rendered within a given rectangle.
5553
*
5654
* @param {BoundingRectangle} screenSpaceRectangle
57-
* @returns {object|undefined} The object rendered in the middle of the rectangle, or undefined if nothing was rendered.
55+
* @param {number} [limit=1] If supplied, stop iterating after collecting this many objects.
56+
* @returns {object[]} A list of rendered objects, ordered by distance to the middle of the rectangle.
5857
*/
59-
PickFramebuffer.prototype.end = function (screenSpaceRectangle) {
58+
PickFramebuffer.prototype.end = function (screenSpaceRectangle, limit = 1) {
6059
const width = screenSpaceRectangle.width ?? 1.0;
6160
const height = screenSpaceRectangle.height ?? 1.0;
6261

@@ -84,6 +83,7 @@ PickFramebuffer.prototype.end = function (screenSpaceRectangle) {
8483

8584
// The region does not have to square and the dimensions do not have to be odd, but
8685
// loop iterations would be wasted. Prefer square regions where the size is odd.
86+
const objects = new Set();
8787
for (let i = 0; i < length; ++i) {
8888
if (
8989
-halfWidth <= x &&
@@ -93,22 +93,19 @@ PickFramebuffer.prototype.end = function (screenSpaceRectangle) {
9393
) {
9494
const index = 4 * ((halfHeight - y) * width + x + halfWidth);
9595

96-
colorScratchForPickFramebuffer.red = Color.byteToFloat(pixels[index]);
97-
colorScratchForPickFramebuffer.green = Color.byteToFloat(
96+
const pickColor = Color.bytesToRgba(
97+
pixels[index],
9898
pixels[index + 1],
99-
);
100-
colorScratchForPickFramebuffer.blue = Color.byteToFloat(
10199
pixels[index + 2],
102-
);
103-
colorScratchForPickFramebuffer.alpha = Color.byteToFloat(
104100
pixels[index + 3],
105101
);
106102

107-
const object = context.getObjectByPickColor(
108-
colorScratchForPickFramebuffer,
109-
);
103+
const object = context.getObjectByPickColor(pickColor);
110104
if (defined(object)) {
111-
return object;
105+
objects.add(object);
106+
if (objects.size >= limit) {
107+
break;
108+
}
112109
}
113110
}
114111

@@ -123,8 +120,7 @@ PickFramebuffer.prototype.end = function (screenSpaceRectangle) {
123120
x += dx;
124121
y += dy;
125122
}
126-
127-
return undefined;
123+
return [...objects];
128124
};
129125

130126
/**

0 commit comments

Comments
 (0)