Last active
April 12, 2018 01:46
-
-
Save burin/ec24c8efd3060043820af5cd914ecba2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Expo from 'expo'; | |
import React from 'react'; | |
import * as THREE from 'three'; | |
import ExpoTHREE from 'expo-three'; | |
console.disableYellowBox = true; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<Expo.GLView | |
style={{ flex: 1 }} | |
/> | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Expo from 'expo'; | |
import React from 'react'; | |
import * as THREE from 'three'; | |
import ExpoTHREE from 'expo-three'; | |
console.disableYellowBox = true; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<Expo.GLView | |
style={{ flex: 1 }} | |
onContextCreate={this._onGLContextCreate} | |
/> | |
); | |
} | |
_onGLContextCreate = async (gl) => { | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera( | |
75, gl.drawingBufferWidth / gl.drawingBufferHeight, 0.1, 1000); | |
const renderer = ExpoTHREE.createRenderer({ gl }); | |
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight); | |
const geometry = new THREE.BoxGeometry(1, 1, 1); | |
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); | |
const cube = new THREE.Mesh(geometry, material); | |
scene.add(cube); | |
camera.position.z = 5; | |
const animate = () => { | |
requestAnimationFrame(animate); | |
renderer.render(scene, camera); | |
gl.endFrameEXP(); | |
} | |
animate(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Expo from 'expo'; | |
import React from 'react'; | |
import * as THREE from 'three'; | |
import ExpoTHREE from 'expo-three'; | |
console.disableYellowBox = true; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<Expo.GLView | |
style={{ flex: 1 }} | |
onContextCreate={this._onGLContextCreate} | |
/> | |
); | |
} | |
_onGLContextCreate = async (gl) => { | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera( | |
75, gl.drawingBufferWidth / gl.drawingBufferHeight, 0.1, 1000); | |
const renderer = ExpoTHREE.createRenderer({ gl }); | |
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight); | |
const geometry = new THREE.BoxGeometry(1, 1, 1); | |
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); | |
const cube = new THREE.Mesh(geometry, material); | |
scene.add(cube); | |
camera.position.z = 5; | |
const animate = () => { | |
requestAnimationFrame(animate); | |
cube.rotation.x += 0.07; | |
cube.rotation.y += 0.04; | |
renderer.render(scene, camera); | |
gl.endFrameEXP(); | |
} | |
animate(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Expo from 'expo'; | |
import React from 'react'; | |
import * as THREE from 'three'; | |
import ExpoTHREE from 'expo-three'; | |
console.disableYellowBox = true; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<Expo.GLView | |
ref={(ref) => this._glView = ref} | |
style={{ flex: 1 }} | |
onContextCreate={this._onGLContextCreate} | |
/> | |
); | |
} | |
_onGLContextCreate = async (gl) => { | |
const arSession = await this._glView.startARSessionAsync(); | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera( | |
75, gl.drawingBufferWidth / gl.drawingBufferHeight, 0.1, 1000); | |
const renderer = ExpoTHREE.createRenderer({ gl }); | |
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight); | |
scene.background = ExpoTHREE.createARBackgroundTexture(arSession, renderer); | |
const geometry = new THREE.BoxGeometry(0.07, 0.07, 0.07); | |
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); | |
const cube = new THREE.Mesh(geometry, material); | |
cube.position.z = -0.4; | |
scene.add(cube); | |
const animate = () => { | |
requestAnimationFrame(animate); | |
cube.rotation.x += 0.07; | |
cube.rotation.y += 0.04; | |
renderer.render(scene, camera); | |
gl.endFrameEXP(); | |
} | |
animate(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Expo from 'expo'; | |
import React from 'react'; | |
import * as THREE from 'three'; | |
import ExpoTHREE from 'expo-three'; | |
console.disableYellowBox = true; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<Expo.GLView | |
ref={(ref) => this._glView = ref} | |
style={{ flex: 1 }} | |
onContextCreate={this._onGLContextCreate} | |
/> | |
); | |
} | |
_onGLContextCreate = async (gl) => { | |
const width = gl.drawingBufferWidth; | |
const height = gl.drawingBufferHeight; | |
const arSession = await this._glView.startARSessionAsync(); | |
const scene = new THREE.Scene(); | |
const camera = ExpoTHREE.createARCamera(arSession, width, height, 0.01, 1000); | |
const renderer = ExpoTHREE.createRenderer({ gl }); | |
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight); | |
scene.background = ExpoTHREE.createARBackgroundTexture(arSession, renderer); | |
// Edit the box dimensions here and see changes immediately! | |
const geometry = new THREE.BoxGeometry(0.07, 0.07, 0.07); | |
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); | |
const cube = new THREE.Mesh(geometry, material); | |
cube.position.z = -0.4; | |
scene.add(cube); | |
const animate = () => { | |
requestAnimationFrame(animate); | |
cube.rotation.x += 0.07; | |
cube.rotation.y += 0.04; | |
renderer.render(scene, camera); | |
gl.endFrameEXP(); | |
} | |
animate(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment