javascript - OBJ 到 Json 到浏览器不工作

标签 javascript three.js .obj

我已使用此 python 脚本将 OBJ 3d 模型转换为 .js 文件:

python convert_obj_three.py -i infile.obj -o outfile.js

但现在我在将 3D 模型实现到我的 html 中时遇到问题。我不确定加载 .js 文件或 .obj 是否有效需要什么样的脚本。任何帮助表示赞赏。谢谢!

最佳答案

您应该检查转换器脚本的版本是否与您正在使用的 Three.js 版本使用的 json 格式版本兼容。

无论如何,您可能可以直接在 Three.js 中直接加载 .obj 文件:查看 loader obj example

loader obj example

如果您确实必须将 .obj 转换为 .json 文件,另一个快速的选项就是:

  1. 加载three.js editor在选项卡中
  2. 将 .obj 文件拖入其中(并根据需要进行缩放/变换)
  3. 通过文件 > 导出对象导出 .json 文件,或者通过文件 > 发布从编辑器中获取整个 Three.js 项目

关于javascript - OBJ 到 Json 到浏览器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41590607/

相关文章:

Three.js Vector.angleTo : How to also get the bigger value

c - 将 C .obj 文件链接到 Delphi 应用程序,解析标准 C 依赖项

javascript - 将对象注入(inject)到服务函数中

javascript - 在 angularjs 中停止选项卡更改上的 $interval

javascript - Three.js Globe 中的 HTML 元素

javascript - 使用 Web Worker 时未加载缓冲区几何网格

使用 GNU make 和 Microsoft Visual Studio 编译器编译 .obj 文件中的所有 .c 文件

python - 有没有办法更改 Pygame 中导入的 .obj 文件的位置和大小?

javascript - 将 JavaScript 函数分配给变量的效果

javascript - 如何找到 Canvas 创建的文本的中心位置坐标?