Skip to content

Commit b11e46a

Browse files
authored
Merge pull request mrdoob#16365 from takahirox/SessionEvent
Dispatch start/endSession event on entering/existing immersive mode
2 parents d770e0a + 72e4a33 commit b11e46a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Diff for: src/renderers/webvr/WebVRManager.js

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @author mrdoob / http://mrdoob.com/
33
*/
44

5+
import { EventDispatcher } from '../../core/EventDispatcher.js';
56
import { Group } from '../../objects/Group.js';
67
import { Matrix4 } from '../../math/Matrix4.js';
78
import { Vector2 } from '../../math/Vector2.js';
@@ -82,6 +83,8 @@ function WebVRManager( renderer ) {
8283

8384
animation.start();
8485

86+
scope.dispatchEvent( { type: 'sessionstart' } );
87+
8588
} else {
8689

8790
if ( scope.enabled ) {
@@ -92,6 +95,8 @@ function WebVRManager( renderer ) {
9295

9396
animation.stop();
9497

98+
scope.dispatchEvent( { type: 'sessionend' } );
99+
95100
}
96101

97102
}
@@ -416,4 +421,6 @@ function WebVRManager( renderer ) {
416421

417422
}
418423

424+
Object.assign( WebVRManager.prototype, EventDispatcher.prototype );
425+
419426
export { WebVRManager };

Diff for: src/renderers/webvr/WebXRManager.js

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @author mrdoob / http://mrdoob.com/
33
*/
44

5+
import { EventDispatcher } from '../../core/EventDispatcher.js';
56
import { Group } from '../../objects/Group.js';
67
import { Matrix4 } from '../../math/Matrix4.js';
78
import { Vector4 } from '../../math/Vector4.js';
@@ -12,6 +13,8 @@ import { setProjectionFromUnion } from './WebVRUtils.js';
1213

1314
function WebXRManager( renderer ) {
1415

16+
var scope = this;
17+
1518
var gl = renderer.context;
1619

1720
var session = null;
@@ -90,6 +93,8 @@ function WebXRManager( renderer ) {
9093
renderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830
9194
animation.stop();
9295

96+
scope.dispatchEvent( { type: 'sessionend' } );
97+
9398
}
9499

95100
function onRequestReferenceSpace( value ) {
@@ -99,6 +104,8 @@ function WebXRManager( renderer ) {
99104
animation.setContext( session );
100105
animation.start();
101106

107+
scope.dispatchEvent( { type: 'sessionstart' } );
108+
102109
}
103110

104111
this.setFramebufferScaleFactor = function ( value ) {
@@ -321,4 +328,6 @@ function WebXRManager( renderer ) {
321328

322329
}
323330

331+
Object.assign( WebXRManager.prototype, EventDispatcher.prototype );
332+
324333
export { WebXRManager };

0 commit comments

Comments
 (0)