Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
209
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. import React, { Component } from 'react';
  4. import {StyleSheet} from 'react-native';
  5.  
  6. import {
  7. ViroARScene,
  8. ViroText,
  9. ViroBox,
  10. ViroMaterials,
  11. Viro3DObject,
  12. ViroAmbientLight,
  13. ViroSpotLight,
  14. ViroAnimations,
  15. } from 'react-viro';
  16.  
  17. export default class HelloWorldSceneAR extends Component {
  18.  
  19. constructor() {
  20. super();
  21.  
  22. // Set initial state here
  23. this.state = {
  24. text : "Initializing AR...",
  25. counter : 1,
  26. };
  27.  
  28. // bind 'this' to functions
  29. this._onInitialized = this._onInitialized.bind(this);
  30. this._varSave = 0;
  31. }
  32.  
  33. render() {
  34. return (
  35. <ViroARScene onTrackingInitialized={this._onInitialized} >
  36. <ViroText text={this.state.text}
  37. scale={[.2, .2, 0.2]}
  38. position={[0, -.5, -2]}
  39. style={styles.helloWorldTextStyle} />
  40.  
  41. <ViroAmbientLight color={"#aaaaaa"} />
  42. <ViroSpotLight
  43. innerAngle={5} outerAngle={90} direction={[0,-1,-.2]}
  44. position={[0, 3, 1]} color="#ffffff" castsShadow={true} />
  45.  
  46. <ViroBox
  47. position={[0, -.5, -1]}
  48. scale={[.3, .3, .001]}
  49. animation={{name: "rotate", run: true, loop: true}}
  50. materials={["grid"]} />
  51.  
  52.  
  53. </ViroARScene>
  54. );
  55. }
  56. _onInitialized() {
  57. this.setState({
  58. text : "RewardLine.fr"
  59. });
  60. }
  61. }
  62.  
  63. var styles = StyleSheet.create({
  64. helloWorldTextStyle: {
  65. fontFamily: 'Arial',
  66. fontSize: 48,
  67. color: '#ffffff',
  68. textAlignVertical: 'center',
  69. textAlign: 'center',
  70. },
  71. });
  72.  
  73. ViroMaterials.createMaterials({
  74. grid: {
  75. diffuseTexture: require('./res/grid_bg.png'),
  76. },
  77. });
  78.  
  79. ViroAnimations.registerAnimations({
  80. rotate: {
  81. properties: {
  82. rotateY: "+=90"
  83. },
  84. duration: 250, //.25 seconds
  85. },
  86. });
  87.  
  88.  
  89.  
  90. module.exports = HelloWorldSceneAR;
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement