Skip to content

Commit

Permalink
Merge pull request #45 from javagl/update-samples-1.1
Browse files Browse the repository at this point in the history
Update samples for 3D Tiles 1.1
  • Loading branch information
lilleyse authored Mar 24, 2022
2 parents 23a1b5e + f3c25d8 commit ec9742f
Show file tree
Hide file tree
Showing 162 changed files with 469 additions and 1,081 deletions.
11 changes: 0 additions & 11 deletions 1.0/TilesetWithExpiration/README.md

This file was deleted.

Binary file removed 1.0/TilesetWithExpiration/cache/points_0.pnts
Binary file not shown.
Binary file removed 1.0/TilesetWithExpiration/cache/points_1.pnts
Binary file not shown.
Binary file removed 1.0/TilesetWithExpiration/cache/points_2.pnts
Binary file not shown.
Binary file removed 1.0/TilesetWithExpiration/cache/points_3.pnts
Binary file not shown.
Binary file removed 1.0/TilesetWithExpiration/cache/points_4.pnts
Binary file not shown.
Binary file removed 1.0/TilesetWithExpiration/points.pnts
Binary file not shown.
Binary file removed 1.0/TilesetWithExpiration/screenshot/screenshot.gif
Binary file not shown.
42 changes: 0 additions & 42 deletions 1.0/TilesetWithExpiration/tileset.json

This file was deleted.

