【问题标题】:React360 Entity exampleReact360 实体示例
【发布时间】:2020-01-17 02:47:32
【问题描述】:

我正在尝试在 react360 项目中使用 3d 对象。我按照setup docs 中的步骤操作。使用react-360 init Hello360 命令创建了一个项目,并使用npm start 启动了服务器。

另外,下载this obj model,放入static_assets文件夹。然后,将Entity 标签放入index.js 以显示对象。整个index.js如下。

import React from 'react';
import {
  AppRegistry,
  Entity,
  asset
} from 'react-360';

export default class Hello360 extends React.Component {
  render() {
    return (
      <Entity source={{ obj: asset('stickman.obj') }} />
    );
  }
};

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

因此,我在浏览器中除了背景图像之外什么都看不到。我做错了什么?

【问题讨论】:

    标签: virtual-reality react-360


    【解决方案1】:

    React360 docs Entity page 缺少导入部分。像this blog 一样导入Entity 解决了这个问题。

    import React from 'react';
    import {
      AppRegistry,
      asset,
    } from 'react-360';
    
    import Entity from 'Entity';
    
    ...
    

    【讨论】:

    • 您确定,文档不正确吗?很奇怪。如果是,您应该向社区提出问题。
    • “不正确”不是这种情况的正确词。实际上,该文档页面中没有用于导入实体的代码示例。我编辑了我的答案。我猜,the community is aware of the problem
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多