Skip to content

Commit 275f6e4

Browse files
committed
Moved to sub-folder.
1 parent 14c5aad commit 275f6e4

4 files changed

Lines changed: 113 additions & 99 deletions

File tree

src/gameobjects/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ var GameObjects = {
1313
DisplayList: require('./DisplayList'),
1414
GameObjectCreator: require('./GameObjectCreator'),
1515
GameObjectFactory: require('./GameObjectFactory'),
16-
LightsManager: require('./LightsManager'),
17-
LightsPlugin: require('./LightsPlugin'),
1816
UpdateList: require('./UpdateList'),
1917

2018
Components: require('./components'),
@@ -79,6 +77,11 @@ if (WEBGL_RENDERER)
7977

8078
GameObjects.Creators.Mesh = require('./mesh/MeshCreator');
8179
GameObjects.Creators.Quad = require('./quad/QuadCreator');
80+
81+
GameObjects.Light = require('./lights/List');
82+
83+
require('./lights/LightsManager');
84+
require('./lights/LightsPlugin');
8285
}
8386

8487
module.exports = GameObjects;

src/gameobjects/lights/Light.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2018 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
var Class = require('../../utils/Class');
8+
var Utils = require('../../renderer/webgl/Utils');
9+
10+
var Light = new Class({
11+
12+
initialize:
13+
14+
function Light (x, y, radius, r, g, b, intensity)
15+
{
16+
this.x = x;
17+
this.y = y;
18+
this.radius = radius;
19+
this.r = r;
20+
this.g = g;
21+
this.b = b;
22+
this.intensity = intensity;
23+
this.scrollFactorX = 1.0;
24+
this.scrollFactorY = 1.0;
25+
},
26+
27+
set: function (x, y, radius, r, g, b, intensity)
28+
{
29+
this.x = x;
30+
this.y = y;
31+
this.radius = radius;
32+
this.r = r;
33+
this.g = g;
34+
this.b = b;
35+
this.intensity = intensity;
36+
this.scrollFactorX = 1.0;
37+
this.scrollFactorY = 1.0;
38+
},
39+
40+
setScrollFactor: function (x, y)
41+
{
42+
this.scrollFactorX = x;
43+
this.scrollFactorY = (y === undefined) ? x : y;
44+
return this;
45+
},
46+
47+
setColor: function (rgb)
48+
{
49+
var color = Utils.getFloatsFromUintRGB(rgb);
50+
51+
this.r = color[0];
52+
this.g = color[1];
53+
this.b = color[2];
54+
55+
return this;
56+
},
57+
58+
setIntensity: function (intensity)
59+
{
60+
this.intensity = intensity;
61+
62+
return this;
63+
},
64+
65+
setPosition: function (x, y)
66+
{
67+
this.x = x;
68+
this.y = y;
69+
70+
return this;
71+
},
72+
73+
setRadius: function (radius)
74+
{
75+
this.radius = radius;
76+
77+
return this;
78+
}
79+
80+
});
81+
82+
module.exports = Light;
Lines changed: 25 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,87 +4,16 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7-
var Class = require('../utils/Class');
8-
var Utils = require('../renderer/webgl/Utils');
9-
var LightPipeline = require('../renderer/webgl/pipelines/ForwardDiffuseLightPipeline');
10-
11-
var Light = new Class({
12-
13-
initialize:
14-
15-
function Light (x, y, radius, r, g, b, intensity)
16-
{
17-
this.x = x;
18-
this.y = y;
19-
this.radius = radius;
20-
this.r = r;
21-
this.g = g;
22-
this.b = b;
23-
this.intensity = intensity;
24-
this.scrollFactorX = 1.0;
25-
this.scrollFactorY = 1.0;
26-
},
27-
28-
set: function (x, y, radius, r, g, b, intensity)
29-
{
30-
this.x = x;
31-
this.y = y;
32-
this.radius = radius;
33-
this.r = r;
34-
this.g = g;
35-
this.b = b;
36-
this.intensity = intensity;
37-
this.scrollFactorX = 1.0;
38-
this.scrollFactorY = 1.0;
39-
},
40-
41-
setScrollFactor: function (x, y)
42-
{
43-
this.scrollFactorX = x;
44-
this.scrollFactorY = (y === undefined) ? x : y;
45-
return this;
46-
},
47-
48-
setColor: function (rgb)
49-
{
50-
var color = Utils.getFloatsFromUintRGB(rgb);
51-
52-
this.r = color[0];
53-
this.g = color[1];
54-
this.b = color[2];
55-
56-
return this;
57-
},
58-
59-
setIntensity: function (intensity)
60-
{
61-
this.intensity = intensity;
62-
63-
return this;
64-
},
65-
66-
setPosition: function (x, y)
67-
{
68-
this.x = x;
69-
this.y = y;
70-
71-
return this;
72-
},
73-
74-
setRadius: function (radius)
75-
{
76-
this.radius = radius;
77-
78-
return this;
79-
}
80-
81-
});
7+
var Class = require('../../utils/Class');
8+
var Light = require('./Light');
9+
var LightPipeline = require('../../renderer/webgl/pipelines/ForwardDiffuseLightPipeline');
10+
var Utils = require('../../renderer/webgl/Utils');
8211

8312
var LightsManager = new Class({
8413

8514
initialize:
8615

87-
function LightsManager()
16+
function LightsManager ()
8817
{
8918
this.lightPool = [];
9019
this.lights = [];
@@ -107,25 +36,6 @@ var LightsManager = new Class({
10736
return this;
10837
},
10938

110-
shutdown: function ()
111-
{
112-
while (this.lights.length > 0)
113-
{
114-
this.lightPool.push(this.lights.pop());
115-
}
116-
117-
this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 };
118-
this.culledLights.length = 0;
119-
this.lights.length = 0;
120-
121-
return this;
122-
},
123-
124-
destroy: function ()
125-
{
126-
this.shutdown();
127-
},
128-
12939
cull: function (camera)
13040
{
13141
var lights = this.lights;
@@ -151,7 +61,7 @@ var LightsManager = new Class({
15161
// if lights should be rendered
15262
var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom));
15363
var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom));
154-
var distance = Math.sqrt(dx * dx + dy * dy);
64+
var distance = Math.sqrt(dx * dx + dy * dy);
15565

15666
if (distance < light.radius + cameraRadius)
15767
{
@@ -239,6 +149,25 @@ var LightsManager = new Class({
239149
this.lightPool.push(light);
240150
this.lights.splice(index, 1);
241151
}
152+
},
153+
154+
shutdown: function ()
155+
{
156+
while (this.lights.length > 0)
157+
{
158+
this.lightPool.push(this.lights.pop());
159+
}
160+
161+
this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 };
162+
this.culledLights.length = 0;
163+
this.lights.length = 0;
164+
165+
return this;
166+
},
167+
168+
destroy: function ()
169+
{
170+
this.shutdown();
242171
}
243172

244173
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66

77
var Class = require('../utils/Class');
8-
var PluginManager = require('../plugins/PluginManager');
98
var LightsManager = require('./LightsManager');
9+
var PluginManager = require('../plugins/PluginManager');
1010

1111
var LightsPlugin = new Class({
1212

0 commit comments

Comments
 (0)