Search in sources :

Example 1 with EllipsePositionsOptions

use of org.cesiumjs.cs.core.options.EllipsePositionsOptions in project gwt-cs by iSergio.

the class CirclePrimitive method getPositions.

public Cartesian3[] getPositions() {
    EllipsePositionsOptions options = new EllipsePositionsOptions();
    options.semiMajorAxis = getRadius();
    options.semiMinorAxis = getRadius();
    options.center = getCenter();
    options.granularity = granularity;
    options.rotation = 0;
    JsObject jsObject = EllipseGeometryLibrary.computeEllipsePositions(options, false, true);
    if (jsObject.getObject("outerPositions") == null) {
        return null;
    }
    List<Cartesian3> positions = new ArrayList<>();
    JsArray<Number> nativePositions = (JsArray<Number>) jsObject.getObject("outerPositions");
    for (int i = 0; i < nativePositions.length(); i += 3) {
        double x = JsObject.getNumber(nativePositions, i).doubleValue();
        double y = JsObject.getNumber(nativePositions, i + 1).doubleValue();
        double z = JsObject.getNumber(nativePositions, i + 2).doubleValue();
        positions.add(new Cartesian3(x, y, z));
    }
    return positions.toArray(new Cartesian3[positions.size()]);
}
Also used : EllipsePositionsOptions(org.cesiumjs.cs.core.options.EllipsePositionsOptions) JsObject(org.cesiumjs.cs.js.JsObject) JsArray(org.cesiumjs.cs.js.JsArray) Cartesian3(org.cesiumjs.cs.core.Cartesian3) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 Cartesian3 (org.cesiumjs.cs.core.Cartesian3)1 EllipsePositionsOptions (org.cesiumjs.cs.core.options.EllipsePositionsOptions)1 JsArray (org.cesiumjs.cs.js.JsArray)1 JsObject (org.cesiumjs.cs.js.JsObject)1