Skip to content

Commit dba84e9

Browse files
committed
Further work on compound speed
1 parent 46b8ec6 commit dba84e9

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

vpython/vpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def _wait(cvs): # wait for an event
392392
cvs._waitfor = None
393393
if _isnotebook: baseObj.trigger() # in notebook environment must send methods immediately
394394
while cvs._waitfor is None:
395-
rate(30)
395+
rate(100)
396396
return cvs._waitfor
397397

398398
class color(object):

vpython/vpython_libraries/glowcomm.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,18 @@ function checkloading() {
118118
function domessage(msg) {
119119
"use strict";
120120
if (timer !== null) clearTimeout(timer)
121-
var t1 = msclock()
121+
var t1 = msclock()
122122
var data = msg.content.data
123123
if (data != 'trigger') {
124124
var msg = decode(data)
125125
handler(msg)
126-
}
127-
var t2 = msclock()
128-
var dt = Math.floor(t1+interval-t2) // attempt to keep the time between renders constant
129-
if (dt < 15) dt = 0 // becaause setTimeout is inaccurate for small dt's
130-
timer = setTimeout(send, dt)
126+
}
127+
if (timer !== null) { // if not a wait situation as with compound/extrusion/text
128+
var t2 = msclock()
129+
var dt = Math.floor(t1+interval-t2) // attempt to keep the time between renders constant
130+
if (dt < 15) dt = 0 // becaause setTimeout is inaccurate for small dt's
131+
timer = setTimeout(send, dt)
132+
}
131133
}
132134

133135
// vpython.py calls onmessage, which responds through domessage, using send
@@ -148,7 +150,7 @@ function onmessage(msg) {
148150
if (timer !== undefined && timer !== null) clearTimeout(timer)
149151

150152
function send() { // periodically send events and update_canvas and request object update
151-
"use strict";
153+
"use strict";
152154
var update = update_canvas()
153155
if (update !== null) events = events.concat(update)
154156
if (events.length === 0) events = [{event:'update_canvas', 'trigger':1}]

0 commit comments

Comments
 (0)