Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Hole in animated ellipsoid entity #3045

Closed
hpinkos opened this issue Sep 24, 2015 · 3 comments
Closed

Hole in animated ellipsoid entity #3045

hpinkos opened this issue Sep 24, 2015 · 3 comments

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Sep 24, 2015

An ellipsoid using a SampledProperty doesn't render correctly at the north pole.
Reported in the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/4ylMB9ou7YA

This example uses a SampledProperty for the radius, but the issue also occurs when using a SampledPositionProperty for the position.

var viewer = new Cesium.Viewer('cesiumContainer');
var start = Cesium.JulianDate.now();
var stop = Cesium.JulianDate.addDays(start, 1, new Cesium.JulianDate());

var startRadius = new Cesium.Cartesian3(100000, 100000, 100000);
var endRadius = new Cesium.Cartesian3(200000, 200000, 200000);
var radius = new Cesium.SampledProperty(Cesium.Cartesian3);
radius.addSample(start, startRadius);
radius.addSample(stop, endRadius);

viewer.entities.add({
    name: 'animated ellipsoid with hole',
    position: Cesium.Cartesian3.fromDegrees(-120, 35),
    ellipsoid: {
        radii: radius,
        outline: false,
        fill: true,
        material: Cesium.Color.RED
    }
});

viewer.entities.add({
    name: 'static ellipsoid with no hole',
    position: Cesium.Cartesian3.fromDegrees(-115, 35),
    ellipsoid: {
        radii: startRadius,
        outline: false,
        fill: true,
        material: Cesium.Color.RED
    }
});

viewer.zoomTo(viewer.entities);
@mramato
Copy link
Contributor

mramato commented Sep 24, 2015

This is a weird bug but I tracked it down primitive.modelMatrix. Basically, if you set GeometryInstance.modelMatrix and leave Primitive.modelMatrix alone, it shows up correctly. But if you don't set GeometryInstance.modelMatrix and instead set Primitive.modelMatrix, the problem occurs. The EllipsoidVisualizer does it this way to provide a fast path specifically for ellipsoid animation, the code is all perfectly valid at the Entity level and the bug is somewhere in Primitive.

Here's a sample that reproduces the problem. Change the last line to ellipsoidInstance.modelMatrix = modelMatrix; and the problem goes away.

// Create the viewer.
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;

// Draw a blue ellipsoid and position it on the globe surface.

var radii = new Cesium.Cartesian3(200000.0, 200000.0, 300000.0);
// Ellipsoid geometries are initially centered on the origin.
// We can use a model matrix to position the ellipsoid on the
// globe surface.
var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-100.0, 40.0);
var modelMatrix = Cesium.Matrix4.multiplyByTranslation(
    Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
    new Cesium.Cartesian3(0.0, 0.0, radii.z), new Cesium.Matrix4()
);
// Create a ellipsoid geometry.
var ellipsoidGeometry = new Cesium.EllipsoidGeometry({
    vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
    radii : radii
});
// Create a geometry instance using the geometry
// and model matrix created above.
var ellipsoidInstance = new Cesium.GeometryInstance({
    geometry : ellipsoidGeometry,
    attributes : {
        color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE)
    }
});
// Add the geometry instance to primitives.
var primitive = scene.primitives.add(new Cesium.Primitive({
    geometryInstances : ellipsoidInstance,
    appearance : new Cesium.PerInstanceColorAppearance({
        translucent : false,
        closed : true
    })
}));

primitive.modelMatrix = modelMatrix;

@hpinkos
Copy link
Contributor Author

hpinkos commented Dec 21, 2015

Also see CZML example posted by @kjartab in #3354

@hpinkos
Copy link
Contributor Author

hpinkos commented Feb 19, 2016

It looks like the first 60 or so positions are being set to (0, 0, 1) somehow
So some triangles have zero area
like triangle with indices [65, 1, 0]

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants