The difference you’re seeing between web mercator and geographic is due to the distortion caused by web mercator using a sphere instead of an ellipsoid. The 3D difference is caused by the perspective projection.
I’ve modified the Sandcastle to center the image on 0, 0 to minimize the 2D distortion. I was then able to take snapshots, crop, and align subimages to compare which showed much less distortion at the equator.
const viewerWM = new Cesium.Viewer("wmContainer", {
sceneMode: Cesium.SceneMode.SCENE2D,
mapProjection: new Cesium.WebMercatorProjection()
});
const viewerG = new Cesium.Viewer("gContainer", {
sceneMode: Cesium.SceneMode.SCENE2D
});
const viewer3D = new Cesium.Viewer("3dContainer", {
sceneMode: Cesium.SceneMode.SCENE3D
});
const westRad = -1.5131722855601586;
const southRad = 0.6062598514783867;
const eastRad = -1.513140827552303;
const northRad = 0.6062823187875973;
const deltaLonOverTwo = (eastRad - westRad) / 2.0;
const deltaLatOverTwo = (northRad - southRad) / 2.0;
var centerLonRad, centerLatRad;
var rectangle;
if (1 === 1) {
centerLonRad = westRad + deltaLonOverTwo;
centerLatRad = southRad + deltaLatOverTwo;
rectangle = Cesium.Rectangle.fromRadians(
westRad, southRad, eastRad, northRad);
} else {
centerLonRad = 0.0;
centerLatRad = 0.0;
rectangle = Cesium.Rectangle.fromRadians(
centerLonRad - deltaLonOverTwo, centerLatRad - deltaLatOverTwo,
centerLonRad + deltaLonOverTwo, centerLatRad + deltaLatOverTwo
);
}
const rotation = Cesium.Math.toRadians(45);
viewerWM.entities.add({
name: "Rotating rectangle with rotating texture coordinate",
rectangle: {
coordinates: rectangle,
material: "../images/Cesium_Logo_Color.jpg",
rotation: rotation,
stRotation: rotation,
//classificationType: Cesium.ClassificationType.TERRAIN,
},
});
viewerG.entities.add({
name: "Rotating rectangle with rotating texture coordinate",
rectangle: {
coordinates: rectangle,
material: "../images/Cesium_Logo_Color.jpg",
rotation: rotation,
stRotation: rotation,
//classificationType: Cesium.ClassificationType.TERRAIN,
},
});
viewer3D.entities.add({
name: "Rotating rectangle with rotating texture coordinate",
rectangle: {
coordinates: rectangle,
material: "../images/Cesium_Logo_Color.jpg",
rotation: rotation,
stRotation: rotation,
//classificationType: Cesium.ClassificationType.TERRAIN,
},
});
const center = Cesium.Cartesian3.fromRadians(centerLonRad, centerLatRad);
//viewerWM.zoomTo(viewerWM.entities)
//viewerG.zoomTo(viewerG.entities)
//viewer3D.zoomTo(viewer3D.entities)
viewerWM.camera.lookAt(center, new Cesium.Cartesian3(0.0, 0, 890.0));
viewerG.camera.lookAt(center, new Cesium.Cartesian3(0.0, 0, 890.0));
viewer3D.camera.lookAt(center, new Cesium.Cartesian3(0.0, 0, 890.0));
Here are cropped images of the web mercator differences at the different latitudes:
![image](https://global.discourse-cdn.com/cesium/original/3X/1/5/15648658c9ebdb2a9d37615eb58db9b0e07221e5.png)
![image](https://global.discourse-cdn.com/cesium/original/3X/5/1/512424538de92a0a8ce8b960767f4827db4a54f3.png)
Hope that helps.
Scott