This class inherits the Sprite
class. The objective of the class is twofold:
Set the position of the sprite at a delta distance from the model so that it moves with the model
Set the orientation of the sprite to face the camera
Open the ModelSprite.js
file from client/primitive/game
in your editor. The constructor takes two parameters: the model
object (the sprite has to be associated with) and the camera
object:
ModelSprite= inherit(Sprite, function (model,cam){ superc(this); this.model=model; this.camera=cam; this.scale=vec3.fromValues(8,8,8); //The relative values to the model position
The delta distance from the model is initialized to zero as shown in the following code snippet:
this.deltaX=0; this.deltaY=0; this.deltaZ=0; });
We have overridden the update
function of the StageObject
class:
ModelSprite.prototype.update=function(){
We have discussed on numerous occasions that the model matrix is the inverse of the camera matrix. Hence, we set...