Skip to content

Commit 555b0e2

Browse files
committed
Added ability to scale axis independantly
1 parent 14e6f9f commit 555b0e2

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

v3/src/gameobjects/sprite3d/Sprite3D.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,34 @@ var Sprite3D = new Class({
2020

2121
this.size = new Vector2(1, 1);
2222

23+
this.adjustScaleX = true;
24+
this.adjustScaleY = true;
25+
2326
this._visible = true;
2427
},
2528

2629
project: function (camera)
2730
{
31+
var pos = this.position;
2832
var gameObject = this.gameObject;
2933

30-
camera.project(this.position, gameObject);
34+
camera.project(pos, gameObject);
35+
36+
var scale = camera.getPointSize(pos, this.size);
3137

32-
var scale = camera.getPointSize(this.position, this.size);
38+
if (this.adjustScaleX)
39+
{
40+
gameObject.scaleX = scale.x;
41+
}
42+
43+
if (this.adjustScaleY)
44+
{
45+
gameObject.scaleY = scale.y;
46+
}
3347

34-
gameObject.setScale(scale.x, scale.y).setDepth(gameObject.z);
48+
gameObject.setDepth(gameObject.z);
3549

36-
gameObject.setVisible((this.position.z > camera.z));
50+
gameObject.setVisible((pos.z > camera.z));
3751
},
3852

3953
visible: {

0 commit comments

Comments
 (0)