Skip to content

Commit 9cf6e7e

Browse files
greggmanphemavax
authored andcommitted
make update option work in lots-o-objects
1 parent 1c45ac8 commit 9cf6e7e

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lots-o-objects/lots-o-objects-draw-elements.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,23 @@ function createApp(gl, settings) {
180180

181181
twgl.resizeCanvasToDisplaySize(gl.canvas);
182182

183-
// Make the camera rotate around the scene.
184-
eyePosition[0] = Math.sin(clock * g_eyeSpeed) * g_eyeRadius;
185-
eyePosition[1] = g_eyeHeight;
186-
eyePosition[2] = Math.cos(clock * g_eyeSpeed) * g_eyeRadius;
183+
if (settings.update) {
184+
// Make the camera rotate around the scene.
185+
eyePosition[0] = Math.sin(clock * g_eyeSpeed) * g_eyeRadius;
186+
eyePosition[1] = g_eyeHeight;
187+
eyePosition[2] = Math.cos(clock * g_eyeSpeed) * g_eyeRadius;
187188

188-
// --Update Instance Positions---------------------------------------
189-
var advance = elapsedTime / 2;
190-
for (var ii = 0; ii < g_numObjects; ++ii) {
191-
var instance = instances[ii];
192-
instance.xClock += advance * instance.xClockSpeed;
193-
instance.yClock += advance * instance.yClockSpeed;
194-
instance.zClock += advance * instance.zClockSpeed;
195-
instance.x = Math.sin(instance.xClock) * instance.xRadius;
196-
instance.y = Math.sin(instance.yClock) * instance.yRadius;
197-
instance.z = Math.cos(instance.zClock) * instance.zRadius;
189+
// --Update Instance Positions---------------------------------------
190+
const advance = elapsedTime / 2;
191+
for (let ii = 0; ii < g_numObjects; ++ii) {
192+
var instance = instances[ii];
193+
instance.xClock += advance * instance.xClockSpeed;
194+
instance.yClock += advance * instance.yClockSpeed;
195+
instance.zClock += advance * instance.zClockSpeed;
196+
instance.x = Math.sin(instance.xClock) * instance.xRadius;
197+
instance.y = Math.sin(instance.yClock) * instance.yRadius;
198+
instance.z = Math.cos(instance.zClock) * instance.zRadius;
199+
}
198200
}
199201
}
200202

0 commit comments

Comments
 (0)