Have polygon image material distort to always fit space

61 views
Skip to first unread message

taka...@gmail.com

unread,
Mar 29, 2020, 6:07:40 AM3/29/20
to cesium-dev
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?)

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);



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

Omar Shehata

unread,
Mar 31, 2020, 4:31:31 PM3/31/20
to cesium-dev
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.
Reply all
Reply to author
Forward
0 new messages