Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09f7766

Browse files
author
Nikolay Grozdanov
committed
Render AnchorCubes
1 parent 1274220 commit 09f7766

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

App.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { View, Text } from 'magic-script-components';
3+
import AnchorCube from './anchor-cube.js';
34

45
import { authorize } from 'react-native-app-auth';
56
import { NativeModules } from 'react-native';
@@ -118,7 +119,8 @@ class MyApp extends React.Component {
118119
<View name='main-view'>
119120
{ scenes.length === 0
120121
? (<Text text='Initializing ...' />)
121-
: scenes.map( scene => <Text key={scene.uuid} anchorUuid={scene.uuid} textSize={0.1} textColor={[1, 0, 0, 1]} text={scene.pcfId} />)
122+
// : scenes.map( scene => <Text key={scene.uuid} anchorUuid={scene.uuid} textSize={0.1} textColor={[1, 0, 0, 1]} text={scene.pcfId} />)
123+
: scenes.map( scene => <AnchorCube key={scene.uuid} uuid={scene.uuid} id={scene.pcfId} />)
122124
}
123125
</View>
124126
);

anchor-cube.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { View, Line, Text } from 'magic-script-components';
3+
4+
const red = [1, 0, 0, 1];
5+
const green = [0, 1, 0, 1];
6+
const blue = [0, 0, 1, 1];
7+
const vecStart = [0, 0, 0];
8+
const length = 0.25;
9+
10+
// props:
11+
// - id
12+
// - uuid
13+
14+
export default function (props) {
15+
const uuid = props.uuid;
16+
const vecX = [vecStart, [length, 0, 0]];
17+
const vecY = [vecStart, [0, length, 0]];
18+
const vecZ = [vecStart, [0, 0, length]];
19+
20+
return (
21+
<View anchorUuid={uuid}>
22+
<Line points={vecX} color={red} />
23+
<Line points={vecY} color={green} />
24+
<Line points={vecZ} color={blue} />
25+
<Text textSize={0.02} text={props.id} textColor={red}/>
26+
</View>
27+
);
28+
}

0 commit comments

Comments
 (0)