Binary file added 1.1/BoundingBoxTests/0_0_0-1_1_2/0_0_0-1_1_2.glb
Binary file not shown.
16 changes: 16 additions & 0 deletions 1.1/BoundingBoxTests/0_0_0-1_1_2/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 1.0,
"root" : {
"boundingVolume" : {
"box" : [ 0.5, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 1.0 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"content" : {
"uri" : "0_0_0-1_1_2.glb"
}
}
}
Binary file added 1.1/BoundingBoxTests/0_0_0-1_2_1/0_0_0-1_2_1.glb
Binary file not shown.
16 changes: 16 additions & 0 deletions 1.1/BoundingBoxTests/0_0_0-1_2_1/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 1.0,
"root" : {
"boundingVolume" : {
"box" : [ 0.5, 1.0, 0.5, 0.5, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"content" : {
"uri" : "0_0_0-1_2_1.glb"
}
}
}
Binary file added 1.1/BoundingBoxTests/0_0_0-2_1_1/0_0_0-2_1_1.glb
Binary file not shown.
16 changes: 16 additions & 0 deletions 1.1/BoundingBoxTests/0_0_0-2_1_1/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 1.0,
"root" : {
"boundingVolume" : {
"box" : [ 1.0, 0.5, 0.5, 1.0, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"content" : {
"uri" : "0_0_0-2_1_1.glb"
}
}
}
Binary file added 1.1/BoundingBoxTests/0_0_2-1_1_4/0_0_2-1_1_4.glb
Binary file not shown.
16 changes: 16 additions & 0 deletions 1.1/BoundingBoxTests/0_0_2-1_1_4/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 1.0,
"root" : {
"boundingVolume" : {
"box" : [ 0.5, 0.5, 3.0, 0.5, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 1.0 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"content" : {
"uri" : "0_0_2-1_1_4.glb"
}
}
}
Binary file added 1.1/BoundingBoxTests/0_2_0-1_4_1/0_2_0-1_4_1.glb
Binary file not shown.
16 changes: 16 additions & 0 deletions 1.1/BoundingBoxTests/0_2_0-1_4_1/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 1.0,
"root" : {
"boundingVolume" : {
"box" : [ 0.5, 3.0, 0.5, 0.5, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"content" : {
"uri" : "0_2_0-1_4_1.glb"
}
}
}
Binary file added 1.1/BoundingBoxTests/2_0_0-4_1_1/2_0_0-4_1_1.glb
Binary file not shown.
16 changes: 16 additions & 0 deletions 1.1/BoundingBoxTests/2_0_0-4_1_1/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.0"
},
"geometricError" : 1.0,
"root" : {
"boundingVolume" : {
"box" : [ 3.0, 0.5, 0.5, 1.0, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"content" : {
"uri" : "2_0_0-4_1_1.glb"
}
}
}
181 changes: 181 additions & 0 deletions 1.1/BoundingBoxTests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Bounding Box Tests

Sample tilesets that embed single, simple glTF models into a tileset, and showing the appropriate tileset bounding volumes for the respective glTF bounding volumes.

## Screenshot

![BoundingBoxTests](screenshot/BoundingBoxTests.gif)

## Structure

The directory contains six different tilesets, each with a single glTF asset. The assets and directories are named based on the bounding volumes of the models, given as the minimum- and maximum points:

- (0,0,0) - (1,1,2)
- (0,0,0) - (1,2,1)
- (0,0,0) - (2,1,1)
- (0,0,2) - (1,1,4)
- (0,2,0) - (1,4,1)
- (2,0,0) - (4,1,1)

## Conversion

The code for computing the tile- or tileset bounding volume from the mimimum- and maximum point of a glTF asset, taking into account the [y-up-to-z-up conversion](https://github.com/CesiumGS/3d-tiles/tree/main/specification#y-up-to-z-up), is shown here:

```JavaScript
/**
* Creates a bounding box for a tileset- or tile bounding volume.
*
* This is the center- and half-axis representation of the
* `boundingVolume.box` that is described at
* https://github.com/CesiumGS/3d-tiles/tree/main/specification#box,
* computed from the minimum- and maximum point of a box.
*
* @param minX The minimum x
* @param minY The minimum y
* @param minZ The minimum z
* @param maxX The maximum x
* @param maxY The maximum y
* @param maxZ The maximum z
* @return The `boundingVolume.box`
*/
function createBoundingBox(
minX, minY, minZ,
maxX, maxY, maxZ) {

// The size of the box
const dx = maxX - minX;
const dy = maxY - minY;
const dz = maxZ - minZ;

// The center of the box
const cx = minX + dx * 0.5;
const cy = minY + dy * 0.5;
const cz = minZ + dz * 0.5;

// The x-direction and half length
const hxx = dx * 0.5;
const hxy = 0.0;
const hxz = 0.0;

// The y-direction and half length
const hyx = 0.0;
const hyy = dy * 0.5;
const hyz = 0.0;

// The z-direction and half length
const hzx = 0.0;
const hzy = 0.0;
const hzz = dz * 0.5;

const box = [
cx, cy, cz,
hxx, hxy, hxz,
hyx, hyy, hyz,
hzx, hzy, hzz];
return box;
}

/**
* Creates a bounding box for a tileset- or tile bounding volume
* from the minimum- and maximum point of a glTF asset.
*
* This is the center- and half-axis representation of the
* `boundingVolume.box` that is described at
* https://github.com/CesiumGS/3d-tiles/tree/main/specification#box,
* computed from the minimum- and maximum point of a box.
*
* @param minX The minimum x
* @param minY The minimum y
* @param minZ The minimum z
* @param maxX The maximum x
* @param maxY The maximum y
* @param maxZ The maximum z
* @return The `boundingVolume.box`
*/
function createBoundingBoxFromGltf(
minX, minY, minZ,
maxX, maxY, maxZ) {

// Take into account the y-up-to-z-up transform:
const tMinX = minX;
const tMinY = -minZ;
const tMinZ = minY;
const tMaxX = maxX;
const tMaxY = -maxZ;
const tMaxZ = maxY;
return createBoundingBox(
tMinX, tMinY, tMinZ,
tMaxX, tMaxY, tMaxZ);
}
```


## Sandcastle Code

The Sandcastle code that can be used to view the test cases:

```JavaScript
const viewer = new Cesium.Viewer("cesiumContainer");

// Stores the tileset that is currently selected
let currentTileset;

// Creates the tileset for the sample with the given name.
function createTileset(exampleName) {
if (Cesium.defined(currentTileset)) {
viewer.scene.primitives.remove(currentTileset);
currentTileset = undefined;
}
// Create the tileset, and move it to a certain position on the globe
currentTileset = viewer.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: `http://localhost:8003/1.1/BoundingBoxTests/${exampleName}/tileset.json`,
debugShowBoundingVolume: true,
})
);
currentTileset.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-75.152325, 39.94704, 0)
);
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. Selecting one of
// these will load the tileset for the sample with the
// given name, and display the given info text in the
// infoTexDisplay
function createSampleOption(name, infoText) {
return {
text: name,
onselect: function () {
createTileset(name);
},
};
}

// Create the list of available samples, and add them
// to the sandcastle toolbar
const sampleOptions = [
createSampleOption("0_0_0-1_1_2", "0_0_0-1_1_2"),
createSampleOption("0_0_0-1_2_1", "0_0_0-1_2_1"),
createSampleOption("0_0_0-2_1_1", "0_0_0-2_1_1"),
createSampleOption("0_0_2-1_1_4", "0_0_2-1_1_4"),
createSampleOption("0_2_0-1_4_1", "0_2_0-1_4_1"),
createSampleOption("2_0_0-4_1_1", "2_0_0-4_1_1"),
];
Sandcastle.addToolbarMenu(sampleOptions);
```

## License

[CC0](https://creativecommons.org/share-your-work/public-domain/cc0/)


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions 1.1/MetadataGranularities/tileset.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@
"box" : [ 0.2524109, 9.536743E-7, 4.5, 16.257824, 0.0, 0.0, 0.0, -19.717258, 0.0, 0.0, 0.0, 4.5 ]
},
"geometricError" : 512.0,
"refine" : "ADD",
"children" : [ {
"boundingVolume" : {
"box" : [ -10.0, 12.988594, 4.0, 6.005413, 0.0, 0.0, 0.0, -6.2098656, 0.0, 0.0, 0.0, 4.0 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"contents" : [ {
"uri" : "house-3-0.glb",
"metadata" : {
Expand Down Expand Up @@ -170,7 +170,6 @@
"box" : [ -10.257616, -12.953957, 4.0, 5.544254, 0.0, 0.0, 0.0, -6.678105, 0.0, 0.0, 0.0, 4.0 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"contents" : [ {
"uri" : "house1-1.glb",
"metadata" : {
Expand Down Expand Up @@ -234,7 +233,6 @@
"box" : [ 10.253603, 12.995412, 3.0, 5.4854355, 0.0, 0.0, 0.0, -6.7218466, 0.0, 0.0, 0.0, 3.0 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"contents" : [ {
"uri" : "house-4-2.glb",
"metadata" : {
Expand Down Expand Up @@ -298,7 +296,6 @@
"box" : [ 10.0, -12.972918, 4.5, 6.510235, 0.0, 0.0, 0.0, -6.7443395, 0.0, 0.0, 0.0, 4.5 ]
},
"geometricError" : 0.0,
"refine" : "REPLACE",
"contents" : [ {
"uri" : "house-5-3.glb",
"metadata" : {
Expand Down
Loading

0 comments on commit ec9742f

Please sign in to comment.