Is it acceptable to update values outside of the animate()
loop?
Could updating values outside the loop impact render performance?
The potential drawback is that some updates might not be fully completed until the next animate call.
Are there any other disadvantages that I should consider?
function animate() {
requestAnimationFrame( animate )
updatePositions()
}
vs.
function animate() {
requestAnimationFrame( animate )
}
function onWebSocketUpdate() {
updatePositions()
}
An alternative perspective:
onWebSocketUpdate(data) {
// Option 1
// WebSocket directly applies the update
model.update(data)
// Option 2
// WebSocket saves data to a buffer
buffer.push(data)
// When animate() runs, it retrieves buffered data
model.update(buffer.pop())
}