使用 JavaScript 解析 .obj 3D 图形文件
我有一个问题。我知道使用 JavaScript 解析 .obj 3D 图形文件是不可能的,我们必须将其转换为其他格式(最好是 JSON)。但我想知道为什么?为什么我们无法使用 JavaScript 解析 .obj 文件?
我非常感谢您的评论和回答。
谢谢 维克
I have a question. I know that its not possible to parse .obj 3D graphics file using JavaScript and we have to convert it into some other format (preferably JSON). But I want to know why? Why we can't parse .obj file using JavaScript?
I would really appreciate your comments and answers.
Thanks
Vik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然可以...为什么不呢?这是一个文本文件,只需继续解析它即可。
在这里,我什至可以让你开始:
Sure you can... why not? It's a text file, just go ahead and parse it.
Here, I'll even get you started:
当然可以。我什至编写了自己的用于解析 3D 格式的库 - K3D.js。它还支持 MD2、3DS 和 Collada。 OBJ 是最容易编码的:)
Of course you can. I have even written my own library for parsing 3D formats - K3D.js. It also supports MD2, 3DS and Collada. OBJ was the easiest to code :)
现在有一些 Javascript 库可以读取 Wavefront OBJ 文件。这个效果很好,但只读取 OBJ 文件而不输出它们 https://www .npmjs.com/package/obj-file-parser。您还可以使用 Three.js 执行此操作: https://thirdjs.org/docs /#examples/en/loaders/OBJLoader。
There are now a few Javascript libraries to read Wavefront OBJ files. This one works well, though only reads OBJ files and does not output them https://www.npmjs.com/package/obj-file-parser. You can also do this with three.js: https://threejs.org/docs/#examples/en/loaders/OBJLoader.