diff --git a/.github/actions/check-for-CLA/index.js b/.github/actions/check-for-CLA/index.js
index e1ee29e17d2f..e8c91f867ba9 100644
--- a/.github/actions/check-for-CLA/index.js
+++ b/.github/actions/check-for-CLA/index.js
@@ -32,7 +32,7 @@ const main = async () => {
const response = await postCommentOnPullRequest(
hasSignedCLA,
- errorFoundOnCLACheck
+ errorFoundOnCLACheck,
);
};
@@ -49,7 +49,7 @@ const checkIfUserHasSignedAnyCLA = async () => {
const checkIfIndividualCLAFound = async () => {
const response = await getValuesFromGoogleSheet(
GOOGLE_SHEETS_INFO.individualCLASheetId,
- "D2:D"
+ "D2:D",
);
const rows = response.data.values;
@@ -70,7 +70,7 @@ const checkIfIndividualCLAFound = async () => {
const checkIfCorporateCLAFound = async () => {
const response = await getValuesFromGoogleSheet(
GOOGLE_SHEETS_INFO.corporateCLASheetId,
- "H2:H"
+ "H2:H",
);
const rows = response.data.values;
@@ -132,14 +132,14 @@ const postCommentOnPullRequest = async (hasSignedCLA, errorFoundOnCLACheck) => {
accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
- }
+ },
);
};
const getCommentBody = (hasSignedCLA, errorFoundOnCLACheck) => {
const commentTemplate = fs.readFileSync(
"./.github/actions/check-for-CLA/templates/pullRequestComment.hbs",
- "utf-8"
+ "utf-8",
);
const getCommentFromTemplate = Handlebars.compile(commentTemplate);
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
index 610927976ada..4ca9ddbf3d8b 100644
--- a/.github/workflows/cla.yml
+++ b/.github/workflows/cla.yml
@@ -16,12 +16,12 @@ jobs:
with:
node-version: '20'
- name: install npm packages
- run: npm install googleapis @octokit/core handlebars fs-extra
+ run: npm install googleapis @octokit/core handlebars fs-extra
- name: run script
run: node .github/actions/check-for-CLA/index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- PULL_REQUEST_ID: ${{ github.event.number }}
+ PULL_REQUEST_ID: ${{ github.event.number }}
GOOGLE_KEYS: ${{ secrets.GOOGLE_KEYS }}
- INDIVIDUAL_CLA_SHEET_ID: ${{ secrets.INDIVIDUAL_CLA_SHEET_ID }}
- CORPORATE_CLA_SHEET_ID: ${{ secrets.CORPORATE_CLA_SHEET_ID }}
\ No newline at end of file
+ INDIVIDUAL_CLA_SHEET_ID: ${{ secrets.INDIVIDUAL_CLA_SHEET_ID }}
+ CORPORATE_CLA_SHEET_ID: ${{ secrets.CORPORATE_CLA_SHEET_ID }}
diff --git a/.gitignore b/.gitignore
index f86fac7a600e..50fe932f1bca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,4 +42,4 @@ yarn.lock
.idea/shelf
# Used in the CLA checking GitHub workflow
-GoogleConfig.json
\ No newline at end of file
+GoogleConfig.json
diff --git a/CHANGES.md b/CHANGES.md
index 7a557856fdaa..ec929e05b322 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -54,7 +54,6 @@
##### Additions :tada:
-- Added `HeightReference.CLAMP_TO_TERRAIN`, `HeightReference.RELATIVE_TO_TERRAIN`, `HeightReference.CLAMP_TO_3D_TILE`, and `HeightReference.RELATIVE_TO_3D_TILE` to position relatve to terrain or 3D tilesets exclusively.[#11604](https://github.com/CesiumGS/cesium/pull/11604)
- Added `Cesium3DTileset.getHeight` to sample height values of the loaded tiles. If using WebGL 1, the `enablePick` option must be set to true to use this function. [#11581](https://github.com/CesiumGS/cesium/pull/11581)
- Added `Cesium3DTileset.disableCollision` to allow the camera from to go inside or below a 3D tileset, for instance, to be used with 3D Tiles interiors. [#11581](https://github.com/CesiumGS/cesium/pull/11581)
- Fog rendering now applies to glTF models and 3D Tiles. This can be configured using `scene.fog` and `scene.atmosphere`. [#11744](https://github.com/CesiumGS/cesium/pull/11744)
@@ -335,6 +334,7 @@ try {
##### Additions :tada:
- Added `Cesium3DTileset.cacheBytes` and `Cesium3DTileset.maximumCacheOverflowBytes` to better control memory usage. To replicate previous behavior, convert `maximumMemoryUsage` from MB to bytes, assign the value to `cacheBytes`, and set `maximumCacheOverflowBytes = Number.MAX_VALUE`
+- Added `Cesium.Scene.webXRContext` and initial support for integrating Cesium into the WebXR redering cycle.
##### Fixes :wrench:
@@ -1968,7 +1968,7 @@ _This is an npm-only release to fix a publishing issue_.
- This is to make clipping planes' coordinates always relative to the object they're attached to. So if you were positioning the clipping planes as in the example below, this is no longer necessary:
```javascript
clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
- tileset.boundingSphere.center
+ tileset.boundingSphere.center,
);
```
- This also fixes several issues with clipping planes not using the correct transform for tilesets with children.
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 8850724dfca6..9a1b9f1b4075 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -381,3 +381,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Harsh Lakhara](https://github.com/harshlakhara)
- [Pavlo Skakun](https://github.com/p-skakun)
- [Taylor Huffman](https://github.com/huffmantayler)
+- [Arturo Espinosa Aldama](https://github.com/pupitetris)
diff --git a/package.json b/package.json
index 4c8066d844ca..644c0993654c 100644
--- a/package.json
+++ b/package.json
@@ -160,4 +160,4 @@
"packages/engine",
"packages/widgets"
]
-}
\ No newline at end of file
+}
diff --git a/packages/engine/Source/Core/PerspectiveOffCenterFrustum.js b/packages/engine/Source/Core/PerspectiveOffCenterFrustum.js
index 00339b199d60..1654f2e4ee71 100644
--- a/packages/engine/Source/Core/PerspectiveOffCenterFrustum.js
+++ b/packages/engine/Source/Core/PerspectiveOffCenterFrustum.js
@@ -92,6 +92,50 @@ function PerspectiveOffCenterFrustum(options) {
this._infinitePerspective = new Matrix4();
}
+/**
+ * Obtains a PerspectiveOffCenterFrustum from a projection matrix.
+ *
+ * @param {Matrix4} projectionMatrix The matrix representing the projection tranformation.
+ * @param {PerspectiveOffCenterFrustum} [result] The object into which to store the result.
+ * @returns {PerspectiveOffCenterFrustum} The modified result parameter or a new PerspectiveOffCenterFrustum instance if one was not provided.
+ */
+PerspectiveOffCenterFrustum.fromProjectionMatrix = function (
+ projectionMatrix,
+ result
+) {
+ if (!defined(result)) {
+ result = new PerspectiveOffCenterFrustum();
+ }
+
+ const near =
+ projectionMatrix[Matrix4.COLUMN3ROW2] /
+ (projectionMatrix[Matrix4.COLUMN2ROW2] - 1);
+
+ result.near = near;
+
+ result.far =
+ projectionMatrix[Matrix4.COLUMN3ROW2] /
+ (1 + projectionMatrix[Matrix4.COLUMN2ROW2]);
+
+ result.right =
+ (near * (1 + projectionMatrix[Matrix4.COLUMN2ROW0])) /
+ projectionMatrix[Matrix4.COLUMN0ROW0];
+
+ result.left =
+ (near * (projectionMatrix[Matrix4.COLUMN2ROW0] - 1)) /
+ projectionMatrix[Matrix4.COLUMN0ROW0];
+
+ result.top =
+ (near * (1 + projectionMatrix[Matrix4.COLUMN2ROW1])) /
+ projectionMatrix[Matrix4.COLUMN1ROW1];
+
+ result.bottom =
+ (near * (projectionMatrix[Matrix4.COLUMN2ROW1] - 1)) /
+ projectionMatrix[Matrix4.COLUMN1ROW1];
+
+ return result;
+};
+
function update(frustum) {
//>>includeStart('debug', pragmas.debug);
if (
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index f1849eaddbd3..86efda73bf17 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -228,7 +228,7 @@ function Cesium3DTileset(options) {
this._cullWithChildrenBounds = defaultValue(
options.cullWithChildrenBounds,
- true
+ true,
);
this._allTilesAdditive = true;
@@ -239,7 +239,7 @@ function Cesium3DTileset(options) {
this._maximumScreenSpaceError = defaultValue(
options.maximumScreenSpaceError,
- 16
+ 16,
);
this._memoryAdjustedScreenSpaceError = this._maximumScreenSpaceError;
@@ -250,13 +250,13 @@ function Cesium3DTileset(options) {
const maximumCacheOverflowBytes = defaultValue(
options.maximumCacheOverflowBytes,
- 512 * 1024 * 1024
+ 512 * 1024 * 1024,
);
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals(
"maximumCacheOverflowBytes",
maximumCacheOverflowBytes,
- 0
+ 0,
);
//>>includeEnd('debug');
this._maximumCacheOverflowBytes = maximumCacheOverflowBytes;
@@ -293,7 +293,7 @@ function Cesium3DTileset(options) {
reverseScreenSpaceError: Number.MAX_VALUE,
};
this._heatmap = new Cesium3DTilesetHeatmap(
- options.debugHeatmapTilePropertyName
+ options.debugHeatmapTilePropertyName,
);
/**
@@ -304,7 +304,7 @@ function Cesium3DTileset(options) {
*/
this.cullRequestsWhileMoving = defaultValue(
options.cullRequestsWhileMoving,
- true
+ true,
);
this._cullRequestsWhileMoving = false;
@@ -316,7 +316,7 @@ function Cesium3DTileset(options) {
*/
this.cullRequestsWhileMovingMultiplier = defaultValue(
options.cullRequestsWhileMovingMultiplier,
- 60.0
+ 60.0,
);
/**
@@ -328,7 +328,7 @@ function Cesium3DTileset(options) {
this.progressiveResolutionHeightFraction = CesiumMath.clamp(
defaultValue(options.progressiveResolutionHeightFraction, 0.3),
0.0,
- 0.5
+ 0.5,
);
/**
@@ -354,12 +354,12 @@ function Cesium3DTileset(options) {
this._vectorClassificationOnly = defaultValue(
options.vectorClassificationOnly,
- false
+ false,
);
this._vectorKeepDecodedPositions = defaultValue(
options.vectorKeepDecodedPositions,
- false
+ false,
);
/**
@@ -378,7 +378,7 @@ function Cesium3DTileset(options) {
*/
this.preloadFlightDestinations = defaultValue(
options.preloadFlightDestinations,
- true
+ true,
);
this._pass = undefined; // Cesium3DTilePass
@@ -394,7 +394,7 @@ function Cesium3DTileset(options) {
*/
this.dynamicScreenSpaceError = defaultValue(
options.dynamicScreenSpaceError,
- true
+ true,
);
/**
@@ -407,12 +407,12 @@ function Cesium3DTileset(options) {
*/
this.foveatedScreenSpaceError = defaultValue(
options.foveatedScreenSpaceError,
- true
+ true,
);
this._foveatedConeSize = defaultValue(options.foveatedConeSize, 0.1);
this._foveatedMinimumScreenSpaceErrorRelaxation = defaultValue(
options.foveatedMinimumScreenSpaceErrorRelaxation,
- 0.0
+ 0.0,
);
/**
@@ -423,7 +423,7 @@ function Cesium3DTileset(options) {
*/
this.foveatedInterpolationCallback = defaultValue(
options.foveatedInterpolationCallback,
- CesiumMath.lerp
+ CesiumMath.lerp,
);
/**
@@ -460,7 +460,7 @@ function Cesium3DTileset(options) {
*/
this.dynamicScreenSpaceErrorDensity = defaultValue(
options.dynamicScreenSpaceErrorDensity,
- 2.0e-4
+ 2.0e-4,
);
/**
@@ -481,7 +481,7 @@ function Cesium3DTileset(options) {
*/
this.dynamicScreenSpaceErrorFactor = defaultValue(
options.dynamicScreenSpaceErrorFactor,
- 24.0
+ 24.0,
);
/**
@@ -495,7 +495,7 @@ function Cesium3DTileset(options) {
*/
this.dynamicScreenSpaceErrorHeightFalloff = defaultValue(
options.dynamicScreenSpaceErrorHeightFalloff,
- 0.25
+ 0.25,
);
// Updated based on the camera position and direction
@@ -758,7 +758,7 @@ function Cesium3DTileset(options) {
*/
this.skipScreenSpaceErrorFactor = defaultValue(
options.skipScreenSpaceErrorFactor,
- 16
+ 16,
);
/**
@@ -785,7 +785,7 @@ function Cesium3DTileset(options) {
*/
this.immediatelyLoadDesiredLevelOfDetail = defaultValue(
options.immediatelyLoadDesiredLevelOfDetail,
- false
+ false,
);
/**
@@ -861,7 +861,7 @@ function Cesium3DTileset(options) {
*/
this.splitDirection = defaultValue(
options.splitDirection,
- SplitDirection.NONE
+ SplitDirection.NONE,
);
/**
@@ -875,7 +875,7 @@ function Cesium3DTileset(options) {
if (defined(options.disableCollision)) {
deprecationWarning(
"Cesium3DTileset options.disableCollision",
- "Cesium3DTileset options.disableCollision has been deprecated in CesiumJS 1.115. It will be removed in CesiumJS 1.116. Use options.enableCollision instead."
+ "Cesium3DTileset options.disableCollision has been deprecated in CesiumJS 1.115. It will be removed in CesiumJS 1.116. Use options.enableCollision instead.",
);
this.enableCollision = !options.disableCollision;
@@ -912,7 +912,7 @@ function Cesium3DTileset(options) {
this._enableDebugWireframe = defaultValue(
options.enableDebugWireframe,
- false
+ false,
);
/**
@@ -930,7 +930,7 @@ function Cesium3DTileset(options) {
if (this.debugWireframe === true && this._enableDebugWireframe === false) {
oneTimeWarning(
"tileset-debug-wireframe-ignored",
- "enableDebugWireframe must be set to true in the Cesium3DTileset constructor, otherwise debugWireframe will be ignored."
+ "enableDebugWireframe must be set to true in the Cesium3DTileset constructor, otherwise debugWireframe will be ignored.",
);
}
@@ -947,7 +947,7 @@ function Cesium3DTileset(options) {
*/
this.debugShowBoundingVolume = defaultValue(
options.debugShowBoundingVolume,
- false
+ false,
);
/**
@@ -962,7 +962,7 @@ function Cesium3DTileset(options) {
*/
this.debugShowContentBoundingVolume = defaultValue(
options.debugShowContentBoundingVolume,
- false
+ false,
);
/**
@@ -976,7 +976,7 @@ function Cesium3DTileset(options) {
*/
this.debugShowViewerRequestVolume = defaultValue(
options.debugShowViewerRequestVolume,
- false
+ false,
);
/**
@@ -999,7 +999,7 @@ function Cesium3DTileset(options) {
*/
this.debugShowGeometricError = defaultValue(
options.debugShowGeometricError,
- false
+ false,
);
/**
@@ -1013,7 +1013,7 @@ function Cesium3DTileset(options) {
*/
this.debugShowRenderingStatistics = defaultValue(
options.debugShowRenderingStatistics,
- false
+ false,
);
/**
@@ -1062,7 +1062,7 @@ function Cesium3DTileset(options) {
let instanceFeatureIdLabel = defaultValue(
options.instanceFeatureIdLabel,
- "instanceFeatureId_0"
+ "instanceFeatureId_0",
);
if (typeof instanceFeatureIdLabel === "number") {
instanceFeatureIdLabel = `instanceFeatureId_${instanceFeatureIdLabel}`;
@@ -1096,7 +1096,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
get: function () {
deprecationWarning(
"Cesium3DTileset.disableCollision",
- "Cesium3DTileset.disableCollision has been deprecated in CesiumJS 1.115. It will be removed in CesiumJS 1.116. Use Cesium3DTileset.enableCollision instead."
+ "Cesium3DTileset.disableCollision has been deprecated in CesiumJS 1.115. It will be removed in CesiumJS 1.116. Use Cesium3DTileset.enableCollision instead.",
);
return !this.enableCollision;
@@ -1104,7 +1104,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
set: function (value) {
deprecationWarning(
"Cesium3DTileset.disableCollision",
- "Cesium3DTileset.disableCollision has been deprecated in CesiumJS 1.115. It will be removed in CesiumJS 1.116. Use Cesium3DTileset.enableCollision instead."
+ "Cesium3DTileset.disableCollision has been deprecated in CesiumJS 1.115. It will be removed in CesiumJS 1.116. Use Cesium3DTileset.enableCollision instead.",
);
this.enableCollision = !value;
@@ -1230,7 +1230,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
get: function () {
deprecationWarning(
"Cesium3DTileset.basePath",
- "Cesium3DTileset.basePath has been deprecated. All tiles are relative to the url of the tileset JSON file that contains them. Use the url property instead."
+ "Cesium3DTileset.basePath has been deprecated. All tiles are relative to the url of the tileset JSON file that contains them. Use the url property instead.",
);
return this._basePath;
},
@@ -1446,7 +1446,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
Check.typeOf.number.greaterThanOrEquals(
"maximumScreenSpaceError",
value,
- 0
+ 0,
);
//>>includeEnd('debug');
@@ -1681,7 +1681,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
Matrix4.multiply(
this.root.computedTransform,
this._initialClippingPlanesOriginMatrix,
- this._clippingPlanesOriginMatrix
+ this._clippingPlanesOriginMatrix,
);
this._clippingPlanesOriginMatrixDirty = false;
}
@@ -1807,12 +1807,12 @@ Object.defineProperties(Cesium3DTileset.prototype, {
Check.typeOf.number.greaterThanOrEquals(
"foveatedMinimumScreenSpaceErrorRelaxation",
value,
- 0.0
+ 0.0,
);
Check.typeOf.number.lessThanOrEquals(
"foveatedMinimumScreenSpaceErrorRelaxation",
value,
- this.maximumScreenSpaceError
+ this.maximumScreenSpaceError,
);
//>>includeEnd('debug');
@@ -2086,7 +2086,7 @@ Cesium3DTileset.fromUrl = async function (url, options) {
const tilesetJson = await Cesium3DTileset.loadJson(resource);
const metadataExtension = await processMetadataExtension(
resource,
- tilesetJson
+ tilesetJson,
);
const tileset = new Cesium3DTileset(options);
@@ -2124,27 +2124,25 @@ Cesium3DTileset.fromUrl = async function (url, options) {
// the tile transform and model matrix at run time
const boundingVolume = tileset._root.createBoundingVolume(
tilesetJson.root.boundingVolume,
- Matrix4.IDENTITY
+ Matrix4.IDENTITY,
);
const clippingPlanesOrigin = boundingVolume.boundingSphere.center;
// If this origin is above the surface of the earth
// we want to apply an ENU orientation as our best guess of orientation.
// Otherwise, we assume it gets its position/orientation completely from the
// root tile transform and the tileset's model matrix
- const originCartographic = tileset._ellipsoid.cartesianToCartographic(
- clippingPlanesOrigin
- );
+ const originCartographic =
+ tileset._ellipsoid.cartesianToCartographic(clippingPlanesOrigin);
if (
defined(originCartographic) &&
originCartographic.height >
ApproximateTerrainHeights._defaultMinTerrainHeight
) {
- tileset._initialClippingPlanesOriginMatrix = Transforms.eastNorthUpToFixedFrame(
- clippingPlanesOrigin
- );
+ tileset._initialClippingPlanesOriginMatrix =
+ Transforms.eastNorthUpToFixedFrame(clippingPlanesOrigin);
}
tileset._clippingPlanesOriginMatrix = Matrix4.clone(
- tileset._initialClippingPlanesOriginMatrix
+ tileset._initialClippingPlanesOriginMatrix,
);
return tileset;
@@ -2180,7 +2178,7 @@ Cesium3DTileset.prototype.makeStyleDirty = function () {
Cesium3DTileset.prototype.loadTileset = function (
resource,
tilesetJson,
- parentTile
+ parentTile,
) {
const asset = tilesetJson.asset;
if (!defined(asset)) {
@@ -2192,7 +2190,7 @@ Cesium3DTileset.prototype.loadTileset = function (
asset.version !== "1.1"
) {
throw new RuntimeError(
- "The tileset must be 3D Tiles version 0.0, 1.0, or 1.1"
+ "The tileset must be 3D Tiles version 0.0, 1.0, or 1.1",
);
}
@@ -2275,7 +2273,7 @@ function makeTile(tileset, baseResource, tileHeader, parentTile) {
const implicitTileset = new ImplicitTileset(
baseResource,
tileHeader,
- metadataSchema
+ metadataSchema,
);
const rootCoordinates = new ImplicitTileCoordinates({
subdivisionScheme: implicitTileset.subdivisionScheme,
@@ -2391,21 +2389,21 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
// Transform camera position and direction into the local coordinate system of the tileset
const transformLocal = Matrix4.inverseTransformation(
root.computedTransform,
- scratchMatrix
+ scratchMatrix,
);
const ellipsoid = frameState.mapProjection.ellipsoid;
const boundingVolume = tileBoundingVolume.boundingVolume;
const centerLocal = Matrix4.multiplyByPoint(
transformLocal,
boundingVolume.center,
- scratchCenter
+ scratchCenter,
);
if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
// The tileset is defined in WGS84. Approximate the minimum and maximum height.
const centerCartographic = Cartographic.fromCartesian(
centerLocal,
ellipsoid,
- scratchCartographic
+ scratchCartographic,
);
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
direction = camera.directionWC;
@@ -2417,13 +2415,13 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
const positionLocal = Matrix4.multiplyByPoint(
transformLocal,
camera.positionWC,
- scratchPosition
+ scratchPosition,
);
up = Cartesian3.UNIT_Z;
direction = Matrix4.multiplyByPointAsVector(
transformLocal,
camera.directionWC,
- scratchDirection
+ scratchDirection,
);
direction = Cartesian3.normalize(direction, direction);
height = positionLocal.z;
@@ -2433,7 +2431,7 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
const halfHeightVector = Matrix3.getColumn(
boundingVolume.halfAxes,
2,
- scratchHalfHeight
+ scratchHalfHeight,
);
const halfHeight = Cartesian3.magnitude(halfHeightVector);
minimumHeight = centerLocal.z - halfHeight;
@@ -2455,7 +2453,7 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
const t = CesiumMath.clamp(
(height - heightClose) / (heightFar - heightClose),
0.0,
- 1.0
+ 1.0,
);
// Increase density as the camera tilts towards the horizon
@@ -2563,7 +2561,7 @@ Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
}
this._timeSinceLoad = Math.max(
JulianDate.secondsDifference(frameState.time, this._loadTimestamp) * 1000,
- 0.0
+ 0.0,
);
if (this.dynamicScreenSpaceError) {
@@ -2689,12 +2687,12 @@ function processUpdateHeight(tileset, tile, frameState) {
const ellipsoid = callbackData.ellipsoid;
const positionCartographic = Cartographic.clone(
callbackData.positionCartographic,
- scratchUpdateHeightCartographic
+ scratchUpdateHeightCartographic,
);
const centerCartographic = Cartographic.fromCartesian(
boundingSphere.center,
ellipsoid,
- scratchUpdateHeightCartographic2
+ scratchUpdateHeightCartographic2,
);
// This can be undefined when the bounding sphere is at the origin
@@ -2705,7 +2703,7 @@ function processUpdateHeight(tileset, tile, frameState) {
const position = Cartographic.toCartesian(
positionCartographic,
ellipsoid,
- scratchUpdateHeightCartesian
+ scratchUpdateHeightCartesian,
);
if (
Cartesian3.distance(position, boundingSphere.center) <=
@@ -2769,7 +2767,7 @@ function increaseScreenSpaceError(tileset) {
"increase-screenSpaceError",
`The tiles needed to meet maximumScreenSpaceError would use more memory than allocated for this tileset.
The tileset will be rendered with a larger screen space error (see memoryAdjustedScreenSpaceError).
- Consider using larger values for cacheBytes and maximumCacheOverflowBytes.`
+ Consider using larger values for cacheBytes and maximumCacheOverflowBytes.`,
);
//>>includeEnd('debug');
@@ -2784,7 +2782,7 @@ function increaseScreenSpaceError(tileset) {
function decreaseScreenSpaceError(tileset) {
tileset._memoryAdjustedScreenSpaceError = Math.max(
tileset.memoryAdjustedScreenSpaceError / 1.02,
- tileset.maximumScreenSpaceError
+ tileset.maximumScreenSpaceError,
);
}
@@ -2825,7 +2823,7 @@ function computeTileLabelPosition(tile) {
normal = Cartesian3.multiplyByScalar(
normal,
0.75 * radius,
- scratchCartesian
+ scratchCartesian,
);
position = Cartesian3.add(normal, center, scratchCartesian);
}
@@ -2871,10 +2869,10 @@ function addTileDebugLabel(tile, tileset, position) {
if (tileset.debugShowMemoryUsage) {
labelString += `\nTexture Memory: ${formatMemoryString(
- tile.content.texturesByteLength
+ tile.content.texturesByteLength,
)}`;
labelString += `\nGeometry Memory: ${formatMemoryString(
- tile.content.geometryByteLength
+ tile.content.geometryByteLength,
)}`;
attributes += 2;
}
@@ -2924,7 +2922,7 @@ function updateTileDebugLabels(tileset, frameState) {
const label = addTileDebugLabel(
tileset.debugPickedTile,
tileset,
- position
+ position,
);
label.pixelOffset = new Cartesian2(15, -15); // Offset to avoid picking the label.
}
@@ -3064,7 +3062,7 @@ function updateTiles(tileset, frameState, passOptions) {
frameState,
numberOfInitialCommands,
tileset.pointCloudShading,
- tileset.boundingSphere
+ tileset.boundingSphere,
);
}
@@ -3168,7 +3166,7 @@ function raiseLoadProgressEvent(tileset, frameState) {
frameState.afterRender.push(function () {
tileset.loadProgress.raiseEvent(
numberOfPendingRequests,
- numberOfTilesProcessing
+ numberOfTilesProcessing,
);
return true;
@@ -3230,12 +3228,12 @@ function detectModelMatrixChanged(tileset, frameState) {
tileset._updatedModelMatrixFrame = frameState.frameNumber;
tileset._modelMatrixChanged = !Matrix4.equals(
tileset.modelMatrix,
- tileset._previousModelMatrix
+ tileset._previousModelMatrix,
);
if (tileset._modelMatrixChanged) {
tileset._previousModelMatrix = Matrix4.clone(
tileset.modelMatrix,
- tileset._previousModelMatrix
+ tileset._previousModelMatrix,
);
}
}
@@ -3325,7 +3323,7 @@ function createCredits(tileset) {
credits.forEach(
(credit) =>
(credit.showOnScreen =
- credit.showOnScreen || tileset._showCreditsOnScreen)
+ credit.showOnScreen || tileset._showCreditsOnScreen),
);
tileset._credits = credits;
@@ -3364,7 +3362,7 @@ Cesium3DTileset.prototype.update = function (frameState) {
*/
Cesium3DTileset.prototype.updateForPass = function (
frameState,
- tilesetPassState
+ tilesetPassState,
) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("frameState", frameState);
@@ -3396,7 +3394,7 @@ Cesium3DTileset.prototype.updateForPass = function (
const commandList = defaultValue(
tilesetPassState.commandList,
- originalCommandList
+ originalCommandList,
);
const commandStart = commandList.length;
@@ -3404,7 +3402,7 @@ Cesium3DTileset.prototype.updateForPass = function (
frameState.camera = defaultValue(tilesetPassState.camera, originalCamera);
frameState.cullingVolume = defaultValue(
tilesetPassState.cullingVolume,
- originalCullingVolume
+ originalCullingVolume,
);
const passStatistics = this._statisticsPerPass[pass];
@@ -3415,7 +3413,7 @@ Cesium3DTileset.prototype.updateForPass = function (
this,
frameState,
passStatistics,
- passOptions
+ passOptions,
);
}
@@ -3527,7 +3525,7 @@ Cesium3DTileset.checkSupportedExtensions = function (extensionsRequired) {
for (let i = 0; i < extensionsRequired.length; i++) {
if (!Cesium3DTileset.supportedExtensions[extensionsRequired[i]]) {
throw new RuntimeError(
- `Unsupported 3D Tiles Extension: ${extensionsRequired[i]}`
+ `Unsupported 3D Tiles Extension: ${extensionsRequired[i]}`,
);
}
}
@@ -3564,7 +3562,7 @@ Cesium3DTileset.prototype.getHeight = function (cartographic, scene) {
const ray = scratchGetHeightRay;
const position = ellipsoid.cartographicToCartesian(
cartographic,
- ray.direction
+ ray.direction,
);
Cartesian3.normalize(ray.direction, ray.direction);
@@ -3573,7 +3571,7 @@ Cesium3DTileset.prototype.getHeight = function (cartographic, scene) {
ray.origin = Cartesian3.multiplyByScalar(
ray.direction,
-2 * ellipsoid.maximumRadius,
- ray.origin
+ ray.origin,
);
const intersection = this.pick(ray, scene.frameState, scratchIntersection);
@@ -3583,7 +3581,7 @@ Cesium3DTileset.prototype.getHeight = function (cartographic, scene) {
return ellipsoid.cartesianToCartographic(
intersection,
- scratchGetHeightCartographic
+ scratchGetHeightCartographic,
)?.height;
};
@@ -3602,7 +3600,7 @@ Cesium3DTileset.prototype.getHeight = function (cartographic, scene) {
Cesium3DTileset.prototype.updateHeight = function (
cartographic,
callback,
- ellipsoid
+ ellipsoid,
) {
ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
@@ -3659,7 +3657,7 @@ Cesium3DTileset.prototype.pick = function (ray, frameState, result) {
const boundsIntersection = IntersectionTests.raySphere(
ray,
tile.contentBoundingVolume.boundingSphere,
- scratchSphereIntersection
+ scratchSphereIntersection,
);
if (!defined(boundsIntersection) || !defined(tile.content)) {
continue;
@@ -3672,11 +3670,11 @@ Cesium3DTileset.prototype.pick = function (ray, frameState, result) {
candidates.sort((a, b) => {
const aDist = BoundingSphere.distanceSquaredTo(
a.contentBoundingVolume.boundingSphere,
- ray.origin
+ ray.origin,
);
const bDist = BoundingSphere.distanceSquaredTo(
b.contentBoundingVolume.boundingSphere,
- ray.origin
+ ray.origin,
);
return aDist - bDist;
@@ -3688,7 +3686,7 @@ Cesium3DTileset.prototype.pick = function (ray, frameState, result) {
const candidate = tile.content.pick(
ray,
frameState,
- scratchPickIntersection
+ scratchPickIntersection,
);
if (defined(candidate)) {
diff --git a/packages/engine/Source/Scene/I3SDataProvider.js b/packages/engine/Source/Scene/I3SDataProvider.js
index c4cd9cd4578e..89e87643ef26 100644
--- a/packages/engine/Source/Scene/I3SDataProvider.js
+++ b/packages/engine/Source/Scene/I3SDataProvider.js
@@ -149,14 +149,14 @@ function I3SDataProvider(options) {
this._showFeatures = defaultValue(options.showFeatures, false);
this._adjustMaterialAlphaMode = defaultValue(
options.adjustMaterialAlphaMode,
- false
+ false,
);
this._applySymbology = defaultValue(options.applySymbology, false);
this._calculateNormals = defaultValue(options.calculateNormals, false);
this._cesium3dTilesetOptions = defaultValue(
options.cesium3dTilesetOptions,
- defaultValue.EMPTY_OBJECT
+ defaultValue.EMPTY_OBJECT,
);
this._layers = [];
@@ -452,7 +452,7 @@ async function addLayers(provider, data, options) {
provider,
buildingLayerUrl,
data.sublayers[i],
- provider
+ provider,
);
promises.push(promise);
}
@@ -476,7 +476,7 @@ async function addLayers(provider, data, options) {
data.fullExtent.xmin,
data.fullExtent.ymin,
data.fullExtent.xmax,
- data.fullExtent.ymax
+ data.fullExtent.ymax,
);
provider._layersExtent.push(extent);
}
@@ -500,7 +500,7 @@ async function addLayers(provider, data, options) {
} else {
// Filter other scene layer types out
console.log(
- `${data.layerType} layer ${data.name} is skipped as not supported.`
+ `${data.layerType} layer ${data.name} is skipped as not supported.`,
);
}
}
@@ -571,7 +571,7 @@ I3SDataProvider.fromUrl = async function (url, options) {
const layerPromises = [];
for (let i = 0; i < provider._layers.length; i++) {
layerPromises.push(
- provider._layers[i].load(options.cesium3dTilesetOptions)
+ provider._layers[i].load(options.cesium3dTilesetOptions),
);
}
@@ -646,7 +646,7 @@ I3SDataProvider.prototype._binarizeGltf = function (rawGltf) {
chunkData: new Uint8Array(
binaryGltfData.buffer,
20,
- rawGltfData.byteLength
+ rawGltfData.byteLength,
),
};
@@ -680,7 +680,7 @@ function getCoveredTiles(terrainProvider, extent) {
const minCornerXY = tilingScheme.positionToTileXY(topLeftCorner, maxLevel);
const maxCornerXY = tilingScheme.positionToTileXY(
bottomRightCorner,
- maxLevel
+ maxLevel,
);
// Get all the tiles in between
@@ -711,7 +711,7 @@ function getCoveredTiles(terrainProvider, extent) {
const requestPromise = tileRequest.terrainProvider.requestTileGeometry(
tileRequest.x,
tileRequest.y,
- tileRequest.level
+ tileRequest.level,
);
tilePromises.push(requestPromise);
@@ -739,7 +739,7 @@ function getCoveredTiles(terrainProvider, extent) {
nativeExtent: tilingScheme.tileXYToNativeRectangle(
options.x,
options.y,
- options.level
+ options.level,
),
height: heightMap._height,
width: heightMap._width,
@@ -772,12 +772,12 @@ async function loadGeoidData(provider) {
try {
const heightMaps = await getCoveredTiles(
geoidTerrainProvider,
- provider._extent
+ provider._extent,
);
provider._geoidDataList = heightMaps;
} catch (error) {
console.log(
- "Error retrieving Geoid Terrain tiles - no geoid conversion will be performed."
+ "Error retrieving Geoid Terrain tiles - no geoid conversion will be performed.",
);
}
}
diff --git a/packages/engine/Source/Scene/Scene.js b/packages/engine/Source/Scene/Scene.js
index 02acfe64cbd3..c2290ba86cc4 100644
--- a/packages/engine/Source/Scene/Scene.js
+++ b/packages/engine/Source/Scene/Scene.js
@@ -72,6 +72,7 @@ import SunLight from "./SunLight.js";
import SunPostProcess from "./SunPostProcess.js";
import TweenCollection from "./TweenCollection.js";
import View from "./View.js";
+import VRPose from "./VRPose.js";
import DebugInspector from "./DebugInspector.js";
import VoxelCell from "./VoxelCell.js";
import VoxelPrimitive from "./VoxelPrimitive.js";
@@ -154,7 +155,7 @@ function Scene(options) {
this._frameState = new FrameState(
context,
new CreditDisplay(creditContainer, " • ", creditViewport),
- this._jobScheduler
+ this._jobScheduler,
);
this._frameState.scene3DOnly = defaultValue(options.scene3DOnly, false);
this._removeCreditContainer = !hasCreditContainer;
@@ -564,7 +565,7 @@ function Scene(options) {
this.invertClassificationColor = Color.clone(Color.WHITE);
this._actualInvertClassificationColor = Color.clone(
- this._invertClassificationColor
+ this._invertClassificationColor,
);
this._invertClassification = new InvertClassification();
@@ -622,11 +623,13 @@ function Scene(options) {
usePostProcess: false,
usePostProcessSelected: false,
useWebVR: false,
+ useWebXR: true,
};
this._useWebVR = false;
- this._cameraVR = undefined;
- this._aspectRatioVR = undefined;
+ this._useWebXR = true;
+ this._webXR = undefined;
+ this._poseVR = undefined;
/**
* When true
, rendering a frame will only occur when needed as determined by changes within the scene.
@@ -660,17 +663,19 @@ function Scene(options) {
*/
this.maximumRenderTimeChange = defaultValue(
options.maximumRenderTimeChange,
- 0.0
+ 0.0,
);
this._lastRenderTime = undefined;
this._frameRateMonitor = undefined;
- this._removeRequestListenerCallback = RequestScheduler.requestCompletedEvent.addEventListener(
- requestRenderAfterFrame(this)
- );
- this._removeTaskProcessorListenerCallback = TaskProcessor.taskCompletedEvent.addEventListener(
- requestRenderAfterFrame(this)
- );
+ this._removeRequestListenerCallback =
+ RequestScheduler.requestCompletedEvent.addEventListener(
+ requestRenderAfterFrame(this),
+ );
+ this._removeTaskProcessorListenerCallback =
+ TaskProcessor.taskCompletedEvent.addEventListener(
+ requestRenderAfterFrame(this),
+ );
this._removeGlobeCallbacks = [];
this._removeTerrainProviderReadyListener = undefined;
@@ -678,7 +683,7 @@ function Scene(options) {
0,
0,
context.drawingBufferWidth,
- context.drawingBufferHeight
+ context.drawingBufferHeight,
);
const camera = new Camera(this);
@@ -751,13 +756,13 @@ function updateGlobeListeners(scene, globe) {
if (defined(globe)) {
removeGlobeCallbacks.push(
globe.imageryLayersUpdatedEvent.addEventListener(
- requestRenderAfterFrame(scene)
- )
+ requestRenderAfterFrame(scene),
+ ),
);
removeGlobeCallbacks.push(
globe.terrainProviderChanged.addEventListener(
- requestRenderAfterFrame(scene)
- )
+ requestRenderAfterFrame(scene),
+ ),
);
}
scene._removeGlobeCallbacks = removeGlobeCallbacks;
@@ -1368,7 +1373,7 @@ Object.defineProperties(Scene.prototype, {
//>>includeStart('debug', pragmas.debug);
if (this.scene3DOnly && value !== SceneMode.SCENE3D) {
throw new DeveloperError(
- "Only SceneMode.SCENE3D is valid when scene3DOnly is true."
+ "Only SceneMode.SCENE3D is valid when scene3DOnly is true.",
);
}
//>>includeEnd('debug');
@@ -1381,7 +1386,7 @@ Object.defineProperties(Scene.prototype, {
//>>includeStart('debug', pragmas.debug);
} else {
throw new DeveloperError(
- "value must be a valid SceneMode enumeration."
+ "value must be a valid SceneMode enumeration.",
);
//>>includeEnd('debug');
}
@@ -1417,7 +1422,7 @@ Object.defineProperties(Scene.prototype, {
/**
* When true
, splits the scene into two viewports with steroscopic views for the left and right eyes.
- * Used for cardboard and WebVR.
+ * Used for cardboard, WebVR and WebXR.
* @memberof Scene.prototype
* @type {boolean}
* @default false
@@ -1430,35 +1435,89 @@ Object.defineProperties(Scene.prototype, {
//>>includeStart('debug', pragmas.debug);
if (this.camera.frustum instanceof OrthographicFrustum) {
throw new DeveloperError(
- "VR is unsupported with an orthographic projection."
+ "VR is unsupported with an orthographic projection.",
);
}
//>>includeEnd('debug');
this._useWebVR = value;
if (this._useWebVR) {
this._frameState.creditDisplay.container.style.visibility = "hidden";
- this._cameraVR = new Camera(this);
+ this._poseVR = new VRPose(this);
if (!defined(this._deviceOrientationCameraController)) {
- this._deviceOrientationCameraController = new DeviceOrientationCameraController(
- this
- );
+ this._deviceOrientationCameraController =
+ new DeviceOrientationCameraController(this);
}
-
- this._aspectRatioVR = this.camera.frustum.aspectRatio;
} else {
this._frameState.creditDisplay.container.style.visibility = "visible";
- this._cameraVR = undefined;
+ this._poseVR = undefined;
this._deviceOrientationCameraController =
this._deviceOrientationCameraController &&
!this._deviceOrientationCameraController.isDestroyed() &&
this._deviceOrientationCameraController.destroy();
-
- this.camera.frustum.aspectRatio = this._aspectRatioVR;
- this.camera.frustum.xOffset = 0.0;
}
},
},
+ /**
+ * When false
, ignores the presence of the WebXR API and falls back to WebVR behavior.
+ * @memberof Scene.prototype
+ * @type {boolean}
+ * @default true
+ */
+ useWebXR: {
+ get: function () {
+ return this._useWebXR;
+ },
+ set: function (value) {
+ this._useWebXR = value;
+ },
+ },
+
+ /**
+ * An object from which WebXR information is pulled.
+ *
+ * Member refSpace
should be set when
+ * XRSession:requestReferenceSpace
is resolved. If
+ * refSpace
is not set, an inline reference space will
+ * be assumed.
+ *
+ * Member frame
must be set with the
+ * XRFrame
parameter received at the callback scheduled
+ * with XRSession:requestAnimationFrame
.
+ *
+ * On prepare
for WebVR, it determines each eye's view
+ * geometry.
+ *
+ * On apply
, it is set to each eye viewport before the
+ * corresponding render.
+ *
apply
, this is the camera that will be modified before
+ * each VR view render.
+ *
+ * @memberof VRPose.prototype
+ * @type {Camera}
+ * @default null
+ */
+ camera: {
+ get: function () {
+ return this._camera;
+ },
+ set: function (value) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(value) || !(value instanceof Camera)) {
+ throw new DeveloperError("value must be a valid Camera.");
+ }
+ //>>includeEnd('debug');
+ if (
+ !this.isWebXR &&
+ this.cameraParams._frustumNear !== value.frustum.near
+ ) {
+ this._paramsChanged = true;
+ }
+ this._camera = value;
+ },
+ },
+});
+
+/**
+ * Perform calculations of the relative translation and frustum for
+ * each of the VR views. As little calculations as possible are performed, by
+ * detecting if there are changes in the basic parameters.
+ *
+ * @memberof VRPose.prototype
+ *
+ * @param {Camera} camera The main camera used as a base for the VR view parameters.
+ * @param {BoundingRectangle} passStateViewport Viewport of the passState that will be set to determine where the render will be performed when apply
is called. Used also for WebVR (Legacy) calculations.
+ * @returns {boolean} Whether calculations were successfully done. In case of WebXR, depends if a VR session is running and a pose was successfully obtained. WebVR (Legacy) always succeeds.
+ */
+VRPose.prototype.prepare = function (camera, passStateViewport) {
+ // These two will be used for apply
+ this.camera = camera;
+ this.passStateViewport = passStateViewport;
+
+ let validPose;
+
+ if (this.isWebXR) {
+ validPose = prepareXR(this, camera);
+ } else {
+ // Plain old WebVR.
+ prepareViewportsLegacy(this);
+ preparePoseCameraParamsLegacy(this, camera);
+ validPose = true;
+ }
+
+ if (validPose) {
+ this._paramsChanged = false;
+ }
+ return validPose;
+};
+
+/**
+ * For each of the views present for the VR session (typically one for the left
+ * and one for the right eye), apply the prepared parameters to the camera and
+ * passState viewport that were provided to the prepare
method and
+ * call the provided callback (so typically, the callback is called twice).
+ *
+ * @memberof VRPose.prototype
+ *
+ * @param {function} execute_cb Execution callback. Receives no parameters.
+ */
+VRPose.prototype.apply = function (execute_cb) {
+ const camera = this._camera;
+ const savedCamera = Camera.clone(camera, this._savedCamera);
+ const savedViewport = BoundingRectangle.clone(
+ this._passStateViewport,
+ this._savedViewport
+ );
+
+ for (const eye of Object.keys(this.viewports)) {
+ if (applyPoseToCamera(this, eye, camera)) {
+ BoundingRectangle.clone(this.viewports[eye], this._passStateViewport);
+ execute_cb();
+ }
+ }
+
+ BoundingRectangle.clone(savedViewport, this._passStateViewport);
+ savedCamera.frustum = camera.frustum;
+ Camera.clone(savedCamera, camera);
+};
+
+export default VRPose;
diff --git a/server.js b/server.js
index 590470ef1ba0..fd0311dbbce8 100644
--- a/server.js
+++ b/server.js
@@ -105,7 +105,7 @@ async function generateDevelopmentBuild() {
});
console.log(
- `Cesium built in ${formatTimeSinceInSeconds(startTime)} seconds.`
+ `Cesium built in ${formatTimeSinceInSeconds(startTime)} seconds.`,
);
return contexts;
@@ -141,7 +141,7 @@ async function generateDevelopmentBuild() {
],
"text/plain": ["glsl"],
},
- true
+ true,
);
const app = express();
@@ -151,7 +151,7 @@ async function generateDevelopmentBuild() {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
- "Origin, X-Requested-With, Content-Type, Accept"
+ "Origin, X-Requested-With, Content-Type, Accept",
);
next();
});
@@ -194,19 +194,19 @@ async function generateDevelopmentBuild() {
"Cesium.js",
"/Build/CesiumUnminified/Cesium.js*",
contexts.iife,
- [iifeWorkersCache]
+ [iifeWorkersCache],
);
const esmCache = createRoute(
app,
"index.js",
"/Build/CesiumUnminified/index.js*",
- contexts.esm
+ contexts.esm,
);
const workersCache = createRoute(
app,
"Workers/*",
"/Build/CesiumUnminified/Workers/*.js",
- contexts.workers
+ contexts.workers,
);
const glslWatcher = chokidar.watch(shaderFiles, { ignoreInitial: true });
@@ -233,7 +233,7 @@ async function generateDevelopmentBuild() {
app,
"TestWorkers/*",
"/Build/Specs/TestWorkers/*",
- contexts.testWorkers
+ contexts.testWorkers,
);
chokidar
.watch(["Specs/TestWorkers/*.js"], { ignoreInitial: true })
@@ -243,7 +243,7 @@ async function generateDevelopmentBuild() {
app,
"Specs/*",
"/Build/Specs/*",
- contexts.specs
+ contexts.specs,
);
const specWatcher = chokidar.watch(specFiles, { ignoreInitial: true });
specWatcher.on("all", async (event) => {
@@ -255,21 +255,24 @@ async function generateDevelopmentBuild() {
});
// Rebuild jsHintOptions as needed and serve as-is
- app.get("/Apps/Sandcastle/jsHintOptions.js", async function (
- //eslint-disable-next-line no-unused-vars
- req,
- res,
- //eslint-disable-next-line no-unused-vars
- next
- ) {
- if (!jsHintOptionsCache) {
- jsHintOptionsCache = await createJsHintOptions();
- }
+ app.get(
+ "/Apps/Sandcastle/jsHintOptions.js",
+ async function (
+ //eslint-disable-next-line no-unused-vars
+ req,
+ res,
+ //eslint-disable-next-line no-unused-vars
+ next,
+ ) {
+ if (!jsHintOptionsCache) {
+ jsHintOptionsCache = await createJsHintOptions();
+ }
- res.append("Cache-Control", "max-age=0");
- res.append("Content-Type", "application/javascript");
- res.send(jsHintOptionsCache);
- });
+ res.append("Cache-Control", "max-age=0");
+ res.append("Content-Type", "application/javascript");
+ res.send(jsHintOptionsCache);
+ },
+ );
// Serve any static files starting with "Build/CesiumUnminified" from the
// development build instead. That way, previous build output is preserved
@@ -294,7 +297,8 @@ async function generateDevelopmentBuild() {
return remoteUrl;
}
- const dontProxyHeaderRegex = /^(?:Host|Proxy-Connection|Connection|Keep-Alive|Transfer-Encoding|TE|Trailer|Proxy-Authorization|Proxy-Authenticate|Upgrade)$/i;
+ const dontProxyHeaderRegex =
+ /^(?:Host|Proxy-Connection|Connection|Keep-Alive|Transfer-Encoding|TE|Trailer|Proxy-Authorization|Proxy-Authenticate|Upgrade)$/i;
//eslint-disable-next-line no-unused-vars
function filterHeaders(req, headers) {
@@ -361,7 +365,7 @@ async function generateDevelopmentBuild() {
}
res.status(code).send(body);
- }
+ },
);
});
@@ -372,28 +376,28 @@ async function generateDevelopmentBuild() {
if (argv.public) {
console.log(
"Cesium development server running publicly. Connect to http://localhost:%d/",
- server.address().port
+ server.address().port,
);
} else {
console.log(
"Cesium development server running locally. Connect to http://localhost:%d/",
- server.address().port
+ server.address().port,
);
}
- }
+ },
);
server.on("error", function (e) {
if (e.code === "EADDRINUSE") {
console.log(
"Error: Port %d is already in use, select a different port.",
- argv.port
+ argv.port,
);
console.log("Example: node server.js --port %d", argv.port + 1);
} else if (e.code === "EACCES") {
console.log(
"Error: This process does not have permission to listen on port %d.",
- argv.port
+ argv.port,
);
if (argv.port < 1024) {
console.log("Try a port number higher than 1024.");