Skip to content

Commit 42e792e

Browse files
committed
Added createRect method
1 parent a90e788 commit 42e792e

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,45 @@ var Camera3D = new Class({
156156
return output;
157157
},
158158

159+
// Create a bunch of Sprite3D objects in a rectangle
160+
// size and spacing are Vec3s (or if integers are converted to vec3s)
161+
createRect: function (size, spacing, key, frame)
162+
{
163+
if (typeof size === 'number') { size = { x: size, y: size, z: size }; }
164+
if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; }
165+
166+
var quantity = size.x * size.y * size.z;
167+
168+
// var width = size.x * spacing.x;
169+
// var height = size.y * spacing.y;
170+
// var depth = size.z * spacing.z;
171+
172+
var sprites = this.createMultiple(quantity, key, frame);
173+
174+
var i = 0;
175+
176+
for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++)
177+
{
178+
for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++)
179+
{
180+
for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++)
181+
{
182+
var bx = (x * spacing.x);
183+
var by = (y * spacing.y);
184+
var bz = (z * spacing.z);
185+
186+
sprites[i].position.set(bx, by, bz);
187+
188+
i++;
189+
}
190+
}
191+
}
192+
193+
this.update();
194+
195+
return sprites;
196+
},
197+
159198
randomSphere: function (radius, sprites)
160199
{
161200
if (sprites === undefined) { sprites = this.getChildren(); }

0 commit comments

Comments
 (0)