Hi everyone!
Awesome stuff in the b19 release!
Quick question, is there any way to access the positions that where used to create a primitive? More precisely a GeometryInstance whose geometry is a PolygonGeometry.
I understand that storing the creational points of the polygon its pretty expensive memory wise, and it’s usually all about saving memory! But maybe there’s an option like releaseGeometryInstances but for PolygonGeometry positions.
Heres what I’ve got (and is not working for me):
// init stuff
var widget = new Cesium.CesiumWidget(‘cesiumContainer’);
var scene = widget.scene;
var primitives = scene.getPrimitives();
var ellipsoid = widget.centralBody.getEllipsoid();
var handler = new Cesium.ScreenSpaceEventHandler(scene.getCanvas());
// create extruded polygon
var extrudedPolygon = new Cesium.GeometryInstance({
geometry : new Cesium.PolygonGeometry({
polygonHierarchy : {
positions : ellipsoid.cartographicArrayToCartesianArray([
Cesium.Cartographic.fromDegrees(-113.0, 30.0),
Cesium.Cartographic.fromDegrees(-110.0, 30.0),
Cesium.Cartographic.fromDegrees(-110.0, 33.0),
Cesium.Cartographic.fromDegrees(-111.5, 31.0),
Cesium.Cartographic.fromDegrees(-113.0, 33.0)
])
},
vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
extrudedHeight: 300000
}),
attributes: {
color : new Cesium.ColorGeometryInstanceAttribute(Math.random(), Math.random(), Math.random(), 1.0)
}
});
// create primitive
var primitive = new Cesium.Primitive({
geometryInstances: extrudedPolygon,
appearance: new Cesium.PerInstanceColorAppearance({
translucent: false,
closed: true
}),
releaseGeometryInstances: false
});
primitives.add(primitive);
// handle click
handler.setInputAction(function (pick) {
var pickedObject = scene.pick(pick.position);
if (pickedObject === primitive) {
spyInside(pickedObject);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
// see what’s inside
function spyInside(primitive) {
console.log(primitive.geometryInstances.geometry); ***//some geometry, works up to here***
console.log(primitive.geometryInstances.geometry.polygonHierarchy); ***//undefined***
console.log(primitive.geometryInstances.geometry.polygonHierarchy.positions); ***//not a chance***
}
Thanks!