Game Development Reference
In-Depth Information
The
start
function initializes the
BsplineInterpolation
object, and it calculates
the interpolates and stores them in its
position
array. In the next line, we simply
copy its value to the
grenadePositions
array. Then, the
start
function loads the
left hand and grenade JSON models.
function start() {
...
var splineInterpolation=new BSplineInterpolation(grenadeControlPoin
ts);
grenadePositions=splineInterpolation.position;
...
loadStageObject("model/weapons/leftHand.json",[0.0,20.0,-
150.0],0.0,0.0,0.0);
loadStageObject("model/weapons/grenade.json",[0.0,20.0,-
150.0],0.0,0.0,0.0);
...
}
The
loadStageObject
function checks the loaded object type, and then
creates the objects for
LeftHand
and
Grenade
. The
leftHand
object's property
grenadeCallback
is initialized with a reference of the
initializeGrenade
function
of our main code. It is invoked once the hand animations have been executed.
function
loadStageObject(url,location,rotationX,rotationY,rotationZ){
...
else if(nameOfObject=="leftHand"){
stageObject=new LeftHand();
leftHand=stageObject;
leftHand.grenadeCallback=initializeGrenade;
}
...
else if(nameOfObject=="grenade"){
stageObject=new Grenade();
grenade=stageObject;
}
...
}