Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Model3DTileContent specs to have parity with 3D Tiles 1.0 formats #10633

Merged
merged 11 commits into from
Aug 4, 2022
Prev Previous commit
Next Next commit
Move some specs to the respective loaders
  • Loading branch information
ptrgags committed Aug 3, 2022
commit 8d50f8a43f89ec2d4cf5e1e0221ad994c445f818
33 changes: 33 additions & 0 deletions Specs/Scene/ModelExperimental/I3dmLoaderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Resource,
ResourceCache,
} from "../../../Source/Cesium.js";
import Cesium3DTilesTester from "../../Cesium3DTilesTester.js";
import createScene from "../../createScene.js";
import waitForLoaderProcess from "../../waitForLoaderProcess.js";

Expand Down Expand Up @@ -81,6 +82,22 @@ describe("Scene/ModelExperimental/I3dmLoader", function () {
});
}

function expectLoadError(arrayBuffer) {
expect(function () {
const resource = Resource.createIfNeeded(
"http://example.com/content.i3dm"
);
const loader = new I3dmLoader({
i3dmResource: resource,
arrayBuffer: arrayBuffer,
});
i3dmLoaders.push(loader);
loader.load();

return waitForLoaderProcess(loader, scene);
}).toThrowDeveloperError();
}

function verifyInstances(components, expectedSemantics, instancesLength) {
for (let i = 0; i < components.nodes.length; i++) {
const node = components.nodes[i];
Expand Down Expand Up @@ -376,4 +393,20 @@ describe("Scene/ModelExperimental/I3dmLoader", function () {
);
});
});

it("throws with invalid format", function () {
const path = "example.i3dm";
const arrayBuffer = Cesium3DTilesTester.generateInstancedTileBuffer({
gltfFormat: 2,
});
expectLoadError(path, arrayBuffer);
});

it("throws with invalid version", function () {
const path = "example.i3dm";
const arrayBuffer = Cesium3DTilesTester.generateInstancedTileBuffer({
version: 2,
});
expectLoadError(path, arrayBuffer);
});
ptrgags marked this conversation as resolved.
Show resolved Hide resolved
});
45 changes: 45 additions & 0 deletions Specs/Scene/ModelExperimental/PntsLoaderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Color,
ComponentDatatype,
defaultValue,
DracoLoader,
MetadataClass,
MetadataComponentType,
MetadataType,
Expand All @@ -13,6 +14,7 @@ import {
VertexAttributeSemantic,
} from "../../../Source/Cesium.js";
import createScene from "../../createScene.js";
import pollToPromise from "../../pollToPromise.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the "renders point cloud with tile transform" test from PointCloud3DTileContentSpec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this comment is in PntsLoaderSpec?

for the tile transform tests, we only wanted to have one set of them since it works the same for each content type. For this one I kept the b3dm ones since I was having difficulty getting the camera setup right for the glTF ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this comment is in PntsLoaderSpec?

Because most of the tilesets tested in Point3DTileContentSpec were copied over to PntsLoaderSpec, except for the one with the tile transform. So if we don't duplicate it, the tileset associated with it will never get tested

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I understand now. I added a test in PntsLoaderSpec, though it seems of limited use, since the transform is applied in the tileset.json, not the .pnts file itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptrgags ah I see... let's just leave it there for now so we don't hold up the PR, we can move things around later.

import waitForLoaderProcess from "../../waitForLoaderProcess.js";
import Cesium3DTilesTester from "../../Cesium3DTilesTester.js";

Expand Down Expand Up @@ -568,6 +570,27 @@ describe("Scene/ModelExperimental/PntsLoader", function () {
});
});

it("BATCH_ID semantic uses componentType of UNSIGNED_SHORT by default", function () {
const arrayBuffer = Cesium3DTilesTester.generatePointCloudTileBuffer({
featureTableJson: {
POINTS_LENGTH: 2,
POSITION: [0.0, 0.0, 0.0, 1.0, 1.0, 1.0],
BATCH_ID: [0, 1],
BATCH_LENGTH: 2,
},
});

return loadPntsArrayBuffer(arrayBuffer).then(function (loader) {
const components = loader.components;
const primitive = components.nodes[0].primitives[0];
const attributes = primitive.attributes;
expect(attributes.length).toBe(3);
expectPosition(attributes[0]);
expectDefaultColor(attributes[1]);
expectBatchId(attributes[2], ComponentDatatype.UNSIGNED_SHORT);
});
});

it("loads PointCloudWithPerPointProperties", function () {
return loadPnts(pointCloudWithPerPointPropertiesUrl).then(function (
loader
Expand Down Expand Up @@ -774,6 +797,28 @@ describe("Scene/ModelExperimental/PntsLoader", function () {
expectLoadError(arrayBuffer);
});

it("error decoding a draco point cloud causes loading to fail", function () {
const readyPromise = pollToPromise(function () {
return DracoLoader._taskProcessorReady;
});
DracoLoader._getDecoderTaskProcessor();
return readyPromise
.then(function () {
const decoder = DracoLoader._getDecoderTaskProcessor();
spyOn(decoder, "scheduleTask").and.callFake(function () {
return Promise.reject({ message: "my error" });
});

return loadPnts(pointCloudDracoUrl);
})
.then(function () {
fail("should not resolve");
})
.catch(function (error) {
expect(error.message).toBe("Failed to load Draco pnts\nmy error");
});
});

it("destroys pnts loader", function () {
return loadPnts(pointCloudBatchedUrl).then(function (loader) {
expect(loader.components).toBeDefined();
Expand Down