You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/src/index.tsx

140 lines
4.6 KiB

import { MaterialManage } from './UI/Editor/Material/MaterialManage';
import * as React from 'react';
7 years ago
import * as ReactDOM from 'react-dom';
//黄金布局
7 years ago
import '../node_modules/golden-layout/src/css/goldenlayout-base.css';
// import '../node_modules/golden-layout/src/css/goldenlayout-dark-theme.css';
import '../node_modules/golden-layout/src/css/goldenlayout-soda-theme.css';
//蓝图
import '../node_modules/normalize.css/normalize.css';
import '../node_modules/@blueprintjs/core/dist/blueprint.css';
//
import './UI/Css/style.less';
import { initDrawLayout } from './UI/Layout/Layout';
import { CommandComponent } from "./UI/Components/Command";
7 years ago
import { CommandMsg } from './UI/Store/CommandStore';
7 years ago
import { autorun, observable } from 'mobx';
import { Provider } from "mobx-react";
import { ApplicationService, app } from './ApplicationServices/Application';
import { DownPanel } from './UI/Components/Panel';
import { DownPanelStore } from './UI/Store/DownPanelStore';
import { DrawBox, DrawCircle, DrawLine, DrawRect, DrawSphere, DrawTest, ZoomE } from './Add-on/DrawLine';
7 years ago
import { UndoData } from './DatabaseServices/UndoData';
import { Solid3d, Line } from './DatabaseServices/Entity';
import { Vector3 } from 'three';
import { Command_Move } from './Add-on/Move';
import { Command_Rotate } from './Add-on/Rotate';
import * as THREE from 'three';
import { MaterialAsset } from './UI/Editor/Asset/MaterialAsset';
import { LoadMater } from './UI/Layout/Material.layout';
7 years ago
import { DrawFloor } from './Add-on/DrawFloor';
import { Command_SwitchCamera } from './Add-on/SwitchCamera';
import { Command_Erase } from './Add-on/Erase';
import { end } from 'xaop';
import { Command_SwitchPass } from './Add-on/SwitchPass';
import { Command_DrawBoard } from './Add-on/DrawBoard';
import { Undo, Redo } from './Add-on/Undo';
document.onselectstart = () => false
/**
* . . .
*
* @returns
*/
function initRootLayout()
7 years ago
{
let top = document.createElement("div");
top.style.height = "20px";
top.id = "TopPanel";
document.body.appendChild(top);
7 years ago
var root = document.createElement('div');
root.id = "app"
root.style.height = "calc(100% - 35px)";
7 years ago
document.body.appendChild(root);
let down = document.createElement("div");
down.style.height = "15px";
down.id = "DownPanel";
document.body.appendChild(down);
return root;
}
7 years ago
//命令栏.
function renderCommand()
{
let commandEl = document.getElementById("commandContainer")
ReactDOM.render(
7 years ago
<Provider commandStore={app.m_Editor.m_CommandStore}>
<CommandComponent />
</Provider>,
commandEl
)
}
//底部状态栏.
function renderDownPanel()
{
let downPanelEl = document.getElementById("DownPanel")
let downPanelStore = new DownPanelStore();
ReactDOM.render(
<Provider store={downPanelStore}>
<DownPanel />
</Provider>,
downPanelEl
)
}
7 years ago
7 years ago
function initApp()
{
7 years ago
new ApplicationService();
7 years ago
//TODO: Test
window["undoData"] = new UndoData(app);
7 years ago
app.m_Editor.m_CommandMachine.m_CommandList.set("l", new DrawLine())
app.m_Editor.m_CommandMachine.m_CommandList.set("u", new Undo())
7 years ago
app.m_Editor.m_CommandMachine.m_CommandList.set("redo", new Redo())
app.m_Editor.m_CommandMachine.m_CommandList.set("ze", new ZoomE())
app.m_Editor.m_CommandMachine.m_CommandList.set("box", new DrawBox())
app.m_Editor.m_CommandMachine.m_CommandList.set("rec", new DrawRect())
app.m_Editor.m_CommandMachine.m_CommandList.set("c", new DrawCircle())
app.m_Editor.m_CommandMachine.m_CommandList.set("t", new DrawTest())
app.m_Editor.m_CommandMachine.m_CommandList.set("m", new Command_Move())
app.m_Editor.m_CommandMachine.m_CommandList.set("ro", new Command_Rotate())
app.m_Editor.m_CommandMachine.m_CommandList.set("sp", new DrawSphere())
7 years ago
app.m_Editor.m_CommandMachine.m_CommandList.set("fl", new DrawFloor())
app.m_Editor.m_CommandMachine.m_CommandList.set("cc", new Command_SwitchCamera())
app.m_Editor.m_CommandMachine.m_CommandList.set("p", new Command_SwitchPass())
7 years ago
app.m_Editor.m_CommandMachine.m_CommandList.set("e", new Command_Erase())
app.m_Editor.m_CommandMachine.m_CommandList.set("br", new Command_DrawBoard())
}
7 years ago
window.onload = function ()
{
initRootLayout();
initDrawLayout();
7 years ago
initApp();
renderCommand();
renderDownPanel();
7 years ago
let mat_view = LoadMater();
let matEditor = new MaterialManage("materialManage", mat_view);
7 years ago
let mat = new THREE.MeshStandardMaterial({
color: new THREE.Color(0, 1, 1)
});
matEditor.addMaterial(mat, "测试");
};