Merge branch 'main' into splat-spz-concept

This commit is contained in:
keyboardspecialist 2025-04-21 13:57:07 -05:00
commit e29eb34e92
556 changed files with 4485 additions and 5474 deletions

View File

@ -22,7 +22,7 @@
"body": [
"//>>includeStart('debug', pragmas.debug);",
"${TM_SELECTED_TEXT}$0",
"//>>includeEnd('debug')"
"//>>includeEnd('debug');"
]
},
"Check type": {

View File

@ -68,7 +68,25 @@
"subtrees": {
"uri": "subtrees/{level}/{x}/{y}/{z}.json"
}
}
},
"transform": [
6378137.0,
0.0,
0.0,
0.0,
0.0,
6378137.0,
0.0,
0.0,
0.0,
0.0,
6378137.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
"extensionsUsed": [
"3DTILES_content_voxels"

View File

@ -33,20 +33,9 @@
"boundingVolume": {
"extensions": {
"3DTILES_bounding_volume_cylinder": {
"cylinder": [
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0
]
"height": 2.0,
"minRadius": 0.0,
"maxRadius": 1.0
}
}
},
@ -72,7 +61,25 @@
"subtrees": {
"uri": "subtrees/{level}/{x}/{y}/{z}.json"
}
}
},
"transform": [
6378137.0,
0.0,
0.0,
0.0,
0.0,
6378137.0,
0.0,
0.0,
0.0,
0.0,
6378137.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
"extensionsUsed": [
"3DTILES_bounding_volume_cylinder",

View File

@ -1,14 +0,0 @@
{
"id": "voxel",
"classes": {
"voxel": {
"properties": {
"a": {
"type": "SCALAR",
"componentType": "FLOAT32",
"required": false
}
}
}
}
}

View File

@ -1,14 +1,11 @@
{
"tileAvailability": {
"availableCount": 1,
"constant": 1
},
"contentAvailability": {
"availableCount": 1,
"contentAvailability": [{
"constant": 1
},
}],
"childSubtreeAvailability": {
"availableCount": 0,
"constant": 0
}
}

View File

@ -2,6 +2,40 @@
"asset": {
"version": "2.0"
},
"extensionsUsed": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensionsRequired": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensions": {
"EXT_structural_metadata": {
"schema": {
"classes": {
"voxel": {
"properties": {
"a": {
"type": "VEC4",
"componentType": "FLOAT32"
}
}
}
}
},
"propertyAttributes": [
{
"class": "voxel",
"properties": {
"a": {
"attribute": "_DATA"
}
}
}
]
}
},
"scene": 0,
"scenes": [
{
@ -19,82 +53,53 @@
{
"primitives": [
{
"mode": 2147483649,
"attributes": {
"_a": 0
"_DATA": 0
},
"mode": 2147483647,
"extensions": {
"EXT_primitive_voxels": {
"shape": 0,
"dimensions": [
2,
2,
2
],
"bounds": {
"min": [
0.0,
0.0,
-1.0
],
"max": [
1.0,
1.0,
0.0
]
}
]
},
"EXT_structural_metadata": {
"propertyAttributes": [0]
}
}
}
]
}
],
"extensionsUsed": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensionsRequired": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensions": {
"EXT_structural_metadata": {
"schemaUri": "../../../../schema.json",
"propertyAttributes": [
{
"class": "voxel",
"properties": {
"a": {
"attribute": "_a"
}
}
}
]
}
},
"accessors": [
{
"bufferView": 0,
"type": "SCALAR",
"byteOffset": 0,
"componentType": 5126,
"min": [
0.0
],
"count": 8,
"max": [
1.0
1.0, 1.0, 1.0, 1.0
],
"count": 8
"min": [
0.0, 0.0, 0.0, 0.0
],
"type": "VEC4"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 32
"byteOffset": 0,
"byteLength": 128
}
],
"buffers": [
{
"uri": "a.bin",
"byteLength": 32
"byteLength": 128
}
]
}
}

View File

