javascript - View 中的 React-360 相机位置

标签 javascript css reactjs react-native react-360

与渲染 View 相比,我想将相机 View 设置得更高。但是我不知道在渲染 View 时在哪里可以设置初始相机位置。

我的组件是这样挂载的:

import {ReactInstance} from 'react-360-web';

function init(bundle, parent, options = {}) {
  const r360 = new ReactInstance(bundle, parent, {
    // Add custom options here
    fullScreen: true,
    ...options,
  });

  // Render your app content to the default cylinder surface
  r360.renderToSurface(
    r360.createRoot('Hello360', { /* initial props */ }),
    r360.getDefaultSurface()
  );
}

window.React360 = {init};

组件看起来像这样:

export default class Hello360 extends React.Component {
  // Our component will keep track of this state
  state = {
    count: 0,
  };
  render() {
    return (
      <View style={styles.panel}>
        <View style={styles.greetingBox}>
          <Text style={styles.greeting}>
            Hello React
          </Text>
          <Text style={styles.greeting}>
            {`Count: ${this.state.count}`}
          </Text>
        </View>
      </View>
    );
  }
};

const styles = StyleSheet.create({
  panel: {
    // Fill the entire surface
    width: 1000,
    height: 600,
    backgroundColor: 'rgba(255, 255, 255, 0.4)',
    alignItems: 'center',
    justifyContent: 'center'
  }
});

AppRegistry.registerComponent('Hello360', () => Hello360);

我尝试将 transform 属性添加到 styles 元素,但这不起作用。在此示例中,如何更改相机相对于已安装的 Hello360 组件的位置?

最佳答案

您可以像这样将相机位置设置得更高(在 client.js 的 init 中):

r360._cameraPosition = [0, 3, 0]; //[x, y, z], default ist [0, 0, 0]

https://github.com/facebook/react-360/blob/master/React360/js/ReactInstance.js

关于javascript - View 中的 React-360 相机位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50220845/

相关文章:

php - 未定义索引 : command

javascript - 除非文件是图像,否则如何防止使用 Multer 上传文件?

javascript - 使用新功能 AJAX 重新加载页面

javascript - 用于创建和编辑的 Redux 表单

javascript - 如何在 ReactJS 中使用适当的、可测试的事件处理程序制作可重用的组件

javascript - JavaScript 中的事件循环和 Node.js 中的异步非阻塞 I/O 有什么区别?

javascript - 使用 javascript 对实时数字进行乘法和格式化

css - Logo 未显示在标题 img 顶部

javascript - 在 React 中,根据之前和当前的 props,在哪里设置状态?

css - drupal..如何修改内容中显示的登录或注册样式