Help with "Uncaught TypeError"

Hi

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

u.multiplyByTranslationCesium.js:380

plotROD(index):62

(anonymous function)(index):142

njquery-1.7.1.min.js:2

o.fireWithjquery-1.7.1.min.js:2

wjquery-1.7.1.min.js:4

djquery-1.7.1.min.js:4

Looks like the third parameter (result) is missing, try:
var boxModelMatrix = new Cesium.Matrix4();
Matrix4.multiplyByTranslation(matrix, translation, boxModelMatrix)

Thanks for responding, Now I get a different error.

var boxModelMatrix = Cesium.Matrix4();

Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid), new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5), boxModelMatrix);

Uncaught ReferenceError: Matrix4 is not defined ids.html:64

plotROD ids.html:64

(anonymous function) ids.html:144

n jquery-1.7.1.min.js:2

o.fireWith jquery-1.7.1.min.js:2

w jquery-1.7.1.min.js:4

d jquery-1.7.1.min.js:4

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

}

});

viewer.zoomTo(entity);

http://cesiumjs.org/2015/02/02/Visualizing-Spatial-Data/

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);

http://cesiumjs.org/2015/02/02/Visualizing-Spatial-Data/

I will try to re-code my app using the new version.