File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { Component , Type } from '@wonderlandengine/api' ;
2
+ import { property } from '@wonderlandengine/api/decorators.js' ;
2
3
3
4
/**
4
5
* Sets the target framerate
@@ -18,23 +19,23 @@ import {Component, Type} from '@wonderlandengine/api';
18
19
*/
19
20
export class TargetFramerate extends Component {
20
21
static TypeName = 'target-framerate' ;
21
- static Properties = {
22
- framerate : { type : Type . Float , default : 90.0 } ,
23
- } ;
22
+
23
+ @ property . float ( 90.0 )
24
+ framerate ! : number ;
24
25
25
26
onActivate ( ) {
26
- this . engine . onXRSessionStart . add ( this . onSessionStartCallback ) ;
27
+ this . engine . onXRSessionStart . add ( this . setTargetFramerate ) ;
27
28
}
28
29
29
30
onDeactivate ( ) {
30
- this . engine . onXRSessionStart . remove ( this . onSessionStartCallback ) ;
31
+ this . engine . onXRSessionStart . remove ( this . setTargetFramerate ) ;
31
32
}
32
33
33
- setTargetFramerate = ( s ) => {
34
- if ( s . supportedFrameRates && s . updateTargetFrameRate ) {
35
- const a = this . engine . xr . session . supportedFrameRates ;
34
+ setTargetFramerate = ( s : XRSession ) => {
35
+ if ( s . supportedFrameRates ) {
36
+ const a = s . supportedFrameRates ;
36
37
a . sort ( ( a , b ) => Math . abs ( a - this . framerate ) - Math . abs ( b - this . framerate ) ) ;
37
- this . engine . xr . session . updateTargetFrameRate ( a [ 0 ] ) ;
38
+ s . updateTargetFrameRate ( a [ 0 ] ) ;
38
39
}
39
40
} ;
40
41
}
You can’t perform that action at this time.
0 commit comments