React Native和THREE.js(WebGL库)集成 [英] React Native and THREE.js (WebGL library) integration

查看:1314
本文介绍了React Native和THREE.js(WebGL库)集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个使用React Web和React Native的项目。我已经实现了一个React Web组件,该组件允许您从OBJ,MTL和图像文件中加载3D模型,一旦加载了模型,您就可以对其进行编辑,在其上粘贴3D标签并填充内容,最后将您编辑的3D模型保存回服务器,而我的实现在幕后使用THREE.js。

I'm working on a project where we are using React Web and React Native. I already implemented a React Web component which allows you to load 3D models from OBJ, MTL and image files, once the model is loaded you can edit it, attach 3D labels on it and stuff, and finally save your edited 3D model back into the server, and my implementation uses THREE.js behind the scenes.

现在,下一步是能够从服务器检索这些文件并渲染编辑的3D模型在React Native应用程序(移动设备)中。所以我的问题是:我应该怎么做呢?我当时在考虑使用一些嵌入式Web视图来响应本机,以便可以从React Web组件中重用尽可能多的代码,然后以某种方式在Web视图与本机应用程序之间实现某种通信,但是我不是

Now, the next step is to be able to retrieve these files from the server and render the edited 3D Model within a React Native app (mobile). So my question is: how should I go about doing this? I was thinking of using some embedded web view for react native so that I could reuse as much code as possible from the React Web component, and then somehow implement some sort of communication between the web view and the native app but I'm not very sure about how to actually implement this.

到目前为止,我已经做过一些研究,发现以下内容:

I've done some research so far and what I found is the following:

适用于React的本地WebView webview和本机应用程序之间的桥梁

通过阅读这些页面,我感到自己想要做的事也许是可行的,但我仍然不确定如何实际实施。如何使React Web组件驻留在Webview中,然后如何使注入的代码与WebView中Web组件的内部工作交互?

By reading those pages I got a sense that what I want to do might be doable but I am still not really sure about how to actually implement this. How do I make the React Web component live inside a Webview, and then how do I make the injected code interact with the inner workings of my web component inside the WebView?

如果我的预期方法不可行,是否有其他方法可以在React Native应用程序中本地渲染3D模型,希望它具有与THREE.js相当的高抽象水平(某种类似于THREE.js的库React Native)?

If my intended approach turns out not being feasible, is there any alternative approaches to render a 3D model natively in a React Native app, hopefully with a high level of abstraction comparable to that of THREE.js (some sort of THREE-like library for React Native)?

推荐答案

Expo (通过create-react-native-app创建应用的框架)具有 GLView ,它提供对本机OpenGL的访问。

Expo, the framework in which an app is created via create-react-native-app has a GLView which provides access native OpenGL.

有一个在博览会中使用Three.js的教程

这篇关于React Native和THREE.js(WebGL库)集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