2011-10-28 52 views
12

我知道THREE.js有各种3D图形格式的导入器。从3dStudioMax导入模型到THREE.js

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

+0

顺便说一下,这将是一个很好的问题提出的3D stackexchange在http://area51.stackexchange.com/proposals/5022/3d-graphics-modeling-applications。 – cdiggins

回答

6

下面是一个MAXScript脚本,它将选定对象的网格转换为JSON。在这篇文章发布时,它在Google代码托管的3ds Max developer community的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 
2

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

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

1

可以使用3DS文件格式保存文件最大。打开3ds模型 与A3dsViewer。单击工具栏上的导出到HTML5,然后您将可以在浏览器中预览模型。