Skip to content

Commit d6fe678

Browse files
committed
Added Sprite3D.fastHide option and tidied up the Camera3D matrix transform
1 parent df0c457 commit d6fe678

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

v3/src/camera/3d/Camera3D.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ var Camera3D = new Class({
166166
children[i].position.transformMat4(mat4);
167167
}
168168

169-
return this.update();
169+
return this.updateChildren();
170170
},
171171

172172
/**

v3/src/gameobjects/sprite3d/Sprite3D.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,25 @@ var Sprite3D = new Class({
2525
this.adjustScaleX = true;
2626
this.adjustScaleY = true;
2727

28+
this.fastHide = true;
29+
2830
this._visible = true;
2931
},
3032

33+
// Performs a simple check to see if this Sprite3D object should be hidden from view if its
34+
// z position is behind the cameras. Very fast but doesn't take camera direction into consideration,
35+
// so not suitable for all types of game.
36+
setFastHide: function (value)
37+
{
38+
this.fastHide = value;
39+
40+
return this;
41+
},
42+
3143
project: function (camera)
3244
{
3345
var pos = this.position;
46+
3447
var gameObject = this.gameObject;
3548

3649
camera.project(pos, gameObject);
@@ -48,6 +61,11 @@ var Sprite3D = new Class({
4861
}
4962

5063
gameObject.setDepth(gameObject.z);
64+
65+
if (this.fastHide)
66+
{
67+
gameObject.setVisible(pos.z > camera.position.z);
68+
}
5169
},
5270

5371
visible: {

0 commit comments

Comments
 (0)