我刚刚开始通过安装初始项目来探索react 360。初始项目始终在用户面前显示初始加载时的文本。我试图使用绝对位置向右移动文本,但在它离开初始表面后,它再也看不到了。我已经看过文档了,但是不清楚。我该怎么办?我是否需要增加表面的宽度,使其围绕整个视图(围绕用户)才能看到该文本?我该怎么做呢?或者是否真的有其他首选的通用技术。我正在寻找解决方案,在过去的2小时内,我没有找到任何解决方案。
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
asset,
VrButton,
Environment,
} from "react-360";
export default class Hello360 extends React.Component {
state = {
name: 'Click me'
}
handleClick = () => {
this.setState({
name: 'You have clicked me'
})
}
componentDidMount() {
Environment.clearBackground();
Environment.setBackgroundImage(asset("360_house.jpg"), { format: "2D" });
}
render() {
return <View style={styles.panel}>
<View style={styles.greetingBox}>
<Text style={styles.greeting}>{this.state.name}</Text>
<VrButton onClick={this.handleClick} style={styles.button}>
<Text style={styles.buttonText}>Click</Text>
</VrButton>
</View>
</View>;
}
};
const styles = StyleSheet.create({
panel: {
// Fill the entire surface
width: 1000,
height: 600,
backgroundColor: 'rgba(255, 255, 255, 0.5)',
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
},
greetingBox: {
padding: 20,
backgroundColor: '#000000',
borderColor: '#639dda',
borderWidth: 2,
},
greeting: {
fontSize: 30,
},
button: {
padding: 20,
backgroundColor: '#000000',
borderColor: '#639dda',
borderWidth: 2,
},
buttonText: {
fontSize: 10,
}
});
AppRegistry.registerComponent('Hello360', () => Hello360);发布于 2019-04-13 05:31:29
正如您所说,您需要增加表面的大小。检查您的client.js文件和relevant surface documentation以确定所需的内容。
这是我实现的,以便能够使用完整的360度作为2D元素的可渲染曲面:
...
import {Surface} from 'react-360-web';
...
const myCylinderSurface = new Surface(
4096, /* width */
720, /* height */
Surface.SurfaceShape.Cylinder /* shape */
);
myCylinderSurface.setDensity(4096); // set density based on webgl limitations doc advice
r360.renderToSurface(
r360.createRoot('myapp'),
myCylinderSurface
);https://stackoverflow.com/questions/52018578
复制相似问题