Maybe I’m missing something, but I’m trying to draw a polygon which changes shape dynamically at every frame update.
Starting from this base example which works:
Cesium.Math.setRandomNumberSeed(1234);
var viewer = new Cesium.Viewer(‘cesiumContainer’, { infoBox : false });
var entities = viewer.entities;
var positions = Cesium.Cartesian3.fromDegreesArray([
-107.0, 31.0,
-107.0, 39.0,
-97.0, 39.0,
-97.0, 31.0
]);
entities.add({
polygon : {
hierarchy : new Cesium.PolygonHierarchy(positions),
material : Cesium.Color.BLUE
}
});
viewer.zoomTo(viewer.entities);
``
I use CallbackProperty in the following manner:
Cesium.Math.setRandomNumberSeed(1234);
var viewer = new Cesium.Viewer(‘cesiumContainer’, { infoBox : false });
var entities = viewer.entities;
var positions = Cesium.Cartesian3.fromDegreesArray([
-107.0, 31.0,
-107.0, 39.0,
-97.0, 39.0,
-97.0, 31.0
]);
entities.add({
polygon : {
hierarchy : new Cesium.CallbackProperty(function(){
return {
positions: positions
};
}, false),
material : Cesium.Color.BLUE
}
});
viewer.zoomTo(viewer.entities);
``
Which results in the polygon not being drawn. Or:
Cesium.Math.setRandomNumberSeed(1234);
var viewer = new Cesium.Viewer(‘cesiumContainer’, { infoBox : false });
var entities = viewer.entities;
var positions = Cesium.Cartesian3.fromDegreesArray([
-107.0, 31.0,
-107.0, 39.0,
-97.0, 39.0,
-97.0, 31.0
]);
entities.add({
polygon : {
hierarchy : {
positions: new Cesium.CallbackProperty(function(){
return positions;
}, false)
},
material : Cesium.Color.BLUE
}
});
viewer.zoomTo(viewer.entities);
``
Which results in a fatal error:
An error occurred while rendering. Rendering has stopped.
undefined
DataCloneError: Failed to execute ‘postMessage’ on ‘Worker’: An object could not be cloned.
Error: Failed to execute ‘postMessage’ on ‘Worker’: An object could not be cloned.
at Error (native)
at http://cesiumjs.org/Cesium/Source/Core/TaskProcessor.js:235:31
at Object.then (http://cesiumjs.org/Cesium/Source/ThirdParty/when.js:196:34)
at http://cesiumjs.org/Cesium/Source/ThirdParty/when.js:297:13
at processQueue (http://cesiumjs.org/Cesium/Source/ThirdParty/when.js:647:4)
at _resolve (http://cesiumjs.org/Cesium/Source/ThirdParty/when.js:333:4)
at Worker.worker.onmessage (http://cesiumjs.org/Cesium/Source/Core/TaskProcessor.js:56:26)
The following example instead works for a polyline:
Cesium.Math.setRandomNumberSeed(1234);
var viewer = new Cesium.Viewer(‘cesiumContainer’, { infoBox : false });
var entities = viewer.entities;
var positions = Cesium.Cartesian3.fromDegreesArray([
-107.0, 31.0,
-107.0, 39.0,
-97.0, 39.0,
-97.0, 31.0
]);
entities.add({
polyline : {
positions: new Cesium.CallbackProperty(function(){
return positions;
}, false),
material : Cesium.Color.BLUE
}
});
viewer.zoomTo(viewer.entities);
``
Am I missing something? Does CallbackProperty work on polygons?
Thanks for any pointers.
p.s. great work on 3D tiles and shadows!