i am trying to loop through my scene graph with a draw function, this function is meant to take the world matrix and multiples it by the local matrix. i believe that i need to call the function recursively so that it work through the tree.
so far my function looks like so
draw(pContext, pWorldTransformMatrix)
{
var newTransformMatrix = new Matrix()
newTransformMatrix = pWorldTransformMatrix.multiply(this.mMatrix);
newTransformMatrix.setTransform(pContext);
// var child = new sceneGraph();
for (var x =0; x<this.getNumberOfChildren(); x+=1)
{
var child = this.getChildAt(x);
// child = this.getChildAt(x);
child.draw(pContext, newTransformMatrix);
}
}
i am getting the error
TypeError: Cannot read property 'draw' of undefined at sceneGraph.draw (\adir.hull.ac.uk\home\528\528986\Desktop\500085 2DCGAS\lab\js\sceneGraph.js:39:20)
the at sceneGraph.draw
is repeated 7 times which i believe to be each node within the tree.
is this error coming from my function? and if so how would i think the error?