2011-10-28 48 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,然後您將可以在瀏覽器中預覽模型。