How can we retrieve glTF image properties on mouse left click on the glTF image ?
What do you mean by image properties? You could use picking to get an entity/model clicked on:
Is that what you mean?
Actually, I am creating a 3D building and adding a super structure on top of the building. The super structures added are the glTF images. Later upon adding I want to edit the glTF image’s colour, make it transparent and make some spatial changes etc. The functionalities should be performed on selecting the image with mouse click. So,here how can I get the image details on clicking on the image ?
A glTF is a 3D model. When you add this model on top of your building are you adding it with code like the following?
viewer.entities.add({
name : url,
position : position,
orientation : orientation,
model : {
uri : url
}
});
``
If so you have a couple of options on the model to change its color, such as model.color and model.colorBlendMode. The Sandcastle below shows you a code example of changing a model’s color this way.
Thats Done. Thank You.
Is there any way by which I can rotate that glTF image ?
You can change the orientation argument. This example shows you how to pass a heading/pitch/roll to rotate a model:
I am adding the gltf image in the following way, by changing the Heading we can rotate the gltf in 2d.
var heading = 0;
var pitch = 0;
var roll = 0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var ss_pos = Cesium.Cartesian3.fromDegrees(building_coords[0], building_coords[1]);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(ss_pos, hpr);
var dish = cesiumViewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(building_coords[0], building_coords[1]),
orientation: orientation,
model: {
uri: ‘/assets/models/dish.glb’,
scale: sc_dish,
color: Cesium.Color.fromCssColorString©,
}
});
but in the console, I’m getting like this.
I’m not able to see ‘heading’ in the gltf object details and also tried to change those w,x,y,z values and check but it wasn’t anything about rotation.
Try changing the pitch and roll to rotate the model along the other 2 axes.
An orientation is stored as a quaternion in Cesium. If you want to retrieve a model’s heading, pitch, roll you can use the HeadingPitchRoll.fromQuaternion function to convert it:
It worked. Thank you.