如何解决Expo-Three在网络上加载多维数据集,但在Android上不加载
我正在尝试使用expo-three 3绘制一个简单的动画立方体。
以下代码适用于网络,但不适用于android。
在Android上,它仅显示backgroundColor
屏幕,而我还没有找出原因。
import * as React from "react";
import { View,StyleSheet } from "react-native";
import Constants from "expo-constants";
import { GLView } from "expo-gl";
import { TextureLoader,THREE } from "expo-three";
import ExpoTHREE from "expo-three";
export default class App extends React.Component {
constructor(props) {
super(props);
}
_onGLContextCreate = async (gl) => {
this.scene = new THREE.Scene();
this.camera = new THREE.Camera(
75,gl.drawingBufferWidth / gl.drawingBufferHeight,0.1,1000
);
this.scene.add(this.camera);
this.renderer = new ExpoTHREE.Renderer({ gl });
this.geometry = new THREE.BoxGeometry(1,1,1);
this.material = new THREE.MeshBasicMaterial({
color: 0xff0000,});
this.obj = new THREE.Mesh(this.geometry,this.material);
this.edges = new THREE.EdgesGeometry(this.geometry);
this.scene.add(this.obj);
this.animate();
};
animate = () => {
requestAnimationFrame(this.animate);
this.obj.rotation.x += 0.01;
this.obj.rotation.y += 0.01;
this.renderer.render(this.scene,this.camera);
};
render = () => {
return (
<View style={styles.container}>
<GLView
style={{ width: 100,height: 100 }}
onContextCreate={this._onGLContextCreate}
/>
</View>
);
};
}
const styles = StyleSheet.create({
container: {
flex: 1,justifyContent: "center",paddingTop: Constants.statusBarHeight,backgroundColor: "#111111",padding: 8,},});
我的包裹信息如下
{
"dependencies": {
"expo": "^38.0.9","expo-gl": "8.3.1","expo-graphics": "^1.1.0","expo-three": "^5.5.1","expo-three-ar": "^0.0.0","react": "~16.11.0","react-dom": "~16.11.0","react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz","react-native-web": "0.11.7","three": "^0.119.1"
},"devDependencies": {
"@babel/core": "7.9.0","@types/react": "~16.9.41","@types/react-dom": "~16.9.8","@types/react-native": "~0.62.13","typescript": "^3.4.5"
},"scripts": {
"start": "expo start","android": "expo start --android","ios": "expo start --ios","web": "expo web","eject": "expo eject"
},"private": true
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。