@@ -63,6 +63,7 @@ module.exports.Component = registerComponent('cursor', {
6363 this . fuseTimeout = undefined ;
6464 this . cursorDownEl = null ;
6565 this . intersectedEl = null ;
66+ this . activeXRInputs = new Set ( ) ;
6667 this . canvasBounds = document . body . getBoundingClientRect ( ) ;
6768 this . isCursorDown = false ;
6869
@@ -88,6 +89,19 @@ module.exports.Component = registerComponent('cursor', {
8889 this . updateMouseEventListeners ( ) ;
8990 } ,
9091
92+ tick : function ( ) {
93+ if ( this . data . rayOrigin === 'xrselect' && this . el . sceneEl . frame ) {
94+ var inputSource = Array . from ( this . activeXRInputs ) . pop ( ) ;
95+ if ( inputSource ) {
96+ this . onMouseMove ( {
97+ inputSource : inputSource ,
98+ type : 'fakeselectmove' ,
99+ frame : this . el . sceneEl . frame
100+ } ) ;
101+ }
102+ }
103+ } ,
104+
91105 play : function ( ) {
92106 this . addEventListeners ( ) ;
93107 } ,
@@ -210,6 +224,12 @@ module.exports.Component = registerComponent('cursor', {
210224 var point ;
211225 var top ;
212226
227+ var frame ;
228+ var inputSource ;
229+ var referenceSpace ;
230+ var pose ;
231+ var transform ;
232+
213233 camera . parent . updateMatrixWorld ( ) ;
214234
215235 // Calculate mouse position based on the canvas element
@@ -225,12 +245,13 @@ module.exports.Component = registerComponent('cursor', {
225245 mouse . x = ( left / bounds . width ) * 2 - 1 ;
226246 mouse . y = - ( top / bounds . height ) * 2 + 1 ;
227247
228- if ( this . data . rayOrigin === 'xrselect' && evt . type === 'selectstart' ) {
229- const frame = evt . frame ;
230- const inputSource = evt . inputSource ;
231- const referenceSpace = this . el . renderer . xr . getReferenceSpace ( ) ;
232- const pose = frame . getPose ( inputSource . targetRaySpace , referenceSpace ) ;
233- const transform = pose . transform ;
248+ if ( this . data . rayOrigin === 'xrselect' && ( evt . type === 'selectstart' || evt . type === 'fakeselectmove' ) ) {
249+ frame = evt . frame ;
250+ inputSource = evt . inputSource ;
251+ this . activeXRInputs . add ( inputSource ) ;
252+ referenceSpace = this . el . renderer . xr . getReferenceSpace ( ) ;
253+ pose = frame . getPose ( inputSource . targetRaySpace , referenceSpace ) ;
254+ transform = pose . transform ;
234255 direction . set ( 0 , 0 , - 1 ) ;
235256 direction . applyQuaternion ( transform . orientation ) ;
236257 origin . copy ( transform . position ) ;
@@ -310,6 +331,10 @@ module.exports.Component = registerComponent('cursor', {
310331 this . cursorDownEl . emit ( EVENTS . MOUSEUP , this . intersectedEventDetail ) ;
311332 }
312333
334+ if ( data . rayOrigin === 'xrselect' ) {
335+ this . activeXRInputs . delete ( evt . inputSource ) ;
336+ }
337+
313338 if ( ( ! data . fuse || data . rayOrigin === 'mouse' || data . rayOrigin === 'xrselect' ) &&
314339 this . intersectedEl && this . cursorDownEl === this . intersectedEl ) {
315340 this . twoWayEmit ( EVENTS . CLICK ) ;
0 commit comments