我正在使用React VR开发一个应用程序,并且我已经用搅拌器创建了一个3D pokeball。我已将其导出为Wavefront .obj
文件,并在我的React VR应用程序中使用它。
在控制台中我看到了这个警告:
THREE.MeshBasicMaterial
:shininess
,emissive
和specular
不是此资料的属性。
您可以在下面找到我的代码:
import React from 'react';
import { AppRegistry, asset, StyleSheet, Pano, Text, View, Mesh } from 'react-vr';
class pokemongo extends React.Component {
render() {
return (
<View>
<Pano source={asset('sky.jpg')} />
<Mesh source={{ mesh: asset('pokeball.obj'), mtl: asset('pokeball.mtl') }}
style={{ height: 1 }}
transform={{ rotate: '0 90 0' }}></Mesh>
</View>
);
}
};
AppRegistry.registerComponent('pokemongo', () => pokemongo);
这是渲染输出
在this GitHub Gist上,您可以找到obj
和mtl
文件,可以下载blend
文件。
在这里你可以在Blender看到我的pokeball。
我在互联网上搜索过,但没有找到与React VR相关问题的解决方案或文档。
我做错了什么?
答案 0 :(得分:6)
react-vr > 0.2.1
与Github issue州相比,这不再是问题。
此外,如果您希望使用颜色和阴影渲染模型,则需要将一些灯光应用到场景中。这是通过在模型上启用lit
道具并使用场景中的AmbientLight
,SpotLight
或DirectionalLight
组件来完成的。
import React from "react";
import {
AppRegistry,
asset,
Pano,
View,
Model,
AmbientLight,
SpotLight
} from "react-vr";
class pokemongo extends React.Component {
render() {
return (
<View>
<Pano source={asset("chess-world.jpg")} />
<AmbientLight intensity={0.5} />
<SpotLight
intensity={1}
style={{ transform: [{ translate: [-5, 5, 0] }] }}
/>
<Model
source={{
obj: asset("pokeball.obj"),
mtl: asset("pokeball.mtl")
}}
style={{
layoutOrigin: [0.5, 0.5],
transform: [
{ translate: [0, 0, -10] }
]
}}
lit={true}
/>
</View>
);
}
}
AppRegistry.registerComponent("pokemongo", () => pokemongo);
对于旋转动画,您可以查看ModelSample以了解它是如何制作的。