Merge branch 'main' into billboard-terrain-clip-fix

This commit is contained in:
Gabby Getz 2025-09-29 10:52:45 -04:00 committed by GitHub
commit 6a5a0c469a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 102 additions and 7 deletions

View File

@ -431,3 +431,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Easy Mahaffey](https://github.com/easymaahffey)
- [Pamela Augustine](https://github.com/pamelaAugustine)
- [宋时旺](https://github.com/BlockCnFuture)
- [Marco Zhan](https://github.com/marcoYxz)

View File

@ -123,7 +123,7 @@ function handleBuildWarnings(result) {
export async function build() {
// Configure build options from command line arguments.
const minify = argv.minify ?? false;
const removePragmas = argv.pragmas ?? false;
const removePragmas = argv.removePragmas ?? false;
const sourcemap = argv.sourcemap ?? true;
const node = argv.node ?? true;

View File

@ -46,7 +46,90 @@ function ClippingPolygon(options) {
//>>includeEnd('debug');
this._ellipsoid = options.ellipsoid ?? Ellipsoid.default;
this._positions = [...options.positions];
this._positions = copyArrayCartesian3(options.positions);
/**
* A copy of the input positions.
*
* This is used to detect modifications of the positions in
* <code>coputeRectangle</code>: The rectangle only has
* to be re-computed when these positions have changed.
*
* @type {Cartesian3[]|undefined}
* @private
*/
this._cachedPositions = undefined;
/**
* A cached version of the rectangle that is computed in
* <code>computeRectangle</code>.
*
* This is only re-computed when the positions have changed, as
* determined by comparing the <code>_positions</code> to the
* <code>_cachedPositions</code>
*
* @type {Rectangle|undefined}
* @private
*/
this._cachedRectangle = undefined;
}
/**
* Returns a deep copy of the given array.
*
* If the input is undefined, then <code>undefined</code> is returned.
*
* Otherwise, the result will be a copy of the given array, where
* each element is copied with <code>Cartesian3.clone</code>.
*
* @param {Cartesian3[]|undefined} input The input array
* @returns {Cartesian3[]|undefined} The copy
*/
function copyArrayCartesian3(input) {
if (!defined(input)) {
return undefined;
}
const n = input.length;
const output = Array(n);
for (let i = 0; i < n; i++) {
output[i] = Cartesian3.clone(input[i]);
}
return output;
}
/**
* Returns whether the given arrays are component-wise equal.
*
* When both arrays are undefined, then <code>true</code> is returned.
* When only one array is defined, or they are both defined but have
* different lengths, then <code>false</code> is returned.
*
* Otherwise, returns whether the corresponding elements of the arrays
* are equal, as of <code>Cartesian3.equals</code>.
*
* @param {Cartesian3[]|undefined} a The first array
* @param {Cartesian3[]|undefined} b The second array
* @returns {boolean} Whether the arrays are equal
*/
function equalsArrayCartesian3(a, b) {
if (!defined(a) && !defined(b)) {
return true;
}
if (defined(a) !== defined(b)) {
return false;
}
if (a.length !== b.length) {
return false;
}
const n = a.length;
for (let i = 0; i < n; i++) {
const ca = a[i];
const cb = b[i];
if (!Cartesian3.equals(ca, cb)) {
return false;
}
}
return true;
}
Object.defineProperties(ClippingPolygon.prototype, {
@ -138,12 +221,18 @@ ClippingPolygon.equals = function (left, right) {
* @returns {Rectangle} The result rectangle
*/
ClippingPolygon.prototype.computeRectangle = function (result) {
return PolygonGeometry.computeRectangleFromPositions(
if (equalsArrayCartesian3(this._positions, this._cachedPositions)) {
return Rectangle.clone(this._cachedRectangle, result);
}
const rectangle = PolygonGeometry.computeRectangleFromPositions(
this.positions,
this.ellipsoid,
undefined,
result,
);
this._cachedPositions = copyArrayCartesian3(this._positions);
this._cachedRectangle = Rectangle.clone(rectangle);
return rectangle;
};
const scratchRectangle = new Rectangle();

View File

@ -299,7 +299,7 @@ if (import.meta.url.endsWith(`${pathToFileURL(process.argv[1])}`)) {
let buildGalleryOptions;
try {
const config = await import(configPath);
const config = await import(pathToFileURL(configPath).href);
const { root, publicDir, gallery, sourceUrl } = config.default;
// Paths are specified relative to the config file

View File

@ -4,7 +4,7 @@ import { readFile, writeFile } from "node:fs/promises";
import { EOL } from "node:os";
import path from "node:path";
import { finished } from "node:stream/promises";
import { fileURLToPath } from "node:url";
import { fileURLToPath, pathToFileURL } from "node:url";
import esbuild from "esbuild";
import { globby } from "globby";
@ -387,6 +387,9 @@ export async function bundleWorkers(options) {
workerConfig.logOverride = {
"empty-import-meta": "silent",
};
workerConfig.plugins = options.removePragmas
? [stripPragmaPlugin]
: undefined;
} else {
workerConfig.format = "esm";
workerConfig.splitting = true;
@ -616,7 +619,7 @@ const externalResolvePlugin = {
export async function getSandcastleConfig() {
const configPath = "packages/sandcastle/sandcastle.config.js";
const configImportPath = path.join(projectRoot, configPath);
const config = await import(configImportPath);
const config = await import(pathToFileURL(configImportPath).href);
const options = config.default;
return {
...options,
@ -650,7 +653,9 @@ export async function buildSandcastleGallery(includeDevelopment) {
__dirname,
"../packages/sandcastle/scripts/buildGallery.js",
);
const { buildGalleryList } = await import(buildGalleryScriptPath);
const { buildGalleryList } = await import(
pathToFileURL(buildGalleryScriptPath).href
);
await buildGalleryList({
rootDirectory,