Skip to content

Commit

Permalink
Cleanup specs, fix sandcastle example
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed Mar 10, 2022
1 parent d576d95 commit 37c9e17
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 33 deletions.
26 changes: 14 additions & 12 deletions Apps/Sandcastle/gallery/CZML Custom Properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
});

const dataSource = new Cesium.CzmlDataSource();
const loadedPromise = dataSource.load(czml);

function scaleProperty(property, scalingFactor) {
// returns a property that scales another property by a constant factor.
Expand All @@ -134,18 +135,20 @@
}

function setExtrudedHeight(propertyName) {
const customPropertyObject = dataSource.entities.getById(
"custom_property_object"
);
const property = customPropertyObject.properties[propertyName];
const colorado = dataSource.entities.getById("colorado");
loadedPromise.then(function () {
const customPropertyObject = dataSource.entities.getById(
"custom_property_object"
);
const property = customPropertyObject.properties[propertyName];
const colorado = dataSource.entities.getById("colorado");

// Because the population values are so large, we scale them down
// by 50 so they fit on the screen.
// If we didn't need to scale, we could directly assign the property
// to extrudedHeight.
// colorado.polygon.extrudedHeight = scaleProperty(property, 1 / 50.0);
colorado.polygon.extrudedHeight = scaleProperty(property, 1 / 50.0);
// Because the population values are so large, we scale them down
// by 50 so they fit on the screen.
// If we didn't need to scale, we could directly assign the property
// to extrudedHeight.
// colorado.polygon.extrudedHeight = scaleProperty(property, 1 / 50.0);
colorado.polygon.extrudedHeight = scaleProperty(property, 1 / 50.0);
});
}

// Custom properties can be used as the value of graphical properties:
Expand All @@ -167,7 +170,6 @@
"propertiesMenu"
);

dataSource.load(czml);
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource); //Sandcastle_End
Sandcastle.finishedLoading();
Expand Down
14 changes: 8 additions & 6 deletions Source/Scene/Instanced3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,15 @@ function initialize(content, arrayBuffer, byteOffset) {
collectionOptions
);
content._modelInstanceCollection.readyPromise
.then(function (collection) {
collection.activeAnimations.addAll({
loop: ModelAnimationLoop.REPEAT,
});
})
.catch(function () {
// The readyPromise failure is handled in modelInstanceCollection
// Any readyPromise failure is handled in modelInstanceCollection
})
.then(function (collection) {
if (content._modelInstanceCollection.ready) {
collection.activeAnimations.addAll({
loop: ModelAnimationLoop.REPEAT,
});
}
});
}

Expand Down
8 changes: 6 additions & 2 deletions Specs/Core/ArcGISTiledElevationTerrainProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,19 @@ describe("Core/ArcGISTiledElevationTerrainProvider", function () {
url: "made/up/url",
});
expect(provider.hasWaterMask).toBe(false);
return provider.readyPromise.catch(function (e) {});
return provider.readyPromise.catch(function (error) {
expect(error).toBeInstanceOf(RuntimeError);
});
});

it("is not ready immediately", function () {
const provider = new ArcGISTiledElevationTerrainProvider({
url: "made/up/url",
});
expect(provider.ready).toBe(false);
return provider.readyPromise.catch(function (e) {});
return provider.readyPromise.catch(function (error) {
expect(error).toBeInstanceOf(RuntimeError);
});
});

it("detects WebMercator tiling scheme", function () {
Expand Down
3 changes: 2 additions & 1 deletion Specs/Core/CesiumTerrainProviderSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CesiumTerrainProvider, defer } from "../../Source/Cesium.js";
import { CesiumTerrainProvider } from "../../Source/Cesium.js";
import { defer } from "../../Source/Cesium.js";
import { Ellipsoid } from "../../Source/Cesium.js";
import { GeographicTilingScheme } from "../../Source/Cesium.js";
import { getAbsoluteUri } from "../../Source/Cesium.js";
Expand Down
3 changes: 2 additions & 1 deletion Specs/Core/IonResourceSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defer, Ion } from "../../Source/Cesium.js";
import { defer } from "../../Source/Cesium.js";
import { Ion } from "../../Source/Cesium.js";
import { IonResource } from "../../Source/Cesium.js";
import { RequestErrorEvent } from "../../Source/Cesium.js";
import { Resource } from "../../Source/Cesium.js";
Expand Down
3 changes: 2 additions & 1 deletion Specs/Core/VRTheWorldTerrainProviderSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DefaultProxy, defer } from "../../Source/Cesium.js";
import { DefaultProxy } from "../../Source/Cesium.js";
import { defer } from "../../Source/Cesium.js";
import { GeographicTilingScheme } from "../../Source/Cesium.js";
import { HeightmapTerrainData } from "../../Source/Cesium.js";
import { Math as CesiumMath } from "../../Source/Cesium.js";
Expand Down
22 changes: 20 additions & 2 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ describe(
});

