新增加载fbx代码 新增测试命令.

pull/7/head
ChenX 7 years ago
parent 14394b86a3
commit 259e74f63f

@ -2,8 +2,11 @@ import { CreateBoardUtil } from "../ApplicationServices/mesh/createBoard";
import * as THREE from "three"; import * as THREE from "three";
import { app } from "../ApplicationServices/Application"; import { app } from "../ApplicationServices/Application";
export function CreateBoardFromData(data: Object)
import { loadFBX } from "../Loader/FBXLoader";
export async function CreateBoardFromData(data: Object)
{ {
console.log('data: ', data);
var brList = data["data"]["Entity"]["cxDbBoard"]; var brList = data["data"]["Entity"]["cxDbBoard"];
var boardList = []; var boardList = [];
for (let i = 0; i < brList.length; i++) for (let i = 0; i < brList.length; i++)
@ -28,4 +31,25 @@ export function CreateBoardFromData(data: Object)
br.receiveShadow = true; br.receiveShadow = true;
app.m_Viewer.m_Scene.add(board); app.m_Viewer.m_Scene.add(board);
} }
//加载fbx文件
let fbxList = data["data"]["FBX"] as Array<any>;
for (let fbxData of fbxList)
{
let path = fbxData.filePath;
let fbxState = await loadFBX("http://localhost:8000/?file=" + path);
if (fbxState.State)
{
let mat = new THREE.Matrix4();
mat.scale(new THREE.Vector3(0.01, 0.01, 0.01));
for (let mesh of fbxState.object.children)
{
mesh.applyMatrix(fbxState.object.matrix);
mesh.applyMatrix(mat);
app.m_Viewer.m_Scene.add(mesh);
}
}
}
app.m_Viewer.m_bNeedUpdate = true;
} }

@ -0,0 +1,12 @@
import { Command } from "../Editor/CommandMachine";
import { app } from '../ApplicationServices/Application';
export class ViewToTop implements Command
{
async exec()
{
app.m_Viewer.ViewToTop();
}
}

@ -0,0 +1,20 @@
import { Command } from "../Editor/CommandMachine";
import { loadFBX } from "../Loader/FBXLoader";
import { app } from '../ApplicationServices/Application';
export class Test implements Command
{
async exec()
{
let url = "http://localhost:8000/?file=d:\\test.fbx";
let fbxState = await loadFBX(url);
console.log('fbxState: ', fbxState);
if (fbxState.State)
{
app.m_Viewer.m_Scene.add(fbxState.object);
}
}
}

@ -13,6 +13,8 @@ import { Command_Erase } from '../Add-on/Erase';
import { Command_DrawBoard } from '../Add-on/DrawBoard'; import { Command_DrawBoard } from '../Add-on/DrawBoard';
import { DrawCircle0 } from '../Add-on/DrawZeroCircle'; import { DrawCircle0 } from '../Add-on/DrawZeroCircle';
import { Stretch } from '../Add-on/Stretch'; import { Stretch } from '../Add-on/Stretch';
import { ViewToTop } from '../Add-on/ViewChange';
import { Test } from '../Add-on/test';
export function registerCommand() export function registerCommand()
@ -44,5 +46,7 @@ export function registerCommand()
commandMachine.m_CommandList.set("s", new Stretch()) commandMachine.m_CommandList.set("s", new Stretch())
commandMachine.m_CommandList.set("fs", new ViewToTop())
commandMachine.m_CommandList.set("tt", new Test())
} }

Loading…
Cancel
Save