-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from CesiumGS/package-entry-compression
Handle package entry compression
- Loading branch information
Showing
5 changed files
with
95 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,32 @@ | ||
/* eslint-disable no-undef */ | ||
const viewer = new Cesium.Viewer("cesiumContainer", { | ||
globe: false, | ||
skybox: false, | ||
skyBox: false, | ||
}); | ||
|
||
const tileset = viewer.scene.primitives.add( | ||
new Cesium.Cesium3DTileset({ | ||
url: `http://localhost:8003/tileset.json`, | ||
await Cesium.Cesium3DTileset.fromUrl(`http://localhost:8003/tileset.json`, { | ||
debugShowBoundingVolume: true, | ||
maximumScreenSpaceError: 0.3, | ||
maximumScreenSpaceError: 16, | ||
}) | ||
); | ||
|
||
class Timer { | ||
constructor(label) { | ||
this.label = label; | ||
this.startTime = undefined; | ||
this.endTime = undefined; | ||
} | ||
|
||
start() { | ||
this.startTime = performance.now(); | ||
} | ||
|
||
stop() { | ||
this.endTime = performance.now(); | ||
} | ||
|
||
print() { | ||
const difference_sec = (this.endTime - this.startTime) / 1000.0; | ||
console.log(`${this.label}: ${difference_sec} sec`); | ||
} | ||
} | ||
|
||
const tileTimer = new Timer("tiles"); | ||
|
||
tileset.readyPromise.then(() => { | ||
console.log("Tileset is ready"); | ||
tileTimer.start(); | ||
}); | ||
// Move the tileset to a certain position on the globe | ||
const transform = Cesium.Transforms.eastNorthUpToFixedFrame( | ||
Cesium.Cartesian3.fromDegrees(-75.152408, 39.946975, 1) | ||
); | ||
const scale = 1.0; | ||
const modelMatrix = Cesium.Matrix4.multiplyByUniformScale( | ||
transform, | ||
scale, | ||
new Cesium.Matrix4() | ||
); | ||
tileset.modelMatrix = modelMatrix; | ||
|
||
// Zoom to the tileset (with a certain offset, to make it fully visible) | ||
const offset = new Cesium.HeadingPitchRange( | ||
Cesium.Math.toRadians(0.0), | ||
Cesium.Math.toRadians(-60.0), | ||
15000.0 | ||
1500.0 | ||
); | ||
viewer.zoomTo(tileset, offset); | ||
|
||
tileset.initialTilesLoaded.addEventListener(() => { | ||
console.log("Initial tiles are loaded"); | ||
tileTimer.stop(); | ||
tileTimer.print(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters