我知道THREE.js有各種3D圖形格式的導入器。從3dStudioMax導入模型到THREE.js
是否有適合顯示在3dStudioMax中創建的模型的導入器?如果沒有一個,有沒有辦法將一個3dStudioMax模型轉換爲可以在THREE.js中導入的東西?
我知道THREE.js有各種3D圖形格式的導入器。從3dStudioMax導入模型到THREE.js
是否有適合顯示在3dStudioMax中創建的模型的導入器?如果沒有一個,有沒有辦法將一個3dStudioMax模型轉換爲可以在THREE.js中導入的東西?
下面是一個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
我在一段時間內沒有使用three.js,但我知道它導入了OBJ,哪些3dsmax可以輕鬆導出,並且有一個將.obj轉換爲three.js .json網格的python腳本。
我注意到,在最新版本中有一個直接適用於json格式的MaxScript Exporter,所以從此開始。它應該基於所選網格生成.js文件,但目前無法訪問PC以進行測試。
你有兩個選擇:
1)使用ThreeJSExporter.ms但考慮到不再編程和維持:
https://github.com/mrdoob/three.js/tree/master/utils/exporters/max
2)(推薦)使用OBJ 3DS Max中的導出器選項。在three.js所的Github上
https://github.com/mrdoob/three.js/blob/master/utils/converters/obj/convert_obj_three.py
更詳細的信息在我的問題:然後使用可在這裏convert_obj_three.py腳本
可以使用3DS文件格式保存文件最大。打開3ds模型 與A3dsViewer。單擊工具欄上的導出到HTML5,然後您將可以在瀏覽器中預覽模型。
順便說一下,這將是一個很好的問題提出的3D stackexchange在http://area51.stackexchange.com/proposals/5022/3d-graphics-modeling-applications。 – cdiggins