# Have polygon image material distort to always fit space

**URL:** <https://community.cesium.com/t/have-polygon-image-material-distort-to-always-fit-space/9200>\
**Category:** CesiumJS\
**Created:** [March 29, 2020, 10:07am UTC](https://community.cesium.com/t/have-polygon-image-material-distort-to-always-fit-space/9200 "2020-03-29T10:07:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![baako](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/baako/32/7057_2.png) [@baako](https://community.cesium.com/u/baako)\
**Post date:** [March 29, 2020, 10:07am UTC](https://community.cesium.com/t/have-polygon-image-material-distort-to-always-fit-space/9200/1 "2020-03-29T10:07:40Z")

</div>

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

Hello, I am having a problem where I need a polygon with an image material that distorts to always fit. Currently if you have a polygon (with lets say 4 points for simplicity) and the image size ratio doesn’t match up with the polygon’s points, the image will be cut off.

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

(this example below uses the image rotation to throw it out of the correct proportions to fit inside but it’s still the same problem. is there a way for it to just distort to fit in there even though it would have to squish inside?)

```auto
let viewer = new Cesium.Viewer('cesiumContainer');

viewer.entities.add(new Cesium.Entity({
    polygon:
    {
        hierarchy:
        {
           positions: [{ x: -5099561.112354739, y: 471018.36210765265, z: -3788996.464597908 },
                       { x: -5099564.409358333, y: 470982.66516832606, z: -3788996.4645979083 },
                       { x: -5099581.806381637, y: 470984.2719126955, z: -3788973.0084019853 },
                       { x: -5099578.5093667945, y: 471019.9689738013, z: -3788973.0084019853 }]
        },
        material: "https://images2.minutemediacdn.com/image/upload/c_crop,h_1414,w_2101,x_20,y_0/v1565279671/shape/mentalfloss/578211-gettyimages-542930526.jpg?itok=Nj49PDxW",
        stRotation: Cesium.Math.toRadians(45),
     }
}));

viewer.zoomTo(viewer.entities);

```

``

[Cesium Sandcastle](https://sandcastle.cesium.com/index.html#c=lVNbT9swFP4rVl7WSsGx40vsUtgktrfdxKbtYZkqk5jGkMRR7BYC4r/PoUO0pTzgF+tcvvOd61r1YG30je7BCWj1DTjTzqwa+OtRN3lXPIpntvXKtLp/Nz3O27zdIKBuvfFGO6jKcrIF/jTqh8l93oKt19l6WNp2tqvdcxpfZXSv+qIaZuCl8YD/JrgLqdjWzcCfe3A7A0cMSck4hhinhNGMyBiEgDTDCAtIeIpRxlnKWQzugjfJhJCSQ8opk5lEAjzEh5l2ktliopAiSZgghPxnQlKkkHOGuSApR/wVJhKowJu4BIYCcSIwJ9kzF4VphiVOuWTbRWUEIiQowlKwt1NlAoafcJ5Jyp47KKHkY2iBMHmd6+9LqkNdbZTXvVF1GHdUed+5WZKYRi21S2Fj2pXXjS6NKsoWFrbZmJJVV1tVJsWi6G0XVwtMMY1vFmGsOL5dpCgeFihZYxZmnEme4cRVqtNJE3ZW1Ze1dS4JxaUYHy2198OG74jRVBIU1gJedcv3xtvrk69XVH7/ePs7jw6k7vy59WpcvNnT8n9RvoLenquQcusmlE33cQ/P8sN056DurG1+2sneeU2PoziaOz/U+nQD/WCazvYerPp6AmESGtTVoYkuuVgV19rDwrkx7jx5As1LswamPMmjvYPOI1DUyrlguVzV9Q9zp/PodJ4E/x3Y2GzTLr+tdV+rYXSp8OnnjRJCOE+C+BLlra0vVL8V8R8)

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

I have images I would like to display on the terrain and be able to distort them to fit the terrain imagery in case they aren’t perfectly aligning.

Currently if I shift a point in my polygon to a new position with the image material in place, the image just crops off.

Note:

I cannot use a rectangle object as whatever I’m trying to align with my image may not be rectangular.

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

Cesium JS 1.66

Windows 10

Chrome

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [March 31, 2020, 8:31pm UTC](https://community.cesium.com/t/have-polygon-image-material-distort-to-always-fit-space/9200/2 "2020-03-31T20:31:30Z")

</div>

It isn’t currently possible to control how the texture coordinates are set up when creating polygons with the Entity API. There’s an issue for getting what I think is the behavior you expect here: [https://github.com/CesiumGS/cesium/issues/4164](https://github.com/CesiumGS/cesium/issues/4164).
