Threejs怎么将json格式模型,转化为obj格式供max使用

兄弟哪位知道,Threejs怎么将json格式模型,转化为obj格式供max使用
最新回答
长青诗

2024-07-01 04:15:16

//只能写个类来转啦....

#region DataTable 转换为Json字符串实例方法
/// <summary>
/// GetClassTypeJosn 的摘要说明
/// </summary>
public class GetClassTypeJosn : IHttpHandler
{
/// <summary>
/// 文件名:DataTable 和Json 字符串互转
/// 版权所有:Copyright (C) Create Family Wealth liangjw
/// 创建标示:2013-08-03
/// </summary>
//用法说明实例
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Charset = "utf-8";
HttpRequest req = context.Request;
string method = req["method"].ToStr().ToLower();

//获取合同明细列表 DataTable 转换为Json字符串
if (method == "txtdate")
{
string json = "";
BO.MakeContractMx bll = new MakeContractMx();
DataSet ds = bll.GetDataTable();
if (ds.Tables.Count > 0)
{
json =ToJson(ds.Tables[0]);
}
context.Response.Write(json);
return;
}

}

public bool IsReusable
{
get
{
return false;
}
}
}

#endregion

#region Json字符串转换为DataTable 实例方法

public DataTable JsonToDataTable(json)
{
DataTable dt= ToDataTable(json);
return dt;
}

#endregion

#region DataTable 转换为Json 字符串
/// <summary>
/// DataTable 对象 转换为Json 字符串
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public static string ToJson(this DataTable dt)
{
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
ArrayList arrayList = new ArrayList();
foreach (DataRow dataRow in dt.Rows)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>(); //实例化一个参数集合
foreach (DataColumn dataColumn in dt.Columns)
{
dictionary.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToStr());
}
arrayList.Add(dictionary); //ArrayList集合中添加键值
}