Added Sprite3D.fastHide option and tidied up the Camera3D matrix transform

This commit is contained in:
Richard Davey 2017-09-19 00:00:24 +01:00
parent df0c457b0d
commit d6fe678966
2 changed files with 19 additions and 1 deletions

View file

@ -166,7 +166,7 @@ var Camera3D = new Class({
children[i].position.transformMat4(mat4);
}
return this.update();
return this.updateChildren();
},
/**

View file

@ -25,12 +25,25 @@ var Sprite3D = new Class({
this.adjustScaleX = true;
this.adjustScaleY = true;
this.fastHide = true;
this._visible = true;
},
// Performs a simple check to see if this Sprite3D object should be hidden from view if its
// z position is behind the cameras. Very fast but doesn't take camera direction into consideration,
// so not suitable for all types of game.
setFastHide: function (value)
{
this.fastHide = value;
return this;
},
project: function (camera)
{
var pos = this.position;
var gameObject = this.gameObject;
camera.project(pos, gameObject);
@ -48,6 +61,11 @@ var Sprite3D = new Class({
}
gameObject.setDepth(gameObject.z);
if (this.fastHide)
{
gameObject.setVisible(pos.z > camera.position.z);
}
},
visible: {