Skip to content

Commit

Permalink
Merge branch 'main' into no-ready-promises
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhembd authored Mar 29, 2023
2 parents 6019435 + 07b1082 commit 72a4215
Show file tree
Hide file tree
Showing 25 changed files with 1,140 additions and 877 deletions.
7 changes: 4 additions & 3 deletions Apps/CesiumViewer/CesiumViewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if (window.CESIUM_BASE_URL === undefined) {
window.CESIUM_BASE_URL = "../../Build/CesiumUnminified/";
}
// eslint-disable-next-line no-undef
window.CESIUM_BASE_URL = window.CESIUM_BASE_URL
? window.CESIUM_BASE_URL
: "../../Build/CesiumUnminified/";

import {
Cartesian3,
Expand Down
1 change: 0 additions & 1 deletion Apps/CesiumViewer/index.js

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ try {

- Fixed issue where passing `children` in the Entity constructor options will override children. [#11101](https://github.com/CesiumGS/cesium/issues/11101)
- Fixed error type to be `RequestErrorEvent` in `Resource.retryCallback`. [#11177](https://github.com/CesiumGS/cesium/pull/11177)
- Fixed issue when render `OrthographicFrustum` geometry by `DebugCameraPrimitive`. [#11159](https://github.com/CesiumGS/cesium/issues/11159)
- Fixed ion URL in `RequestScheduler` throttling overrides. [#11193](https://github.com/CesiumGS/cesium/pull/11193)
- Fixed `SingleTileImageryProvider` fetching image when `show` is `false` by allowing lazy-loading for `SingleTileImageryProvider` if `tileWidth` and `tileHeight` are provided to the constructor. [#9529](https://github.com/CesiumGS/cesium/issues/9529)
- Fixed various race conditions from async operations. [#10909](https://github.com/CesiumGS/cesium/issues/10909)

Expand Down
10 changes: 5 additions & 5 deletions Documentation/CustomShaderGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ The user is responsible for assigning a value to this varying in
const customShader = new Cesium.CustomShader({
// Varying is declared here
varyings: {
v_selectedColor: VaryingType.VEC3,
v_selectedColor: Cesium.VaryingType.VEC4,
},
// User assigns the varying in the vertex shader
vertexShaderText: `
void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput) {
float positiveX = step(0.0, positionMC.x);
float positiveX = step(0.0, vsOutput.positionMC.x);
v_selectedColor = mix(
vsInput.attributes.color_0,
vsInput.attributes.color_1,
Expand All @@ -160,7 +160,7 @@ const customShader = new Cesium.CustomShader({
// User uses the varying in the fragment shader
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
material.diffuse = v_selectedColor;
material.diffuse = v_selectedColor.rgb;
}
`,
});
Expand Down Expand Up @@ -838,7 +838,7 @@ For `ENUM` type metadata, the statistics struct for that property should contain

## `czm_modelVertexOutput` struct

This struct is built-in, see the [documentation comment](../../../Shaders/Builtin/Structs/modelVertexOutput.glsl).
This struct is built-in, see the [documentation comment](../../packages/engine/Source/Shaders/Builtin/Structs/modelVertexOutput.glsl).

This struct contains the output of the custom vertex shader. This includes:

Expand All @@ -856,7 +856,7 @@ This struct contains the output of the custom vertex shader. This includes:
## `czm_modelMaterial` struct

This struct is a built-in, see the [documentation comment](../../Source/Shaders/Builtin/Structs/modelMaterial.glsl). This is similar to `czm_material` from the old Fabric system, but has slightly different fields as this one supports PBR lighting.
This struct is a built-in, see the [documentation comment](../../packages/engine/Source/Shaders/Builtin/Structs/modelMaterial.glsl). This is similar to `czm_material` from the old Fabric system, but has slightly different fields as this one supports PBR lighting.

This struct serves as the basic input/output of the fragment shader pipeline stages. For example:

Expand Down
5 changes: 3 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,8 @@ async function buildCesiumViewer() {
".png": "text",
};
config.format = "iife";
config.inject = ["Apps/CesiumViewer/index.js"];
// Configure Cesium base path to use built
config.define = { CESIUM_BASE_URL: `"."` };
config.external = ["https", "http", "url", "zlib"];
config.outdir = cesiumViewerOutputDirectory;
config.outbase = "Apps/CesiumViewer";
Expand All @@ -2247,7 +2248,7 @@ async function buildCesiumViewer() {
".gif": "text",
".png": "text",
},
outdir: cesiumViewerOutputDirectory,
outdir: join(cesiumViewerOutputDirectory, "Widgets"),
outbase: "packages/widgets/Source/",
});

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@
"karma-jasmine": "^5.1.0",
"karma-longest-reporter": "^1.1.0",
"karma-safari-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.8",
"karma-sourcemap-loader": "^0.4.0",
"karma-spec-reporter": "^0.0.36",
"markdownlint-cli": "^0.33.0",
"merge-stream": "^2.0.0",
"mime": "^3.0.0",
"mkdirp": "^2.1.3",
"node-fetch": "^3.2.10",
"open": "^8.2.1",
"open": "^9.1.0",
"p-limit": "^4.0.0",
"prettier": "2.1.2",
"prismjs": "^1.28.0",
Expand All @@ -114,7 +114,7 @@
"rollup-plugin-strip-pragma": "^1.0.0",
"stream-to-promise": "^3.0.0",
"tsd-jsdoc": "^2.5.0",
"typescript": "^4.9.4",
"typescript": "^5.0.2",
"yargs": "^17.0.1"
},
"scripts": {
Expand Down Expand Up @@ -167,4 +167,4 @@
"packages/engine",
"packages/widgets"
]
}
}
2 changes: 1 addition & 1 deletion packages/engine/Source/Core/FrustumGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ FrustumGeometry._computeNearFarPlanes = function (

let inverseView;
let inverseViewProjection;
const projection = frustum.projectionMatrix;
if (frustumType === PERSPECTIVE) {
const projection = frustum.projectionMatrix;
const viewProjection = Matrix4.multiply(
projection,
view,
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/Source/Core/RequestScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ RequestScheduler.maximumRequestsPerServer = 6;
*/
RequestScheduler.requestsByServer = {
"api.cesium.com:443": 18,
"assets.cesium.com:443": 18,
"assets.ion.cesium.com:443": 18,
};

/**
Expand Down
112 changes: 80 additions & 32 deletions packages/engine/Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,22 @@ Object.defineProperties(Cesium3DTile.prototype, {
},
},

/**
* Determines if the tile is visible within the current field of view
*
* @memberof Cesium3DTile.prototype
*
* @type {boolean}
* @readonly
*
* @private
*/
isVisible: {
get: function () {
return this._visible && this._inRequestVolume;
},
},

/**
* Returns the <code>extras</code> property in the tileset JSON for this tile, which contains application specific metadata.
* Returns <code>undefined</code> if <code>extras</code> does not exist.
Expand Down Expand Up @@ -616,6 +632,27 @@ Object.defineProperties(Cesium3DTile.prototype, {
},
},

/**
* Determines if the tile's content is renderable. <code>false</code> if the
* tile has empty content or if it points to an external tileset or implicit content
*
* @memberof Cesium3DTile.prototype
*
* @type {boolean}
* @readonly
*
* @private
*/
hasRenderableContent: {
get: function () {
return (
!this.hasEmptyContent &&
!this.hasTilesetContent &&
!this.hasImplicitContent
);
},
},

/**
* Determines if the tile has available content to render. <code>true</code> if the tile's
* content is ready or if it has expired content that renders while new content loads; otherwise,
Expand All @@ -631,10 +668,7 @@ Object.defineProperties(Cesium3DTile.prototype, {
contentAvailable: {
get: function () {
return (
(this.contentReady &&
!this.hasEmptyContent &&
!this.hasTilesetContent &&
!this.hasImplicitContent) ||
(this.contentReady && this.hasRenderableContent) ||
(defined(this._expiredContent) && !this.contentFailed)
);
},
Expand Down Expand Up @@ -674,6 +708,22 @@ Object.defineProperties(Cesium3DTile.prototype, {
},
},

/**
* Determines if the tile has renderable content which is unloaded
*
* @memberof Cesium3DTile.prototype
*
* @type {boolean}
* @readonly
*
* @private
*/
hasUnloadedRenderableContent: {
get: function () {
return this.hasRenderableContent && this.contentUnloaded;
},
},

/**
* Determines if the tile's content is expired. <code>true</code> if tile's
* content is expired; otherwise, <code>false</code>.
Expand Down Expand Up @@ -791,7 +841,7 @@ function isPriorityDeferred(tile, frameState) {
// Skip this feature if: non-skipLevelOfDetail and replace refine, if the foveated settings are turned off, if tile is progressive resolution and replace refine and skipLevelOfDetail (will help get rid of ancestor artifacts faster)
// Or if the tile is a preload of any kind
const replace = tile.refine === Cesium3DTileRefine.REPLACE;
const skipLevelOfDetail = tileset._skipLevelOfDetail;
const skipLevelOfDetail = tileset.isSkippingLevelOfDetail;
if (
(replace && !skipLevelOfDetail) ||
!tileset.foveatedScreenSpaceError ||
Expand Down Expand Up @@ -935,7 +985,7 @@ function getPriorityReverseScreenSpaceError(tileset, tile) {
const parent = tile.parent;
const useParentScreenSpaceError =
defined(parent) &&
(!tileset._skipLevelOfDetail ||
(!tileset.isSkippingLevelOfDetail ||
tile._screenSpaceError === 0.0 ||
parent.hasTilesetContent ||
parent.hasImplicitContent);
Expand All @@ -953,6 +1003,11 @@ function getPriorityReverseScreenSpaceError(tileset, tile) {
*/
Cesium3DTile.prototype.updateVisibility = function (frameState) {
const { parent, tileset } = this;
if (this._updatedVisibilityFrame === tileset._updatedVisibilityFrame) {
// The tile has already been updated for this frame
return;
}

const parentTransform = defined(parent)
? parent.computedTransform
: tileset.modelMatrix;
Expand Down Expand Up @@ -983,6 +1038,8 @@ Cesium3DTile.prototype.updateVisibility = function (frameState) {
this
);
this.priorityDeferred = isPriorityDeferred(this, frameState);

this._updatedVisibilityFrame = tileset._updatedVisibilityFrame;
};

/**
Expand Down Expand Up @@ -1342,11 +1399,7 @@ Cesium3DTile.prototype.cancelRequests = function () {
* @private
*/
Cesium3DTile.prototype.unloadContent = function () {
if (
this.hasEmptyContent ||
this.hasTilesetContent ||
this.hasImplicitContent
) {
if (!this.hasRenderableContent) {
return;
}

Expand Down Expand Up @@ -1720,19 +1773,15 @@ Cesium3DTile.prototype.createBoundingVolume = function (
);
}

if (defined(boundingVolumeHeader.box)) {
return createBox(boundingVolumeHeader.box, transform, result);
const { box, region, sphere } = boundingVolumeHeader;
if (defined(box)) {
return createBox(box, transform, result);
}
if (defined(boundingVolumeHeader.region)) {
return createRegion(
boundingVolumeHeader.region,
transform,
this._initialTransform,
result
);
if (defined(region)) {
return createRegion(region, transform, this._initialTransform, result);
}
if (defined(boundingVolumeHeader.sphere)) {
return createSphere(boundingVolumeHeader.sphere, transform, result);
if (defined(sphere)) {
return createSphere(sphere, transform, result);
}
throw new RuntimeError(
"boundingVolume must contain a sphere, region, or box"
Expand Down Expand Up @@ -1824,8 +1873,6 @@ function applyDebugSettings(tile, tileset, frameState, passOptions) {

const hasContentBoundingVolume =
defined(tile._contentHeader) && defined(tile._contentHeader.boundingVolume);
const empty =
tile.hasEmptyContent || tile.hasTilesetContent || tile.hasImplicitContent;

const showVolume =
tileset.debugShowBoundingVolume ||
Expand All @@ -1834,7 +1881,7 @@ function applyDebugSettings(tile, tileset, frameState, passOptions) {
let color;
if (!tile._finalResolution) {
color = Color.YELLOW;
} else if (empty) {
} else if (!tile.hasRenderableContent) {
color = Color.DARKGRAY;
} else {
color = Color.WHITE;
Expand Down Expand Up @@ -1981,18 +2028,18 @@ function updateClippingPlanes(tile, tileset) {
* @param {object} passOptions
*/
Cesium3DTile.prototype.update = function (tileset, frameState, passOptions) {
const commandStart = frameState.commandList.length;
const { commandList } = frameState;
const commandStart = commandList.length;

updateClippingPlanes(this, tileset);
applyDebugSettings(this, tileset, frameState, passOptions);
updateContent(this, tileset, frameState);

const commandEnd = frameState.commandList.length;
const commandsLength = commandEnd - commandStart;
this._commandsLength = commandsLength;
const commandEnd = commandList.length;
this._commandsLength = commandEnd - commandStart;

for (let i = 0; i < commandsLength; ++i) {
const command = frameState.commandList[commandStart + i];
for (let i = commandStart; i < commandEnd; ++i) {
const command = commandList[i];
const translucent = command.pass === Pass.TRANSLUCENT;
command.depthForTranslucentClassification = translucent;
}
Expand Down Expand Up @@ -2132,7 +2179,8 @@ Cesium3DTile.prototype.updatePriority = function () {

// Map 0-1 then convert to digit. Include a distance sort when doing non-skipLOD and replacement refinement, helps things like non-skipLOD photogrammetry
const useDistance =
!tileset._skipLevelOfDetail && this.refine === Cesium3DTileRefine.REPLACE;
!tileset.isSkippingLevelOfDetail &&
this.refine === Cesium3DTileRefine.REPLACE;
const normalizedPreferredSorting = useDistance
? priorityNormalizeAndClamp(
this._priorityHolder._distanceToCamera,
Expand Down
4 changes: 2 additions & 2 deletions packages/engine/Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,8 @@ Cesium3DTileBatchTable.prototype.addDerivedCommands = function (
const finalResolution = tile._finalResolution;
const tileset = tile.tileset;
const bivariateVisibilityTest =
tileset._skipLevelOfDetail &&
tileset._hasMixedContent &&
tileset.isSkippingLevelOfDetail &&
tileset.hasMixedContent &&
frameState.context.stencilBuffer;
const styleCommandsNeeded = getStyleCommandsNeeded(this);

Expand Down
Loading

0 comments on commit 72a4215

Please sign in to comment.