Having Issues Trying to Centre The View on a specific Lat/Lng

1. A concise explanation of the problem you’re experiencing.

I have some point cloud data displaying in Cesium which I am now trying to place in its real world location, but trying to centre the Cesium viewer on that location doesn’t seem to be working in terms of setting the right location.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

animation: false,

terrainProvider: Cesium.createWorldTerrain(),

timeline: false

});

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url : ‘http://127.0.0.1:8081/cesium/test/tileset.json

}));

viewer.camera.setView({

destination : Cesium.Cartesian3.fromDegrees(

lng,

lat,

Cesium.Ellipsoid.WGS84.cartesianToCartographic(viewer.camera.position).height

)

});

// also tried

var center = Cesium.Cartesian3.fromDegrees(

lng,

lat,

Cesium.Ellipsoid.WGS84.cartesianToCartographic(viewer.camera.position).height

);

viewer.camera.lookAt(center, new Cesium.Cartesian3(0.0, 0.0, 0.0));

viewer.zoomTo(tileset);

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I am displaying point cloud data converted to 3D tiles using entwine.io. The data is showing fine, but the location it is set to on the globe seems to be deep under the Pacific ocean instead of where I’d like it to be, I am aiming to display the data where it actually is in the real world using a set of lat/lng coordinate (or any other kind that can be determined).

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.61 on OS X using Chrome 76.

Thanks,
Martin

After looking in to it some more, I believe my problem is actually to do with my tileset rather than the map centering.

I’ve managed to get the map centered where I like, and where I expected the tileset to appear, but the tiles are appearing in an entirely different location.

To outline my process, I had point cloud in .las format which was then compressed to an .laz. I then used Entwine (entwine.io) to reproject from EPSG:27700 to EPSG:4978 which is what Cesium uses I believe?

What is confusing me however, is that I see WGS84 mentioned on the documentation quite frequently, but is that not EPSG:4326? I am wondering if I have reprojected my data incorrectly or if there’s something else I have done wrong.

I also had a look at other answers and trying to adjust my tileset by specifying where it should appear but that didn’t work.

Current code is:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

animation: false,

baseLayerPicker: false,

terrainProvider: new Cesium.EllipsoidTerrainProvider({

tilingScheme : new Cesium.WebMercatorTilingScheme()

}),

timeline: false

});

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({

url: ‘http://127.0.0.1:8081/cesium/test/tileset.json

}));

tileset.readyPromise.then(function(tileset) {

var longitude = [lng];

var latitude = [lat];

var height = 1000.00;

var cartesian = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);

var transform = Cesium.Transforms.headingPitchRollToFixedFrame(cartesian, new Cesium.HeadingPitchRoll());

tileset._root.transform = Cesium.Matrix4.IDENTITY;

tileset.modelMatrix = transform;

});

viewer.camera.setView({

destination: new Cesium.Cartesian3.fromDegrees(

[lng],

[lat],

1000.00

),

orientation: {

heading: Cesium.Math.toRadians(0),

pitch: Cesium.Math.toRadians(-90),

roll: 0.0

}

});

Just to narrow down where the issue lies, can you try to upload the LAS file(s) to Cesium ion to get a 3D Tileset that way?

There was a similar issue where the Entwine generated 3D Tiles didn’t have the bounding volume computed correctly, see: https://groups.google.com/d/msg/cesium-dev/104gZkCV6ew/LKV0MEQUBAAJ

Thanks Omar.

I tried uploading it to Cesium ion and it worked fine that way, but locally the same data isn’t in the right location, not sure why at the moment.

Cheers,
Martin