Hey,
I am trying to get a rectangle to encircle my object as it move. I’ve included a picture in case its not clear what I meant. Right now I have my objects (basically taken from examples) and I have a rectangle that uses the position of the object to determine its own position, but I cannot get it to move! I am wondering if by piecing together bits of example code I missed something.
This is the code for my rectangle
// Draw the outline of a box.
var dimensions = new Cesium.Cartesian3(400000.0, 0, 400000);
// Box geometries are initially centered on the origin.
// We can use a model matrix to position the box on the
// globe surface.
var positionOnEllipsoid = czmlDataSource.entities.getById(“object1”).position.getValue(viewer.clock.currentTime);
var boxModelMatrix = Cesium.Matrix4.multiplyByTranslation(
Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5), new Cesium.Matrix4());
// Create a box outline geometry.
var boxOutlineGeometry = Cesium.BoxOutlineGeometry.fromDimensions({
dimensions : dimensions
});
// Create a geometry instance using the geometry
// and model matrix created above.
var boxOutlineInstance = new Cesium.GeometryInstance({
geometry : boxOutlineGeometry,
modelMatrix : boxModelMatrix,
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.WHITE)
}
});
//Multiple Boxes
var positionOnEllipsoid2 = czmlDataSource.entities.getById(“object2”).position.getValue(viewer.clock.currentTime);
var boxModelMatrix2 = Cesium.Matrix4.multiplyByTranslation(
Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid2),
new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5), new Cesium.Matrix4());
var boxOutlineGeometry2 = Cesium.BoxOutlineGeometry.fromDimensions({
dimensions : dimensions
});
var boxOutlineInstance2 = new Cesium.GeometryInstance({
geometry : boxOutlineGeometry2,
modelMatrix : boxModelMatrix2,
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.WHITE)
}
});
// Add the geometry instance to primitives.
scene.primitives.add(new Cesium.Primitive({
geometryInstances : [boxOutlineInstance, boxOutlineInstance2],
appearance : new Cesium.PerInstanceColorAppearance({
flat : true,
renderState : {
depthTest : {
enabled : true
},
lineWidth : Math.min(2.0, scene.maximumAliasedLineWidth)
}
})
}));
``
Any suggestions would be really helpful