@ -2,7 +2,19 @@
"asset": {
"version": "1.1"
},
"schemaUri": "schema.json",
"schema": {
"id": "voxel",
"classes": {
"voxel": {
"properties": {
"a": {
"type": "VEC4",
"componentType": "FLOAT32"
}
}
}
}
},
"statistics": {
"classes": {
"voxel": {
@ -28,7 +40,7 @@
500000.0
]
},
"geometricError": 0.0,
"geometricError": 16.0,
"refine": "REPLACE",
"content": {
"uri": "tiles/{level}/{x}/{y}/{z}.gltf",
@ -45,7 +57,7 @@
},
"implicitTiling": {
"subdivisionScheme": "OCTREE",
"subtreeLevels": 3,
"subtreeLevels": 1,
"availableLevels": 1,
"subtrees": {
"uri": "subtrees/{level}/{x}/{y}/{z}.json"

View File

@ -301,10 +301,7 @@
const propertyValue = feature.getProperty(propertyId);
const property = metadataClass.properties[propertyId];
const propertyType = Cesium.defaultValue(
property.componentType,
property.type,
);
const propertyType = property.componentType ?? property.type;
tableHtmlScratch += `<tr style='font-family: monospace;' title='${property.description}'><th>${property.name}</th><th><b>${property.id}</b></th><td>${propertyType}</td><td>${propertyValue}</td></tr>`;
}
tableHtmlScratch +=

View File

@ -49,7 +49,7 @@
const styles = [];
function addStyle(name, style) {
style.pointSize = Cesium.defaultValue(style.pointSize, 5.0);
style.pointSize = style.pointSize ?? 5.0;
styles.push({
name: name,
style: style,

View File

@ -169,12 +169,14 @@
);
addBaseLayerOption("OpenStreetMaps", new Cesium.OpenStreetMapImageryProvider());
addBaseLayerOption(
"Stamen Maps",
"Stadia x Stamen Watercolor",
new Cesium.OpenStreetMapImageryProvider({
url: "https://stamen-tiles.a.ssl.fastly.net/watercolor/",
url: "https://tiles.stadiamaps.com/tiles/stamen_watercolor/",
fileExtension: "jpg",
credit:
"Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.",
credit: `&copy; <a href="https://stamen.com/" target="_blank">Stamen Design</a>
&copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
&copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
&copy; <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`,
}),
);
addBaseLayerOption(
@ -269,8 +271,8 @@
try {
const imageryProvider = await Promise.resolve(imageryProviderPromise);
const layer = new Cesium.ImageryLayer(imageryProvider);
layer.alpha = Cesium.defaultValue(alpha, 0.5);
layer.show = Cesium.defaultValue(show, true);
layer.alpha = alpha ?? 0.5;
layer.show = show ?? true;
layer.name = name;
imageryLayers.add(layer);
Cesium.knockout.track(layer, ["alpha", "show", "name"]);

View File

@ -64,6 +64,14 @@
const scratchColor = new Cesium.Color();
const globalTransform = Cesium.Matrix4.fromScale(
Cesium.Cartesian3.fromElements(
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
),
);
function ProceduralMultiTileVoxelProvider(shape) {
this.shape = shape;
this.dimensions = new Cesium.Cartesian3(4, 4, 4);
@ -71,6 +79,7 @@
this.types = [Cesium.MetadataType.VEC4];
this.componentTypes = [Cesium.MetadataComponentType.FLOAT32];
this._levelCount = 3;
this.globalTransform = globalTransform;
}
ProceduralMultiTileVoxelProvider.prototype.requestData = function (options) {
@ -157,19 +166,10 @@
},
});
const modelMatrix = Cesium.Matrix4.fromScale(
Cesium.Cartesian3.fromElements(
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
),
);
const voxelPrimitive = scene.primitives.add(
new Cesium.VoxelPrimitive({
provider: provider,
customShader: customShader,
modelMatrix: modelMatrix,
}),
);

View File

@ -44,14 +44,6 @@
viewer.extend(Cesium.viewerVoxelInspectorMixin);
viewer.scene.debugShowFramesPerSecond = true;
const customShaderWhite = new Cesium.CustomShader({
fragmentShaderText: `void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)
{
material.diffuse = vec3(1.0);
material.alpha = 1.0;
}`,
});
const customShaderColor = new Cesium.CustomShader({
fragmentShaderText: `void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)
{
@ -60,22 +52,13 @@
}`,
});
const modelMatrix = Cesium.Matrix4.fromScale(
Cesium.Cartesian3.fromElements(
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
),
);
function createPrimitive(provider, customShader, modelMatrix) {
function createPrimitive(provider) {
viewer.scene.primitives.removeAll();
const voxelPrimitive = viewer.scene.primitives.add(
new Cesium.VoxelPrimitive({
provider: provider,
customShader: customShader,
modelMatrix: modelMatrix,
customShader: customShaderColor,
}),
);
@ -96,7 +79,7 @@
const provider = await Cesium.Cesium3DTilesVoxelProvider.fromUrl(
"../../SampleData/Cesium3DTiles/Voxel/VoxelBox3DTiles/tileset.json",
);
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider);
},
},
{
@ -105,7 +88,7 @@
const provider = await Cesium.Cesium3DTilesVoxelProvider.fromUrl(
"../../SampleData/Cesium3DTiles/Voxel/VoxelCylinder3DTiles/tileset.json",
);
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider);
},
},
{
@ -114,11 +97,7 @@
const provider = await Cesium.Cesium3DTilesVoxelProvider.fromUrl(
"../../SampleData/Cesium3DTiles/Voxel/VoxelEllipsoid3DTiles/tileset.json",
);
const primitive = createPrimitive(
provider,
customShaderWhite,
Cesium.Matrix4.IDENTITY,
);
const primitive = createPrimitive(provider);
},
},
]);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -47,6 +47,14 @@
viewer.extend(Cesium.viewerVoxelInspectorMixin);
viewer.scene.debugShowFramesPerSecond = true;
const globalTransform = Cesium.Matrix4.fromScale(
Cesium.Cartesian3.fromElements(
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
),
);
function ProceduralSingleTileVoxelProvider(shape) {
this.shape = shape;
this.minBounds = Cesium.VoxelShapeType.getMinBounds(shape).clone();
@ -55,6 +63,7 @@
this.names = ["color"];
this.types = [Cesium.MetadataType.VEC4];
this.componentTypes = [Cesium.MetadataComponentType.FLOAT32];
this.globalTransform = globalTransform;
}
const scratchColor = new Cesium.Color();
@ -110,6 +119,7 @@
this.names = ["color"];
this.types = [Cesium.MetadataType.VEC4];
this.componentTypes = [Cesium.MetadataComponentType.FLOAT32];
this.globalTransform = globalTransform;
this._levelCount = 2;
this._allVoxelData = new Array(this._levelCount);
@ -214,14 +224,13 @@
return Promise.resolve(content);
};
function createPrimitive(provider, customShader, modelMatrix) {
function createPrimitive(provider, customShader) {
viewer.scene.primitives.removeAll();
const voxelPrimitive = viewer.scene.primitives.add(
new Cesium.VoxelPrimitive({
provider: provider,
customShader: customShader,
modelMatrix: modelMatrix,
}),
);
@ -245,14 +254,6 @@
}`,
});
const modelMatrix = Cesium.Matrix4.fromScale(
Cesium.Cartesian3.fromElements(
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
Cesium.Ellipsoid.WGS84.maximumRadius,
),
);
Sandcastle.addToolbarMenu([
{
text: "Ellipsoid - Procedural Tile",
@ -262,7 +263,7 @@
);
provider.minBounds.z = 0.0;
provider.maxBounds.z = 1000000.0;
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider, customShaderColor);
},
},
{
@ -271,7 +272,7 @@
const provider = new ProceduralSingleTileVoxelProvider(
Cesium.VoxelShapeType.CYLINDER,
);
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider, customShaderColor);
},
},
{
@ -280,7 +281,7 @@
const provider = new ProceduralSingleTileVoxelProvider(
Cesium.VoxelShapeType.BOX,
);
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider, customShaderColor);
},
},
{
@ -289,7 +290,7 @@
const provider = new ProceduralMultiTileVoxelProvider(
Cesium.VoxelShapeType.BOX,
);
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider, customShaderColor);
},
},
{
@ -300,7 +301,7 @@
);
provider.minBounds.z = 0.0;
provider.maxBounds.z = 1000000.0;
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider, customShaderColor);
},
},
{
@ -309,7 +310,7 @@
const provider = new ProceduralMultiTileVoxelProvider(
Cesium.VoxelShapeType.CYLINDER,
);
const primitive = createPrimitive(provider, customShaderColor, modelMatrix);
const primitive = createPrimitive(provider, customShaderColor);
},
},
]);

View File

@ -152,10 +152,10 @@
});
async function createModel(url, height, heading, pitch, roll) {
height = Cesium.defaultValue(height, 0.0);
heading = Cesium.defaultValue(heading, 0.0);
pitch = Cesium.defaultValue(pitch, 0.0);
roll = Cesium.defaultValue(roll, 0.0);
height = height ?? 0.0;
heading = heading ?? 0.0;
pitch = pitch ?? 0.0;
roll = roll ?? 0.0;
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
const origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);

View File

@ -31,10 +31,13 @@
window.startup = async function (Cesium) {
"use strict";
//Sandcastle_Begin
const serviceResponse = await fetch("https://api.cesium.com/itwin/token");
const { access_token: token } = await serviceResponse.json();
// Generate a share key for access to an iTwin without OAuth
// https://developer.bentley.com/apis/access-control-v2/operations/create-itwin-share/
Cesium.ITwinPlatform.defaultShareKey =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpVHdpbklkIjoiNTM1YTI0YTMtOWIyOS00ZTIzLWJiNWQtOWNlZGI1MjRjNzQzIiwiaWQiOiJmZTliOTgyMS0wYWI5LTQ4ZjItYmMzOC01NjQ5MTg5MDQyOTEiLCJleHAiOjE3NDQ5OTA2MjZ9.7bQIX32CGE4slLDPkOQZ4rRr4BqBSjbUOFAUvcdrFXE";
Cesium.ITwinPlatform.defaultAccessToken = token;
// For alternative forms of authentication you can use, visit https://developer.bentley.com/apis/overview/authorization/. Then set your access token like this:
// Cesium.ITwinPlatform.defaultAccessToken = 'your token'
// Set up viewer
const viewer = new Cesium.Viewer("cesiumContainer", {

View File

@ -29,10 +29,13 @@
window.startup = async function (Cesium) {
"use strict";
//Sandcastle_Begin
const serviceResponse = await fetch("https://api.cesium.com/itwin/token");
const { access_token: token } = await serviceResponse.json();
// Generate a share key for access to an iTwin without OAuth
// https://developer.bentley.com/apis/access-control-v2/operations/create-itwin-share/
Cesium.ITwinPlatform.defaultShareKey =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpVHdpbklkIjoiMDRiYTcyNWYtZjNjMC00ZjMwLTgwMTQtYTQ0ODhjYmQ2MTJkIiwiaWQiOiI3ZDI2MTQ2YS1mMWE4LTRmYzYtODI5Ny05ODA4ZGRlZDdkOTciLCJleHAiOjE3NDQ5OTAzNzl9.w8B077BL6TJ8Ohit9Pzyw8DlqicKDVBMwgcE0ujLOBQ";
Cesium.ITwinPlatform.defaultAccessToken = token;
// For alternative forms of authentication you can use, visit https://developer.bentley.com/apis/overview/authorization/. Then set your access token like this:
// Cesium.ITwinPlatform.defaultAccessToken = 'your token'
const iTwinId = "04ba725f-f3c0-4f30-8014-a4488cbd612d";

View File

@ -1,18 +1,41 @@
# Change Log
## 1.129 - 2025-05-01
### @cesium/engine
#### Fixes :wrench:
- `QuadtreePrimitive.updateHeights` now converts position to Cartographic before invoking the callback, ensuring compatibility with change introduced by [commit 53889cb](https://github.com/CesiumGS/cesium/commit/53889cb) and preventing unnecessary computation. [#12555](https://github.com/CesiumGS/cesium/pull/12555)
## 1.128 - 2025-04-01
### @cesium/engine
#### Breaking Changes :mega:
- `Camera.getPickRay` was erroneous returning a result in camera coordinates. It is now returned in world coordinates as stated in the documentation. The result can be transformed using `Camera.inverseViewMatrix` to achieve the previous behavior.
- `Camera.getPickRay` was erroneously returning a result in camera coordinates. It is now returned in world coordinates as stated in the documentation. The result can be transformed using `Camera.inverseViewMatrix` to achieve the previous behavior.
- `VoxelMetadataOrder` has been made private, and the `metadataOrder` property has been removed from the `VoxelProvider` interface.
#### Additions :tada:
- Added support for loading iTwin data using share keys as an alternative to user-based OAuth. When using a share key, set `ITwinPlatform.defaultShareKey`. [#12530](https://github.com/CesiumGS/cesium/pull/12530)
- Added `Frozen.EMPTY_OBJECT` and `Frozen.EMPTY_ARRAY` for use as default parameter values that avoid unnecessary memory allocations. [#12507](https://github.com/CesiumGS/cesium/pull/12507)
#### Fixes :wrench:
- Fixed broken Entity Tracking [sandcastle](https://sandcastle.cesium.com/?src=Entity%20tracking.html). [#12467](https://github.com/CesiumGS/cesium/pull/12467)
- Fixed entity tracking for delayed datasource bounding spheres. [#12465](https://github.com/CesiumGS/cesium/issues/12465)
- `Camera.getPickRay` now correctly returns a ray with origin in world coordinates in orthographic mode. [#12500](https://github.com/CesiumGS/cesium/pull/12500)
- Fixed camera zooming in 3D orthographic mode when pixelRatio is not 1. [#12487](https://github.com/CesiumGS/cesium/pull/12487)
- Fixed shape bounds and transforms for cylinder-shaped voxels. [#12522](https://github.com/CesiumGS/cesium/pull/12522)
- Fixed metadata ordering for ellipsoid voxel tilesets. [#12544](https://github.com/CesiumGS/cesium/pull/12544)
- Fixed an issue where clamped entities' height updates could stall when using high-resolution terrain due to a growing queue of tiles in `updateHeights` in `QuadtreePrimitive`. [#12476](https://github.com/CesiumGS/cesium/issues/12476)
- Fixed `VaryingType.MAT3` definition. [#12524](https://github.com/CesiumGS/cesium/issues/12524)
#### Deprecated :hourglass_flowing_sand:
- The `defaultValue` function has been deprecated, and will be removed in 1.134. Instead, use the logical OR (`||`) the [nullish coalescing (`??`)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing) operator. See the [Coding Guide](https://github.com/CesiumGS/cesium/tree/main/Documentation/Contributors/CodingGuide#default-parameter-values) for usage information and examples.
- `defaultValue.EMPTY_OBJECT` has been deprecated, and will be removed in 1.134. Instead, use `Frozen.EMPTY_OBJECT`. See the [Coding Guide](https://github.com/CesiumGS/cesium/tree/main/Documentation/Contributors/CodingGuide#default-parameter-values) for usage information and examples.
## 1.127 - 2025-03-03

View File

@ -427,3 +427,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Yutao Liu](https://github.com/liuyutao)
- [Andrew Dassonville](https://github.com/andrewda)
- [Cody Butler](https://github.com/CodyBu)
- [Hiwen](https://github.com/Hiwen)

View File

@ -42,17 +42,17 @@ To some extent, this guide can be summarized as _make new code similar to existi
- [Widgets](#widgets)
- [Knockout subscriptions](#knockout-subscriptions)
- [GLSL](#glsl)
- [Naming](#naming-1)
- [Formatting](#formatting-1)
- [Performance](#performance)
- [GLSL Naming](#glsl-naming)
- [GLSL Formatting](#glsl-formatting)
- [GLSL Performance](#glsl-performance)
- [Resources](#resources)
## Naming
- Directory names are `PascalCase`, e.g., `Source/Scene`.
- Constructor functions are `PascalCase`, e.g., `Cartesian3`.
- Functions are `camelCase`, e.g., `defaultValue()`, `Cartesian3.equalsEpsilon()`.
- Files end in `.js` and have the same name as the JavaScript identifier, e.g., `Cartesian3.js` and `defaultValue.js`.
- Functions are `camelCase`, e.g., `binarySearch()`, `Cartesian3.equalsEpsilon()`.
- Files end in `.js` and have the same name as the JavaScript identifier, e.g., `Cartesian3.js` and `binarySearch.js`.
- Variables, including class properties, are `camelCase`, e.g.,
```javascript
@ -438,39 +438,30 @@ const p = new Cartesian3(1.0, 2.0, 3.0);
### Default Parameter Values
If a _sensible_ default exists for a function parameter or class property, don't require the user to provide it. Use Cesium's `defaultValue` to assign a default value. For example, `height` defaults to zero in `Cartesian3.fromRadians`:
If a _sensible_ default exists for a function parameter or class property, don't require the user to provide it. Use the nullish coalescing operator [`??`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing) to assign a default value. For example, `height` defaults to zero in `Cartesian3.fromRadians`:
```javascript
Cartesian3.fromRadians = function (longitude, latitude, height) {
height = defaultValue(height, 0.0);
height = height ?? 0.0;
// ...
};
```
- :speedboat: Don't use `defaultValue` if it could cause an unnecessary function call or memory allocation, e.g.,
- :speedboat: `??` operator can also be used with a memory allocations in the right hand side, as it will be allocated only if the left hand side is either `null` or `undefined`, and therefore has no negative impact on performances, e.g.,
```javascript
this._mapProjection = defaultValue(
options.mapProjection,
new GeographicProjection(),
);
this._mapProjection = options.mapProjection ?? new GeographicProjection();
```
is better written as
- If an `options` parameter is optional and never modified afterwards, use `Frozen.EMPTY_OBJECT` or `Frozen.EMPTY_ARRAY`, this could prevent from unnecessary memory allocations in code critical path, e.g.,
```javascript
this._mapProjection = defined(options.mapProjection)
? options.mapProjection
: new GeographicProjection();
```
function BaseLayerPickerViewModel(options) {
options = options ?? Frozen.EMPTY_OBJECT;
- If an `options` parameter is optional, use `defaultValue.EMPTY_OBJECT`, e.g.,
```javascript
function DebugModelMatrixPrimitive(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this.length = defaultValue(options.length, 10000000.0);
this.width = defaultValue(options.width, 2.0);
const globe = options.globe;
const imageryProviderViewModels =
options.imageryProviderViewModels ?? Frozen.EMPTY_ARRAY;
// ...
}
```
@ -594,9 +585,9 @@ result = Cartesian3.add(result, v2, result);
```javascript
function Cartesian3(x, y, z) {
this.x = defaultValue(x, 0.0);
this.y = defaultValue(y, 0.0);
this.z = defaultValue(z, 0.0);
this.x = x ?? 0.0;
this.y = y ?? 0.0;
this.z = z ?? 0.0;
}
```
@ -771,7 +762,7 @@ Public properties that can be read or written without extra processing can simpl
```javascript
function Model(options) {
this.show = defaultValue(options.show, true);
this.show = options.show ?? true;
}
```
@ -827,9 +818,7 @@ When the overhead of getter/setter functions is prohibitive or reference-type se
```javascript
function Model(options) {
this.modelMatrix = Matrix4.clone(
defaultValue(options.modelMatrix, Matrix4.IDENTITY),
);
this.modelMatrix = Matrix4.clone(options.modelMatrix ?? Matrix4.IDENTITY);
this._modelMatrix = Matrix4.clone(this.modelMatrix);
}
@ -989,63 +978,70 @@ fullscreenSubscription.dispose();
## GLSL
### Naming
### GLSL Naming
- GLSL files end with `.glsl` and are in the [Shaders](https://github.com/CesiumGS/cesium/tree/main/Source/Shaders) directory.
- GLSL files end with `.glsl` and are in the [Shaders](https://github.com/CesiumGS/cesium/tree/main/packages/engine/Source/Shaders) directory.
- Files for vertex shaders have a `VS` suffix; fragment shaders have an `FS` suffix. For example: `BillboardCollectionVS.glsl` and `BillboardCollectionFS.glsl`.
- Generally, identifiers, such as functions and variables, use `camelCase`.
- Cesium built-in identifiers start with `czm_`, for example, [`czm_material`](https://github.com/CesiumGS/cesium/blob/main/Source/Shaders/Builtin/Structs/material.glsl). Files have the same name without the `czm_` prefix, e.g., `material.glsl`.
- Cesium built-in identifiers start with `czm_`, for example, [`czm_material`](https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Shaders/Builtin/Structs/material.glsl). Files have the same name without the `czm_` prefix, e.g., `material.glsl`.
- Use `czm_textureCube` when sampling a cube map instead of `texture`. This is to preserve backwards compatibility with WebGL 1.
- Varyings start with `v_`, e.g.,
```javascript
in vec2 v_textureCoordinates;
```
```javascript
in vec2 v_textureCoordinates;
```
- Uniforms start with `u_`, e.g.,
```javascript
uniform sampler2D u_atlas;
```
```javascript
uniform sampler2D u_atlas;
```
- An `EC` suffix indicates the point or vector is in eye coordinates, e.g.,
```glsl
varying vec3 v_positionEC;
// ...
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
```
```glsl
varying vec3 v_positionEC;
// ...
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
```
- When [GPU RTE](https://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm) is used, `High` and `Low` suffixes define the high and low bits, respectively, e.g.,
```glsl
attribute vec3 position3DHigh;
attribute vec3 position3DLow;
```
```glsl
attribute vec3 position3DHigh;
attribute vec3 position3DLow;
```
- 2D texture coordinates are `s` and `t`, not `u` and `v`, e.g.,
```glsl
attribute vec2 st;
```
```glsl
attribute vec2 st;
```
### Formatting
### GLSL Formatting
- Use the same formatting as JavaScript, except put `{` on a new line, e.g.,
```glsl
struct czm_ray
{
vec3 origin;
vec3 direction;
};
```
```glsl
struct czm_ray
{
vec3 origin;
vec3 direction;
};
```
### Performance
### GLSL Performance
- :speedboat: Compute expensive values as infrequently as possible, e.g., prefer computing a value in JavaScript and passing it in a uniform instead of redundantly computing the same value per-vertex. Likewise, prefer to compute a value per-vertex and pass a varying, instead of computing per-fragment when possible.
- :speedboat: Use `discard` sparingly since it disables early-z GPU optimizations.
#### Branching in shaders
Conditional logic may have a performance impact when executing shader code. GPUs rely on many parallel calculations being executable at once, and branching code can disrupt that parallelism— executing expensive instructions for one vertex or fragment in one thread may block the execution of the others.
- Avoid executing non-trivial code in `if-else` statements.
- Branching based on the value of uniform, e.g. `if (czm_orthographicIn3D == 1.0)`, or variables consistent across all vertices or fragments shouldn't cause a bottleneck.
- :speedboat: Use `czm_branchFreeTernary` to avoid branching. For example:
```glsl
if (sphericalLatLong.y >= czm_pi) {
sphericalLatLong.y = sphericalLatLong.y - czm_twoPi;
}
```
could be better written as
```glsl
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
```
## Resources
See Section 4.1 to 4.3 of [Getting Serious with JavaScript](http://webglinsights.github.io/downloads/WebGL-Insights-Chapter-4.pdf) by Cesium contributors Matthew Amato and Kevin Ring in _WebGL Insights_ for deeper coverage of modules and performance.

View File

@ -291,7 +291,7 @@ function Cartesian3(x, y) {
* @type {number}
* @default 0.0
*/
this.x = defaultValue(x, 0.0);
this.x = x ?? 0.0;
// ...
```

View File

@ -28,7 +28,7 @@ There is no release manager; instead, our community shares the responsibility. A
2. Go to Content at the top
3. Click "New Item" -> Developer Credentials -> API Key credentials
4. Set the expiration date to the day after the next release (no referrer URLs)
5. Only turn on "Basemaps" permissions
5. Only turn on "Static maps" permissions
6. Skip adding items
7. Set the title and copy the API key on the last screen
8. Open the previous release's item and Delete it

View File

@ -5,8 +5,8 @@
| 1/2/2025 | `@ggetz` |
| 2/3/2025 | `@jjhembd` |
| 3/3/2025 | `@lukemckinstry` |
| 4/1/2025 | `@jjspace` |
| 5/1/2025 | `@ggetz` |
| 4/1/2025 | `@ggetz` |
| 5/1/2025 | `@jjspace` |
| 6/2/2025 | `@jjhembd` |
| 7/1/2025 | `@lukemckinstry` |
| 8/1/2025 | `@jjspace` |

View File

@ -1,7 +1,7 @@
import {
Cartesian3,
Color,
defaultValue,
Frozen,
defined,
JulianDate,
ImageBasedLighting,
@ -120,15 +120,9 @@ const defaultIbl = new ImageBasedLighting({
});
Cesium3DTilesTester.loadTileset = async function (scene, url, options) {
options = defaultValue(options, {});
options.cullRequestsWhileMoving = defaultValue(
options.cullRequestsWhileMoving,
false,
);
options.imageBasedLighting = defaultValue(
options.imageBasedLighting,
defaultIbl,
);
options = options ?? {};
options.cullRequestsWhileMoving = options.cullRequestsWhileMoving ?? false;
options.imageBasedLighting = options.imageBasedLighting ?? defaultIbl;
options.environmentMapOptions = {
enabled: false, // disable other diffuse lighting by default
...options.environmentMapOptions,
@ -170,10 +164,10 @@ Cesium3DTilesTester.tileDestroys = function (scene, url, options) {
Cesium3DTilesTester.generateBatchedTileBuffer = function (options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const magic = defaultValue(options.magic, [98, 51, 100, 109]);
const version = defaultValue(options.version, 1);
const featuresLength = defaultValue(options.featuresLength, 1);
options = options ?? Frozen.EMPTY_OBJECT;
const magic = options.magic ?? [98, 51, 100, 109];
const version = options.version ?? 1;
const featuresLength = options.featuresLength ?? 1;
const featureTableJson = {
BATCH_LENGTH: featuresLength,
};
@ -207,12 +201,12 @@ Cesium3DTilesTester.generateBatchedTileBuffer = function (options) {
Cesium3DTilesTester.generateInstancedTileBuffer = function (options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const magic = defaultValue(options.magic, [105, 51, 100, 109]);
const version = defaultValue(options.version, 1);
options = options ?? Frozen.EMPTY_OBJECT;
const magic = options.magic ?? [105, 51, 100, 109];
const version = options.version ?? 1;
const gltfFormat = defaultValue(options.gltfFormat, 1);
const gltfUri = defaultValue(options.gltfUri, "model.gltf");
const gltfFormat = options.gltfFormat ?? 1;
const gltfUri = options.gltfUri ?? "model.gltf";
const gltfUriByteLength = gltfUri.length;
const featureTableJson = options.featureTableJson;
@ -222,7 +216,7 @@ Cesium3DTilesTester.generateInstancedTileBuffer = function (options) {
featureTableJsonString = JSON.stringify(featureTableJson);
}
} else {
const featuresLength = defaultValue(options.featuresLength, 1);
const featuresLength = options.featuresLength ?? 1;
featureTableJsonString = JSON.stringify({
INSTANCES_LENGTH: featuresLength,
POSITION: new Array(featuresLength * 3).fill(0),
@ -231,10 +225,7 @@ Cesium3DTilesTester.generateInstancedTileBuffer = function (options) {
featureTableJsonString = padStringToByteAlignment(featureTableJsonString, 8);
const featureTableJsonByteLength = featureTableJsonString.length;
const featureTableBinary = defaultValue(
options.featureTableBinary,
new Uint8Array(0),
);
const featureTableBinary = options.featureTableBinary ?? new Uint8Array(0);
const featureTableBinaryByteLength = featureTableBinary.length;
const batchTableJson = options.batchTableJson;
@ -245,10 +236,7 @@ Cesium3DTilesTester.generateInstancedTileBuffer = function (options) {
batchTableJsonString = padStringToByteAlignment(batchTableJsonString, 8);
const batchTableJsonByteLength = batchTableJsonString.length;
const batchTableBinary = defaultValue(
options.batchTableBinary,
new Uint8Array(0),
);
const batchTableBinary = options.batchTableBinary ?? new Uint8Array(0);
const batchTableBinaryByteLength = batchTableBinary.length;
const headerByteLength = 32;
@ -300,9 +288,9 @@ Cesium3DTilesTester.generateInstancedTileBuffer = function (options) {
Cesium3DTilesTester.generatePointCloudTileBuffer = function (options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const magic = defaultValue(options.magic, [112, 110, 116, 115]);
const version = defaultValue(options.version, 1);
options = options ?? Frozen.EMPTY_OBJECT;
const magic = options.magic ?? [112, 110, 116, 115];
const version = options.version ?? 1;
let featureTableJson = options.featureTableJson;
if (!defined(featureTableJson)) {
featureTableJson = {
@ -315,10 +303,8 @@ Cesium3DTilesTester.generatePointCloudTileBuffer = function (options) {
let featureTableJsonString = JSON.stringify(featureTableJson);
featureTableJsonString = padStringToByteAlignment(featureTableJsonString, 4);
const featureTableJsonByteLength = defaultValue(
options.featureTableJsonByteLength,
featureTableJsonString.length,
);
const featureTableJsonByteLength =
options.featureTableJsonByteLength ?? featureTableJsonString.length;
const featureTableBinary = new ArrayBuffer(12); // Enough space to hold 3 floats
const featureTableBinaryByteLength = featureTableBinary.byteLength;
@ -356,10 +342,10 @@ Cesium3DTilesTester.generatePointCloudTileBuffer = function (options) {
Cesium3DTilesTester.generateCompositeTileBuffer = function (options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const magic = defaultValue(options.magic, [99, 109, 112, 116]);
const version = defaultValue(options.version, 1);
const tiles = defaultValue(options.tiles, []);
options = options ?? Frozen.EMPTY_OBJECT;
const magic = options.magic ?? [99, 109, 112, 116];
const version = options.version ?? 1;
const tiles = options.tiles ?? Frozen.EMPTY_ARRAY;
const tilesLength = tiles.length;
let i;
@ -393,20 +379,20 @@ Cesium3DTilesTester.generateCompositeTileBuffer = function (options) {
Cesium3DTilesTester.generateVectorTileBuffer = function (options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const magic = defaultValue(options.magic, [118, 99, 116, 114]);
const version = defaultValue(options.version, 1);
options = options ?? Frozen.EMPTY_OBJECT;
const magic = options.magic ?? [118, 99, 116, 114];
const version = options.version ?? 1;
let featureTableJsonString;
let featureTableJsonByteLength = 0;
const defineFeatureTable = defaultValue(options.defineFeatureTable, true);
const defineFeatureTable = options.defineFeatureTable ?? true;
if (defineFeatureTable) {
const defineRegion = defaultValue(options.defineRegion, true);
const defineRegion = options.defineRegion ?? true;
const featureTableJson = {
REGION: defineRegion ? [-1.0, -1.0, 1.0, 1.0, -1.0, 1.0] : undefined,
POLYGONS_LENGTH: defaultValue(options.polygonsLength, 0),
POLYLINES_LENGTH: defaultValue(options.polylinesLength, 0),
POINTS_LENGTH: defaultValue(options.pointsLength, 0),
POLYGONS_LENGTH: options.polygonsLength ?? 0,
POLYLINES_LENGTH: options.polylinesLength ?? 0,
POINTS_LENGTH: options.pointsLength ?? 0,
POLYGON_BATCH_IDS: options.polygonBatchIds,
POLYLINE_BATCH_IDS: options.polylineBatchIds,
POINT_BATCH_IDS: options.pointBatchIds,
@ -446,19 +432,19 @@ Cesium3DTilesTester.generateVectorTileBuffer = function (options) {
Cesium3DTilesTester.generateGeometryTileBuffer = function (options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const magic = defaultValue(options.magic, [103, 101, 111, 109]);
const version = defaultValue(options.version, 1);
options = options ?? Frozen.EMPTY_OBJECT;
const magic = options.magic ?? [103, 101, 111, 109];
const version = options.version ?? 1;
let featureTableJsonString;
let featureTableJsonByteLength = 0;
const defineFeatureTable = defaultValue(options.defineFeatureTable, true);
const defineFeatureTable = options.defineFeatureTable ?? true;
if (defineFeatureTable) {
const featureTableJson = {
BOXES_LENGTH: defaultValue(options.boxesLength, 0),
CYLINDERS_LENGTH: defaultValue(options.cylindersLength, 0),
ELLIPSOIDS_LENGTH: defaultValue(options.ellipsoidsLength, 0),
SPHERES_LENGTH: defaultValue(options.spheresLength, 0),
BOXES_LENGTH: options.boxesLength ?? 0,
CYLINDERS_LENGTH: options.cylindersLength ?? 0,
ELLIPSOIDS_LENGTH: options.ellipsoidsLength ?? 0,
SPHERES_LENGTH: options.spheresLength ?? 0,
BOX_BATCH_IDS: options.boxBatchIds,
CYLINDER_BATCH_IDS: options.cylinderBatchIds,
ELLIPSOID_BATCH_IDS: options.ellipsoidBatchIds,

View File

@ -21,20 +21,9 @@
"boundingVolume": {
"extensions": {
"3DTILES_bounding_volume_cylinder": {
"cylinder": [
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0
]
"height": 2.0,
"minRadius": 0.0,
"maxRadius": 1.0
}
}
},

View File

@ -1,21 +1,21 @@
import { defaultValue, FeatureDetection } from "@cesium/engine";
import { Frozen, FeatureDetection } from "@cesium/engine";
function createMouseEvent(type, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const canBubble = defaultValue(options.canBubble, true);
const cancelable = defaultValue(options.cancelable, true);
const view = defaultValue(options.view, window);
const detail = defaultValue(options.detail, 0);
const screenX = defaultValue(options.screenX, 0);
const screenY = defaultValue(options.screenY, 0);
const clientX = defaultValue(options.clientX, 0);
const clientY = defaultValue(options.clientY, 0);
const ctrlKey = defaultValue(options.ctrlKey, false);
const altKey = defaultValue(options.altKey, false);
const shiftKey = defaultValue(options.shiftKey, false);
const metaKey = defaultValue(options.metaKey, false);
const button = defaultValue(options.button, 0);
const relatedTarget = defaultValue(options.relatedTarget, null);
options = options ?? Frozen.EMPTY_OBJECT;
const canBubble = options.canBubble ?? true;
const cancelable = options.cancelable ?? true;
const view = options.view ?? window;
const detail = options.detail ?? 0;
const screenX = options.screenX ?? 0;
const screenY = options.screenY ?? 0;
const clientX = options.clientX ?? 0;
const clientY = options.clientY ?? 0;
const ctrlKey = options.ctrlKey ?? false;
const altKey = options.altKey ?? false;
const shiftKey = options.shiftKey ?? false;
const metaKey = options.metaKey ?? false;
const button = options.button ?? 0;
const relatedTarget = options.relatedTarget ?? null;
const event = document.createEvent("MouseEvent");
event.initMouseEvent(
@ -57,22 +57,22 @@ function createModifiersList(ctrlKey, altKey, shiftKey, metaKey) {
// MouseWheelEvent is legacy
function createMouseWheelEvent(type, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const canBubble = defaultValue(options.canBubble, true);
const cancelable = defaultValue(options.cancelable, true);
const view = defaultValue(options.view, window);
const detail = defaultValue(options.detail, 0);
const screenX = defaultValue(options.screenX, 0);
const screenY = defaultValue(options.screenY, 0);
const clientX = defaultValue(options.clientX, 0);
const clientY = defaultValue(options.clientY, 0);
const button = defaultValue(options.button, 0);
const relatedTarget = defaultValue(options.relatedTarget, null);
const ctrlKey = defaultValue(options.ctrlKey, false);
const altKey = defaultValue(options.altKey, false);
const shiftKey = defaultValue(options.shiftKey, false);
const metaKey = defaultValue(options.metaKey, false);
const wheelDelta = defaultValue(options.wheelDelta, 0);
options = options ?? Frozen.EMPTY_OBJECT;
const canBubble = options.canBubble ?? true;
const cancelable = options.cancelable ?? true;
const view = options.view ?? window;
const detail = options.detail ?? 0;
const screenX = options.screenX ?? 0;
const screenY = options.screenY ?? 0;
const clientX = options.clientX ?? 0;
const clientY = options.clientY ?? 0;
const button = options.button ?? 0;
const relatedTarget = options.relatedTarget ?? null;
const ctrlKey = options.ctrlKey ?? false;
const altKey = options.altKey ?? false;
const shiftKey = options.shiftKey ?? false;
const metaKey = options.metaKey ?? false;
const wheelDelta = options.wheelDelta ?? 0;
const event = document.createEvent("MouseWheelEvent");
const modifiersList = createModifiersList(ctrlKey, altKey, shiftKey, metaKey);
@ -95,25 +95,25 @@ function createMouseWheelEvent(type, options) {
}
function createWheelEvent(type, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const canBubble = defaultValue(options.canBubble, true);
const cancelable = defaultValue(options.cancelable, true);
const view = defaultValue(options.view, window);
const detail = defaultValue(options.detail, 0);
const screenX = defaultValue(options.screenX, 0);
const screenY = defaultValue(options.screenY, 0);
const clientX = defaultValue(options.clientX, 0);
const clientY = defaultValue(options.clientY, 0);
const button = defaultValue(options.button, 0);
const relatedTarget = defaultValue(options.relatedTarget, null);
const ctrlKey = defaultValue(options.ctrlKey, false);
const altKey = defaultValue(options.altKey, false);
const shiftKey = defaultValue(options.shiftKey, false);
const metaKey = defaultValue(options.metaKey, false);
const deltaX = defaultValue(options.deltaX, 0);
const deltaY = defaultValue(options.deltaY, 0);
const deltaZ = defaultValue(options.deltaZ, 0);
const deltaMode = defaultValue(options.deltaMode, 0);
options = options ?? Frozen.EMPTY_OBJECT;
const canBubble = options.canBubble ?? true;
const cancelable = options.cancelable ?? true;
const view = options.view ?? window;
const detail = options.detail ?? 0;
const screenX = options.screenX ?? 0;
const screenY = options.screenY ?? 0;
const clientX = options.clientX ?? 0;
const clientY = options.clientY ?? 0;
const button = options.button ?? 0;
const relatedTarget = options.relatedTarget ?? null;
const ctrlKey = options.ctrlKey ?? false;
const altKey = options.altKey ?? false;
const shiftKey = options.shiftKey ?? false;
const metaKey = options.metaKey ?? false;
const deltaX = options.deltaX ?? 0;
const deltaY = options.deltaY ?? 0;
const deltaZ = options.deltaZ ?? 0;
const deltaMode = options.deltaMode ?? 0;
try {
return new WheelEvent(type, {
@ -165,53 +165,53 @@ function createWheelEvent(type, options) {
}
function createTouchEvent(type, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const canBubble = defaultValue(options.canBubble, true);
const cancelable = defaultValue(options.cancelable, true);
const view = defaultValue(options.view, window);
const detail = defaultValue(options.detail, 0);
options = options ?? Frozen.EMPTY_OBJECT;
const canBubble = options.canBubble ?? true;
const cancelable = options.cancelable ?? true;
const view = options.view ?? window;
const detail = options.detail ?? 0;
const event = document.createEvent("UIEvent");
event.initUIEvent(type, canBubble, cancelable, view, detail);
event.touches = defaultValue(options.touches, []);
event.targetTouches = defaultValue(options.targetTouches, []);
event.changedTouches = defaultValue(options.changedTouches, []);
event.touches = options.touches ?? Frozen.EMPTY_ARRAY;
event.targetTouches = options.targetTouches ?? Frozen.EMPTY_ARRAY;
event.changedTouches = options.changedTouches ?? Frozen.EMPTY_ARRAY;
return event;
}
function createPointerEvent(type, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
let event;
if (FeatureDetection.isInternetExplorer()) {
const canBubble = defaultValue(options.canBubble, true);
const cancelable = defaultValue(options.cancelable, true);
const view = defaultValue(options.view, window);
const detail = defaultValue(options.detail, 0);
const screenX = defaultValue(options.screenX, 0);
const screenY = defaultValue(options.screenY, 0);
const clientX = defaultValue(options.clientX, 0);
const clientY = defaultValue(options.clientY, 0);
const ctrlKey = defaultValue(options.ctrlKey, false);
const altKey = defaultValue(options.altKey, false);
const shiftKey = defaultValue(options.shiftKey, false);
const metaKey = defaultValue(options.metaKey, false);
const button = defaultValue(options.button, 0);
const relatedTarget = defaultValue(options.relatedTarget, null);
const offsetX = defaultValue(options.offsetX, 0);
const offsetY = defaultValue(options.offsetY, 0);
const width = defaultValue(options.width, 0);
const height = defaultValue(options.height, 0);
const pressure = defaultValue(options.pressure, 0);
const rotation = defaultValue(options.rotation, 0);
const tiltX = defaultValue(options.tiltX, 0);
const tiltY = defaultValue(options.tiltY, 0);
const pointerId = defaultValue(options.pointerId, 1);
const pointerType = defaultValue(options.pointerType, 0);
const hwTimestamp = defaultValue(options.hwTimestamp, 0);
const isPrimary = defaultValue(options.isPrimary, 0);
const canBubble = options.canBubble ?? true;
const cancelable = options.cancelable ?? true;
const view = options.view ?? window;
const detail = options.detail ?? 0;
const screenX = options.screenX ?? 0;
const screenY = options.screenY ?? 0;
const clientX = options.clientX ?? 0;
const clientY = options.clientY ?? 0;
const ctrlKey = options.ctrlKey ?? false;
const altKey = options.altKey ?? false;
const shiftKey = options.shiftKey ?? false;
const metaKey = options.metaKey ?? false;
const button = options.button ?? 0;
const relatedTarget = options.relatedTarget ?? null;
const offsetX = options.offsetX ?? 0;
const offsetY = options.offsetY ?? 0;
const width = options.width ?? 0;
const height = options.height ?? 0;
const pressure = options.pressure ?? 0;
const rotation = options.rotation ?? 0;
const tiltX = options.tiltX ?? 0;
const tiltY = options.tiltY ?? 0;
const pointerId = options.pointerId ?? 1;
const pointerType = options.pointerType ?? 0;
const hwTimestamp = options.hwTimestamp ?? 0;
const isPrimary = options.isPrimary ?? 0;
event = document.createEvent("PointerEvent");
event.initPointerEvent(
@ -245,45 +245,45 @@ function createPointerEvent(type, options) {
);
} else {
event = new window.PointerEvent(type, {
canBubble: defaultValue(options.canBubble, true),
cancelable: defaultValue(options.cancelable, true),
view: defaultValue(options.view, window),
detail: defaultValue(options.detail, 0),
screenX: defaultValue(options.screenX, 0),
screenY: defaultValue(options.screenY, 0),
clientX: defaultValue(options.clientX, 0),
clientY: defaultValue(options.clientY, 0),
ctrlKey: defaultValue(options.ctrlKey, false),
altKey: defaultValue(options.altKey, false),
shiftKey: defaultValue(options.shiftKey, false),
metaKey: defaultValue(options.metaKey, false),
button: defaultValue(options.button, 0),
relatedTarget: defaultValue(options.relatedTarget, null),
offsetX: defaultValue(options.offsetX, 0),
offsetY: defaultValue(options.offsetY, 0),
width: defaultValue(options.width, 0),
height: defaultValue(options.height, 0),
pressure: defaultValue(options.pressure, 0),
rotation: defaultValue(options.rotation, 0),
tiltX: defaultValue(options.tiltX, 0),
tiltY: defaultValue(options.tiltY, 0),
pointerId: defaultValue(options.pointerId, 1),
pointerType: defaultValue(options.pointerType, 0),
hwTimestamp: defaultValue(options.hwTimestamp, 0),
isPrimary: defaultValue(options.isPrimary, 0),
canBubble: options.canBubble ?? true,
cancelable: options.cancelable ?? true,
view: options.view ?? window,
detail: options.detail ?? 0,
screenX: options.screenX ?? 0,
screenY: options.screenY ?? 0,
clientX: options.clientX ?? 0,
clientY: options.clientY ?? 0,
ctrlKey: options.ctrlKey ?? false,
altKey: options.altKey ?? false,
shiftKey: options.shiftKey ?? false,
metaKey: options.metaKey ?? false,
button: options.button ?? 0,
relatedTarget: options.relatedTarget ?? null,
offsetX: options.offsetX ?? 0,
offsetY: options.offsetY ?? 0,
width: options.width ?? 0,
height: options.height ?? 0,
pressure: options.pressure ?? 0,
rotation: options.rotation ?? 0,
tiltX: options.tiltX ?? 0,
tiltY: options.tiltY ?? 0,
pointerId: options.pointerId ?? 1,
pointerType: options.pointerType ?? 0,
hwTimestamp: options.hwTimestamp ?? 0,
isPrimary: options.isPrimary ?? 0,
});
}
return event;
}
function createDeviceOrientationEvent(type, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
const canBubble = defaultValue(options.canBubble, true);
const cancelable = defaultValue(options.cancelable, true);
const alpha = defaultValue(options.alpha, 0.0);
const beta = defaultValue(options.beta, 0.0);
const gamma = defaultValue(options.gamma, 0.0);
const absolute = defaultValue(options.absolute, false);
options = options ?? Frozen.EMPTY_OBJECT;
const canBubble = options.canBubble ?? true;
const cancelable = options.cancelable ?? true;
const alpha = options.alpha ?? 0.0;
const beta = options.beta ?? 0.0;
const gamma = options.gamma ?? 0.0;
const absolute = options.absolute ?? false;
let event;
event = document.createEvent("DeviceOrientationEvent");

View File

@ -1,4 +1,4 @@
import { defined, defaultValue } from "@cesium/engine";
import { defined } from "@cesium/engine";
import concatTypedArrays from "./concatTypedArrays.js";
import MetadataTester from "./MetadataTester.js";
@ -87,7 +87,7 @@ ImplicitTilingTester.generateSubtreeBuffers = function (
subtreeDescription,
constantOnly,
) {
constantOnly = defaultValue(constantOnly, false);
constantOnly = constantOnly ?? false;
// This will be populated by makeBufferViews() and makeBuffers()
let subtreeJson = {};
@ -148,10 +148,7 @@ function makeBufferViews(subtreeDescription, subtreeJson) {
count: 0,
};
const useLegacySchema = defaultValue(
subtreeDescription.useLegacySchema,
false,
);
const useLegacySchema = subtreeDescription.useLegacySchema ?? false;
const bufferViewJsonArray = [];
gatherBufferViews(
bufferViewsU8,

View File

@ -1,6 +1,6 @@
import {
defined,
defaultValue,
Frozen,
DeveloperError,
FeatureDetection,
PropertyTable,
@ -109,7 +109,7 @@ function createProperties(options) {
}
if (classProperty.isVariableLengthArray) {
const arrayOffsetBufferType = defaultValue(arrayOffsetType, offsetType);
const arrayOffsetBufferType = arrayOffsetType ?? offsetType;
const arrayOffsetBuffer = addPadding(
createArrayOffsetBuffer(
values,
@ -123,10 +123,7 @@ function createProperties(options) {
}
if (classProperty.type === MetadataType.STRING) {
const stringOffsetBufferType = defaultValue(
stringOffsetType,
offsetType,
);
const stringOffsetBufferType = stringOffsetType ?? offsetType;
const stringOffsetBuffer = addPadding(
createStringOffsetBuffer(values, stringOffsetBufferType),
);
@ -146,7 +143,7 @@ function createProperties(options) {
}
MetadataTester.createMetadataTable = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const disableBigIntSupport = options.disableBigIntSupport;
const disableBigInt64ArraySupport = options.disableBigInt64ArraySupport;
const disableBigUint64ArraySupport = options.disableBigUint64ArraySupport;
@ -193,7 +190,7 @@ MetadataTester.createMetadataTable = function (options) {
};
MetadataTester.createPropertyTable = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const disableBigIntSupport = options.disableBigIntSupport;
const disableBigInt64ArraySupport = options.disableBigInt64ArraySupport;
const disableBigUint64ArraySupport = options.disableBigUint64ArraySupport;
@ -248,7 +245,7 @@ MetadataTester.createPropertyTable = function (options) {
// for EXT_structural_metadata
MetadataTester.createPropertyTables = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const propertyTables = [];
const bufferViews = {};
@ -280,7 +277,7 @@ MetadataTester.createPropertyTables = function (options) {
// For EXT_feature_metadata
MetadataTester.createFeatureTables = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const featureTables = {};
const bufferViews = {};
@ -312,7 +309,7 @@ MetadataTester.createFeatureTables = function (options) {
};
MetadataTester.createGltf = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const propertyTableResults = MetadataTester.createPropertyTables(options);
@ -483,7 +480,7 @@ function createStringOffsetBuffer(values, offsetType) {
offset += encoder.encode(strings[i]).length;
}
offsets[length] = offset;
offsetType = defaultValue(offsetType, MetadataComponentType.UINT32);
offsetType = offsetType ?? MetadataComponentType.UINT32;
return createBuffer(offsets, offsetType);
}
@ -497,7 +494,7 @@ function createArrayOffsetBuffer(values, type, offsetType) {
offset += values[i].length / componentCount;
}
offsets[length] = offset;
offsetType = defaultValue(offsetType, MetadataComponentType.UINT32);
offsetType = offsetType ?? MetadataComponentType.UINT32;
return createBuffer(offsets, offsetType);
}

View File

@ -1,6 +1,5 @@
import {
Cartesian2,
defaultValue,
defined,
DeveloperError,
FeatureDetection,
@ -393,7 +392,7 @@ function createDefaultMatchers(debug) {
return {
compare: function (actual, expected, args) {
const scene = actual;
const result = scene.pick(defaultValue(args, new Cartesian2(0, 0)));
const result = scene.pick(args ?? new Cartesian2(0, 0));
const webglStub = !!window.webglStub;
if (!webglStub) {
@ -414,9 +413,7 @@ function createDefaultMatchers(debug) {
return {
compare: function (actual, expected, args) {
const scene = actual;
const result = scene.pickVoxel(
defaultValue(args, new Cartesian2(0, 0)),
);
const result = scene.pickVoxel(args ?? new Cartesian2(0, 0));
const webglStub = !!window.webglStub;
if (!webglStub) {
@ -571,8 +568,8 @@ function createDefaultMatchers(debug) {
compare: function (actual, expected, x, y) {
const scene = actual;
const canvas = scene.canvas;
x = defaultValue(x, canvas.clientWidth / 2);
y = defaultValue(y, canvas.clientHeight / 2);
x = x ?? canvas.clientWidth / 2;
y = y ?? canvas.clientHeight / 2;
const result = scene.pickPosition(new Cartesian2(x, y));
const webglStub = !!window.webglStub;
@ -602,7 +599,7 @@ function createDefaultMatchers(debug) {
// options were passed to to a framebuffer
context = options.context;
framebuffer = options.framebuffer;
epsilon = defaultValue(options.epsilon, epsilon);
epsilon = options.epsilon ?? epsilon;
} else {
context = options;
}
@ -889,8 +886,8 @@ function contextRenderAndReadPixels(options) {
let sp = options.shaderProgram;
const uniformMap = options.uniformMap;
const modelMatrix = options.modelMatrix;
const depth = defaultValue(options.depth, 0.0);
const clear = defaultValue(options.clear, true);
const depth = options.depth ?? 0.0;
const clear = options.clear ?? true;
let clearColor;
if (!defined(context)) {
@ -973,8 +970,8 @@ function contextRenderAndReadPixels(options) {
function expectContextToRender(actual, expected, expectEqual) {
const options = actual;
const context = options.context;
const clear = defaultValue(options.clear, true);
const epsilon = defaultValue(options.epsilon, 0);
const clear = options.clear ?? true;
const epsilon = options.epsilon ?? 0;
if (!defined(expected)) {
expected = [255, 255, 255, 255];

View File

@ -1,6 +1,6 @@
import {
Cartesian3,
defaultValue,
Frozen,
defined,
GeographicProjection,
Matrix4,
@ -8,10 +8,10 @@ import {
} from "@cesium/engine";
function MockScene(canvas) {
canvas = defaultValue(canvas, {
canvas = canvas ?? {
clientWidth: 512,
clientHeight: 384,
});
};
this.canvas = canvas;
this.drawingBufferWidth = canvas.clientWidth * 2;
@ -20,14 +20,14 @@ function MockScene(canvas) {
}
function createCamera(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const scene = new MockScene(options.canvas);
const camera = new Camera(scene);
camera.frustum.near = defaultValue(options.near, 0.01);
camera.frustum.far = defaultValue(options.far, 10.0);
camera.frustum.near = options.near ?? 0.01;
camera.frustum.far = options.far ?? 10.0;
const offset = defaultValue(options.offset, new Cartesian3(-1.0, 0.0, 0.0));
const offset = options.offset ?? new Cartesian3(-1.0, 0.0, 0.0);
if (defined(options.target)) {
camera.lookAt(options.target, offset);

View File

@ -1,10 +1,8 @@
import { defaultValue } from "@cesium/engine";
let canvasCount = 0;
function createCanvas(width, height) {
width = defaultValue(width, 1);
height = defaultValue(height, 1);
width = width ?? 1;
height = height ?? 1;
const canvas = document.createElement("canvas");
canvas.id = `canvas${canvasCount++}`;

View File

@ -1,4 +1,4 @@
import { clone, defaultValue, Context } from "@cesium/engine";
import { clone, Context } from "@cesium/engine";
import createCanvas from "./createCanvas.js";
import createFrameState from "./createFrameState.js";
@ -6,9 +6,9 @@ import getWebGLStub from "./getWebGLStub.js";
function createContext(options, canvasWidth, canvasHeight) {
// clone options so we can change properties
options = clone(defaultValue(options, {}));
options.webgl = clone(defaultValue(options.webgl, {}));
options.webgl.antialias = defaultValue(options.webgl.antialias, false);
options = clone(options ?? {});
options.webgl = clone(options.webgl ?? {});
options.webgl.antialias = options.webgl.antialias ?? false;
if (!!window.webglStub) {
options.getWebGLStub = getWebGLStub;
}

View File

@ -1,6 +1,5 @@
import {
Atmosphere,
defaultValue,
GeographicProjection,
JulianDate,
Camera,
@ -23,20 +22,17 @@ function createFrameState(context, camera, frameNumber, time) {
const projection = new GeographicProjection();
frameState.mapProjection = projection;
frameState.frameNumber = defaultValue(frameNumber, 1.0);
frameState.time = defaultValue(
time,
JulianDate.fromDate(new Date("January 1, 2011 12:00:00 EST")),
);
frameState.frameNumber = frameNumber ?? 1.0;
frameState.time =
time ?? JulianDate.fromDate(new Date("January 1, 2011 12:00:00 EST"));
camera = defaultValue(
camera,
camera =
camera ??
new Camera({
drawingBufferWidth: 1,
drawingBufferHeight: 1,
mapProjection: projection,
}),
);
});
frameState.camera = camera;
frameState.cullingVolume = camera.frustum.computeCullingVolume(
camera.position,

View File

@ -1,7 +1,7 @@
import { defaultValue, Ellipsoid, Event } from "@cesium/engine";
import { Ellipsoid, Event } from "@cesium/engine";
function createGlobe(ellipsoid) {
ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
ellipsoid = ellipsoid ?? Ellipsoid.WGS84;
const globe = {
_callback: undefined,

View File

@ -1,5 +1,3 @@
import { defaultValue } from "@cesium/engine";
function createPackableArraySpecs(
packable,
unpackedArray,
@ -7,7 +5,7 @@ function createPackableArraySpecs(
stride,
namePrefix,
) {
namePrefix = defaultValue(namePrefix, "");
namePrefix = namePrefix ?? "";
it(`${namePrefix} can pack`, function () {
const actualPackedArray = packable.packArray(unpackedArray);

View File

@ -1,7 +1,7 @@
import { defaultValue, defined, Math as CesiumMath } from "@cesium/engine";
import { defined, Math as CesiumMath } from "@cesium/engine";
function createPackableSpecs(packable, instance, packedInstance, namePrefix) {
namePrefix = defaultValue(namePrefix, "");
namePrefix = namePrefix ?? "";
it(`${namePrefix} can pack`, function () {
const packedArray = [];

View File

@ -1,25 +1,16 @@
import {
Cartesian2,
clone,
defaultValue,
defined,
Scene,
} from "@cesium/engine";
import { Cartesian2, clone, defined, Scene } from "@cesium/engine";
import createCanvas from "./createCanvas.js";
import getWebGLStub from "./getWebGLStub.js";
function createScene(options) {
options = defaultValue(options, {});
options = options ?? {};
// Render tests can be difficult to debug. Let the caller choose a larger
// canvas size temporarily. By stepping through a render test, you can see
// what the camera sees after each render call.
const debugWidth = window.debugCanvasWidth;
const debugHeight = defaultValue(
window.debugCanvasHeight,
window.debugCanvasWidth,
);
const debugHeight = window.debugCanvasHeight ?? window.debugCanvasWidth;
// save the canvas so we don't try to clone an HTMLCanvasElement
const canvas = defined(options.canvas)
@ -30,18 +21,12 @@ function createScene(options) {
options = clone(options, true);
options.canvas = canvas;
options.contextOptions = defaultValue(options.contextOptions, {});
options.contextOptions = options.contextOptions ?? {};
const contextOptions = options.contextOptions;
contextOptions.webgl = defaultValue(contextOptions.webgl, {});
contextOptions.webgl.antialias = defaultValue(
contextOptions.webgl.antialias,
false,
);
contextOptions.webgl.stencil = defaultValue(
contextOptions.webgl.stencil,
true,
);
contextOptions.webgl = contextOptions.webgl ?? {};
contextOptions.webgl.antialias = contextOptions.webgl.antialias ?? false;
contextOptions.webgl.stencil = contextOptions.webgl.stencil ?? true;
if (!!window.webglStub) {
contextOptions.getWebGLStub = getWebGLStub;
}
@ -80,7 +65,7 @@ function createScene(options) {
this.pick(new Cartesian2(0, 0));
};
scene.rethrowRenderErrors = defaultValue(options.rethrowRenderErrors, true);
scene.rethrowRenderErrors = options.rethrowRenderErrors ?? true;
return scene;
}

View File

@ -1,11 +1,9 @@
import { defaultValue } from "@cesium/engine";
function generateJsonBuffer(json, byteOffset, boundary) {
let i;
const jsonString = JSON.stringify(json);
byteOffset = defaultValue(byteOffset, 0);
boundary = defaultValue(boundary, 1);
byteOffset = byteOffset ?? 0;
boundary = boundary ?? 1;
const byteLength = jsonString.length;
const remainder = (byteOffset + byteLength) % boundary;

View File

@ -1,10 +1,4 @@
import {
clone,
defaultValue,
defined,
DeveloperError,
WebGLConstants,
} from "@cesium/engine";
import { clone, defined, DeveloperError, WebGLConstants } from "@cesium/engine";
function getWebGLStub(canvas, options) {
const stub = clone(WebGLConstants);
@ -184,17 +178,14 @@ function checkFramebufferStatusStub(target) {
function getContextAttributesStub(options) {
const contextAttributes = {
alpha: defaultValue(options.alpha, true),
depth: defaultValue(options.depth, true),
stencil: defaultValue(options.stencil, false),
antialias: defaultValue(options.antialias, true),
premultipliedAlpha: defaultValue(options.premultipliedAlpha, true),
preserveDrawingBuffer: defaultValue(options.preserveDrawingBuffer, false),
powerPreference: defaultValue(options.powerPreference, false),
failIfMajorPerformanceCaveat: defaultValue(
options.failIfMajorPerformanceCaveat,
false,
),
alpha: options.alpha ?? true,
depth: options.depth ?? true,
stencil: options.stencil ?? false,
antialias: options.antialias ?? true,
premultipliedAlpha: options.premultipliedAlpha ?? true,
preserveDrawingBuffer: options.preserveDrawingBuffer ?? false,
powerPreference: options.powerPreference ?? false,
failIfMajorPerformanceCaveat: options.failIfMajorPerformanceCaveat ?? false,
};
return function () {

View File

@ -1,10 +1,10 @@
import { defaultValue, getTimestamp } from "@cesium/engine";
import { Frozen, getTimestamp } from "@cesium/engine";
function pollToPromise(f, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const pollInterval = defaultValue(options.pollInterval, 1);
const timeout = defaultValue(options.timeout, 5000);
const pollInterval = options.pollInterval ?? 1;
const timeout = options.timeout ?? 5000;
return new Promise(function (resolve, reject) {
const startTimestamp = getTimestamp();

View File

@ -1,10 +1,10 @@
import { defaultValue, getTimestamp } from "@cesium/engine";
import { Frozen, getTimestamp } from "@cesium/engine";
function pollWhilePromise(promise, f, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const pollInterval = defaultValue(options.pollInterval, 1);
const timeout = defaultValue(options.timeout, 5000);
const pollInterval = options.pollInterval ?? 1;
const timeout = options.timeout ?? 5000;
return new Promise(function (resolve, reject) {
const startTimestamp = getTimestamp();

View File

@ -1,7 +1,5 @@
import { defaultValue } from "@cesium/engine";
function runLater(functionToRunLater, milliseconds) {
milliseconds = defaultValue(milliseconds, 0);
milliseconds = milliseconds ?? 0;
return new Promise((resolve, reject) => {
setTimeout(function () {

View File

@ -12,7 +12,7 @@
"license": [
"BSD-3-Clause"
],
"version": "2.7.57",
"version": "2.7.60",
"url": "https://www.npmjs.com/package/@zip.js/zip.js"
},
{
@ -133,7 +133,7 @@
"license": [
"MIT"
],
"version": "0.22.0",
"version": "0.23.0",
"url": "https://www.npmjs.com/package/meshoptimizer"
},
{

View File

@ -1,6 +1,6 @@
{
"name": "cesium",
"version": "1.127.0",
"version": "1.128.0",
"description": "CesiumJS is a JavaScript library for creating 3D globes and 2D maps in a web browser without a plugin.",
"homepage": "http://cesium.com/cesiumjs/",
"license": "Apache-2.0",
@ -51,9 +51,9 @@
"./Specs/**/*"
],
"dependencies": {
"@cesium/engine": "^15.0.0",
"@cesium/engine": "^16.0.0",
"@cesium/wasm-splats": "^0.1.0-alpha.1",
"@cesium/widgets": "^11.0.0",
"@cesium/widgets": "^11.1.0",
"@spz-loader/core": "^0.1.0"
},
"devDependencies": {
@ -97,7 +97,7 @@
"mkdirp": "^3.0.1",
"node-fetch": "^3.2.10",
"open": "^10.0.2",
"prettier": "3.5.1",
"prettier": "3.5.3",
"prismjs": "^1.28.0",
"request": "^2.79.0",
"rimraf": "^5.0.0",

View File

@ -4,7 +4,6 @@ import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Ellipsoid from "./Ellipsoid.js";
@ -71,7 +70,7 @@ ApproximateTerrainHeights.getMinimumMaximumHeights = function (
);
}
//>>includeEnd('debug');
ellipsoid = defaultValue(ellipsoid, Ellipsoid.default);
ellipsoid = ellipsoid ?? Ellipsoid.default;
const xyLevel = getTileXYLevel(rectangle);
@ -142,7 +141,7 @@ ApproximateTerrainHeights.getBoundingSphere = function (rectangle, ellipsoid) {
);
}
//>>includeEnd('debug');
ellipsoid = defaultValue(ellipsoid, Ellipsoid.default);
ellipsoid = ellipsoid ?? Ellipsoid.default;
const xyLevel = getTileXYLevel(rectangle);

View File

@ -1,7 +1,7 @@
import Cartesian2 from "./Cartesian2.js";
import Check from "./Check.js";
import Credit from "./Credit.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Event from "./Event.js";
@ -41,7 +41,7 @@ const ALL_CHILDREN = 15;
* @param {ArcGISTiledElevationTerrainProvider.ConstructorOptions} [options] An object describing initialization options.
*/
function TerrainProviderBuilder(options) {
this.ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
this.ellipsoid = options.ellipsoid ?? Ellipsoid.default;
this.credit = undefined;
this.tilingScheme = undefined;
@ -85,7 +85,7 @@ function parseMetadataSuccess(terrainProviderBuilder, metadata) {
}
const spatialReference = metadata.spatialReference;
const wkid = defaultValue(spatialReference.latestWkid, spatialReference.wkid);
const wkid = spatialReference.latestWkid ?? spatialReference.wkid;
const extent = metadata.extent;
const tilingSchemeOptions = {
ellipsoid: terrainProviderBuilder.ellipsoid,
@ -234,7 +234,7 @@ async function requestMetadata(
* @see TerrainProvider
*/
function ArcGISTiledElevationTerrainProvider(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
this._resource = undefined;
this._credit = undefined;
@ -325,7 +325,7 @@ Object.defineProperties(ArcGISTiledElevationTerrainProvider.prototype, {
* at points and in rectangles. This property may be undefined if availability
* information is not available.
* @memberof ArcGISTiledElevationTerrainProvider.prototype
* @type {TileAvailability}
* @type {TileAvailability|undefined}
* @readonly
*/
availability: {
@ -357,7 +357,7 @@ ArcGISTiledElevationTerrainProvider.fromUrl = async function (url, options) {
Check.defined("url", url);
//>>includeEnd('debug');
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
url = await Promise.resolve(url);
let resource = Resource.createIfNeeded(url);

View File

@ -1,6 +1,5 @@
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import Intersect from "./Intersect.js";
@ -22,14 +21,14 @@ function AxisAlignedBoundingBox(minimum, maximum, center) {
* @type {Cartesian3}
* @default {@link Cartesian3.ZERO}
*/
this.minimum = Cartesian3.clone(defaultValue(minimum, Cartesian3.ZERO));
this.minimum = Cartesian3.clone(minimum ?? Cartesian3.ZERO);
/**
* The maximum point defining the bounding box.
* @type {Cartesian3}
* @default {@link Cartesian3.ZERO}
*/
this.maximum = Cartesian3.clone(defaultValue(maximum, Cartesian3.ZERO));
this.maximum = Cartesian3.clone(maximum ?? Cartesian3.ZERO);
// If center was not defined, compute it.
if (!defined(center)) {

View File

@ -1,6 +1,6 @@
import Check from "./Check.js";
import Credit from "./Credit.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import Rectangle from "./Rectangle.js";
import Resource from "./Resource.js";
import defined from "./defined.js";
@ -20,7 +20,7 @@ const url = "https://dev.virtualearth.net/REST/v1/Locations";
* @param {string} [options.culture] A Bing Maps {@link https://docs.microsoft.com/en-us/bingmaps/rest-services/common-parameters-and-types/supported-culture-codes|Culture Code} to return results in a specific culture and language.
*/
function BingMapsGeocoderService(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const key = options.key;
//>>includeStart('debug', pragmas.debug);
if (!defined(key)) {

View File

@ -1,7 +1,6 @@
import Cartesian2 from "./Cartesian2.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import GeographicProjection from "./GeographicProjection.js";
@ -27,28 +26,28 @@ function BoundingRectangle(x, y, width, height) {
* @type {number}
* @default 0.0
*/
this.x = defaultValue(x, 0.0);
this.x = x ?? 0.0;
/**
* The y coordinate of the rectangle.
* @type {number}
* @default 0.0
*/
this.y = defaultValue(y, 0.0);
this.y = y ?? 0.0;
/**
* The width of the rectangle.
* @type {number}
* @default 0.0
*/
this.width = defaultValue(width, 0.0);
this.width = width ?? 0.0;
/**
* The height of the rectangle.
* @type {number}
* @default 0.0
*/
this.height = defaultValue(height, 0.0);
this.height = height ?? 0.0;
}
/**
@ -72,7 +71,7 @@ BoundingRectangle.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
@ -95,7 +94,7 @@ BoundingRectangle.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new BoundingRectangle();
@ -179,7 +178,7 @@ BoundingRectangle.fromRectangle = function (rectangle, projection, result) {
}
defaultProjection._ellipsoid = Ellipsoid.default;
projection = defaultValue(projection, defaultProjection);
projection = projection ?? defaultProjection;
const lowerLeft = projection.project(
Rectangle.southwest(rectangle, fromRectangleLowerLeft),

View File

@ -1,7 +1,6 @@
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import GeographicProjection from "./GeographicProjection.js";
@ -30,14 +29,14 @@ function BoundingSphere(center, radius) {
* @type {Cartesian3}
* @default {@link Cartesian3.ZERO}
*/
this.center = Cartesian3.clone(defaultValue(center, Cartesian3.ZERO));
this.center = Cartesian3.clone(center ?? Cartesian3.ZERO);
/**
* The radius of the sphere.
* @type {number}
* @default 0.0
*/
this.radius = defaultValue(radius, 0.0);
this.radius = radius ?? 0.0;
}
const fromPointsXMin = new Cartesian3();
@ -276,7 +275,7 @@ BoundingSphere.fromRectangleWithHeights2D = function (
}
defaultProjection._ellipsoid = Ellipsoid.default;
projection = defaultValue(projection, defaultProjection);
projection = projection ?? defaultProjection;
Rectangle.southwest(rectangle, fromRectangle2DSouthwest);
fromRectangle2DSouthwest.height = minimumHeight;
@ -323,8 +322,8 @@ BoundingSphere.fromRectangle3D = function (
surfaceHeight,
result,
) {
ellipsoid = defaultValue(ellipsoid, Ellipsoid.default);
surfaceHeight = defaultValue(surfaceHeight, 0.0);
ellipsoid = ellipsoid ?? Ellipsoid.default;
surfaceHeight = surfaceHeight ?? 0.0;
if (!defined(result)) {
result = new BoundingSphere();
@ -388,9 +387,9 @@ BoundingSphere.fromVertices = function (positions, center, stride, result) {
return result;
}
center = defaultValue(center, Cartesian3.ZERO);
center = center ?? Cartesian3.ZERO;
stride = defaultValue(stride, 3);
stride = stride ?? 3;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals("stride", stride, 3);
@ -956,7 +955,7 @@ BoundingSphere.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const center = value.center;
array[startingIndex++] = center.x;
@ -980,7 +979,7 @@ BoundingSphere.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new BoundingSphere();
@ -1279,7 +1278,7 @@ BoundingSphere.projectTo2D = function (sphere, projection, result) {
//>>includeEnd('debug');
projectTo2DProjection._ellipsoid = Ellipsoid.default;
projection = defaultValue(projection, projectTo2DProjection);
projection = projection ?? projectTo2DProjection;
const ellipsoid = projection.ellipsoid;
let center = sphere.center;

View File

@ -2,7 +2,7 @@ import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Geometry from "./Geometry.js";
@ -40,7 +40,7 @@ const diffScratch = new Cartesian3();
* const geometry = Cesium.BoxGeometry.createGeometry(box);
*/
function BoxGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const min = options.minimum;
const max = options.maximum;
@ -58,7 +58,7 @@ function BoxGeometry(options) {
}
//>>includeEnd('debug');
const vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
const vertexFormat = options.vertexFormat ?? VertexFormat.DEFAULT;
this._minimum = Cartesian3.clone(min);
this._maximum = Cartesian3.clone(max);
@ -88,7 +88,7 @@ function BoxGeometry(options) {
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromDimensions = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const dimensions = options.dimensions;
//>>includeStart('debug', pragmas.debug);
@ -161,7 +161,7 @@ BoxGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._minimum, array, startingIndex);
Cartesian3.pack(
@ -176,7 +176,7 @@ BoxGeometry.pack = function (value, array, startingIndex) {
);
array[
startingIndex + 2 * Cartesian3.packedLength + VertexFormat.packedLength
] = defaultValue(value._offsetAttribute, -1);
] = value._offsetAttribute ?? -1;
return array;
};
@ -204,7 +204,7 @@ BoxGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const min = Cartesian3.unpack(array, startingIndex, scratchMin);
const max = Cartesian3.unpack(

View File

@ -2,7 +2,7 @@ import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Geometry from "./Geometry.js";
@ -35,7 +35,7 @@ const diffScratch = new Cartesian3();
* const geometry = Cesium.BoxOutlineGeometry.createGeometry(box);
*/
function BoxOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const min = options.minimum;
const max = options.maximum;
@ -78,7 +78,7 @@ function BoxOutlineGeometry(options) {
* @see BoxOutlineGeometry.createGeometry
*/
BoxOutlineGeometry.fromDimensions = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const dimensions = options.dimensions;
//>>includeStart('debug', pragmas.debug);
@ -149,14 +149,12 @@ BoxOutlineGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._min, array, startingIndex);
Cartesian3.pack(value._max, array, startingIndex + Cartesian3.packedLength);
array[startingIndex + Cartesian3.packedLength * 2] = defaultValue(
value._offsetAttribute,
-1,
);
array[startingIndex + Cartesian3.packedLength * 2] =
value._offsetAttribute ?? -1;
return array;
};
@ -182,7 +180,7 @@ BoxOutlineGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const min = Cartesian3.unpack(array, startingIndex, scratchMin);
const max = Cartesian3.unpack(

View File

@ -1,5 +1,4 @@
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import CesiumMath from "./Math.js";
@ -22,14 +21,14 @@ function Cartesian2(x, y) {
* @type {number}
* @default 0.0
*/
this.x = defaultValue(x, 0.0);
this.x = x ?? 0.0;
/**
* The Y component.
* @type {number}
* @default 0.0
*/
this.y = defaultValue(y, 0.0);
this.y = y ?? 0.0;
}
/**
@ -113,7 +112,7 @@ Cartesian2.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value.x;
array[startingIndex] = value.y;
@ -134,7 +133,7 @@ Cartesian2.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new Cartesian2();

View File

@ -1,5 +1,4 @@
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import CesiumMath from "./Math.js";
@ -23,21 +22,21 @@ function Cartesian3(x, y, z) {
* @type {number}
* @default 0.0
*/
this.x = defaultValue(x, 0.0);
this.x = x ?? 0.0;
/**
* The Y component.
* @type {number}
* @default 0.0
*/
this.y = defaultValue(y, 0.0);
this.y = y ?? 0.0;
/**
* The Z component.
* @type {number}
* @default 0.0
*/
this.z = defaultValue(z, 0.0);
this.z = z ?? 0.0;
}
/**
@ -58,7 +57,7 @@ Cartesian3.fromSpherical = function (spherical, result) {
const clock = spherical.clock;
const cone = spherical.cone;
const magnitude = defaultValue(spherical.magnitude, 1.0);
const magnitude = spherical.magnitude ?? 1.0;
const radial = magnitude * Math.sin(cone);
result.x = radial * Math.cos(clock);
result.y = radial * Math.sin(clock);
@ -139,7 +138,7 @@ Cartesian3.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
@ -161,7 +160,7 @@ Cartesian3.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new Cartesian3();
@ -925,7 +924,7 @@ Cartesian3.fromRadians = function (
Check.typeOf.number("latitude", latitude);
//>>includeEnd('debug');
height = defaultValue(height, 0.0);
height = height ?? 0.0;
const radiiSquared = !defined(ellipsoid)
? Cartesian3._ellipsoidRadiiSquared

View File

@ -1,5 +1,4 @@
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import CesiumMath from "./Math.js";
@ -24,28 +23,28 @@ function Cartesian4(x, y, z, w) {
* @type {number}
* @default 0.0
*/
this.x = defaultValue(x, 0.0);
this.x = x ?? 0.0;
/**
* The Y component.
* @type {number}
* @default 0.0
*/
this.y = defaultValue(y, 0.0);
this.y = y ?? 0.0;
/**
* The Z component.
* @type {number}
* @default 0.0
*/
this.z = defaultValue(z, 0.0);
this.z = z ?? 0.0;
/**
* The W component.
* @type {number}
* @default 0.0
*/
this.w = defaultValue(w, 0.0);
this.w = w ?? 0.0;
}
/**
@ -137,7 +136,7 @@ Cartesian4.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
@ -160,7 +159,7 @@ Cartesian4.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new Cartesian4();

View File

@ -1,6 +1,5 @@
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import CesiumMath from "./Math.js";
import scaleToGeodeticSurface from "./scaleToGeodeticSurface.js";
@ -22,21 +21,21 @@ function Cartographic(longitude, latitude, height) {
* @type {number}
* @default 0.0
*/
this.longitude = defaultValue(longitude, 0.0);
this.longitude = longitude ?? 0.0;
/**
* The latitude, in radians.
* @type {number}
* @default 0.0
*/
this.latitude = defaultValue(latitude, 0.0);
this.latitude = latitude ?? 0.0;
/**
* The height, in meters, above the ellipsoid.
* @type {number}
* @default 0.0
*/
this.height = defaultValue(height, 0.0);
this.height = height ?? 0.0;
}
/**
@ -55,7 +54,7 @@ Cartographic.fromRadians = function (longitude, latitude, height, result) {
Check.typeOf.number("latitude", latitude);
//>>includeEnd('debug');
height = defaultValue(height, 0.0);
height = height ?? 0.0;
if (!defined(result)) {
return new Cartographic(longitude, latitude, height);
@ -240,7 +239,7 @@ Cartographic.equals = function (left, right) {
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
*/
Cartographic.equalsEpsilon = function (left, right, epsilon) {
epsilon = defaultValue(epsilon, 0);
epsilon = epsilon ?? 0;
return (
left === right ||

View File

@ -1,7 +1,7 @@
import Cartesian3 from "./Cartesian3.js";
import Cartesian4 from "./Cartesian4.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import HermiteSpline from "./HermiteSpline.js";
import Matrix4 from "./Matrix4.js";
@ -148,7 +148,7 @@ const lastTangentScratch = new Cartesian3();
* @see MorphWeightSpline
*/
function CatmullRomSpline(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const points = options.points;
const times = options.times;

View File

@ -3,7 +3,7 @@ import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import Credit from "./Credit.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Event from "./Event.js";
@ -59,10 +59,10 @@ function LayerInformation(layer) {
* @param {CesiumTerrainProvider.ConstructorOptions} options An object describing initialization options
*/
function TerrainProviderBuilder(options) {
this.requestVertexNormals = defaultValue(options.requestVertexNormals, false);
this.requestWaterMask = defaultValue(options.requestWaterMask, false);
this.requestMetadata = defaultValue(options.requestMetadata, true);
this.ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
this.requestVertexNormals = options.requestVertexNormals ?? false;
this.requestWaterMask = options.requestWaterMask ?? false;
this.requestMetadata = options.requestMetadata ?? true;
this.ellipsoid = options.ellipsoid ?? Ellipsoid.default;
this.heightmapWidth = 65;
this.heightmapStructure = undefined;
@ -475,7 +475,7 @@ async function requestLayerJson(terrainProviderBuilder, provider) {
* @see TerrainProvider
*/
function CesiumTerrainProvider(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
this._heightmapWidth = undefined;
this._heightmapStructure = undefined;
@ -491,10 +491,7 @@ function CesiumTerrainProvider(options) {
* @default false
* @private
*/
this._requestVertexNormals = defaultValue(
options.requestVertexNormals,
false,
);
this._requestVertexNormals = options.requestVertexNormals ?? false;
/**
* Boolean flag that indicates if the client should request tile watermasks from the server.
@ -502,7 +499,7 @@ function CesiumTerrainProvider(options) {
* @default false
* @private
*/
this._requestWaterMask = defaultValue(options.requestWaterMask, false);
this._requestWaterMask = options.requestWaterMask ?? false;
/**
* Boolean flag that indicates if the client should request tile metadata from the server.
@ -510,7 +507,7 @@ function CesiumTerrainProvider(options) {
* @default true
* @private
*/
this._requestMetadata = defaultValue(options.requestMetadata, true);
this._requestMetadata = options.requestMetadata ?? true;
this._errorEvent = new Event();
@ -1132,7 +1129,7 @@ Object.defineProperties(CesiumTerrainProvider.prototype, {
* exists deeper in the tree rather than it all being discoverable at the root. However, a tile that
* is available now will not become unavailable in the future.
* @memberof CesiumTerrainProvider.prototype
* @type {TileAvailability}
* @type {TileAvailability|undefined}
* @readonly
*/
availability: {
@ -1229,7 +1226,7 @@ CesiumTerrainProvider.fromUrl = async function (url, options) {
Check.defined("url", url);
//>>includeEnd('debug');
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
url = await Promise.resolve(url);
const resource = Resource.createIfNeeded(url);

View File

@ -1,6 +1,6 @@
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import EllipseGeometry from "./EllipseGeometry.js";
import Ellipsoid from "./Ellipsoid.js";
@ -37,7 +37,7 @@ import VertexFormat from "./VertexFormat.js";
* const geometry = Cesium.CircleGeometry.createGeometry(circle);
*/
function CircleGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const radius = options.radius;
//>>includeStart('debug', pragmas.debug);

View File

@ -1,6 +1,6 @@
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import EllipseOutlineGeometry from "./EllipseOutlineGeometry.js";
import Ellipsoid from "./Ellipsoid.js";
@ -35,7 +35,7 @@ import Ellipsoid from "./Ellipsoid.js";
* const geometry = Cesium.CircleOutlineGeometry.createGeometry(circle);
*/
function CircleOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const radius = options.radius;
//>>includeStart('debug', pragmas.debug);

View File

@ -1,6 +1,6 @@
import ClockRange from "./ClockRange.js";
import ClockStep from "./ClockStep.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Event from "./Event.js";
@ -41,7 +41,7 @@ import JulianDate from "./JulianDate.js";
* @see JulianDate
*/
function Clock(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
let currentTime = options.currentTime;
let startTime = options.startTime;
@ -103,7 +103,7 @@ function Clock(options) {
* @type {ClockRange}
* @default {@link ClockRange.UNBOUNDED}
*/
this.clockRange = defaultValue(options.clockRange, ClockRange.UNBOUNDED);
this.clockRange = options.clockRange ?? ClockRange.UNBOUNDED;
/**
* Indicates whether {@link Clock#tick} can advance time. This could be false if data is being buffered,
@ -112,7 +112,7 @@ function Clock(options) {
* @type {boolean}
* @default true
*/
this.canAnimate = defaultValue(options.canAnimate, true);
this.canAnimate = options.canAnimate ?? true;
/**
* An {@link Event} that is fired whenever {@link Clock#tick} is called.
@ -135,12 +135,9 @@ function Clock(options) {
// make values consistent.
this.currentTime = currentTime;
this.multiplier = defaultValue(options.multiplier, 1.0);
this.shouldAnimate = defaultValue(options.shouldAnimate, false);
this.clockStep = defaultValue(
options.clockStep,
ClockStep.SYSTEM_CLOCK_MULTIPLIER,
);
this.multiplier = options.multiplier ?? 1.0;
this.shouldAnimate = options.shouldAnimate ?? false;
this.clockStep = options.clockStep ?? ClockStep.SYSTEM_CLOCK_MULTIPLIER;
}
Object.defineProperties(Clock.prototype, {

View File

@ -1,5 +1,5 @@
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import FeatureDetection from "./FeatureDetection.js";
import CesiumMath from "./Math.js";
@ -42,25 +42,25 @@ function Color(red, green, blue, alpha) {
* @type {number}
* @default 1.0
*/
this.red = defaultValue(red, 1.0);
this.red = red ?? 1.0;
/**
* The green component.
* @type {number}
* @default 1.0
*/
this.green = defaultValue(green, 1.0);
this.green = green ?? 1.0;
/**
* The blue component.
* @type {number}
* @default 1.0
*/
this.blue = defaultValue(blue, 1.0);
this.blue = blue ?? 1.0;
/**
* The alpha component.
* @type {number}
* @default 1.0
*/
this.alpha = defaultValue(alpha, 1.0);
this.alpha = alpha ?? 1.0;
}
/**
@ -99,10 +99,10 @@ Color.fromCartesian4 = function (cartesian, result) {
* @returns {Color} The modified result parameter or a new Color instance if one was not provided.
*/
Color.fromBytes = function (red, green, blue, alpha, result) {
red = Color.byteToFloat(defaultValue(red, 255.0));
green = Color.byteToFloat(defaultValue(green, 255.0));
blue = Color.byteToFloat(defaultValue(blue, 255.0));
alpha = Color.byteToFloat(defaultValue(alpha, 255.0));
red = Color.byteToFloat(red ?? 255.0);
green = Color.byteToFloat(green ?? 255.0);
blue = Color.byteToFloat(blue ?? 255.0);
alpha = Color.byteToFloat(alpha ?? 255.0);
if (!defined(result)) {
return new Color(red, green, blue, alpha);
@ -190,10 +190,10 @@ Color.fromRgba = function (rgba, result) {
* @see {@link http://www.w3.org/TR/css3-color/#hsl-color|CSS color values}
*/
Color.fromHsl = function (hue, saturation, lightness, alpha, result) {
hue = defaultValue(hue, 0.0) % 1.0;
saturation = defaultValue(saturation, 0.0);
lightness = defaultValue(lightness, 0.0);
alpha = defaultValue(alpha, 1.0);
hue = (hue ?? 0.0) % 1.0;
saturation = saturation ?? 0.0;
lightness = lightness ?? 0.0;
alpha = alpha ?? 1.0;
let red = lightness;
let green = lightness;
@ -269,12 +269,12 @@ Color.fromHsl = function (hue, saturation, lightness, alpha, result) {
* });
*/
Color.fromRandom = function (options, result) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
let red = options.red;
if (!defined(red)) {
const minimumRed = defaultValue(options.minimumRed, 0);
const maximumRed = defaultValue(options.maximumRed, 1.0);
const minimumRed = options.minimumRed ?? 0;
const maximumRed = options.maximumRed ?? 1.0;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.lessThanOrEquals("minimumRed", minimumRed, maximumRed);
@ -286,8 +286,8 @@ Color.fromRandom = function (options, result) {
let green = options.green;
if (!defined(green)) {
const minimumGreen = defaultValue(options.minimumGreen, 0);
const maximumGreen = defaultValue(options.maximumGreen, 1.0);
const minimumGreen = options.minimumGreen ?? 0;
const maximumGreen = options.maximumGreen ?? 1.0;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.lessThanOrEquals(
@ -303,8 +303,8 @@ Color.fromRandom = function (options, result) {
let blue = options.blue;
if (!defined(blue)) {
const minimumBlue = defaultValue(options.minimumBlue, 0);
const maximumBlue = defaultValue(options.maximumBlue, 1.0);
const minimumBlue = options.minimumBlue ?? 0;
const maximumBlue = options.maximumBlue ?? 1.0;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.lessThanOrEquals(
@ -320,8 +320,8 @@ Color.fromRandom = function (options, result) {
let alpha = options.alpha;
if (!defined(alpha)) {
const minimumAlpha = defaultValue(options.minimumAlpha, 0);
const maximumAlpha = defaultValue(options.maximumAlpha, 1.0);
const minimumAlpha = options.minimumAlpha ?? 0;
const maximumAlpha = options.maximumAlpha ?? 1.0;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.lessThanOrEquals(
@ -396,7 +396,7 @@ Color.fromCssColorString = function (color, result) {
result.red = parseInt(matches[1], 16) / 15;
result.green = parseInt(matches[2], 16) / 15.0;
result.blue = parseInt(matches[3], 16) / 15.0;
result.alpha = parseInt(defaultValue(matches[4], "f"), 16) / 15.0;
result.alpha = parseInt(matches[4] ?? "f", 16) / 15.0;
return result;
}
@ -405,7 +405,7 @@ Color.fromCssColorString = function (color, result) {
result.red = parseInt(matches[1], 16) / 255.0;
result.green = parseInt(matches[2], 16) / 255.0;
result.blue = parseInt(matches[3], 16) / 255.0;
result.alpha = parseInt(defaultValue(matches[4], "ff"), 16) / 255.0;
result.alpha = parseInt(matches[4] ?? "ff", 16) / 255.0;
return result;
}
@ -417,7 +417,7 @@ Color.fromCssColorString = function (color, result) {
parseFloat(matches[2]) / ("%" === matches[2].substr(-1) ? 100.0 : 255.0);
result.blue =
parseFloat(matches[3]) / ("%" === matches[3].substr(-1) ? 100.0 : 255.0);
result.alpha = parseFloat(defaultValue(matches[4], "1.0"));
result.alpha = parseFloat(matches[4] ?? "1.0");
return result;
}
@ -427,7 +427,7 @@ Color.fromCssColorString = function (color, result) {
parseFloat(matches[1]) / 360.0,
parseFloat(matches[2]) / 100.0,
parseFloat(matches[3]) / 100.0,
parseFloat(defaultValue(matches[4], "1.0")),
parseFloat(matches[4] ?? "1.0"),
result,
);
}
@ -457,7 +457,7 @@ Color.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value.red;
array[startingIndex++] = value.green;
array[startingIndex++] = value.blue;
@ -479,7 +479,7 @@ Color.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new Color();
}

View File

@ -1,6 +1,5 @@
import Color from "./Color.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
@ -33,10 +32,10 @@ import DeveloperError from "./DeveloperError.js";
* @see GeometryInstanceAttribute
*/
function ColorGeometryInstanceAttribute(red, green, blue, alpha) {
red = defaultValue(red, 1.0);
green = defaultValue(green, 1.0);
blue = defaultValue(blue, 1.0);
alpha = defaultValue(alpha, 1.0);
red = red ?? 1.0;
green = green ?? 1.0;
blue = blue ?? 1.0;
alpha = alpha ?? 1.0;
/**
* The values for the attributes stored in a typed array.

View File

@ -1,4 +1,3 @@
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import WebGLConstants from "./WebGLConstants.js";
@ -274,12 +273,11 @@ ComponentDatatype.createArrayBufferView = function (
}
//>>includeEnd('debug');
byteOffset = defaultValue(byteOffset, 0);
length = defaultValue(
length,
byteOffset = byteOffset ?? 0;
length =
length ??
(buffer.byteLength - byteOffset) /
ComponentDatatype.getSizeInBytes(componentDatatype),
);
ComponentDatatype.getSizeInBytes(componentDatatype);
switch (componentDatatype) {
case ComponentDatatype.BYTE:

View File

@ -6,7 +6,7 @@ import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import CoplanarPolygonGeometryLibrary from "./CoplanarPolygonGeometryLibrary.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Geometry from "./Geometry.js";
@ -247,20 +247,18 @@ function createGeometryFromPolygon(
*
*/
function CoplanarPolygonGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const polygonHierarchy = options.polygonHierarchy;
const textureCoordinates = options.textureCoordinates;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.polygonHierarchy", polygonHierarchy);
//>>includeEnd('debug');
const vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
const vertexFormat = options.vertexFormat ?? VertexFormat.DEFAULT;
this._vertexFormat = VertexFormat.clone(vertexFormat);
this._polygonHierarchy = polygonHierarchy;
this._stRotation = defaultValue(options.stRotation, 0.0);
this._ellipsoid = Ellipsoid.clone(
defaultValue(options.ellipsoid, Ellipsoid.default),
);
this._stRotation = options.stRotation ?? 0.0;
this._ellipsoid = Ellipsoid.clone(options.ellipsoid ?? Ellipsoid.default);
this._workerName = "createCoplanarPolygonGeometry";
this._textureCoordinates = textureCoordinates;
@ -311,7 +309,7 @@ function CoplanarPolygonGeometry(options) {
* @see PolygonGeometry#createGeometry
*/
CoplanarPolygonGeometry.fromPositions = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.positions", options.positions);
@ -344,7 +342,7 @@ CoplanarPolygonGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
startingIndex = PolygonGeometryLibrary.packPolygonHierarchy(
value._polygonHierarchy,
@ -393,7 +391,7 @@ CoplanarPolygonGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const polygonHierarchy = PolygonGeometryLibrary.unpackPolygonHierarchy(
array,

View File

@ -4,7 +4,7 @@ import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import CoplanarPolygonGeometryLibrary from "./CoplanarPolygonGeometryLibrary.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Geometry from "./Geometry.js";
import GeometryAttribute from "./GeometryAttribute.js";
@ -71,7 +71,7 @@ function createGeometryFromPositions(positions) {
* const geometry = Cesium.CoplanarPolygonOutlineGeometry.createGeometry(polygonOutline);
*/
function CoplanarPolygonOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const polygonHierarchy = options.polygonHierarchy;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.polygonHierarchy", polygonHierarchy);
@ -99,7 +99,7 @@ function CoplanarPolygonOutlineGeometry(options) {
* @returns {CoplanarPolygonOutlineGeometry}
*/
CoplanarPolygonOutlineGeometry.fromPositions = function (options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.positions", options.positions);
@ -128,7 +128,7 @@ CoplanarPolygonOutlineGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
startingIndex = PolygonGeometryLibrary.packPolygonHierarchy(
value._polygonHierarchy,
@ -162,7 +162,7 @@ CoplanarPolygonOutlineGeometry.unpack = function (
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const polygonHierarchy = PolygonGeometryLibrary.unpackPolygonHierarchy(
array,

View File

@ -6,7 +6,7 @@ import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import CornerType from "./CornerType.js";
import CorridorGeometryLibrary from "./CorridorGeometryLibrary.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Geometry from "./Geometry.js";
@ -1070,7 +1070,7 @@ function computeRectangle(positions, ellipsoid, width, cornerType, result) {
* });
*/
function CorridorGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const positions = options.positions;
const width = options.width;
@ -1079,25 +1079,20 @@ function CorridorGeometry(options) {
Check.defined("options.width", width);
//>>includeEnd('debug');
const height = defaultValue(options.height, 0.0);
const extrudedHeight = defaultValue(options.extrudedHeight, height);
const height = options.height ?? 0.0;
const extrudedHeight = options.extrudedHeight ?? height;
this._positions = positions;
this._ellipsoid = Ellipsoid.clone(
defaultValue(options.ellipsoid, Ellipsoid.default),
);
this._ellipsoid = Ellipsoid.clone(options.ellipsoid ?? Ellipsoid.default);
this._vertexFormat = VertexFormat.clone(
defaultValue(options.vertexFormat, VertexFormat.DEFAULT),
options.vertexFormat ?? VertexFormat.DEFAULT,
);
this._width = width;
this._height = Math.max(height, extrudedHeight);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
this._granularity = defaultValue(
options.granularity,
CesiumMath.RADIANS_PER_DEGREE,
);
this._shadowVolume = defaultValue(options.shadowVolume, false);
this._cornerType = options.cornerType ?? CornerType.ROUNDED;
this._granularity = options.granularity ?? CesiumMath.RADIANS_PER_DEGREE;
this._shadowVolume = options.shadowVolume ?? false;
this._workerName = "createCorridorGeometry";
this._offsetAttribute = options.offsetAttribute;
this._rectangle = undefined;
@ -1129,7 +1124,7 @@ CorridorGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const positions = value._positions;
const length = positions.length;
@ -1151,7 +1146,7 @@ CorridorGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._cornerType;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._shadowVolume ? 1.0 : 0.0;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -1184,7 +1179,7 @@ CorridorGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const length = array[startingIndex++];
const positions = new Array(length);
@ -1253,7 +1248,7 @@ CorridorGeometry.unpack = function (array, startingIndex, result) {
* @returns {Rectangle} The result rectangle.
*/
CorridorGeometry.computeRectangle = function (options, result) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const positions = options.positions;
const width = options.width;
@ -1262,8 +1257,8 @@ CorridorGeometry.computeRectangle = function (options, result) {
Check.defined("options.width", width);
//>>includeEnd('debug');
const ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
const cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
const ellipsoid = options.ellipsoid ?? Ellipsoid.default;
const cornerType = options.cornerType ?? CornerType.ROUNDED;
return computeRectangle(positions, ellipsoid, width, cornerType, result);
};

View File

@ -5,7 +5,7 @@ import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import CornerType from "./CornerType.js";
import CorridorGeometryLibrary from "./CorridorGeometryLibrary.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Geometry from "./Geometry.js";
@ -376,7 +376,7 @@ function computePositionsExtruded(params) {
* });
*/
function CorridorOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const positions = options.positions;
const width = options.width;
@ -385,21 +385,16 @@ function CorridorOutlineGeometry(options) {
Check.typeOf.number("options.width", width);
//>>includeEnd('debug');
const height = defaultValue(options.height, 0.0);
const extrudedHeight = defaultValue(options.extrudedHeight, height);
const height = options.height ?? 0.0;
const extrudedHeight = options.extrudedHeight ?? height;
this._positions = positions;
this._ellipsoid = Ellipsoid.clone(
defaultValue(options.ellipsoid, Ellipsoid.default),
);
this._ellipsoid = Ellipsoid.clone(options.ellipsoid ?? Ellipsoid.default);
this._width = width;
this._height = Math.max(height, extrudedHeight);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
this._granularity = defaultValue(
options.granularity,
CesiumMath.RADIANS_PER_DEGREE,
);
this._cornerType = options.cornerType ?? CornerType.ROUNDED;
this._granularity = options.granularity ?? CesiumMath.RADIANS_PER_DEGREE;
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createCorridorOutlineGeometry";
@ -426,7 +421,7 @@ CorridorOutlineGeometry.pack = function (value, array, startingIndex) {
Check.typeOf.object("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const positions = value._positions;
const length = positions.length;
@ -444,7 +439,7 @@ CorridorOutlineGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._cornerType;
array[startingIndex++] = value._granularity;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -474,7 +469,7 @@ CorridorOutlineGeometry.unpack = function (array, startingIndex, result) {
Check.typeOf.object("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const length = array[startingIndex++];
const positions = new Array(length);

View File

@ -1,6 +1,5 @@
import DOMPurify from "dompurify";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
let nextCreditId = 0;
@ -34,7 +33,7 @@ function Credit(html, showOnScreen) {
creditToId[key] = id;
}
showOnScreen = defaultValue(showOnScreen, false);
showOnScreen = showOnScreen ?? false;
// Credits are immutable so generate an id to use to optimize equal()
this._id = id;

View File

@ -1,6 +1,5 @@
import Cartesian3 from "./Cartesian3.js";
import Cartesian4 from "./Cartesian4.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Intersect from "./Intersect.js";
@ -22,7 +21,7 @@ function CullingVolume(planes) {
* @type {Cartesian4[]}
* @default []
*/
this.planes = defaultValue(planes, []);
this.planes = planes ?? [];
}
const faces = [new Cartesian3(), new Cartesian3(), new Cartesian3()];

View File

@ -1,6 +1,6 @@
import Check from "./Check.js";
import Credit from "./Credit.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Event from "./Event.js";
@ -54,7 +54,7 @@ import TerrainProvider from "./TerrainProvider.js";
* @see TerrainProvider
*/
function CustomHeightmapTerrainProvider(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.callback", options.callback);
@ -67,7 +67,7 @@ function CustomHeightmapTerrainProvider(options) {
this._tilingScheme = options.tilingScheme;
if (!defined(this._tilingScheme)) {
this._tilingScheme = new GeographicTilingScheme({
ellipsoid: defaultValue(options.ellipsoid, Ellipsoid.default),
ellipsoid: options.ellipsoid ?? Ellipsoid.default,
});
}

View File

@ -3,7 +3,7 @@ import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import ComponentDatatype from "./ComponentDatatype.js";
import CylinderGeometryLibrary from "./CylinderGeometryLibrary.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Geometry from "./Geometry.js";
@ -48,13 +48,13 @@ const positionScratch = new Cartesian3();
* const geometry = Cesium.CylinderGeometry.createGeometry(cylinder);
*/
function CylinderGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const length = options.length;
const topRadius = options.topRadius;
const bottomRadius = options.bottomRadius;
const vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
const slices = defaultValue(options.slices, 128);
const vertexFormat = options.vertexFormat ?? VertexFormat.DEFAULT;
const slices = options.slices ?? 128;
//>>includeStart('debug', pragmas.debug);
if (!defined(length)) {
@ -115,7 +115,7 @@ CylinderGeometry.pack = function (value, array, startingIndex) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.packedLength;
@ -124,7 +124,7 @@ CylinderGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -154,7 +154,7 @@ CylinderGeometry.unpack = function (array, startingIndex, result) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const vertexFormat = VertexFormat.unpack(
array,

View File

@ -4,7 +4,7 @@ import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import CylinderGeometryLibrary from "./CylinderGeometryLibrary.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Geometry from "./Geometry.js";
@ -47,14 +47,14 @@ const radiusScratch = new Cartesian2();
* const geometry = Cesium.CylinderOutlineGeometry.createGeometry(cylinder);
*/
function CylinderOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const length = options.length;
const topRadius = options.topRadius;
const bottomRadius = options.bottomRadius;
const slices = defaultValue(options.slices, 128);
const slices = options.slices ?? 128;
const numberOfVerticalLines = Math.max(
defaultValue(options.numberOfVerticalLines, 16),
options.numberOfVerticalLines ?? 16,
0,
);
@ -103,14 +103,14 @@ CylinderOutlineGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -137,7 +137,7 @@ CylinderOutlineGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const length = array[startingIndex++];
const topRadius = array[startingIndex++];

View File

@ -1,4 +1,3 @@
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
@ -16,10 +15,10 @@ import DeveloperError from "./DeveloperError.js";
* billboard.distanceDisplayCondition = new Cesium.DistanceDisplayCondition(10.0, 20.0);
*/
function DistanceDisplayCondition(near, far) {
near = defaultValue(near, 0.0);
near = near ?? 0.0;
this._near = near;
far = defaultValue(far, Number.MAX_VALUE);
far = far ?? Number.MAX_VALUE;
this._far = far;
}
@ -79,7 +78,7 @@ DistanceDisplayCondition.pack = function (value, array, startingIndex) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
array[startingIndex++] = value.near;
array[startingIndex] = value.far;
@ -102,7 +101,7 @@ DistanceDisplayCondition.unpack = function (array, startingIndex, result) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
if (!defined(result)) {
result = new DistanceDisplayCondition();

View File

@ -1,5 +1,4 @@
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
@ -33,8 +32,8 @@ import DeveloperError from "./DeveloperError.js";
* @see GeometryInstanceAttribute
*/
function DistanceDisplayConditionGeometryInstanceAttribute(near, far) {
near = defaultValue(near, 0.0);
far = defaultValue(far, Number.MAX_VALUE);
near = near ?? 0.0;
far = far ?? Number.MAX_VALUE;
//>>includeStart('debug', pragmas.debug);
if (far <= near) {

View File

@ -1,6 +1,6 @@
import binarySearch from "./binarySearch.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import EarthOrientationParametersSample from "./EarthOrientationParametersSample.js";
import JulianDate from "./JulianDate.js";
@ -33,7 +33,7 @@ import TimeStandard from "./TimeStandard.js";
* @private
*/
function EarthOrientationParameters(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
this._dates = undefined;
this._samples = undefined;
@ -49,7 +49,7 @@ function EarthOrientationParameters(options) {
this._columnCount = 0;
this._lastIndex = -1;
this._addNewLeapSeconds = defaultValue(options.addNewLeapSeconds, true);
this._addNewLeapSeconds = options.addNewLeapSeconds ?? true;
if (defined(options.data)) {
// Use supplied EOP data.
@ -107,7 +107,7 @@ EarthOrientationParameters.fromUrl = async function (url, options) {
Check.defined("url", url);
//>>includeEnd('debug');
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const resource = Resource.createIfNeeded(url);

View File

@ -4,7 +4,7 @@ import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import EllipseGeometryLibrary from "./EllipseGeometryLibrary.js";
@ -918,17 +918,14 @@ function computeRectangle(
* @see EllipseGeometry.createGeometry
*/
function EllipseGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const center = options.center;
const ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
const ellipsoid = options.ellipsoid ?? Ellipsoid.default;
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const granularity = defaultValue(
options.granularity,
CesiumMath.RADIANS_PER_DEGREE,
);
const vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
const granularity = options.granularity ?? CesiumMath.RADIANS_PER_DEGREE;
const vertexFormat = options.vertexFormat ?? VertexFormat.DEFAULT;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.center", center);
@ -944,20 +941,20 @@ function EllipseGeometry(options) {
}
//>>includeEnd('debug');
const height = defaultValue(options.height, 0.0);
const extrudedHeight = defaultValue(options.extrudedHeight, height);
const height = options.height ?? 0.0;
const extrudedHeight = options.extrudedHeight ?? height;
this._center = Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Ellipsoid.clone(ellipsoid);
this._rotation = defaultValue(options.rotation, 0.0);
this._stRotation = defaultValue(options.stRotation, 0.0);
this._rotation = options.rotation ?? 0.0;
this._stRotation = options.stRotation ?? 0.0;
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._vertexFormat = VertexFormat.clone(vertexFormat);
this._extrudedHeight = Math.min(extrudedHeight, height);
this._shadowVolume = defaultValue(options.shadowVolume, false);
this._shadowVolume = options.shadowVolume ?? false;
this._workerName = "createEllipseGeometry";
this._offsetAttribute = options.offsetAttribute;
@ -990,7 +987,7 @@ EllipseGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._center, array, startingIndex);
startingIndex += Cartesian3.packedLength;
@ -1009,7 +1006,7 @@ EllipseGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._shadowVolume ? 1.0 : 0.0;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -1045,7 +1042,7 @@ EllipseGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const center = Cartesian3.unpack(array, startingIndex, scratchCenter);
startingIndex += Cartesian3.packedLength;
@ -1117,17 +1114,14 @@ EllipseGeometry.unpack = function (array, startingIndex, result) {
* @returns {Rectangle} The result rectangle
*/
EllipseGeometry.computeRectangle = function (options, result) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const center = options.center;
const ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
const ellipsoid = options.ellipsoid ?? Ellipsoid.default;
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const granularity = defaultValue(
options.granularity,
CesiumMath.RADIANS_PER_DEGREE,
);
const rotation = defaultValue(options.rotation, 0.0);
const granularity = options.granularity ?? CesiumMath.RADIANS_PER_DEGREE;
const rotation = options.rotation ?? 0.0;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.center", center);

View File

@ -1,7 +1,7 @@
import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import EllipseGeometryLibrary from "./EllipseGeometryLibrary.js";
@ -137,7 +137,7 @@ function computeExtrudedEllipse(options) {
});
}
let numberOfVerticalLines = defaultValue(options.numberOfVerticalLines, 16);
let numberOfVerticalLines = options.numberOfVerticalLines ?? 16;
numberOfVerticalLines = CesiumMath.clamp(
numberOfVerticalLines,
0,
@ -211,16 +211,13 @@ function computeExtrudedEllipse(options) {
* const geometry = Cesium.EllipseOutlineGeometry.createGeometry(ellipse);
*/
function EllipseOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const center = options.center;
const ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
const ellipsoid = options.ellipsoid ?? Ellipsoid.default;
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const granularity = defaultValue(
options.granularity,
CesiumMath.RADIANS_PER_DEGREE,
);
const granularity = options.granularity ?? CesiumMath.RADIANS_PER_DEGREE;
//>>includeStart('debug', pragmas.debug);
if (!defined(center)) {
@ -242,19 +239,19 @@ function EllipseOutlineGeometry(options) {
}
//>>includeEnd('debug');
const height = defaultValue(options.height, 0.0);
const extrudedHeight = defaultValue(options.extrudedHeight, height);
const height = options.height ?? 0.0;
const extrudedHeight = options.extrudedHeight ?? height;
this._center = Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Ellipsoid.clone(ellipsoid);
this._rotation = defaultValue(options.rotation, 0.0);
this._rotation = options.rotation ?? 0.0;
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(
defaultValue(options.numberOfVerticalLines, 16),
options.numberOfVerticalLines ?? 16,
0,
);
this._offsetAttribute = options.offsetAttribute;
@ -287,7 +284,7 @@ EllipseOutlineGeometry.pack = function (value, array, startingIndex) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._center, array, startingIndex);
startingIndex += Cartesian3.packedLength;
@ -302,7 +299,7 @@ EllipseOutlineGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -337,7 +334,7 @@ EllipseOutlineGeometry.unpack = function (array, startingIndex, result) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const center = Cartesian3.unpack(array, startingIndex, scratchCenter);
startingIndex += Cartesian3.packedLength;

View File

@ -2,16 +2,15 @@ import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import CesiumMath from "./Math.js";
import scaleToGeodeticSurface from "./scaleToGeodeticSurface.js";
function initialize(ellipsoid, x, y, z) {
x = defaultValue(x, 0.0);
y = defaultValue(y, 0.0);
z = defaultValue(z, 0.0);
x = x ?? 0.0;
y = y ?? 0.0;
z = z ?? 0.0;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals("x", x, 0.0);
@ -321,7 +320,7 @@ Ellipsoid.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._radii, array, startingIndex);
@ -341,7 +340,7 @@ Ellipsoid.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const radii = Cartesian3.unpack(array, startingIndex);
return Ellipsoid.fromCartesian3(radii, result);
@ -470,7 +469,7 @@ Ellipsoid.prototype.cartographicArrayToCartesianArray = function (
) {
//>>includeStart('debug', pragmas.debug);
Check.defined("cartographics", cartographics);
//>>includeEnd('debug')
//>>includeEnd('debug');
const length = cartographics.length;
if (!defined(result)) {
@ -716,7 +715,7 @@ Ellipsoid.prototype.getSurfaceNormalIntersectionWithZAxis = function (
Check.typeOf.number.greaterThan("Ellipsoid.radii.z", this._radii.z, 0);
//>>includeEnd('debug');
buffer = defaultValue(buffer, 0.0);
buffer = buffer ?? 0.0;
const squaredXOverSquaredZ = this._squaredXOverSquaredZ;

View File

@ -1,7 +1,6 @@
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import CesiumMath from "./Math.js";
@ -284,7 +283,7 @@ function computeProperties(ellipsoidGeodesic, start, end, ellipsoid) {
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the geodesic lies.
*/
function EllipsoidGeodesic(start, end, ellipsoid) {
const e = defaultValue(ellipsoid, Ellipsoid.default);
const e = ellipsoid ?? Ellipsoid.default;
this._ellipsoid = e;
this._start = new Cartographic();
this._end = new Cartographic();

View File

@ -2,7 +2,7 @@ import BoundingSphere from "./BoundingSphere.js";
import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Ellipsoid from "./Ellipsoid.js";
@ -55,17 +55,17 @@ const sin = Math.sin;
* const geometry = Cesium.EllipsoidGeometry.createGeometry(ellipsoid);
*/
function EllipsoidGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const radii = defaultValue(options.radii, defaultRadii);
const innerRadii = defaultValue(options.innerRadii, radii);
const minimumClock = defaultValue(options.minimumClock, 0.0);
const maximumClock = defaultValue(options.maximumClock, CesiumMath.TWO_PI);
const minimumCone = defaultValue(options.minimumCone, 0.0);
const maximumCone = defaultValue(options.maximumCone, CesiumMath.PI);
const stackPartitions = Math.round(defaultValue(options.stackPartitions, 64));
const slicePartitions = Math.round(defaultValue(options.slicePartitions, 64));
const vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
const radii = options.radii ?? defaultRadii;
const innerRadii = options.innerRadii ?? radii;
const minimumClock = options.minimumClock ?? 0.0;
const maximumClock = options.maximumClock ?? CesiumMath.TWO_PI;
const minimumCone = options.minimumCone ?? 0.0;
const maximumCone = options.maximumCone ?? CesiumMath.PI;
const stackPartitions = Math.round(options.stackPartitions ?? 64);
const slicePartitions = Math.round(options.slicePartitions ?? 64);
const vertexFormat = options.vertexFormat ?? VertexFormat.DEFAULT;
//>>includeStart('debug', pragmas.debug);
if (slicePartitions < 3) {
@ -119,7 +119,7 @@ EllipsoidGeometry.pack = function (value, array, startingIndex) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartesian3.packedLength;
@ -136,7 +136,7 @@ EllipsoidGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -172,7 +172,7 @@ EllipsoidGeometry.unpack = function (array, startingIndex, result) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const radii = Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartesian3.packedLength;

View File

@ -1,7 +1,7 @@
import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Ellipsoid from "./Ellipsoid.js";
@ -47,17 +47,17 @@ const sin = Math.sin;
* const geometry = Cesium.EllipsoidOutlineGeometry.createGeometry(ellipsoid);
*/
function EllipsoidOutlineGeometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
const radii = defaultValue(options.radii, defaultRadii);
const innerRadii = defaultValue(options.innerRadii, radii);
const minimumClock = defaultValue(options.minimumClock, 0.0);
const maximumClock = defaultValue(options.maximumClock, CesiumMath.TWO_PI);
const minimumCone = defaultValue(options.minimumCone, 0.0);
const maximumCone = defaultValue(options.maximumCone, CesiumMath.PI);
const stackPartitions = Math.round(defaultValue(options.stackPartitions, 10));
const slicePartitions = Math.round(defaultValue(options.slicePartitions, 8));
const subdivisions = Math.round(defaultValue(options.subdivisions, 128));
const radii = options.radii ?? defaultRadii;
const innerRadii = options.innerRadii ?? radii;
const minimumClock = options.minimumClock ?? 0.0;
const maximumClock = options.maximumClock ?? CesiumMath.TWO_PI;
const minimumCone = options.minimumCone ?? 0.0;
const maximumCone = options.maximumCone ?? CesiumMath.PI;
const stackPartitions = Math.round(options.stackPartitions ?? 10);
const slicePartitions = Math.round(options.slicePartitions ?? 8);
const subdivisions = Math.round(options.subdivisions ?? 128);
//>>includeStart('debug', pragmas.debug);
if (stackPartitions < 1) {
@ -119,7 +119,7 @@ EllipsoidOutlineGeometry.pack = function (value, array, startingIndex) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartesian3.packedLength;
@ -134,7 +134,7 @@ EllipsoidOutlineGeometry.pack = function (value, array, startingIndex) {
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex++] = value._subdivisions;
array[startingIndex] = defaultValue(value._offsetAttribute, -1);
array[startingIndex] = value._offsetAttribute ?? -1;
return array;
};
@ -169,7 +169,7 @@ EllipsoidOutlineGeometry.unpack = function (array, startingIndex, result) {
}
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const radii = Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartesian3.packedLength;

View File

@ -1,7 +1,6 @@
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Ellipsoid from "./Ellipsoid.js";
@ -391,7 +390,7 @@ function interpolateUsingSurfaceDistance(
* @exception {DeveloperError} angle between start and end must be at least 0.0125 radians.
*/
function EllipsoidRhumbLine(start, end, ellipsoid) {
const e = defaultValue(ellipsoid, Ellipsoid.default);
const e = ellipsoid ?? Ellipsoid.default;
this._ellipsoid = e;
this._start = new Cartographic();
this._end = new Cartographic();
@ -500,7 +499,7 @@ EllipsoidRhumbLine.fromStartHeadingDistance = function (
Check.typeOf.number.greaterThan("distance", distance, 0.0);
//>>includeEnd('debug');
const e = defaultValue(ellipsoid, Ellipsoid.default);
const e = ellipsoid ?? Ellipsoid.default;
const major = e.maximumRadius;
const minor = e.minimumRadius;
const majorSquared = major * major;

View File

@ -3,7 +3,6 @@ import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import Cartesian4 from "./Cartesian4.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Ellipsoid from "./Ellipsoid.js";
@ -31,7 +30,7 @@ function EllipsoidTangentPlane(origin, ellipsoid) {
Check.defined("origin", origin);
//>>includeEnd('debug');
ellipsoid = defaultValue(ellipsoid, Ellipsoid.default);
ellipsoid = ellipsoid ?? Ellipsoid.default;
origin = ellipsoid.scaleToGeodeticSurface(origin);
//>>includeStart('debug', pragmas.debug);

View File

@ -1,4 +1,4 @@
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Event from "./Event.js";
@ -24,12 +24,12 @@ import TerrainProvider from "./TerrainProvider.js";
* @see TerrainProvider
*/
function EllipsoidTerrainProvider(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
this._tilingScheme = options.tilingScheme;
if (!defined(this._tilingScheme)) {
this._tilingScheme = new GeographicTilingScheme({
ellipsoid: defaultValue(options.ellipsoid, Ellipsoid.default),
ellipsoid: options.ellipsoid ?? Ellipsoid.default,
});
}
@ -115,7 +115,7 @@ Object.defineProperties(EllipsoidTerrainProvider.prototype, {
* at points and in rectangles. This property may be undefined if availability
* information is not available.
* @memberof EllipsoidTerrainProvider.prototype
* @type {TileAvailability}
* @type {TileAvailability|undefined}
* @readonly
*/
availability: {

View File

@ -1,7 +1,6 @@
import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import Rectangle from "./Rectangle.js";
@ -418,8 +417,8 @@ function computeHorizonCullingPointFromVertices(
result = new Cartesian3();
}
stride = defaultValue(stride, 3);
center = defaultValue(center, Cartesian3.ZERO);
stride = stride ?? 3;
center = center ?? Cartesian3.ZERO;
const scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(
ellipsoid,
directionToPoint,

View File

@ -1,5 +1,4 @@
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Fullscreen from "./Fullscreen.js";
@ -314,7 +313,7 @@ const FeatureDetection = {
firefoxVersion: firefoxVersion,
isWindows: isWindows,
isIPadOrIOS: isIPadOrIOS,
hardwareConcurrency: defaultValue(theNavigator.hardwareConcurrency, 3),
hardwareConcurrency: theNavigator.hardwareConcurrency ?? 3,
supportsPointerEvents: supportsPointerEvents,
supportsImageRenderingPixelated: supportsImageRenderingPixelated,
supportsWebP: supportsWebP,

View File

@ -0,0 +1,24 @@
/**
* Utilities helpful for setting a default value for a parameter.
*
* @namespace Frozen
*/
const Frozen = {};
/**
* A frozen empty object that can be used as the default value for options passed as
* an object literal.
* @type {object}
* @memberof Frozen
*/
Frozen.EMPTY_OBJECT = Object.freeze({});
/**
* A frozen empty array that can be used as the default value for options passed as
* an array literal.
* @type {array}
* @memberof Frozen
*/
Frozen.EMPTY_ARRAY = Object.freeze([]);
export default Frozen;

View File

@ -3,7 +3,6 @@ import Cartesian3 from "./Cartesian3.js";
import Cartesian4 from "./Cartesian4.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import Geometry from "./Geometry.js";
import GeometryAttribute from "./GeometryAttribute.js";
@ -42,12 +41,12 @@ function FrustumGeometry(options) {
const frustum = options.frustum;
const orientation = options.orientation;
const origin = options.origin;
const vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
const vertexFormat = options.vertexFormat ?? VertexFormat.DEFAULT;
// This is private because it is used by DebugCameraPrimitive to draw a multi-frustum by
// creating multiple FrustumGeometry objects. This way the near plane of one frustum doesn't overlap
// the far plane of another.
const drawNearPlane = defaultValue(options._drawNearPlane, true);
const drawNearPlane = options._drawNearPlane ?? true;
let frustumType;
let frustumPackedLength;
@ -94,7 +93,7 @@ FrustumGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const frustumType = value._frustumType;
const frustum = value._frustum;
@ -138,7 +137,7 @@ FrustumGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const frustumType = array[startingIndex++];
@ -277,9 +276,9 @@ FrustumGeometry._computeNearFarPlanes = function (
orientation,
scratchRotationMatrix,
);
let x = defaultValue(xDirection, scratchXDirection);
let y = defaultValue(yDirection, scratchYDirection);
let z = defaultValue(zDirection, scratchZDirection);
let x = xDirection ?? scratchXDirection;
let y = yDirection ?? scratchYDirection;
let z = zDirection ?? scratchZDirection;
x = Matrix3.getColumn(rotationMatrix, 0, x);
y = Matrix3.getColumn(rotationMatrix, 1, y);

View File

@ -2,7 +2,6 @@ import BoundingSphere from "./BoundingSphere.js";
import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import FrustumGeometry from "./FrustumGeometry.js";
import Geometry from "./Geometry.js";
@ -42,7 +41,7 @@ function FrustumOutlineGeometry(options) {
// This is private because it is used by DebugCameraPrimitive to draw a multi-frustum by
// creating multiple FrustumOutlineGeometrys. This way the near plane of one frustum doesn't overlap
// the far plane of another.
const drawNearPlane = defaultValue(options._drawNearPlane, true);
const drawNearPlane = options._drawNearPlane ?? true;
let frustumType;
let frustumPackedLength;
@ -84,7 +83,7 @@ FrustumOutlineGeometry.pack = function (value, array, startingIndex) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const frustumType = value._frustumType;
const frustum = value._frustum;
@ -125,7 +124,7 @@ FrustumOutlineGeometry.unpack = function (array, startingIndex, result) {
Check.defined("array", array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
startingIndex = startingIndex ?? 0;
const frustumType = array[startingIndex++];

View File

@ -1,6 +1,5 @@
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Ellipsoid from "./Ellipsoid.js";
@ -19,7 +18,7 @@ import Ellipsoid from "./Ellipsoid.js";
* @see WebMercatorProjection
*/
function GeographicProjection(ellipsoid) {
this._ellipsoid = defaultValue(ellipsoid, Ellipsoid.default);
this._ellipsoid = ellipsoid ?? Ellipsoid.default;
this._semimajorAxis = this._ellipsoid.maximumRadius;
this._oneOverSemimajorAxis = 1.0 / this._semimajorAxis;
}

View File

@ -1,6 +1,6 @@
import Cartesian2 from "./Cartesian2.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import GeographicProjection from "./GeographicProjection.js";
@ -25,19 +25,13 @@ import Rectangle from "./Rectangle.js";
* the tile tree.
*/
function GeographicTilingScheme(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.default);
this._rectangle = defaultValue(options.rectangle, Rectangle.MAX_VALUE);
this._ellipsoid = options.ellipsoid ?? Ellipsoid.default;
this._rectangle = options.rectangle ?? Rectangle.MAX_VALUE;
this._projection = new GeographicProjection(this._ellipsoid);
this._numberOfLevelZeroTilesX = defaultValue(
options.numberOfLevelZeroTilesX,
2,
);
this._numberOfLevelZeroTilesY = defaultValue(
options.numberOfLevelZeroTilesY,
1,
);
this._numberOfLevelZeroTilesX = options.numberOfLevelZeroTilesX ?? 2;
this._numberOfLevelZeroTilesY = options.numberOfLevelZeroTilesY ?? 1;
}
Object.defineProperties(GeographicTilingScheme.prototype, {

View File

@ -2,7 +2,7 @@ import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import GeometryType from "./GeometryType.js";
@ -65,7 +65,7 @@ import Transforms from "./Transforms.js";
* });
*/
function Geometry(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.attributes", options.attributes);
@ -135,10 +135,7 @@ function Geometry(options) {
*
* @default PrimitiveType.TRIANGLES
*/
this.primitiveType = defaultValue(
options.primitiveType,
PrimitiveType.TRIANGLES,
);
this.primitiveType = options.primitiveType ?? PrimitiveType.TRIANGLES;
/**
* An optional bounding sphere that fully encloses the geometry. This is
@ -153,7 +150,7 @@ function Geometry(options) {
/**
* @private
*/
this.geometryType = defaultValue(options.geometryType, GeometryType.NONE);
this.geometryType = options.geometryType ?? GeometryType.NONE;
/**
* @private

View File

@ -1,4 +1,4 @@
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
@ -38,7 +38,7 @@ import DeveloperError from "./DeveloperError.js";
* @see Geometry
*/
function GeometryAttribute(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
if (!defined(options.componentDatatype)) {
@ -110,7 +110,7 @@ function GeometryAttribute(options) {
* Cesium.Color.floatToByte(color.alpha)
* ]);
*/
this.normalize = defaultValue(options.normalize, false);
this.normalize = options.normalize ?? false;
/**
* The values for the attributes stored in a typed array. In the code example,

View File

@ -1,4 +1,4 @@
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
/**
* Attributes, which make up a geometry's vertices. Each property in this object corresponds to a
@ -11,7 +11,7 @@ import defaultValue from "./defaultValue.js";
* @constructor
*/
function GeometryAttributes(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
/**
* The 3D position attribute.

View File

@ -1,4 +1,4 @@
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import Matrix4 from "./Matrix4.js";
@ -49,7 +49,7 @@ import Matrix4 from "./Matrix4.js";
* @see Geometry
*/
function GeometryInstance(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
if (!defined(options.geometry)) {
@ -75,9 +75,7 @@ function GeometryInstance(options) {
*
* @default Matrix4.IDENTITY
*/
this.modelMatrix = Matrix4.clone(
defaultValue(options.modelMatrix, Matrix4.IDENTITY),
);
this.modelMatrix = Matrix4.clone(options.modelMatrix ?? Matrix4.IDENTITY);
/**
* User-defined object returned when the instance is picked or used to get/set per-instance attributes.
@ -106,7 +104,7 @@ function GeometryInstance(options) {
*
* @default {}
*/
this.attributes = defaultValue(options.attributes, {});
this.attributes = options.attributes ?? {};
/**
* @private

View File

@ -1,4 +1,4 @@
import defaultValue from "./defaultValue.js";
import Frozen from "./Frozen.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
@ -40,7 +40,7 @@ import DeveloperError from "./DeveloperError.js";
* @see DistanceDisplayConditionGeometryInstanceAttribute
*/
function GeometryInstanceAttribute(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
if (!defined(options.componentDatatype)) {
@ -111,7 +111,7 @@ function GeometryInstanceAttribute(options) {
* Cesium.Color.floatToByte(color.alpha)
* ];
*/
this.normalize = defaultValue(options.normalize, false);
this.normalize = options.normalize ?? false;
/**
* The values for the attributes stored in a typed array. In the code example,

View File

@ -6,7 +6,6 @@ import Cartesian3 from "./Cartesian3.js";
import Cartesian4 from "./Cartesian4.js";
import Cartographic from "./Cartographic.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import EncodedCartesian3 from "./EncodedCartesian3.js";
@ -169,7 +168,7 @@ GeometryPipeline.createLineSegmentsForVectors = function (
attributeName,
length,
) {
attributeName = defaultValue(attributeName, "normal");
attributeName = attributeName ?? "normal";
//>>includeStart('debug', pragmas.debug);
if (!defined(geometry)) {
@ -185,7 +184,7 @@ GeometryPipeline.createLineSegmentsForVectors = function (
}
//>>includeEnd('debug');
length = defaultValue(length, 10000.0);
length = length ?? 10000.0;
const positions = geometry.attributes.position.values;
const vectors = geometry.attributes[attributeName].values;
@ -243,7 +242,7 @@ GeometryPipeline.createAttributeLocations = function (geometry) {
if (!defined(geometry)) {
throw new DeveloperError("geometry is required.");
}
//>>includeEnd('debug')
//>>includeEnd('debug');
// There can be a WebGL performance hit when attribute 0 is disabled, so
// assign attribute locations to well-known attributes.

View File

@ -2,7 +2,6 @@ import * as protobuf from "protobufjs/dist/minimal/protobuf.js";
import buildModuleUrl from "./buildModuleUrl.js";
import Check from "./Check.js";
import Credit from "./Credit.js";
import defaultValue from "./defaultValue.js";
import defined from "./defined.js";
import GoogleEarthEnterpriseTileInformation from "./GoogleEarthEnterpriseTileInformation.js";
import isBitSet from "./isBitSet.js";
@ -304,8 +303,8 @@ GoogleEarthEnterpriseMetadata.prototype.getQuadTreePacket = function (
version,
request,
) {
version = defaultValue(version, 1);
quadKey = defaultValue(quadKey, "");
version = version ?? 1;
quadKey = quadKey ?? "";
const resource = getMetadataResource(this, quadKey, version, request);
const promise = resource.fetchArrayBuffer();
@ -549,34 +548,24 @@ function requestDbRoot(that) {
const dbRoot = dbrootParser.DbRootProto.decode(
new Uint8Array(result.buffer),
);
that.imageryPresent = defaultValue(
dbRoot.imageryPresent,
that.imageryPresent,
);
that.imageryPresent = dbRoot.imageryPresent ?? that.imageryPresent;
that.protoImagery = dbRoot.protoImagery;
that.terrainPresent = defaultValue(
dbRoot.terrainPresent,
that.terrainPresent,
);
that.terrainPresent = dbRoot.terrainPresent ?? that.terrainPresent;
if (defined(dbRoot.endSnippet) && defined(dbRoot.endSnippet.model)) {
const model = dbRoot.endSnippet.model;
that.negativeAltitudeExponentBias = defaultValue(
model.negativeAltitudeExponentBias,
that.negativeAltitudeExponentBias,
);
that.negativeAltitudeThreshold = defaultValue(
model.compressedNegativeAltitudeThreshold,
that.negativeAltitudeThreshold,
);
that.negativeAltitudeExponentBias =
model.negativeAltitudeExponentBias ??
that.negativeAltitudeExponentBias;
that.negativeAltitudeThreshold =
model.compressedNegativeAltitudeThreshold ??
that.negativeAltitudeThreshold;
}
if (defined(dbRoot.databaseVersion)) {
that._quadPacketVersion = defaultValue(
dbRoot.databaseVersion.quadtreeVersion,
that._quadPacketVersion,
);
that._quadPacketVersion =
dbRoot.databaseVersion.quadtreeVersion ?? that._quadPacketVersion;
}
const providers = that.providers;
const providerInfo = defaultValue(dbRoot.providerInfo, []);
const providerInfo = dbRoot.providerInfo ?? [];
const count = providerInfo.length;
for (let i = 0; i < count; ++i) {
const provider = providerInfo[i];

Some files were not shown because too many files have changed in this diff Show More