Skip to content
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

RectangeGeometry rotation error when center is to the right of the IDL #3874

Closed
hpinkos opened this issue Apr 22, 2016 · 1 comment
Closed

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Apr 22, 2016

Reported on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/fXy4QD27KCQ

Cesium.Camera.DEFAULT_VIEW_RECTANGLE = new Cesium.Rectangle(
    Math.PI - 0.01,
    Cesium.Math.PI_OVER_SIX - 0.01,
    0.01 - Math.PI,
    Cesium.Math.PI_OVER_SIX + 0.01
);
Cesium.Camera.DEFAULT_VIEW_FACTOR = 0.25;

var viewer = new Cesium.Viewer('cesiumContainer', { infoBox : false });

// Show dateline
viewer.entities.add({
    polyline : {
        positions: Cesium.Cartesian3.fromDegreesArray([180, 80,
                                                       180, -80]),
        width: 1,
        material: Cesium.Color.RED
    }
});

function createEasternRectangle(rotation) {
    // Rectangle with center on Eastern Hemisphere
    var easternRectangle = new Cesium.Rectangle(
        Math.PI - 0.01,
        Cesium.Math.PI_OVER_SIX - 0.01,
        0.005 - Math.PI,
        Cesium.Math.PI_OVER_SIX + 0.01
    );

    return new Cesium.GeometryInstance({
        geometry: new Cesium.RectangleGeometry({
            rectangle: easternRectangle,
            rotation: rotation
        }),
        attributes: {
            // yellow
            color: new Cesium.ColorGeometryInstanceAttribute(1.0, 1.0, 0.0, 0.5)
        }
    });
}

function createWesternRectangle(rotation) {
    // Rectangle with center on Western Hemisphere
    var westernRectangle = new Cesium.Rectangle(
        Math.PI - 0.005,
        Cesium.Math.PI_OVER_SIX + 0.02,
        0.01 - Math.PI,
        Cesium.Math.PI_OVER_SIX + 0.04
    );

    return new Cesium.GeometryInstance({
        geometry: new Cesium.RectangleGeometry({
            rectangle: westernRectangle,
            rotation: rotation
        }),
        attributes: {
            // blue
            color: new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5)
        }
    });
}

var eastern1 = createEasternRectangle(0);
var eastern2 = createEasternRectangle(0.5);
var western1 = createWesternRectangle(0);
var western2 = createWesternRectangle(0.005);

viewer.scene.primitives.add(new Cesium.Primitive({
  geometryInstances: [eastern1, eastern2, western1, western2],
  appearance: new Cesium.PerInstanceColorAppearance()
}));
@pjcozzi
Copy link
Contributor

pjcozzi commented Oct 25, 2016

Fixed in #4507.

@pjcozzi pjcozzi closed this as completed Oct 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants