13

我知道 THREE.js 有来自各种 3d 图形格式的导入器。

是否有适合显示在 3dStudioMax 中创建的模型的导入器?如果没有,有没有办法将 3dStudioMax 模型转换为可以在 THREE.js 中导入的东西?

4

5 回答 5

18

你有两个选择:

1)使用 ThreeJSExporter.ms 但考虑到不再维护:

https://github.com/mrdoob/three.js/tree/master/utils/exporters/max

2)(推荐)在 3DS Max 中使用 OBJ 导出器选项。然后使用此处提供的 convert_obj_three.py 脚本:

https://github.com/mrdoob/three.js/blob/master/utils/converters/obj/convert_obj_three.py

我在 Three.js 的 Github 上的问题中提供了更多详细信息:

https://github.com/mrdoob/three.js/issues/893

于 2011-12-23T09:11:40.433 回答
6

下面是将选定对象的网格转换为 JSON 的 MAXScript 脚本。在撰写本文时,它已在 Google 代码托管的3ds Max 开发人员社区的 SVN 中可用。

tmesh = snapshotAsMesh selection[1]
out_file = createfile "$scripts\\output.json

num_faces = tmesh.numfaces
num_verts = tmesh.numverts 

fn PrintPoint pt = (
 format "%, %, %, " pt.x pt.y pt.z to:out_file
)   

fn PrintPointUV pt = (
 format "%, %, " pt.x pt.y to:out_file
)   

fn PrintPointInt pt = (
    x = int(pt.x) - 1
    y = int(pt.y) - 1
    z = int(pt.z) - 1
    format "%, %, %, " x y z to:out_file
)   

format "{\n" to:out_file

-- Vertex Positions 
-- format "    \"vertexPositions\" : [" to:out_file
format "    positions : [" to:out_file
for i = 1 to num_verts do
(
 vert = getVert tmesh i
 PrintPoint vert
)
format "],\n" to:out_file

-- Vertex Normals
-- format "    \"vertexNormals\" : [" to:out_file
format "    normals : [" to:out_file
for i = 1 to num_verts do
(
  vert = getNormal tmesh i
  PrintPoint vert
)
format "],\n" to:out_file

-- Vertex Texture Coordinates 
-- format "    \"vertexTextureCoords\" : [" to:out_file
format "    uv : [" to:out_file
for i = 1 to num_faces do
(
    -- Iterate over faces 
    tvface = getTVFace tmesh i
    for j = 1 to 3 do (
        -- Get a specific texture vertex
        tvert = getTVert tmesh tvface[j]        
        PrintPointUV tvert
    )
)
format "],\n" to:out_file

-- Face Indexes
-- format "    \"indices\" : [" to:out_file
format "    indices : [" to:out_file
for f = 1 to num_faces do
(
   face = getFace tmesh f
   PrintPointInt face
)
format "],\n" to:out_file

format "}" to:out_file

close out_file
delete tmesh
edit out_name
于 2011-10-30T13:07:32.463 回答
2

我有一段时间没有使用three.js,但我知道它会导入3dsmax 可以轻松导出的OBJ,并且有一个python 脚本可以将.obj 转换为three.js .json 网格。

我注意到在最新版本中有一个直接转换为 json 格式的MaxScript 导出器,所以从它开始。它应该基于所选网格生成一个 .js 文件,但目前无法访问 PC 进行测试。

于 2011-10-29T17:36:13.603 回答
1

您可以使用 3ds 文件格式保存 max 文件。使用A3dsViewer打开 3ds 模型。单击工具栏中的导出到 HTML5,您将能够在浏览器中预览模型。

于 2013-12-23T08:28:09.450 回答
0

现在在 2018 年,我们确实有glTF和一个非常好的 3ds max 导出器,由巴比伦社区开发和积极维护:

在此处输入图像描述

描述和如何安装在这里广泛描述:

https://doc.babylonjs.com/resources/3dsmax_to_gltf

然后可以在 three.js 中轻松使用 gltf 模型,请参阅一些示例:

https://threejs.org/examples/webgl_loader_gltf.html

https://threejs.org/examples/#misc_exporter_gltf

享受!

于 2018-11-28T22:16:07.007 回答