升级包. 更新CADView代码.

pull/7/head
ChenX 7 years ago
parent e246fb8377
commit 302ce77891

File diff suppressed because one or more lines are too long

18081
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"@types/dat-gui": "^0.6.3",
"@types/jest": "^20.0.5",
"@types/jquery": "^3.2.10",
"@types/lodash": "^4.14.71",
"@types/node": "^7.0.39",
"@types/jest": "^20.0.7",
"@types/jquery": "^3.2.11",
"@types/lodash": "^4.14.73",
"@types/node": "^7.0.42",
"@types/react": "^15.6.1",
"@types/react-dom": "^15.5.1",
"@types/react-dom": "^15.5.3",
"@types/stats.js": "^0.16.0",
"@types/three": "^0.84.19",
"add-asset-html-webpack-plugin": "^2.0.1",
"awesome-typescript-loader": "^3.2.2",
"css-loader": "^0.28.4",
"add-asset-html-webpack-plugin": "^2.1.1",
"awesome-typescript-loader": "^3.2.3",
"css-loader": "^0.28.5",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^0.11.2",
"html-loader": "^0.4.5",
@ -36,17 +36,17 @@
"less": "^2.7.2",
"less-loader": "^4.0.5",
"mobx-react-devtools": "^4.2.15",
"required-loader": "^1.2.11",
"required-loader": "^1.3.13",
"source-map-loader": "^0.2.1",
"style-loader": "^0.18.2",
"ts-jest": "^20.0.7",
"ts-jest": "^20.0.10",
"typed-css-modules": "^0.2.0",
"typescript": "^2.4.2",
"typescript": "^2.5.1",
"typings": "^2.1.1",
"typings-for-css-modules-loader": "^1.5.0",
"url-loader": "^0.5.9",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1"
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1"
},
"dependencies": {
"css-element-queries": "^0.4.0",
@ -60,7 +60,7 @@
"react": "^15.6.1",
"react-dom": "^15.6.1",
"stats.js": "^0.17.0",
"three": "^0.85.2",
"three": "^0.87.1",
"verb-nurbs-web": "^2.1.3",
"xaop": "^1.1.5"
},
@ -75,4 +75,4 @@
"js"
]
}
}
}

@ -0,0 +1,34 @@
function getBox(obj: THREE.Object3D): THREE.Box3
{
if (obj.hasOwnProperty("geometry"))
{
let geom = obj["geometry"];
geom.computeBoundingBox();
return geom.boundingBox;
}
else
{
if (obj.children.length > 0)
{
let box;
for (var index = 0; index < obj.children.length; index++)
{
var element = obj.children[index];
let box2 = getBox(element);
if (box2)
{
if (box)
{
box.union(box2);
}
else
box = box2;
}
}
return box;
}
return null;
}
}

@ -346,4 +346,9 @@ export class Viewer
}
this.m_Camera.Update();
}
}
ZoomAll()
{
// this.ZoomExtensBox3(getBox(this.m_Scene))
}
}

@ -1,8 +1,22 @@
import { Viewer } from '../GraphicsSystem/Viewer';
import { Editor } from '../Editor/Editor';
import { CameraControls } from '../Editor/CameraControls';
import * as THREE from 'three';
//
interface FBXData
{
fileName: string,
Color: number
}
//
interface LoadFileRes
{
State: boolean,
Obj?: Object
}
/**
*
* view. view.
@ -13,10 +27,8 @@ import { CameraControls } from '../Editor/CameraControls';
export class WebCADView
{
private m_View:Viewer;
m_Editor:Editor;
private m_View: Viewer;
m_Editor: Editor;
/**
* Creates an instance of WebCADView.
*
@ -25,19 +37,77 @@ export class WebCADView
* @param {HTMLElement} domNode
* @memberof WebCADView
*/
constructor(domNode:HTMLElement)
constructor(domNode: HTMLElement)
{
//渲染器
this.m_View = new Viewer(domNode);
//相机控制
new CameraControls(this.m_View, this.m_View.m_Render.domElement);
}
//加载场景.
Load(SceneData:Object)
/**
*
*
*
* @param {string} jsonFile
* @memberof WebCADView
*/
async Load(jsonFile: string)
{
let res = await this.LoadJson(jsonFile);
if (!res.State) return;
res.Obj["Entity"]["FBXFile"].forEach((element: FBXData) =>
{
});
this.m_View.m_bNeedUpdate = true;
}
/**
* json
*
* @param {string} jsonFile
* @returns {Promise<LoadFileRes>}
* @memberof WebCADView
*/
LoadJson(jsonFile: string): Promise<LoadFileRes>
{
return new Promise<LoadFileRes>((res, rej) =>
{
let loader = new THREE.FileLoader();
//load a text file a output the result to the console
loader.load(
// resource URL
jsonFile,
// Function when resource is loaded
function (data)
{
try
{
let obj = JSON.parse(data);
res({ State: true, Obj: obj })
}
catch (error)
{
res({ State: false })
}
},
// Function called when download progresses
function (xhr)
{
console.log((xhr.loaded / xhr.total * 100) + '% loaded');
},
// Function called when download errors
function (xhr)
{
console.error('An error happened');
res({ State: false });
}
);
});
}
//缩放到全部
ZoomAll()
{
@ -45,8 +115,12 @@ export class WebCADView
//前视图
ViewToFont()
{
this.m_View.ViewToFont();
}
//俯视图
ViewToTop()
{
this.m_View.ViewToTop()
}
//西南等轴视图
}

@ -69,4 +69,4 @@ window.onload = function ()
initApp();
renderCommand();
renderDownPanel()
};
};

Loading…
Cancel
Save