我正在尝试创建一个使用React的web应用程序,并使用Samsung运行它。
在我的场景中,在VR模式下,我看不到默认的白点(VR指针)。因此,"onInput“和"onClick”等方法不起作用。如果我在VR模式之外查看相同的场景,即使使用Gear VR中提供的浏览器,同样的方法也能很好地工作。
我是不是遗漏了什么?在齿轮虚拟现实中,如何在虚拟现实模式下访问这些方法?
示例代码,在正常的web浏览器(包括齿轮虚拟现实中的),但不是当我在虚拟现实。
<Text
style={{
// backgroundColor: '#777879',
fontSize: 0.2,
transform: [{translate: [0, 0, -5]}],
color: this.state.textColor
}}
onEnter={() => this.setState({textColor: 'gold'})}
onExit={() => this.setState({textColor: 'white'})}>
This text will turn gold when you look at it.
</Text>发布于 2017-07-06 12:30:52
您需要添加一个光线播音器:
要做到这一点,您需要执行以下操作:
在您的项目中,请访问<project root>/vr/client.js。就在init方法之前,添加一个SimpleRaycaster常量。
const SimpleRaycaster = {
getType: () => "simple",
getRayOrigin: () => [0, 0, 0],
getRayDirection: () => [0, 0, -1],
drawsCursor: () => true
};
function init(bundle, parent, options) {
//...然后,在init方法中,设置cursorVisibility: visible并将raycaster添加到raycasters数组中
function init(bundle, parent, options) {
const vr = new VRInstance(bundle, 'Example', parent, {
raycasters: [
SimpleRaycaster // Add SimpleRaycaster to the options
],
cursorVisibility: "visible", // Add cursorVisibility
enableHotReload: true,
...options,
});
vr.render = function() {
// Any custom behavior you want to perform on each frame goes here
};
// Begin the animation loop
vr.start();
return vr;
}
window.ReactVR = {init};就这样。现在,您应该在视图的中间有一个白点。
https://stackoverflow.com/questions/44259273
复制相似问题