Skip to content

Commit 32786ac

Browse files
committed
Added x, y, z getters and setters and removed some test code.
1 parent a03922d commit 32786ac

2 files changed

Lines changed: 67 additions & 30 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ var Camera3D = new Class({
165165

166166
var quantity = size.x * size.y * size.z;
167167

168-
// var width = size.x * spacing.x;
169-
// var height = size.y * spacing.y;
170-
// var depth = size.z * spacing.z;
171-
172168
var sprites = this.createMultiple(quantity, key, frame);
173169

174170
var i = 0;
@@ -499,8 +495,12 @@ var Camera3D = new Class({
499495
var brx = tmp.x;
500496
var bry = tmp.y;
501497

502-
var w = Math.abs(brx - tlx);
503-
var h = Math.abs(bry - tly);
498+
// var w = Math.abs(brx - tlx);
499+
// var h = Math.abs(bry - tly);
500+
501+
// Allow the projection to get negative ...
502+
var w = brx - tlx;
503+
var h = bry - tly;
504504

505505
return out.set(w, h);
506506
},

v3/src/gameobjects/sprite3d/Sprite3D.js

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

28-
this.fastHide = true;
29-
3028
this._visible = true;
3129
},
3230

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-
4331
project: function (camera)
4432
{
4533
var pos = this.position;
@@ -50,21 +38,28 @@ var Sprite3D = new Class({
5038

5139
camera.getPointSize(pos, this.size, this.scale);
5240

53-
if (this.adjustScaleX)
41+
if (this.scale.x <= 0 || this.scale.y <= 0)
5442
{
55-
gameObject.scaleX = this.scale.x;
43+
gameObject.setVisible(false);
5644
}
57-
58-
if (this.adjustScaleY)
59-
{
60-
gameObject.scaleY = this.scale.y;
61-
}
62-
63-
gameObject.setDepth(gameObject.z);
64-
65-
if (this.fastHide)
45+
else
6646
{
67-
gameObject.setVisible(pos.z > camera.position.z);
47+
if (!gameObject.visible)
48+
{
49+
gameObject.setVisible(true);
50+
}
51+
52+
if (this.adjustScaleX)
53+
{
54+
gameObject.scaleX = this.scale.x;
55+
}
56+
57+
if (this.adjustScaleY)
58+
{
59+
gameObject.scaleY = this.scale.y;
60+
}
61+
62+
gameObject.setDepth(gameObject.z * -1);
6863
}
6964
},
7065

@@ -88,6 +83,48 @@ var Sprite3D = new Class({
8883
this.visible = value;
8984

9085
return this;
86+
},
87+
88+
x: {
89+
90+
get: function ()
91+
{
92+
return this.position.x;
93+
},
94+
95+
set: function (value)
96+
{
97+
this.position.x = value;
98+
}
99+
100+
},
101+
102+
y: {
103+
104+
get: function ()
105+
{
106+
return this.position.y;
107+
},
108+
109+
set: function (value)
110+
{
111+
this.position.y = value;
112+
}
113+
114+
},
115+
116+
z: {
117+
118+
get: function ()
119+
{
120+
return this.position.z;
121+
},
122+
123+
set: function (value)
124+
{
125+
this.position.z = value;
126+
}
127+
91128
}
92129

93130
});

0 commit comments

Comments
 (0)