@@ -7,6 +7,8 @@ define(["jupyter-js-widgets", "underscore", "three"],
7
7
require ( "./examples/js/controls/OrbitControls.js" ) ;
8
8
require ( "./examples/js/controls/MomentumCameraControls.js" ) ;
9
9
require ( "./examples/js/controls/TrackballControls.js" ) ;
10
+ var $ = require ( "jquery" ) ;
11
+
10
12
var Detector = require ( "./examples/js/Detector.js" ) ;
11
13
12
14
var RendererView = widgets . DOMWidgetView . extend ( {
@@ -495,8 +497,10 @@ define(["jupyter-js-widgets", "underscore", "three"],
495
497
this . model . on ( 'change:root' , this . change_root , this ) ;
496
498
this . change_root ( this . model , this . model . get ( 'root' ) ) ;
497
499
this . options . dom . addEventListener ( this . model . get ( 'event' ) , function ( event ) {
498
- var mouseX = ( ( event . pageX - this . offsetLeft ) / that . options . dom . getBoundingClientRect ( ) . width ) * 2 - 1 ;
499
- var mouseY = - ( ( event . pageY - this . offsetTop ) / that . options . dom . getBoundingClientRect ( ) . height ) * 2 + 1 ;
500
+ var offset = $ ( this ) . offset ( ) ;
501
+ var $el = $ ( that . options . dom ) ;
502
+ var mouseX = ( ( event . pageX - offset . left ) / $el . width ( ) ) * 2 - 1 ;
503
+ var mouseY = - ( ( event . pageY - offset . top ) / $el . height ( ) ) * 2 + 1 ;
500
504
var vector = new THREE . Vector3 ( mouseX , mouseY , that . options . renderer . camera . obj . near ) ;
501
505
502
506
vector . unproject ( that . options . renderer . camera . obj ) ;
0 commit comments