我是react native开发的新手,我面临着一个相当大的问题.
我正在编写一个应用程序,与BLE连接和接收数据.有了这些,我必须制作一个3D element的动画.
我已经正确地完成了BLE连接的所有部分,但现在我在3D部分遇到了麻烦.
我使用REACTION Native without expo,因为我读到EXPO与BLE PLX包不兼容.现在我看到所有的包都带有expo-cli和Three.js.我下载了一个免费的3D模型.obj,但当我试图请求它时,应用程序找不到该文件.
这是我的\src\Model\Three.js
import { GLView } from "expo-gl";
import { View } from "react-native";
import { loadObjAsync, Renderer } from "expo-three";
import { Scene } from "three";
export const Three = (props) => {
async function onContextCreate(gl) {
const renderer = new Renderer({gl});
renderer.setSize(200, 200);
const scene = new Scene();
const obj = await loadObjAsync({
asset: require('./model.obj')
});
scene.add(obj);
// Setup an animation loop
const render = () => {
renderer.render(scene, camera);
gl.endFrameEXP();
};
render();
}
return (
<View>
<GLView onContextCreate={onContextCreate} />
</View>
);
};
在同一个文件夹中,我有mod.obj(\src\Model\Model.obj)
以下是我在Package.json中添加的依赖项
"base64-arraybuffer": "^1.0.1",
"expo-gl": "^10.4.2",
"expo-gl-cpp": "^10.4.1",
"expo-three": "^5.7.0",
"react-native-unimodules": "^0.14.6",
"three": "^0.127.0"
这就是我所得到的
Error: Unable to resolve module ./model.obj from D:\projects\AppName\src\model\three.js:
None of these files exist:
* src\model\model.obj(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)
* src\model\model.obj\index(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)
我跟踪了this comment个人,但没有成功
请救救我!