Could you please point where I am going wrong ? This particular line[1] is throwing error as shown in [2]. This piece of code ran flawlessly on 0.9 version of Cesium.
[1]
var boxModelMatrix = Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid), new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5));
[2]
Uncaught TypeError: Cannot set property ‘0’ of undefined Cesium.js:380
Looks like the third parameter (result) is missing, try:
var boxModelMatrix = new Cesium.Matrix4();
Matrix4.multiplyByTranslation(matrix, translation, boxModelMatrix)
You are missing a new before Cesium.Matrix4() and you are also missing the Cesium prefix before Matrix4.multiplyByTranslation. Here’s the fixed version.
var boxModelMatrix = new Cesium.Matrix4();
Cesium.Matrix4.multiplyByTranslation(
Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5),
boxModelMatrix);
You might also want to look into the newer Entity API, which tries to make creating geometry easier, for instance, here’s a complete example of a box.
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var dimensions = new Cesium.Cartesian3(1000, 1000, 1000);
var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(0.0, 0.0, dimensions.z * 0.5);
var entity = viewer.entities.add({
position : positionOnEllipsoid,
box : {
dimensions : dimensions
}
You are missing a `new` before Cesium.Matrix4() and you are also missing
the Cesium prefix before Matrix4.multiplyByTranslation. Here's the fixed
version.
var boxModelMatrix = new Cesium.Matrix4();
Cesium.Matrix4.multiplyByTranslation(
Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5),
boxModelMatrix);
Thanks a lot this works now.
You might also want to look into the newer Entity API, which tries to make
creating geometry easier, for instance, here's a complete example of a box.
var viewer = new Cesium.Viewer('cesiumContainer');
var dimensions = new Cesium.Cartesian3(1000, 1000, 1000);
var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(0.0, 0.0,
dimensions.z * 0.5);
var entity = viewer.entities.add({
position : positionOnEllipsoid,
box : {
dimensions : dimensions
}
});
viewer.zoomTo(entity);