Scale ModelGraphics by Z axis


Is there a way to scale ModelGraphics by Z only?
I need to stretch 3D model in different directions. Tried to use nodeTransformation but it doesn’t seem that asset has node names to refer to in nodeTransformations.

In this case, the easiest thing to do is to add node names to the asset and then use nodeTransformations, which will allow you to individually scale nodes in different directions: Cesium Sandcastle. There is not another method to scale ModelGraphics in the z direction.

Are you using a gltf model? You can manually add the names to the file in this case and reupload it.

1 Like

Thank you for the idea!

I had model in fbx format. So I converted it to glTF and uploaded without any optimizations and compression and it worked!

Disabling optimization is critical here because it cuts off node names.

My code sample:
var entity = self.entities.add({
name: name,
position: position,
orientation: orientation,
model: {
uri: resource,
minimumPixelSize : 40,
// nodeTransformations: {
// “YourNodeName”: new Cesium.TranslationRotationScale(Cesium.Cartesian3.ZERO, Cesium.Quaternion.IDENTITY, new Cesium.Cartesian3(100000.0, 1.0, 1.0))
// },
runAnimations: false,
shadows: Cesium.ShadowMode.DISABLED,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND

if (!Cesium.defined(entity.model.nodeTransformations)) {
entity.model.nodeTransformations = new Cesium.PropertyBag({});
new Cesium.TranslationRotationScale(Cesium.Cartesian3.ZERO, Cesium.Quaternion.IDENTITY, new Cesium.Cartesian3(10.0, 1.0, 1.0))

(sorry for formatting, couldn’t find suitable feature in the editor)

1 Like