// Throws several unhandled 404 errors
// https://github.com/CesiumGS/cesium/issues/10178
xit("rejects readyPromise with invalid tileset JSON file", function () {
spyOn(Resource._Implementations, "loadWithXhr").and.callFake(function (
url,
Expand Down Expand Up @@ -587,6 +588,7 @@ describe(
});

// Throws several unhandled errors
// https://github.com/CesiumGS/cesium/issues/10178
xit("requests tile with invalid magic", function () {
const invalidMagicBuffer = Cesium3DTilesTester.generateBatchedTileBuffer({
magic: [120, 120, 120, 120],
Expand Down Expand Up @@ -620,6 +622,7 @@ describe(
});

// Throws several unhandled 404 errors
// https://github.com/CesiumGS/cesium/issues/10178
xit("handles failed tile requests", function () {
viewRootOnly();
options.url = tilesetUrl;
Expand Down Expand Up @@ -654,7 +657,9 @@ describe(
});
});

it("handles failed tile processing", function () {
// Throws several unhandled errors
// https://github.com/CesiumGS/cesium/issues/10178
xit("handles failed tile processing", function () {
viewRootOnly();
options.url = tilesetUrl;
const tileset = scene.primitives.add(new Cesium3DTileset(options));
Expand Down Expand Up @@ -2440,6 +2445,7 @@ describe(
});

// Throws several unhandled 404 errors
// https://github.com/CesiumGS/cesium/issues/10178
xit("tile failed event is raised", function () {
viewNothing();
const spyUpdate = jasmine.createSpy("listener");
Expand Down Expand Up @@ -2517,6 +2523,7 @@ describe(
});

// Throws error in release tests
// https://github.com/CesiumGS/cesium/issues/10178
xit("destroys before tile finishes loading", function () {
viewRootOnly();
options.url = tilesetUrl;
Expand Down Expand Up @@ -4230,6 +4237,7 @@ describe(
});

// Throws several unhandled 404 errors
// https://github.com/CesiumGS/cesium/issues/10178
xit("tile expires and request fails", function () {
return Cesium3DTilesTester.loadTileset(scene, batchedExpirationUrl).then(
function (tileset) {
Expand Down Expand Up @@ -4923,7 +4931,9 @@ describe(
});
});

it("cancels out-of-view tiles", function () {
// Cancelling a request throws an unhandled 404
// https://github.com/CesiumGS/cesium/issues/10178
xit("cancels out-of-view tiles", function () {
viewNothing();

return Cesium3DTilesTester.loadTileset(scene, tilesetUniform).then(
Expand Down Expand Up @@ -4983,6 +4993,8 @@ describe(

expect(allSorted).toBe(true);
expect(lastPriority).not.toEqual(requestedTilesInFlight[0]._priority); // Not all the same value

return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset);
}
);
});
Expand All @@ -5007,6 +5019,8 @@ describe(
const requestedTilesInFlight = tileset._requestedTilesInFlight;
expect(requestedTilesInFlight.length).toBe(1);
expect(requestedTilesInFlight[0].priorityDeferred).toBe(true);

return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset);
}
);
});
Expand Down Expand Up @@ -5037,6 +5051,8 @@ describe(
expect(tileset._requestedTilesInFlight[0].priorityDeferred).toBe(
true
);

return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset);
});
}
);
Expand All @@ -5062,6 +5078,7 @@ describe(
});
scene.renderForSpecs();
expect(tileset._requestedTilesInFlight.length).toBeGreaterThan(0);
return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset);
}
);
});
Expand All @@ -5087,6 +5104,7 @@ describe(
viewAllTiles();
scene.renderForSpecs();
expect(tileset._requestedTilesInFlight.length).toEqual(2);
return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset);
}
);
});
Expand Down
2 changes: 2 additions & 0 deletions Specs/Scene/GltfLoaderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,7 @@ describe(
});

