Skip to content

Commit

Permalink
react -> react-native: babylonjs Drag and drop component works on A…
Browse files Browse the repository at this point in the history
…ndroid
  • Loading branch information
flyskywhy committed Dec 21, 2022
1 parent e037acd commit c7ba86b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@babylonjs/core": "5.1.0",
"@babylonjs/gui": "5.1.0",
"@babylonjs/loaders": "5.1.0",
"@flyskywhy/react-native-gcanvas": "5.0.0",
"@flyskywhy/react-native-gcanvas": "5.0.1",
"@githubprimer/octicons-react": "^8.5.0",
"@react-navigation/native": "^6.0.10",
"@react-navigation/native-stack": "6.6.2",
Expand Down
13 changes: 5 additions & 8 deletions src/dragNdrop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Engine, Scene } from 'react-babylonjs';
import { View } from 'react-native';
import { Engine, Scene } from 'react-native-babylonjs';
import { Vector3, Color3 } from '@babylonjs/core';

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

function dragNdrop() {
function dragNdrop() {
return (
<div>
<div className="row">
<div className="col-xs-12 col-md-12">
<View style={{flex: 1}}>
<Engine antialias={true} engineOptions={{preserveDrawingBuffer:true, stencil:true}} canvasId="sample-canvas">
<Scene clearColor={new Color3(0, 0, 0)}>
<pointLight name='omni' position={new Vector3(0, 50, 0)} />
Expand Down Expand Up @@ -45,9 +44,7 @@ function dragNdrop() {
</torus>
</Scene>
</Engine>
</div>
</div>
</div>
</View>
);
}

Expand Down

0 comments on commit c7ba86b

Please sign in to comment.