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

Take glTF up axis into account during upgrade #166

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions specs/data/upgradeTileset/upAxisHandling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

Data for testing the handling of the `gltfUpAxis` in the `upgrade` command.

Pre-1.0 tilesets could specify an `asset.gltfUpAxis` to be `X`, `Y`, or `Z`, to denote
the axis that should be considered to be the up-axis in the glTF 1.0 data that was
contained in B3DM or I3DM.

During the `upgrade` command, when the `--targetVersion 1.1` was specified, the
glTF from the B3DM and I3DM are extracted and converted into standard glTF 2.0.
This conversion has to take into account the possible `gltfUpAxis` values.

The tilesets in the `input` directory have been carefully crafted to contain B3DM-
and I3DM data with glTF 1.0, with different up-axis conventions. When running
the `TilesetUpgraderAxesSpec` (and not deleting the "output" directory), then
the upgraded tilesets will be available in the `output` subdirectory.

A sandcastle for visually inspecting the results is added in `UpAxisHandlingSandcastle.js`.
When serving this directory (i.e. the `./specs/data/upgradeTileset/upAxisHandling` directory)
with a server, then this sandcastle allows selecting the different inputs and outputs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const viewer = new Cesium.Viewer("cesiumContainer", {
globe: false
});

// Stores the tileset that is currently selected
let currentTileset;
let currentTilesetName = "glTF1-y-up";
let inputOrOutput = "input";
let doZoom = false;

// Creates the tileset for the sample with the current name
async function recreateTileset() {
if (Cesium.defined(currentTileset)) {
viewer.scene.primitives.remove(currentTileset);
currentTileset = undefined;
doZoom = true;
}
// Create the tileset, and move it to a certain position on the globe
currentTileset = viewer.scene.primitives.add(
await Cesium.Cesium3DTileset.fromUrl(
`http://localhost:8003/${inputOrOutput}/${currentTilesetName}/tileset.json`,
{
debugShowBoundingVolume: true,
}
)
);
currentTileset.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-75.152325, 39.94704, 100)
);
const offset = new Cesium.HeadingPitchRange(
Cesium.Math.toRadians(-22.5),
Cesium.Math.toRadians(-22.5),
12.0
);
viewer.zoomTo(currentTileset, offset);
}

//============================================================================
// Sandcastle UI setup:

// Create one entry for the list of examples that can
// be selected in the dropdown menu.
function createSampleOption(name) {
return {
text: name,
onselect: async function () {
currentTilesetName = name;
doZoom = true;
await recreateTileset();
},
};
}

// Create the list of available samples, and add them
// to the sandcastle toolbar
const sampleOptions = [
createSampleOption("glTF1-x-up"),
createSampleOption("glTF1-x-up-with-gltfUpAxis-x"),
createSampleOption("glTF1-y-up"),
createSampleOption("glTF1-y-up-with-gltfUpAxis-y"),
createSampleOption("glTF1-z-up"),
createSampleOption("glTF1-z-up-with-gltfUpAxis-z"),
createSampleOption("glTF1-z-up-instanced"),
createSampleOption("glTF1-z-up-instanced-with-gltfUpAxis-z"),
createSampleOption("glTF2"),
];
Sandcastle.addToolbarMenu(sampleOptions);

Sandcastle.addToolbarButton("Input", function () {
inputOrOutput = "input";
recreateTileset();
});
Sandcastle.addToolbarButton("Output", function () {
inputOrOutput = "output";
recreateTileset();
});
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"asset": {
"version": "1.1"
},
"geometricError": 4096,
"root": {
"boundingVolume": {
"box": [
1,
0.5,
2,
1,
0,
0,
0,
1.5,
0,
0,
0,
2
]
},
"geometricError": 1024,
"refine": "ADD",
"children": [
{
"boundingVolume": {
"box": [
0.5,
-0.5,
0.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-x-up.glb"
}
},
{
"boundingVolume": {
"box": [
1.5,
1.5,
3.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-x-up-RTC-1-2-3.glb"
}
}
]
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"asset": {
"version": "1.1"
},
"geometricError": 4096,
"root": {
"boundingVolume": {
"box": [
1,
1.5,
1,
1,
0,
0,
0,
1.5,
0,
0,
0,
2
]
},
"geometricError": 1024,
"refine": "ADD",
"children": [
{
"boundingVolume": {
"box": [
0.5,
0.5,
-0.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-x-up.glb"
}
},
{
"boundingVolume": {
"box": [
1.5,
2.5,
2.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-x-up-RTC-1-2-3.glb"
}
}
]
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"asset": {
"version": "1.1"
},
"geometricError": 4096,
"root": {
"boundingVolume": {
"box": [
1,
0.5,
2,
1,
0,
0,
0,
1.5,
0,
0,
0,
2
]
},
"geometricError": 1024,
"refine": "ADD",
"children": [
{
"boundingVolume": {
"box": [
0.5,
-0.5,
0.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-y-up.glb"
}
},
{
"boundingVolume": {
"box": [
1.5,
1.5,
3.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-y-up-RTC-1-2-3.glb"
}
}
]
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"asset": {
"version": "1.1"
},
"geometricError": 4096,
"root": {
"boundingVolume": {
"box": [
1,
0.5,
2,
1,
0,
0,
0,
1.5,
0,
0,
0,
2
]
},
"geometricError": 1024,
"refine": "ADD",
"children": [
{
"boundingVolume": {
"box": [
0.5,
-0.5,
0.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-y-up.glb"
}
},
{
"boundingVolume": {
"box": [
1.5,
1.5,
3.5,
0.5,
0,
0,
0,
0.5,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "Axes-glTF1-y-up-RTC-1-2-3.glb"
}
}
]
}
}
Binary file not shown.
Loading
Loading