Skip to content

Commit 95be8b8

Browse files
committed
type improvements and integration of sem default synthetic environments
1 parent e65695d commit 95be8b8

File tree

9 files changed

+52
-51
lines changed

9 files changed

+52
-51
lines changed

.github/workflows/alpha.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ jobs:
4949
uses: gittools/actions/gitversion/execute@v0
5050

5151
- name: Build
52-
run: |
53-
pnpm -r copy
54-
pnpm -F './packages/**/*' build
52+
run: pnpm -F './packages/**/*' build
5553

5654
- name: Copy README
5755
run: cp ./README.md packages/react/xr

.github/workflows/packages.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ jobs:
4949
uses: gittools/actions/gitversion/execute@v0
5050

5151
- name: Build
52-
run: |
53-
pnpm -r copy
54-
pnpm -F './packages/**/*' build
52+
run: pnpm -F './packages/**/*' build
5553

5654
- name: Copy README
5755
run: cp ./README.md packages/react/xr

.github/workflows/static.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ jobs:
3535

3636
# Examples
3737
- name: Building Examples
38-
run: |
39-
pnpm -r copy
40-
pnpm -r build
38+
run: pnpm -r build
4139

4240
- name: Copy Examples
4341
run: |

packages/xr/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"license": "SEE LICENSE IN LICENSE",
2222
"scripts": {
2323
"build": "tsc",
24-
"copy": "node -e \"require('fs').copyFile(require('path').resolve(__dirname, './node_modules/@iwer/sem/captures/office_small.json'), require('path').resolve(__dirname, './src/default-environment.json'), () => {})\"",
2524
"check:prettier": "prettier --check src",
2625
"check:eslint": "eslint 'src/**/*.ts'",
2726
"fix:prettier": "prettier --write src",
@@ -34,10 +33,10 @@
3433
"three": "*"
3534
},
3635
"dependencies": {
37-
"@iwer/devui": "^1.1.0",
38-
"@iwer/sem": "~0.2.2",
36+
"@iwer/devui": "^1.1.1",
37+
"@iwer/sem": "~0.2.4",
3938
"@pmndrs/pointer-events": "workspace:~",
40-
"iwer": "^2.0.0",
39+
"iwer": "^2.0.1",
4140
"meshline": "^3.3.1",
4241
"zustand": "^4.5.2"
4342
},

packages/xr/src/controller/gamepad.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type XRControllerGamepadComponentId =
1111
| `xr-standard-thumbstick`
1212
| `xr-standard-trigger`
1313
| `thumbrest`
14-
| string
14+
| (string & {})
1515

1616
export type XRControllerGamepadComponentState = {
1717
state: 'default' | 'touched' | 'pressed'
@@ -24,10 +24,7 @@ export type XRControllerGamepadComponentState = {
2424
const ButtonTouchThreshold = 0.05
2525
const AxisTouchThreshold = 0.1
2626

27-
export type XRControllerGamepadState = Record<
28-
XRControllerGamepadComponentId,
29-
XRControllerGamepadComponentState | undefined
30-
>
27+
export type XRControllerGamepadState = Record<string, XRControllerGamepadComponentState | undefined>
3128

3229
export function updateXRControllerGamepadState(
3330
target: XRControllerGamepadState,

packages/xr/src/controller/layout.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type XRControllerVisualResponse = {
1818
)
1919

2020
export type XRControllerComponent = {
21-
type: 'trigger' | 'squeeze' | 'touchpad' | 'thumbstick' | 'button' | string
21+
type: 'trigger' | 'squeeze' | 'touchpad' | 'thumbstick' | 'button' | (string & {})
2222
gamepadIndices: {
2323
[Key in 'button' | 'xAxis' | 'yAxis']?: number
2424
}

packages/xr/src/emulate.ts

+25-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { DevUI } from '@iwer/devui'
33
import type { XRDeviceOptions } from 'iwer/lib/device/XRDevice'
44
import { Euler, Quaternion, Vector3, Vector3Tuple, Vector4Tuple } from 'three'
55
import { SyntheticEnvironmentModule } from '@iwer/sem'
6-
import defaultEnvironment from './default-environment.json' assert { type: 'json' }
76

87
const configurations = { metaQuest3, metaQuest2, metaQuestPro, oculusQuest1 }
98

@@ -15,6 +14,22 @@ export type EmulatorTransformationOptions = {
1514
quaternion?: Quaternion | Vector4Tuple
1615
}
1716

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+
1833
export type EmulatorOptions =
1934
| EmulatorType
2035
| ({
@@ -24,7 +39,7 @@ export type EmulatorOptions =
2439
inject?: boolean | { hostname: string }
2540
controller?: Partial<Record<XRHandedness, EmulatorTransformationOptions>>
2641
hand?: Partial<Record<XRHandedness, EmulatorTransformationOptions>>
27-
syntheticEnvironment?: null | boolean | JSON | string
42+
syntheticEnvironment?: null | boolean | JSON | (string & {}) | DefaultSyntheticEnvironment
2843
} & Partial<Pick<XRDeviceOptions, 'ipd' | 'fovy' | 'stereoEnabled' | 'canvasContainer'>>)
2944

3045
const handednessList: Array<XRHandedness> = ['left', 'none', 'right']
@@ -53,9 +68,15 @@ export function emulate(options: EmulatorOptions) {
5368
return xrdevice
5469
}
5570

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+
5677
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])
5980
return xrdevice
6081
}
6182

packages/xr/src/plane.ts

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import { Box2, BufferGeometry, Shape, ShapeGeometry, Vector2 } from 'three'
22

3-
declare global {
4-
type XRSemanticLabel = 'desk' | 'couch' | 'floor' | 'ceiling' | 'wall' | 'door' | 'window' | 'other' | string
5-
interface XRPlane {
6-
semanticLabel?: XRSemanticLabel
7-
}
8-
interface XRMesh {
9-
semanticLabel?: XRSemanticLabel
10-
}
11-
}
12-
133
export function updateXRPlaneGeometry(
144
plane: XRPlane,
155
geometry: (BufferGeometry & { createdAt?: number }) | undefined,

pnpm-lock.yaml

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)