同步代码

This commit is contained in:
FishOrBear 2020-05-07 10:51:27 +08:00
parent 85db279fab
commit e712b7b4e2
10 changed files with 492 additions and 17 deletions

View File

@ -2,26 +2,30 @@ import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
import * as webpack from 'webpack';
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const TS_LOADER = [
{ loader: 'cache-loader', options: { cacheDirectory: "node_modules/.cache_loader" } },
{
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
}
];
const config: webpack.Configuration = {
devtool: "source-map",
//项目需要解析的文件拓展名称
resolve: {
extensions: [".ts", ".tsx", ".js", "json"]
},
externals: {
'three': "THREE"
},
//模块加载器设置
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
use: TS_LOADER,
},
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },

View File

@ -8,6 +8,9 @@ const config: webpack.Configuration = merge(
{
mode: "production",
entry: "./src/index.ts",
externals: {
'three': "THREE"
},
//输出设置
output: {
filename: "cad.js",

View File

@ -9,7 +9,7 @@ const config: webpack.Configuration = merge(
mode: "development",
entry: "./src/ViewSrc/index.ts",
output: { pathinfo: false },
devtool: "cheap-module-eval-source-map",
devtool: "eval-source-map",
devServer: {
contentBase: "./dist/",
port: 7776,
@ -26,6 +26,4 @@ const config: webpack.Configuration = merge(
}
);
config.externals = {};
export default config;

View File

@ -27,6 +27,7 @@
"@types/webpack-env": "^1.15.2",
"@types/webpack-merge": "^4.1.5",
"awesome-typescript-loader": "^5.2.1",
"cache-loader": "^4.1.0",
"fork-ts-checker-webpack-plugin": "^4.1.3",
"hard-source-webpack-plugin": "^0.13.1",
"html-webpack-plugin": "^4.2.1",

View File

@ -56,7 +56,6 @@ export class CameraControls
}
/**
* .
*
* @memberof CameraControls
*/
onBlur = () =>
@ -136,7 +135,7 @@ export class CameraControls
//最后一次按中键的时间
lastMiddleClickTime = 0;
//鼠标
//鼠标
onMouseDown = (event: MouseEvent) =>
{
event.preventDefault();
@ -220,12 +219,11 @@ export class CameraControls
}
/**
*
*
*
* @memberof CameraControls
*/
onMouseWheel = (event: WheelEvent) =>
{
event.preventDefault();
event.stopPropagation();
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);

View File

@ -71,7 +71,8 @@ export class ThreeBSP
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
vertex.applyMatrix4(this.matrix);
polygon.vertices.push(vertex);
} else
}
else
{
throw 'Invalid face type at index ' + i;
}

444
src/ViewSrc/data.json Normal file
View File

@ -0,0 +1,444 @@
[
{
"L": 4408.678960586129,
"W": 4408.678960586129,
"H": 18,
"CabName": "主卧",
"BoardName": "",
"BasePoint": {
"x": -82.91743119266054,
"y": 73.39449541284404,
"z": 0
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 4408.678960586129,
"y": 2204.3394802930643
},
{
"x": 0,
"y": 2204.3394802930648
},
{
"x": 4408.678960586129,
"y": 2204.3394802930643
}
],
"Buls": [
-0.9999999999999999,
-0.9999999999999999,
0
],
"SubBoardLocal": [
{
"L": 633.2307692307686,
"W": 633.2307692307686,
"H": 5,
"CabName": "",
"BoardName": "",
"BasePoint": {
"x": -95.91743119266054,
"y": 2910.9647449366785,
"z": 1405.2625572161414
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 633.2307692307686,
"y": 316.6153846153843
},
{
"x": 0,
"y": 316.61538461538436
},
{
"x": 633.2307692307686,
"y": 316.6153846153843
}
],
"Buls": [
-0.9999999999999999,
-0.9999999999999999,
0
],
"SubBoardLocal": [],
"SubBoardAssoc": null,
"Drillings": null
},
{
"L": 557.8461538461524,
"W": 557.8461538461524,
"H": 5,
"CabName": "",
"BoardName": "",
"BasePoint": {
"x": -82.91743119266054,
"y": 3016.50320647514,
"z": 2257.1087110622957
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 557.8461538461524,
"y": 278.9230769230762
},
{
"x": 0,
"y": 278.9230769230763
},
{
"x": 557.8461538461524,
"y": 278.9230769230762
}
],
"Buls": [
-0.9999999999999999,
-0.9999999999999999,
0
],
"SubBoardLocal": [],
"SubBoardAssoc": null,
"Drillings": null
},
{
"L": 444.76923076923117,
"W": 686,
"H": 5,
"CabName": "",
"BoardName": "",
"BasePoint": {
"x": -95.91743119266054,
"y": 1689.7339757059085,
"z": 1556.0317879853721
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 0,
"y": 0
},
{
"x": 686,
"y": 0
},
{
"x": 686,
"y": 444.76923076923117
},
{
"x": 0,
"y": 444.76923076923117
},
{
"x": 0,
"y": 0
}
],
"Buls": [
0,
0,
0,
0,
0
],
"SubBoardLocal": [],
"SubBoardAssoc": null,
"Drillings": null
},
{
"L": 625.6923076923076,
"W": 1349.3846153846157,
"H": 5,
"CabName": "",
"BoardName": "",
"BasePoint": {
"x": -82.91743119266054,
"y": 1177.1185910905238,
"z": 2626.493326446911
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 0,
"y": 0
},
{
"x": 1349.3846153846157,
"y": 0
},
{
"x": 1349.3846153846157,
"y": 625.6923076923076
},
{
"x": 0,
"y": 625.6923076923076
},
{
"x": 0,
"y": 0
}
],
"Buls": [
0,
0,
0,
0,
0
],
"SubBoardLocal": [],
"SubBoardAssoc": null,
"Drillings": null
}
],
"SubBoardAssoc": null,
"Drillings": null
},
{
"L": 2000,
"W": 600,
"H": 18,
"CabName": "主卧",
"BoardName": "",
"BasePoint": {
"x": 1099.0825688073396,
"y": 73.39449541284404,
"z": 0
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 0,
"y": 0
},
{
"x": 600,
"y": 0
},
{
"x": 600,
"y": 2000
},
{
"x": 0,
"y": 2000
},
{
"x": 0,
"y": 0
}
],
"Buls": [
0,
0,
0,
0,
0
],
"SubBoardLocal": [
{
"L": 144.00000000000023,
"W": 170.42201834862385,
"H": 5,
"CabName": "",
"BoardName": "",
"BasePoint": {
"x": 1099.0825688073396,
"y": 288.2935779816515,
"z": 1001.247706422018
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 0,
"y": 0
},
{
"x": 170.42201834862385,
"y": 0
},
{
"x": 170.42201834862385,
"y": 144.00000000000023
},
{
"x": 0,
"y": 144.00000000000023
},
{
"x": 0,
"y": 0
}
],
"Buls": [
0,
0,
0,
0,
0
],
"SubBoardLocal": [],
"SubBoardAssoc": null,
"Drillings": null
},
{
"L": 189.0974955047293,
"W": 189.0974955047293,
"H": 18,
"CabName": "",
"BoardName": "",
"BasePoint": {
"x": 1099.0825688073396,
"y": 234.6989586696538,
"z": 1267.3595091283692
},
"XVec": {
"x": 0,
"y": 1,
"z": 0
},
"YVec": {
"x": 0,
"y": 0,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 0
},
"Grain": 0,
"Pts": [
{
"x": 189.0974955047293,
"y": 94.54874775236476
},
{
"x": -1.4210854715202004e-14,
"y": 94.54874775236478
},
{
"x": 189.0974955047293,
"y": 94.54874775236476
}
],
"Buls": [
-0.9999999999999999,
-0.9999999999999999,
0
],
"SubBoardLocal": [],
"SubBoardAssoc": null,
"Drillings": null
}
],
"SubBoardAssoc": null,
"Drillings": null
}
]

14
src/ViewSrc/index.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>WebCAD</title>
</head>
<body>
</body>
</html>

12
src/ViewSrc/style.css Normal file
View File

@ -0,0 +1,12 @@
body {
font-size: 11px;
overflow: hidden;
}
html,
body {
background: #5C7080;
height: 100%;
padding: 0;
margin: 0;
}

View File

@ -4,7 +4,7 @@
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"target": "es5",
"target": "esnext",
"lib": [
"esnext",
"dom"