Hello Cesium Community,
I am currently facing an issue with positioning a glTF model using CesiumJS and would greatly appreciate any assistance you could provide.
Issue Description: I am trying to load a glTF model into my scene using Cesium.IonResource.fromAssetId
. However, the model does not appear at the correct geographic coordinates and is also not oriented properly. Here are the key points:
- Model Loading: I am using
Cesium.IonResource.fromAssetId
to load a model with the asset ID2600805
. The model loads without errors but does not appear at the intended location. - Coordinate Issues: I attempted to position the model at specific geographic coordinates (25N, 80W), which corresponds to -80.0 longitude and 25.0 latitude in decimal degrees. However, the model appears off-site, and I suspect there might be an issue with how I’m translating these coordinates in Cesium (using WGS84 currently).
- Orientation Problems: The model is also appearing sideways, which suggests there might be an issue with how the model’s orientation is being handled.
- Height Problems: Even when height parameter is set to 0, the rendering shows up in the stratosphere.
Even upon changing the coordinates in Celcius JS, the rendering does not map to the correct coordinates.
Code:
// Grant CesiumJS access to your ion assets
Cesium.Ion.defaultAccessToken = “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxZGI1NWM5ZC02YmJjLTRjOGItOGIzNi0yMTExMGQ3NDhlOGYiLCJpZCI6MjE4OTY3LCJpYXQiOjE3MTcwNzk3NzJ9.8579GUuzssWhb-C_rrhPoU0h5-qnWhcINc61kBDWCLc”;
const viewer = new Cesium.Viewer(“cesiumContainer”);
try {
const resource = await Cesium.IonResource.fromAssetId(2600805);
const longitude = -80.194521; // Longitude in degrees, e.g., near Philadelphia
const latitude = -25.322150; // Latitude in degrees, e.g., near Ottawa
const height = 0; // Height in meters above the ground
const position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
const entity = viewer.entities.add({
position: position,
model: {
uri: resource,
},
});
viewer.trackedEntity = entity;
} catch (error) {
console.log(error);
}
Questions:
- How can I ensure that the model is positioned accurately at the given coordinates?
- What steps should I take to correct the orientation of the glTF model in the scene?
- Are there any best practices for handling the scaling and orientation of glTF models in CesiumJS that I should be aware of?
- Is there a better way to upload glTF files so they contain the geolocation metadata so I can avoid all of this mess?
Thank you in advance for your help and guidance. I look forward to your suggestions and recommendations.
Best regards,
JLTS