@@ -30,6 +30,7 @@ import '!!file-loader?name=/vpython_data/[name].[ext]!../vpython_data/wood_textu
3030export var comm
3131var ws = null
3232var isopen = false
33+ var isjupyterlab_vpython = true
3334
3435console . log ( 'START OF GLOWCOMM' )
3536
@@ -819,20 +820,25 @@ function handle_cmds(dcmds) {
819820 case 'local_light' : { glowObjs [ idx ] = local_light ( cfg ) ; break }
820821 case 'distant_light' : { glowObjs [ idx ] = distant_light ( cfg ) ; break }
821822 case 'canvas' : {
822- var container = document . getElementById ( "glowscript" ) ;
823- if ( container !== null ) {
824- window . __context = { glowscript_container : $ ( "#glowscript" ) . removeAttr ( "id" ) }
825- }
826- glowObjs [ idx ] = canvas ( cfg )
827- glowObjs [ idx ] [ 'idx' ] = idx
828- try {
829- glowObjs [ idx ] . wrapper [ 0 ] . addEventListener ( "contextmenu" , function ( event ) {
830- event . preventDefault ( ) ;
831- event . stopPropagation ( ) ;
832- } ) ;
833- }
834- catch ( err ) {
835- console . log ( "glowcomm canvas contextmenu event : " , err . message ) ;
823+ if ( ( typeof isjupyterlab_vpython !== 'undefined' ) && ( isjupyterlab_vpython === true ) ) {
824+ var container = document . getElementById ( "glowscript" ) ;
825+ if ( container !== null ) {
826+ window . __context = { glowscript_container : $ ( "#glowscript" ) . removeAttr ( "id" ) }
827+ }
828+ glowObjs [ idx ] = canvas ( cfg )
829+ glowObjs [ idx ] [ 'idx' ] = idx
830+ try {
831+ glowObjs [ idx ] . wrapper [ 0 ] . addEventListener ( "contextmenu" , function ( event ) {
832+ event . preventDefault ( ) ;
833+ event . stopPropagation ( ) ;
834+ } ) ;
835+ }
836+ catch ( err ) {
837+ console . log ( "glowcomm canvas contextmenu event : " , err . message ) ;
838+ }
839+ } else {
840+ glowObjs [ idx ] = canvas ( cfg )
841+ glowObjs [ idx ] [ 'idx' ] = idx
836842 }
837843 break
838844 // Display frames per second and render time:
0 commit comments