-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Texture rotation incorrect #2737
Comments
Was this posted on the forum? If so can you include a link to the post so we can follow up later? |
It was my thread on the forum: https://groups.google.com/forum/#!topic/cesium-dev/UF9wQugwRf0 |
Thanks @devguy22! |
Any updates on this? |
No update. We've been focused on Cesium 1.11. |
I have also run into this issue when creating a rectangular entity and then rotating it along with it's texture. Here's an interactive example of the issue: |
I'm also running into this. In the special case where the rotation is multiples of 90 degrees, it looks fine, but anything else and the texture is wrong. See my SANDCASTLE here. |
@pjcozzi One thing I noticed while trying to debug this, is the comment on line 787 of RectangleGeometry.js. It says:
... but stRotation is defined as ccw, and the function it's used in immediately below:
says that the "angle" parameter is:
That strikes me as an unnecessary negation. When I tried removing the minus sign it didn't completely solve this issue, but I think it might be one of perhaps several small issues? |
@dwhipps we would definitely welcome pull requests with incremental fixes even if it doesn't fix this issue completely. Thanks for looking into this! |
Also reported here: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/N7MXm_0OwsE |
Updated code example that can be pasted in the Sandcastle: var viewer = new Cesium.Viewer('cesiumContainer');
var width = 1189;
var height = 300;
var entity = new Cesium.Entity();
var image = new Image(width, height);
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var context = canvas.getContext('2d');
var rot = 0.0;
var doRotation = false;
function addBillboard() {
image.src = '../images/Cesium_Logo_Color.jpg';
//Need to wait for image to load before proceeding to draw
image.onload = function () {
canvas.getContext('2d').drawImage(image, 0, 0);
entity.rectangle = new Cesium.RectangleGraphics(
{
coordinates: Cesium.Rectangle.fromDegrees(-86.69777, 30.03883, -76.69777, 40.03883),
material: new Cesium.ImageMaterialProperty( {image: canvas} ),
// material: new Cesium.StripeMaterialProperty({repeat: 4}),
rotation: new Cesium.CallbackProperty(getRotationValue, false),
stRotation: new Cesium.CallbackProperty(getRotationValue, false)
}
);
viewer.entities.add(entity);
viewer.flyTo(viewer.entities)
.then(function() {
setInterval(rotateRect, 50);
});
};
}
function getRotationValue() {
return rot;
}
function rotateRect() {
rot = (rot + 0.015) % Cesium.Math.TWO_PI;
}
addBillboard(); |
This was fixed in #4430. |
Great work @jorpiell, thanks for looking into this! This was a frequently reported issue, lots of people will be happy to know it's been fixed. |
I'm not sure this is fixed. In the above example, why is the texture "changing size" inside the rectangle? |
@dwhipps did you pull down master? This is what I see after the change was merged: The texture was changing size before this fix was made. |
Sorry, I misunderstood. I thought the example could be pasted into the current (web) Sandbox. I didn’t realize that it wasn’t up to date with master. Looks good now. Thanks, Dave
|
No problem =) Yeah, Sandcastle on the website is always using the latest Cesium release |
@hpinkos Could you try the above example with these coordinates, and tell me if it looks right?
Not sure if I'm going crazy or what, but it still seems broken to me. |
Thanks @dwhipps, you're right. I think we'll have to take a closer look at how we're computing texture coordinates. |
It seems that the texture is correctly rotated when the angle is multiple of Math.PI/4 and it fails in the |
@jorpiell Agreed. But where do we look next? Is someone on this issue? It's a big one for me. |
A bit more on this... You can easily see the effect by changing just the value of the "north" boundary in the rectangle in the @bagnell example above. (That is, my counter-example used a different centre. That has no effect, only the aspect ratio seem to matter.) Simply lower it to "32" and you'll see the bug. I.e.
|
@dwhipps this is a little overly complicated because we allow the texture and the geometry to rotate separately. I think creating a specific trapezoid geometry (like the KML LatLonQuad) is probably what users are looking for. We have an issue written up to create this here: #4164 |
December is way to far away for me. (I thought this one was part of this "bug bash?") I'm having a look right now, but it's pretty dense stuff, and almost no comments in code. |
Ok. After all that complaining, I think I got it. See my PR. |
@dwhipps, you fixed the bug. I've tested it just removing the "* options.lonScalar" and the "* options.latScalar" in RectangleGeometryLibrary.js . Well done! |
@hpinkos This should be good to go now. |
Simplified example var viewer = new Cesium.Viewer('cesiumContainer');
var rectangle = Cesium.Rectangle.fromDegrees(-86.69777, 30.03883, -76.69777, 40.03883);
var stRotation = Cesium.Math.toRadians(0.0);
var rotation = Cesium.Math.toRadians(30);
viewer.entities.add({
rectangle: {
coordinates: rectangle,
material: '../images/Cesium_Logo_Color.jpg',
rotation: rotation,
stRotation: stRotation
}
}); |
…is fixes everything, I would love to know.
When rotating a rectangle the texture is zooming in and out, even when using the default cesium materials.
I've attached some sample html to quickly reproduce.
The text was updated successfully, but these errors were encountered: