@@ -188,7 +188,7 @@ var lastrange = 1
188188var lastautoscale = true
189189var lastsliders = { }
190190var lastkeysdown = [ ]
191- var interval = 33 // milliseconds
191+ var interval = 17 // milliseconds
192192
193193function update_canvas ( ) { // mouse location and other stuff
194194 "use strict" ;
@@ -293,13 +293,17 @@ function send_pick(cvs, p, seg) {
293293 "use strict" ;
294294 var evt = { event : 'pick' , 'canvas' : cvs , 'pick' : p , 'segment' :seg }
295295 events . push ( evt )
296+ if ( timer !== null ) clearTimeout ( timer )
297+ send ( ) // send the info NOW
296298}
297299
298300function send_compound ( cvs , pos , size , up ) {
299301 "use strict" ;
300302 var evt = { event : '_compound' , 'canvas' : cvs , 'pos' : [ pos . x , pos . y , pos . z ] ,
301303 'size' : [ size . x , size . y , size . z ] , 'up' : [ up . x , up . y , up . z ] }
302304 events . push ( evt )
305+ if ( timer !== null ) clearTimeout ( timer )
306+ send ( ) // send the info NOW
303307}
304308
305309var waitfor_canvas = null
@@ -445,7 +449,7 @@ var attrsb = {'a':'userzoom', 'b':'userspin', 'c':'range', 'd':'autoscale', 'e':
445449 'p' :'left' , 'q' :'right' , 'r' :'top' , 's' :'bottom' , 't' :'_cloneid' ,
446450 'u' :'logx' , 'v' :'logy' , 'w' :'dot' , 'x' :'dot_radius' ,
447451 'y' :'markers' , 'z' :'legend' , 'A' :'label' , 'B' :'delta' , 'C' :'marker_color' ,
448- 'D' :'size_units' , 'E' :'userpan' , 'F' :'scroll' }
452+ 'D' :'size_units' , 'E' :'userpan' , 'F' :'scroll' , 'G' : 'choices' }
449453
450454// methods are X in {'m': '23X....'}
451455var methods = { 'a' :'select' , 'b' :'pos' , 'c' :'start' , 'd' :'stop' , 'f' :'clear' , // unused eghijklmnopvxyzCDFAB
@@ -460,7 +464,7 @@ var vecattrs = ['pos', 'up', 'color', 'trail_color', 'axis', 'size', 'origin', '
460464 'marker_color' ]
461465
462466var textattrs = [ 'text' , 'align' , 'caption' , 'title' , 'title_align' , 'xtitle' , 'ytitle' , 'selected' , 'capture' ,
463- 'label' , 'append_to_caption' , 'append_to_title' , 'bind' , 'unbind' , 'pause' , 'GSprint' ]
467+ 'label' , 'append_to_caption' , 'append_to_title' , 'bind' , 'unbind' , 'pause' , 'GSprint' , 'choices' ]
464468
465469// patt gets idx and attr code; vpatt gets x,y,z of a vector
466470var patt = / ( \d + ) ( .) ( .* ) /
@@ -504,8 +508,12 @@ function decode(data) {
504508 vs = [ Number ( val [ 1 ] ) , Number ( val [ 2 ] ) , Number ( val [ 3 ] ) , Number ( val [ 4 ] ) ]
505509 }
506510 } else if ( textattrs . indexOf ( attr ) > - 1 ) {
507- // '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
508- val = m [ 3 ] . replace ( / < b r > / g, "\n" )
511+ if ( attr == 'choices' ) { // menu choices to be wrapped in a list
512+ val = m [ 3 ] . split ( ' ' )
513+ } else {
514+ // '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
515+ val = m [ 3 ] . replace ( / < b r > / g, "\n" )
516+ }
509517 } else if ( attr == 'rotate' ) { // angle,x,y,z,x,y,z
510518 var temp = m [ 3 ]
511519 val = [ ]
@@ -528,6 +536,9 @@ function decode(data) {
528536 }
529537 } else if ( attr == 'waitfor' || attr == 'pause' || attr == 'delete' ) {
530538 val = m [ 3 ]
539+ } else if ( attr == 'follow' ) {
540+ if ( m [ 3 ] == 'None' ) val = null
541+ else val = Number ( m [ 3 ] )
531542 } else val = Number ( m [ 3 ] )
532543 out = { 'idx' :idx , 'attr' :attr , 'val' :val }
533544 if ( datatype == 'attr' ) as . push ( out )
@@ -938,7 +949,8 @@ async function handle_methods(dmeth) {
938949 }
939950 obj . unbind ( val , process_binding )
940951 } else if ( method === "follow" ) {
941- obj . camera . follow ( glowObjs [ val ] )
952+ if ( val === null ) obj . camera . follow ( null )
953+ else obj . camera . follow ( glowObjs [ val ] )
942954 } else if ( method === "capture" ) {
943955 await obj . capture ( val )
944956 } else if ( method === 'waitfor' ) {
@@ -955,7 +967,7 @@ async function handle_methods(dmeth) {
955967 }
956968 process_pause ( )
957969 } else if ( method === 'pick' ) {
958- var p = glowObjs [ val ] . mouse . pick ( ) // wait for pick render; val is canvas
970+ var p = glowObjs [ val ] . mouse . pick ( ) // wait for pick render; val is canvas
959971 var seg = null
960972 if ( p !== null ) {
961973 if ( p instanceof curve ) seg = p . segment
0 commit comments