Skip to content

Commit 25173d0

Browse files
committed
Add missing changes to App.tsx
1 parent 1bfa3fd commit 25173d0

File tree

1 file changed

+8
-9
lines changed
  • Apps/Playground/playground-shared

1 file changed

+8
-9
lines changed

Apps/Playground/playground-shared/App.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React, { useState, FunctionComponent, useEffect, useCallback } from 'reac
99
import { SafeAreaView, StatusBar, Button, View, Text, ViewProps, Image } from 'react-native';
1010

1111
import { EngineView, useEngine, EngineViewCallbacks } from '@babylonjs/react-native';
12-
import { Scene, Vector3, ArcRotateCamera, Camera, WebXRSessionManager, SceneLoader, TransformNode, DeviceSourceManager, DeviceType, DeviceSource, PointerInput, WebXRTrackingState, Nullable } from '@babylonjs/core';
12+
import { Scene, Vector3, ArcRotateCamera, Camera, WebXRSessionManager, SceneLoader, TransformNode, DeviceSourceManager, DeviceType, PointerInput, WebXRTrackingState, IMouseEvent } from '@babylonjs/core';
1313
import '@babylonjs/loaders';
1414
import Slider from '@react-native-community/slider';
1515

@@ -40,24 +40,23 @@ const EngineScreen: FunctionComponent<ViewProps> = (props: ViewProps) => {
4040
setRootNode(rootNode);
4141

4242
const deviceSourceManager = new DeviceSourceManager(engine);
43-
const handlePointerInput = (inputIndex: PointerInput, previousState: Nullable<number>, currentState: Nullable<number>) => {
44-
if (inputIndex === PointerInput.Horizontal &&
45-
currentState && previousState) {
46-
rootNode.rotate(Vector3.Down(), (currentState - previousState) * 0.005);
43+
const handlePointerInput = (event: IMouseEvent) => {
44+
if (event.inputIndex === PointerInput.Move && event.movementX) {
45+
rootNode.rotate(Vector3.Down(), event.movementX * 0.005);
4746
};
4847
};
4948

5049
deviceSourceManager.onDeviceConnectedObservable.add(device => {
5150
if (device.deviceType === DeviceType.Touch) {
52-
const touch: DeviceSource<DeviceType.Touch> = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
51+
const touch = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
5352
touch.onInputChangedObservable.add(touchEvent => {
54-
handlePointerInput(touchEvent.inputIndex, touchEvent.previousState, touchEvent.currentState);
53+
handlePointerInput(touchEvent);
5554
});
5655
} else if (device.deviceType === DeviceType.Mouse) {
57-
const mouse: DeviceSource<DeviceType.Mouse> = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
56+
const mouse = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
5857
mouse.onInputChangedObservable.add(mouseEvent => {
5958
if (mouse.getInput(PointerInput.LeftClick)) {
60-
handlePointerInput(mouseEvent.inputIndex, mouseEvent.previousState, mouseEvent.currentState);
59+
handlePointerInput(mouseEvent);
6160
}
6261
});
6362
}

0 commit comments

Comments
 (0)