// Throws an extraneous promise through the texture loader which cannot be cleanly caught
// https://github.com/CesiumGS/cesium/issues/10178
xit("rejects promise if glTF JSON fails to load", function () {
const error = new Error("404 Not Found");
spyOn(GltfJsonLoader.prototype, "_fetchGltf").and.returnValue(
Expand Down Expand Up @@ -2427,6 +2428,7 @@ describe(
});

// Throws an extraneous promise through the texture loader which cannot be cleanly caught
// https://github.com/CesiumGS/cesium/issues/10178
xit("rejects promise if resource fails to load", function () {
spyOn(Resource.prototype, "fetchImage").and.callFake(function () {
const error = new Error("404 Not Found");
Expand Down
3 changes: 2 additions & 1 deletion Specs/Scene/LabelCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { BoundingSphere } from "../../Source/Cesium.js";
import { Cartesian2 } from "../../Source/Cesium.js";
import { Cartesian3 } from "../../Source/Cesium.js";
import { Color } from "../../Source/Cesium.js";
import { defined, DistanceDisplayCondition } from "../../Source/Cesium.js";
import { defined } from "../../Source/Cesium.js";
import { DistanceDisplayCondition } from "../../Source/Cesium.js";
import { Math as CesiumMath } from "../../Source/Cesium.js";
import { NearFarScalar } from "../../Source/Cesium.js";
import { Rectangle } from "../../Source/Cesium.js";
Expand Down
2 changes: 2 additions & 0 deletions Specs/Scene/ModelExperimental/ModelExperimentalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe(
});

// Throws an extraneous promise through the texture loader which cannot be cleanly caught
// https://github.com/CesiumGS/cesium/issues/10178
xit("rejects ready promise when texture fails to load", function () {
const resource = Resource.createIfNeeded(boxTexturedGltfUrl);
return resource.fetchJson().then(function (gltf) {
Expand All @@ -188,6 +189,7 @@ describe(
});

// Throws an extraneous promise through the texture loader which cannot be cleanly caught
// https://github.com/CesiumGS/cesium/issues/10178
xit("rejects ready promise when external buffer fails to load", function () {
const resource = Resource.createIfNeeded(boxTexturedGltfUrl);
return resource.fetchJson().then(function (gltf) {
Expand Down
8 changes: 6 additions & 2 deletions Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2824,20 +2824,24 @@ describe(
})
.then(function (m) {
// Get the rendered color of the model before textures are loaded

m.zoomTo();
expect(scene).toRenderAndCall(function (rgba) {
expect(rgba).not.toEqual([0, 0, 0, 255]);
loadedColor = rgba;
});

model = m;

// Render at least once to initialize
scene.renderForSpecs();
})
.then(function () {
return pollToPromise(
function () {
// Render scene to progressively load textures
scene.renderForSpecs();
// Textures have finished loading
return m.pendingTextureLoads === 0;
return model.pendingTextureLoads === 0;
},
{ timeout: 10000 }
);
Expand Down
1 change: 1 addition & 0 deletions Specs/Scene/TimeDynamicPointCloudSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ describe(
});

// Throws an un-catchable 404
// https://github.com/CesiumGS/cesium/issues/10178
xit("frame failed event is raised from request failure", function () {
const pointCloud = createTimeDynamicPointCloud();
spyOn(Resource._Implementations, "loadWithXhr").and.callFake(function (
Expand Down
13 changes: 8 additions & 5 deletions Specs/TerrainTileProcessor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { clone, defer } from "../Source/Cesium.js";
import { Texture } from "../Source/Cesium.js";
import { GlobeSurfaceTile } from "../Source/Cesium.js";
import { ImageryLayer } from "../Source/Cesium.js";
import { TerrainState } from "../Source/Cesium.js";
import {
clone,
defer,
ImageryLayer,
GlobeSurfaceTile,
TerrainState,
Texture,
} from "../Source/Cesium.js";

function TerrainTileProcessor(
frameState,
Expand Down

0 comments on commit 37c9e17

Please sign in to comment.