@@ -3,7 +3,6 @@ import { DevUI } from '@iwer/devui'
3
3
import type { XRDeviceOptions } from 'iwer/lib/device/XRDevice'
4
4
import { Euler , Quaternion , Vector3 , Vector3Tuple , Vector4Tuple } from 'three'
5
5
import { SyntheticEnvironmentModule } from '@iwer/sem'
6
- import defaultEnvironment from './default-environment.json' assert { type : 'json' }
7
6
8
7
const configurations = { metaQuest3, metaQuest2, metaQuestPro, oculusQuest1 }
9
8
@@ -15,6 +14,22 @@ export type EmulatorTransformationOptions = {
15
14
quaternion ?: Quaternion | Vector4Tuple
16
15
}
17
16
17
+ export type DefaultSyntheticEnvironment =
18
+ | 'meeting_room'
19
+ | 'living_room'
20
+ | 'music_room'
21
+ | 'office_large'
22
+ | 'office_small'
23
+
24
+ const defaultSyntheticEnvironments : Array < DefaultSyntheticEnvironment > = [
25
+ //default default environment:
26
+ 'office_small' ,
27
+ 'meeting_room' ,
28
+ 'living_room' ,
29
+ 'music_room' ,
30
+ 'office_large' ,
31
+ ]
32
+
18
33
export type EmulatorOptions =
19
34
| EmulatorType
20
35
| ( {
@@ -24,7 +39,7 @@ export type EmulatorOptions =
24
39
inject ?: boolean | { hostname : string }
25
40
controller ?: Partial < Record < XRHandedness , EmulatorTransformationOptions > >
26
41
hand ?: Partial < Record < XRHandedness , EmulatorTransformationOptions > >
27
- syntheticEnvironment ?: null | boolean | JSON | string
42
+ syntheticEnvironment ?: null | boolean | JSON | ( string & { } ) | DefaultSyntheticEnvironment
28
43
} & Partial < Pick < XRDeviceOptions , 'ipd' | 'fovy' | 'stereoEnabled' | 'canvasContainer' > > )
29
44
30
45
const handednessList : Array < XRHandedness > = [ 'left' , 'none' , 'right' ]
@@ -53,9 +68,15 @@ export function emulate(options: EmulatorOptions) {
53
68
return xrdevice
54
69
}
55
70
71
+ if ( typeof syntheticEnvironment === 'string' && defaultSyntheticEnvironments . includes ( syntheticEnvironment as any ) ) {
72
+ //load the selected default environment
73
+ xrdevice . sem ?. loadDefaultEnvironment ( syntheticEnvironment )
74
+ return xrdevice
75
+ }
76
+
56
77
if ( syntheticEnvironment === true || syntheticEnvironment === undefined ) {
57
- //load the default environment
58
- xrdevice . sem ?. loadEnvironment ( defaultEnvironment )
78
+ //load the first default environment
79
+ xrdevice . sem ?. loadDefaultEnvironment ( defaultSyntheticEnvironments [ 0 ] )
59
80
return xrdevice
60
81
}
61
82
0 commit comments