Hello,
I'm new using Cesium and what I want to do is to draw a cone pointing in a certain direction and shift the cone so that one of the edges connect to a pole.
I have managed to draw the cone in the desired location, but I can't find a way to offset the cone to make the tip connect to a pole on the original coordinate.
What I need to do is to offset an object by half his size in a specific angle.
Here is the code I have so far. This function puts the cone pointing in the direction I want but it doesn't move where I want it:
create3DNetwork = function (networkItem) {
var solidLength = 2.0;
var position = networkItem._position._value;
var azimuthRadians = Cesium.Math.toRadians(networkItem.properties.AZIMUTH);
var shift_x = -Math.sin(Cesium.Math.PI - azimuthRadians) * solidLength;
var shift_y = -Math.cos(Cesium.Math.PI - azimuthRadians) * solidLength;
//Transform a point
var transformationMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position);
var offset = new Cesium.Cartesian3(shift_x, shift_y, 0);
var finalPos = Cesium.Matrix4.multiplyByPoint(transformationMatrix, offset, new Cesium.Cartesian3());
var heading = azimuthRadians;
var pitch = 0.0;
var roll = Cesium.Math.PI_OVER_TWO - Cesium.Math.toRadians(networkItem.properties.TILT);
orientation = Cesium.Transforms.headingPitchRollQuaternion(finalPos, heading, pitch, roll);
$scope.viewer.entities.add({
position: finalPos,
orientation: orientation,
cylinder: {
length: solidLength * 2,
topRadius: 0.0,
bottomRadius: solidLength,
//slices: 4, //Add this parameter if you want to change the shape of the cilinder (e.g. to a pyramid)
material: Cesium.Color.fromCssColorString("#7A0304").withAlpha(0.5) //RBG: 122,3,4
}
});
}
Thank you so much
Migue Dias