将模型从3dStudioMax导入THREE.js

And*_*rea 13 3d 3dsmax three.js

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

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

Rog*_*ger 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


cdi*_*ins 6

下面是一个MAXScript脚本,它将选定对象的网格转换为JSON.在本文发布时,它可以在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
Run Code Online (Sandbox Code Playgroud)