Skip to content

Commit 2e032ba

Browse files
committed
Factor out a truncated upper bound
1 parent cd1ed07 commit 2e032ba

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

v3/src/gameobjects/mesh/Mesh.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ var Mesh = new Class({
4040
throw new Error('Phaser: Vertex count must match UV count');
4141
}
4242

43-
if (colors.length > 0 && colors.length < ((vertices.length / 2)|0))
43+
var verticesUB = (vertices.length / 2) | 0;
44+
45+
if (colors.length > 0 && colors.length < verticesUB)
4446
{
4547
throw new Error('Phaser: Color count must match Vertex count');
4648
}
4749

48-
if (alphas.length > 0 && alphas.length < ((vertices.length / 2)|0))
50+
if (alphas.length > 0 && alphas.length < verticesUB)
4951
{
5052
throw new Error('Phaser: Alpha count must match Vertex count');
5153
}
@@ -54,15 +56,15 @@ var Mesh = new Class({
5456

5557
if (colors.length === 0)
5658
{
57-
for (i = 0; i < (vertices.length / 2)|0; ++i)
59+
for (i = 0; i < verticesUB; ++i)
5860
{
5961
colors[i] = 0xFFFFFF;
6062
}
6163
}
6264

6365
if (alphas.length === 0)
6466
{
65-
for (i = 0; i < (vertices.length / 2)|0; ++i)
67+
for (i = 0; i < verticesUB; ++i)
6668
{
6769
alphas[i] = 1.0;
6870
}

0 commit comments

Comments
 (0)