Skip to content

Commit 989e3e6

Browse files
committed
Swapped to use RGB objects
1 parent 82c8ada commit 989e3e6

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

src/gameobjects/mesh/MeshLight.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
var Class = require('../../utils/Class');
8+
var RGB = require('../../display/RGB');
89
var Vector3 = require('../../math/Vector3');
910

1011
/**
@@ -23,9 +24,32 @@ var MeshLight = new Class({
2324
function MeshLight (x, y, z)
2425
{
2526
this.position = new Vector3(x, y, z);
26-
this.ambient = new Vector3(1, 1, 1);
27-
this.diffuse = new Vector3(1, 1, 1);
28-
this.specular = new Vector3(1, 1, 1);
27+
this.ambient = new RGB(1, 1, 1);
28+
this.diffuse = new RGB(1, 1, 1);
29+
this.specular = new RGB(1, 1, 1);
30+
31+
// cache structure = position
32+
this.dirtyCache = [ 0, 0, 0 ];
33+
},
34+
35+
isDirty: function ()
36+
{
37+
var position = this.position;
38+
var dirtyCache = this.dirtyCache;
39+
40+
var x = position.x;
41+
var y = position.y;
42+
var z = position.z;
43+
44+
var xCached = dirtyCache[0];
45+
var yCached = dirtyCache[1];
46+
var zCached = dirtyCache[2];
47+
48+
dirtyCache[0] = x;
49+
dirtyCache[1] = y;
50+
dirtyCache[2] = z;
51+
52+
return (xCached !== x || yCached !== y || zCached !== z);
2953
},
3054

3155
setPosition: function (x, y, z)

0 commit comments

Comments
 (0)