Skip to content

Commit c7ba86b

Browse files
committed
react -> react-native: babylonjs Drag and drop component works on Android
1 parent e037acd commit c7ba86b

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@babylonjs/core": "5.1.0",
2828
"@babylonjs/gui": "5.1.0",
2929
"@babylonjs/loaders": "5.1.0",
30-
"@flyskywhy/react-native-gcanvas": "5.0.0",
30+
"@flyskywhy/react-native-gcanvas": "5.0.1",
3131
"@githubprimer/octicons-react": "^8.5.0",
3232
"@react-navigation/native": "^6.0.10",
3333
"@react-navigation/native-stack": "6.6.2",

src/dragNdrop.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import { Engine, Scene } from 'react-babylonjs';
2+
import { View } from 'react-native';
3+
import { Engine, Scene } from 'react-native-babylonjs';
34
import { Vector3, Color3 } from '@babylonjs/core';
45

56
// start copy from https://www.babylonjs.com/demos/dragndrop/dragdrop.js
@@ -8,11 +9,9 @@ const validateDrag = (targetPosition) => {
89
return Math.max(Math.abs(targetPosition.x), Math.abs(targetPosition.z)) <= (GROUND_SIZE / 2) - 10; // should be -15 for torus
910
}
1011

11-
function dragNdrop() {
12+
function dragNdrop() {
1213
return (
13-
<div>
14-
<div className="row">
15-
<div className="col-xs-12 col-md-12">
14+
<View style={{flex: 1}}>
1615
<Engine antialias={true} engineOptions={{preserveDrawingBuffer:true, stencil:true}} canvasId="sample-canvas">
1716
<Scene clearColor={new Color3(0, 0, 0)}>
1817
<pointLight name='omni' position={new Vector3(0, 50, 0)} />
@@ -45,9 +44,7 @@ function dragNdrop() {
4544
</torus>
4645
</Scene>
4746
</Engine>
48-
</div>
49-
</div>
50-
</div>
47+
</View>
5148
);
5249
}
5350

0 commit comments

Comments
 (0)