Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
623fa9ac9a | ||
![]() |
e712b7b4e2 |
31
.vscode/settings.json
vendored
31
.vscode/settings.json
vendored
@@ -3,8 +3,10 @@
|
|||||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||||
//格式化设置
|
//格式化设置
|
||||||
"editor.tabSize": 4,
|
"editor.tabSize": 4,
|
||||||
"editor.formatOnPaste": true,
|
"editor.formatOnPaste": false,
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
|
"editor.insertSpaces": true,
|
||||||
|
"editor.detectIndentation": false,
|
||||||
//格式设置
|
//格式设置
|
||||||
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
|
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
|
||||||
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
|
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
|
||||||
@@ -12,5 +14,30 @@
|
|||||||
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
|
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
|
||||||
"javascript.format.enable": true,
|
"javascript.format.enable": true,
|
||||||
"files.insertFinalNewline": true,
|
"files.insertFinalNewline": true,
|
||||||
"editor.detectIndentation": true,
|
"typescript.format.semicolons": "insert",
|
||||||
|
"files.trimFinalNewlines": true,
|
||||||
|
"files.trimTrailingWhitespace": true,
|
||||||
|
//保存时
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports": true,
|
||||||
|
},
|
||||||
|
"gitlens.remotes": [
|
||||||
|
{
|
||||||
|
"domain": "gitee.com",
|
||||||
|
"type": "Custom",
|
||||||
|
"name": "码云",
|
||||||
|
"protocol": "https",
|
||||||
|
"urls": {
|
||||||
|
"repository": "https://gitee.com/cf-fz/${repoPath}",
|
||||||
|
"branches": "https://gitee.com/cf-fz/${repoPath}/branches",
|
||||||
|
"branch": "https://gitee.com/cf-fz/${repoPath}/commits/${branch}",
|
||||||
|
"commit": "https://gitee.com/cf-fz/${repoPath}/commit/${id}",
|
||||||
|
"file": "https://gitee.com/cf-fz/${repoPath}?path=${file}${line}",
|
||||||
|
"fileInBranch": "https://gitee.com/cf-fz/${repoPath}/blob/${branch}/${file}${line}",
|
||||||
|
"fileInCommit": "https://gitee.com/cf-fz/${repoPath}/blob/${id}/${file}${line}",
|
||||||
|
"fileLine": "#L${line}",
|
||||||
|
"fileRange": "#L${start}-L${end}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
# 显示板件的控件
|
# 显示板件的控件
|
||||||
|
|
||||||
使用例子请参照项目:[CADViewSample](http://git.cf/cx/CADViewSample)
|
使用例子请参照项目:[CADViewSample](http://git.cf/cx/CADViewSample)
|
||||||
|
|
||||||
|
|
||||||
|
删除"@types/webpack-merge" 下的 node_modules/webpack 定义 坑爹导致项目跑不起来
|
||||||
|
@@ -1,6 +1,15 @@
|
|||||||
import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
|
|
||||||
import * as webpack from 'webpack';
|
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 = {
|
const config: webpack.Configuration = {
|
||||||
devtool: "source-map",
|
devtool: "source-map",
|
||||||
@@ -8,20 +17,13 @@ const config: webpack.Configuration = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".tsx", ".js", "json"]
|
extensions: [".ts", ".tsx", ".js", "json"]
|
||||||
},
|
},
|
||||||
externals: {
|
|
||||||
'three': "THREE"
|
|
||||||
},
|
|
||||||
//模块加载器设置
|
//模块加载器设置
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.tsx?$/,
|
test: /\.tsx?$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'ts-loader',
|
use: TS_LOADER,
|
||||||
options: {
|
|
||||||
transpileOnly: true,
|
|
||||||
experimentalWatchApi: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
||||||
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
||||||
@@ -29,8 +31,6 @@ const config: webpack.Configuration = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new HardSourceWebpackPlugin(),
|
|
||||||
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
|
import path from 'path';
|
||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
import * as merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import common from './webpack.common';
|
import common from './webpack.common';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
const config: webpack.Configuration = merge(
|
const config: webpack.Configuration = merge(
|
||||||
common,
|
common,
|
||||||
{
|
{
|
||||||
mode: "production",
|
mode: "production",
|
||||||
entry: "./src/index.ts",
|
entry: "./src/index.ts",
|
||||||
|
externals: {
|
||||||
|
'three': "THREE"
|
||||||
|
},
|
||||||
//输出设置
|
//输出设置
|
||||||
output: {
|
output: {
|
||||||
filename: "cad.js",
|
filename: "cad.js",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
import * as merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import common from './webpack.common';
|
import common from './webpack.common';
|
||||||
import * as HtmlWebPackPlugin from "html-webpack-plugin";
|
import HtmlWebPackPlugin from "html-webpack-plugin";
|
||||||
|
|
||||||
const config: webpack.Configuration = merge(
|
const config: webpack.Configuration = merge(
|
||||||
common,
|
common,
|
||||||
@@ -9,7 +9,7 @@ const config: webpack.Configuration = merge(
|
|||||||
mode: "development",
|
mode: "development",
|
||||||
entry: "./src/ViewSrc/index.ts",
|
entry: "./src/ViewSrc/index.ts",
|
||||||
output: { pathinfo: false },
|
output: { pathinfo: false },
|
||||||
devtool: "cheap-module-eval-source-map",
|
devtool: "eval-source-map",
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: "./dist/",
|
contentBase: "./dist/",
|
||||||
port: 7776,
|
port: 7776,
|
||||||
@@ -26,6 +26,4 @@ const config: webpack.Configuration = merge(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
config.externals = {};
|
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
92
package.json
92
package.json
@@ -1,46 +1,50 @@
|
|||||||
{
|
{
|
||||||
"name": "cadview",
|
"name": "cadview",
|
||||||
"version": "1.1.9",
|
"version": "1.1.9",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"t": "tsc --noEmit -w",
|
"t": "tsc --noEmit -w",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"umd": "webpack --config ./config/webpack.umd.ts",
|
"umd": "webpack --config ./config/webpack.umd.ts",
|
||||||
"dev": "webpack-dev-server --config ./config/webpack.view.ts"
|
"dev": "webpack-dev-server --config ./config/webpack.view.ts",
|
||||||
},
|
"postinstall": "ts-node ./utils/rmtype.ts"
|
||||||
"repository": {
|
},
|
||||||
"type": "git",
|
"repository": {
|
||||||
"url": "http://git.cf/cx/CADViewComponent.git"
|
"type": "git",
|
||||||
},
|
"url": "http://git.cf/cx/CADViewComponent.git"
|
||||||
"author": "cx",
|
},
|
||||||
"license": "ISC",
|
"author": "cx",
|
||||||
"devDependencies": {
|
"license": "ISC",
|
||||||
"@types/hard-source-webpack-plugin": "^1.0.1",
|
"devDependencies": {
|
||||||
"@types/node": "^13.13.4",
|
"@types/hard-source-webpack-plugin": "^1.0.1",
|
||||||
"@types/three": "^0.103.2",
|
"@types/node": "^13.13.52",
|
||||||
"@types/uglifyjs-webpack-plugin": "^1.1.0",
|
"@types/three": "^0.103.2",
|
||||||
"@types/webpack": "^4.41.12",
|
"@types/uglifyjs-webpack-plugin": "^1.1.0",
|
||||||
"@types/webpack-dev-server": "^3.10.1",
|
"@types/webpack": "^4.41.32",
|
||||||
"@types/webpack-env": "^1.15.2",
|
"@types/webpack-dev-server": "^3.11.6",
|
||||||
"@types/webpack-merge": "^4.1.5",
|
"@types/webpack-env": "^1.15.2",
|
||||||
"awesome-typescript-loader": "^5.2.1",
|
"@types/webpack-merge": "^4.1.5",
|
||||||
"fork-ts-checker-webpack-plugin": "^4.1.3",
|
"awesome-typescript-loader": "^5.2.1",
|
||||||
"hard-source-webpack-plugin": "^0.13.1",
|
"cache-loader": "^4.1.0",
|
||||||
"html-webpack-plugin": "^4.2.1",
|
"fork-ts-checker-webpack-plugin": "^4.1.6",
|
||||||
"ts-loader": "^7.0.2",
|
"hard-source-webpack-plugin": "^0.13.1",
|
||||||
"ts-node": "^8.9.1",
|
"html-webpack-plugin": "^4.5.2",
|
||||||
"typescript": "^3.8.3",
|
"ts-loader": "^7.0.5",
|
||||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
"ts-node": "^8.10.2",
|
||||||
"webpack": "^4.43.0",
|
"typescript": "^4.5.5",
|
||||||
"webpack-cli": "^3.3.11",
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||||
"webpack-dev-server": "^3.10.3",
|
"webpack": "^4.46.0",
|
||||||
"webpack-merge": "^4.2.2"
|
"webpack-cli": "^3.3.12",
|
||||||
},
|
"webpack-dev-server": "^3.11.3",
|
||||||
"dependencies": {
|
"webpack-merge": "^4.2.2"
|
||||||
"three": "^0.115.0",
|
},
|
||||||
"wolfy87-eventemitter": "^5.2.9"
|
"dependencies": {
|
||||||
}
|
"@jscad/modeling": "^2.7.1",
|
||||||
|
"flatbush": "^3.3.0",
|
||||||
|
"three": "^0.115.0",
|
||||||
|
"webcad_ue4_api": "http://gitea.cf/cx/webcad-ue4-api/archive/0.2.3.tar.gz"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,6 @@ export class CameraControls
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 窗体失去焦点时.
|
* 窗体失去焦点时.
|
||||||
*
|
|
||||||
* @memberof CameraControls
|
* @memberof CameraControls
|
||||||
*/
|
*/
|
||||||
onBlur = () =>
|
onBlur = () =>
|
||||||
@@ -136,7 +135,7 @@ export class CameraControls
|
|||||||
|
|
||||||
//最后一次按中键的时间
|
//最后一次按中键的时间
|
||||||
lastMiddleClickTime = 0;
|
lastMiddleClickTime = 0;
|
||||||
//鼠标
|
//鼠标
|
||||||
onMouseDown = (event: MouseEvent) =>
|
onMouseDown = (event: MouseEvent) =>
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -220,12 +219,11 @@ export class CameraControls
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 鼠标滚轮事件
|
* 鼠标滚轮事件
|
||||||
*
|
*
|
||||||
* @memberof CameraControls
|
* @memberof CameraControls
|
||||||
*/
|
*/
|
||||||
onMouseWheel = (event: WheelEvent) =>
|
onMouseWheel = (event: WheelEvent) =>
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);
|
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);
|
||||||
|
@@ -71,7 +71,8 @@ export class ThreeBSP
|
|||||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
||||||
vertex.applyMatrix4(this.matrix);
|
vertex.applyMatrix4(this.matrix);
|
||||||
polygon.vertices.push(vertex);
|
polygon.vertices.push(vertex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw 'Invalid face type at index ' + i;
|
throw 'Invalid face type at index ' + i;
|
||||||
}
|
}
|
||||||
|
444
src/ViewSrc/data.json
Normal file
444
src/ViewSrc/data.json
Normal 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
14
src/ViewSrc/index.html
Normal 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>
|
@@ -2,21 +2,20 @@
|
|||||||
// import "./style.css";
|
// import "./style.css";
|
||||||
import { Vector3 } from "three";
|
import { Vector3 } from "three";
|
||||||
import { CameraControlState } from "../CameraControls";
|
import { CameraControlState } from "../CameraControls";
|
||||||
import { data } from "../data";
|
|
||||||
import { GetBox } from "../GeUtils";
|
import { GetBox } from "../GeUtils";
|
||||||
import { LoadBoard } from "../Utils";
|
import { LoadBoard } from "../Utils";
|
||||||
import { Viewer } from "../Viewer";
|
import { Viewer } from "../Viewer";
|
||||||
|
|
||||||
let btn = document.createElement("button");
|
let btn = document.createElement("button");
|
||||||
btn.innerHTML = "载入"
|
btn.innerHTML = "载入";
|
||||||
document.body.appendChild(btn);
|
document.body.appendChild(btn);
|
||||||
|
|
||||||
let btn2 = document.createElement("button");
|
let btn2 = document.createElement("button");
|
||||||
btn2.innerHTML = "清理"
|
btn2.innerHTML = "清理";
|
||||||
document.body.appendChild(btn2);
|
document.body.appendChild(btn2);
|
||||||
|
|
||||||
let btn3 = document.createElement("button");
|
let btn3 = document.createElement("button");
|
||||||
btn3.innerHTML = "爆炸图"
|
btn3.innerHTML = "爆炸图";
|
||||||
document.body.appendChild(btn3);
|
document.body.appendChild(btn3);
|
||||||
|
|
||||||
let el = document.createElement("canvas");
|
let el = document.createElement("canvas");
|
||||||
@@ -36,15 +35,16 @@ view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Pan, CameraControlState.
|
|||||||
btn.onclick = () =>
|
btn.onclick = () =>
|
||||||
{
|
{
|
||||||
console.time();
|
console.time();
|
||||||
|
let data = require("./data.json");
|
||||||
for (let i = 0; i < 1; i++)
|
for (let i = 0; i < 1; i++)
|
||||||
LoadBoard(view, data);
|
LoadBoard(view, data);
|
||||||
console.timeEnd();
|
console.timeEnd();
|
||||||
}
|
};
|
||||||
|
|
||||||
btn2.onclick = () =>
|
btn2.onclick = () =>
|
||||||
{
|
{
|
||||||
// LoadBoard(view, []);
|
// LoadBoard(view, []);
|
||||||
}
|
};
|
||||||
|
|
||||||
btn3.onclick = () =>
|
btn3.onclick = () =>
|
||||||
{
|
{
|
||||||
@@ -91,5 +91,5 @@ btn3.onclick = () =>
|
|||||||
|
|
||||||
if (count === 60)
|
if (count === 60)
|
||||||
clearInterval(t);
|
clearInterval(t);
|
||||||
}, 16)
|
}, 16);
|
||||||
}
|
};
|
||||||
|
12
src/ViewSrc/style.css
Normal file
12
src/ViewSrc/style.css
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
body {
|
||||||
|
font-size: 11px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
background: #5C7080;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
@@ -1,9 +1,8 @@
|
|||||||
import { CylinderGeometry, Geometry, LineSegments, Mesh, Shape, Vector2, Vector3, Matrix4, ExtrudeGeometry, EdgesGeometry } from 'three';
|
import { CylinderGeometry, EdgesGeometry, Geometry, LineSegments, Matrix4, Mesh, Shape, Vector2, Vector3 } from 'three';
|
||||||
|
import { boardUVGenerator2, ExtrudeSolid, Polyline } from 'webcad_ue4_api';
|
||||||
import { ColorMaterial } from './ColorPalette';
|
import { ColorMaterial } from './ColorPalette';
|
||||||
import { equalv3, polar } from './GeUtils';
|
import { polar } from './GeUtils';
|
||||||
import { boardMaterial, edgeMaterial } from './Material';
|
import { boardMaterial, edgeMaterial } from './Material';
|
||||||
import { RotateUVs } from './RotateUV';
|
|
||||||
import { ThreeBSP } from './ThreeCSG';
|
|
||||||
//解析二维圆弧类.
|
//解析二维圆弧类.
|
||||||
export class Arc2d
|
export class Arc2d
|
||||||
{
|
{
|
||||||
@@ -56,7 +55,7 @@ export function createPath(pts: Vector2[], buls: number[], shapeOut?: Shape): Sh
|
|||||||
let nextPt = pts[i + 1];
|
let nextPt = pts[i + 1];
|
||||||
if (buls[i] == 0)
|
if (buls[i] == 0)
|
||||||
{
|
{
|
||||||
shape.lineTo(nextPt.x, nextPt.y)
|
shape.lineTo(nextPt.x, nextPt.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -76,8 +75,7 @@ export function getVec(data: object): Vector3
|
|||||||
return new Vector3(data["x"], data["y"], data["z"]);
|
return new Vector3(data["x"], data["y"], data["z"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建板件 暂时这么写
|
function Conver2Ext(boardData: object): ExtrudeSolid
|
||||||
export function createBoard(boardData: object)
|
|
||||||
{
|
{
|
||||||
let pts: Vector2[] = [];
|
let pts: Vector2[] = [];
|
||||||
let buls: number[] = [];
|
let buls: number[] = [];
|
||||||
@@ -93,6 +91,7 @@ export function createBoard(boardData: object)
|
|||||||
let yD = getVec(boardData["YVec"]);
|
let yD = getVec(boardData["YVec"]);
|
||||||
let ZD = getVec(boardData["ZVec"]);
|
let ZD = getVec(boardData["ZVec"]);
|
||||||
let pBase = getVec(boardData["BasePoint"]);
|
let pBase = getVec(boardData["BasePoint"]);
|
||||||
|
pBase.add(ZD.clone().multiplyScalar(-boardHeight));
|
||||||
|
|
||||||
boardMat.makeBasis(xD, yD, ZD);
|
boardMat.makeBasis(xD, yD, ZD);
|
||||||
boardMat.setPosition(pBase);
|
boardMat.setPosition(pBase);
|
||||||
@@ -111,7 +110,6 @@ export function createBoard(boardData: object)
|
|||||||
{
|
{
|
||||||
let length = boardData["L"];
|
let length = boardData["L"];
|
||||||
let width = boardData["W"];
|
let width = boardData["W"];
|
||||||
let height = boardData["H"];
|
|
||||||
pts.push(new Vector2(0, 0),
|
pts.push(new Vector2(0, 0),
|
||||||
new Vector2(width, 0),
|
new Vector2(width, 0),
|
||||||
new Vector2(width, length),
|
new Vector2(width, length),
|
||||||
@@ -121,78 +119,66 @@ export function createBoard(boardData: object)
|
|||||||
buls.push(0, 0, 0, 0, 0);
|
buls.push(0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sp = createPath(pts, buls);
|
let ext = new ExtrudeSolid();
|
||||||
let extrudeSettings = {
|
ext.OCSNoClone.copy(boardMat);
|
||||||
steps: 1,
|
let pl = new Polyline(pts.map((p, i) => { return { pt: p, bul: buls[i] }; }));
|
||||||
bevelEnabled: false,
|
ext.Thickness = boardHeight;
|
||||||
depth: boardHeight
|
ext.ContourCurve = pl;
|
||||||
};
|
|
||||||
|
|
||||||
let ext = new ExtrudeGeometry(sp, extrudeSettings) as Geometry;
|
if (checkObjectArray(boardData, "SubBoardLocal"))
|
||||||
ext.computeBoundingSphere();
|
ext.Grooves.push(...boardData["SubBoardLocal"].map(Conver2Ext));
|
||||||
ext.computeBoundingBox();
|
return ext;
|
||||||
ext.translate(0, 0, -boardHeight)
|
}
|
||||||
ext.applyMatrix4(boardMat);
|
|
||||||
|
|
||||||
if (!equalv3(xD.clone().cross(yD), ZD))
|
|
||||||
{
|
|
||||||
for (let f of ext.faces)
|
|
||||||
[f.a, f.c] = [f.c, f.a];
|
|
||||||
}
|
|
||||||
|
|
||||||
//外边.
|
|
||||||
let edges: (LineSegments | Mesh)[] = [createEdge(ext)];
|
|
||||||
|
|
||||||
//差集
|
|
||||||
if (checkObjectArray(boardData, "SubBoardLocal")
|
|
||||||
|| checkObjectArray(boardData, "Drillings"))
|
|
||||||
{
|
|
||||||
let thisCsg = new ThreeBSP(ext);
|
|
||||||
|
|
||||||
if (boardData["SubBoardLocal"])
|
|
||||||
{
|
|
||||||
let subBoardList = boardData["SubBoardLocal"].map(d => createBoard(d));
|
|
||||||
for (let br of subBoardList)
|
|
||||||
{
|
|
||||||
edges.push(...br.edges);
|
|
||||||
let subCsg = new ThreeBSP(br.mesh);
|
|
||||||
thisCsg = thisCsg.subtract(subCsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (boardData["Drillings"])
|
|
||||||
{
|
|
||||||
let dris = boardData["Drillings"];
|
|
||||||
for (let dri of dris)
|
|
||||||
{
|
|
||||||
let geo = new CylinderGeometry(dri.r, dri.r, dri.h, 8);
|
|
||||||
geo.rotateX(Math.PI * 0.5);
|
|
||||||
|
|
||||||
if (dri.f === 0) //0正
|
|
||||||
geo.translate(dri.x, dri.y, -dri.h * 0.5);
|
|
||||||
else //1反
|
|
||||||
geo.translate(dri.x, dri.y, dri.h * 0.5 - boardData["H"]);
|
|
||||||
|
|
||||||
geo.applyMatrix4(boardMat);
|
|
||||||
|
|
||||||
let mesh = new Mesh(geo, ColorMaterial.GetBasicMaterial(1));
|
|
||||||
edges.push(mesh);
|
|
||||||
// let edge = createEdge(geo);
|
|
||||||
// edge.material = new LineBasicMaterial({ color: new Color(1, 0, 0) });
|
|
||||||
// edges.push(edge);
|
|
||||||
|
|
||||||
// let subCsg = new ThreeBSP(geo);
|
|
||||||
// thisCsg = thisCsg.subtract(subCsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ext = thisCsg.toGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//创建板件 暂时这么写
|
||||||
|
export function createBoard(boardData: object)
|
||||||
|
{
|
||||||
|
let ext = Conver2Ext(boardData);
|
||||||
if (boardData["BoardName"] === "地脚线")
|
if (boardData["BoardName"] === "地脚线")
|
||||||
RotateUVs(ext);
|
Object.defineProperty(ext, "UCGenerator",
|
||||||
|
{
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
return boardUVGenerator2;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let mesh = new Mesh(ext, boardMaterial);
|
//板件被镜像时.
|
||||||
mesh.userData = ZD;
|
// if (!equalv3(xD.clone().cross(yD), ZD))
|
||||||
edges.forEach(e => e.userData = ZD);
|
// {
|
||||||
|
// for (let f of ext.faces)
|
||||||
|
// [f.a, f.c] = [f.c, f.a];
|
||||||
|
// }
|
||||||
|
|
||||||
|
//边
|
||||||
|
let edges: (LineSegments | Mesh)[] = [new LineSegments(ext.EdgeGeometry, edgeMaterial)];
|
||||||
|
edges[0].applyMatrix4(ext.OCSNoClone);
|
||||||
|
|
||||||
|
if (checkObjectArray(boardData, "Drillings"))
|
||||||
|
{
|
||||||
|
let dris = boardData["Drillings"];
|
||||||
|
for (let dri of dris)
|
||||||
|
{
|
||||||
|
let geo = new CylinderGeometry(dri.r, dri.r, dri.h, 8);
|
||||||
|
geo.rotateX(Math.PI * 0.5);
|
||||||
|
|
||||||
|
if (dri.f === 0) //0正
|
||||||
|
geo.translate(dri.x, dri.y, -dri.h * 0.5 + boardData["H"]);
|
||||||
|
else //1反
|
||||||
|
geo.translate(dri.x, dri.y, dri.h * 0.5);
|
||||||
|
|
||||||
|
geo.applyMatrix4(ext.OCSNoClone);
|
||||||
|
|
||||||
|
let mesh = new Mesh(geo, ColorMaterial.GetBasicMaterial(1));
|
||||||
|
edges.push(mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mesh = new Mesh(ext.MeshGeometry, boardMaterial);
|
||||||
|
mesh.userData = ext.Normal;
|
||||||
|
edges.forEach(e => e.userData = ext.Normal);
|
||||||
|
mesh.applyMatrix4(ext.OCSNoClone);
|
||||||
|
mesh.updateWorldMatrix(false, true);
|
||||||
return { mesh, edges };
|
return { mesh, edges };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
"compileOnSave": true,
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"sourceMap": true,
|
|
||||||
"declaration": true,
|
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"target": "es5",
|
"sourceMap": true,
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es2020",
|
||||||
|
"noLib": false,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
"esnext",
|
"esnext",
|
||||||
"dom"
|
"dom"
|
||||||
@@ -12,13 +15,13 @@
|
|||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"webpack-env",
|
"webpack-env",
|
||||||
"webpack-dev-server"
|
"webpack-dev-server",
|
||||||
],
|
],
|
||||||
"module": "commonjs",
|
"jsx": "react",
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./src/**/*",
|
"./src/**/*",
|
||||||
// "./config/**/*"
|
"./config/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
7
utils/rmtype.ts
Normal file
7
utils/rmtype.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
|
||||||
|
fs.rmdir(".\\node_modules\\@types\\webpack-merge\\node_modules\\webpack", { recursive: true }, (err) =>
|
||||||
|
{
|
||||||
|
console.log("删除webpack目录");
|
||||||
|
if (err) console.log(err);
|
||||||
|
});
|
Reference in New Issue
Block a user