如何将 ASCII JSON 3D 模型文件转换为二进制?
在研究一些 webGL 示例(主要是基于 Three.js 的示例)时,我注意到大型模型是通过 ASCII+二进制 JSON 的组合加载的。这种方法对我来说非常有吸引力,因为它减少了文件大小。 ASCII JSON 的一般格式为(取自 Three.js 示例,webgl_geometry_large_mesh.html):
{
"metadata" :
{
"formatVersion" : 3,
"sourceFile" : "lucy100k.obj",
"generatedBy" : "OBJConverter",
"vertices" : 50002,
"faces" : 100000,
"normals" : 0,
"uvs" : 0,
"materials" : 0
},
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "default"
}],
"buffers": "Lucy100k_bin.bin"
}
如上所示,不是包含大量顶点、法线、UV 等的部分,而是全部打包到引用的二进制文件中文件。有谁知道如何创建该二进制文件?我可以用搅拌机做吗?如果没有,有我可以使用的脚本吗?
谢谢
While looking into some webGL examples (mostly Three.js based examples) I noticed large models are loaded via a combination of ASCII+binary JSON. This approach is very attractive to me because of the reduced file size.
The ASCII JSON has the general format of (taken from Three.js example, webgl_geometry_large_mesh.html) :
{
"metadata" :
{
"formatVersion" : 3,
"sourceFile" : "lucy100k.obj",
"generatedBy" : "OBJConverter",
"vertices" : 50002,
"faces" : 100000,
"normals" : 0,
"uvs" : 0,
"materials" : 0
},
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "default"
}],
"buffers": "Lucy100k_bin.bin"
}
As seen above, instead of a section containing a truck-load of vertices, normals, UVs, etc it is all packed into the referred binary file. Does anyone know how to create that binary file? Can I do it with Blender? If not, is there a script I can use?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这一行:
该文件是由 OBJConverter 生成的(来自一些 .obj 和 .mtl 文件)。
OBJConverter
是一个名为convert_obj_third.py
的 Python 脚本,位于Three.js / utils / converters / obj
中。自己的脚本有一个关于“如何使用 Blender 获取正确的 OBJ + MTL 文件”的评论。
According to this line:
That file was generated by
OBJConverter
(from some .obj and .mtl files).OBJConverter
is a Python script calledconvert_obj_three.py
sited inthree.js / utils / converters / obj
.The own script has a comment about "How to get proper OBJ + MTL files with Blender".