调整板初始化代码,新增自定义编号
This commit is contained in:
parent
eb736bce84
commit
e70354267b
@ -20,18 +20,74 @@ const config: webpack.Configuration = {
|
|||||||
//模块加载器设置
|
//模块加载器设置
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.worker\.ts$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: [
|
||||||
|
{ loader: 'worker-loader', },
|
||||||
|
...TS_LOADER
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: /\.tsx?$/,
|
test: /\.tsx?$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
use: TS_LOADER,
|
use: TS_LOADER,
|
||||||
},
|
},
|
||||||
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
{
|
||||||
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
test: /\.[(png)|(obj)|(json)]$/,
|
||||||
|
loader: "file-loader"
|
||||||
|
},
|
||||||
|
//样式加载 css
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: ['style-loader', 'css-loader']
|
||||||
|
},
|
||||||
|
//样式加载 less
|
||||||
|
{
|
||||||
|
test: /\.less$/,
|
||||||
|
use: [
|
||||||
|
{ loader: "style-loader" },
|
||||||
|
{ loader: 'css-loader', options: { sourceMap: false } },
|
||||||
|
{
|
||||||
|
loader: "less-loader",
|
||||||
|
options: {
|
||||||
|
lessOptions: {
|
||||||
|
strictMath: true,
|
||||||
|
noIeCompat: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
//字体加载 blueprint
|
||||||
|
{
|
||||||
|
test: /\.(ttf|eot|svg|FBX)$/,
|
||||||
|
use: {
|
||||||
|
loader: 'file-loader',
|
||||||
|
options: { name: 'fonts/[contenthash].[ext]' }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//字体加载 blueprint
|
||||||
|
{
|
||||||
|
test: /\.(woff|woff2|jpg|png)$/,
|
||||||
|
use: {
|
||||||
|
loader: 'url-loader',
|
||||||
|
options: {
|
||||||
|
name: 'fonts/[contenthash].[ext]',
|
||||||
|
limit: 5000,
|
||||||
|
mimetype: 'application/font-woff'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(glsl|vs|fs)$/,
|
||||||
|
loader: 'shader-loader'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import HtmlWebPackPlugin from "html-webpack-plugin";
|
||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import common from './webpack.common';
|
import common from './webpack.common';
|
||||||
import HtmlWebPackPlugin from "html-webpack-plugin";
|
|
||||||
|
|
||||||
const config: webpack.Configuration = merge(
|
const config: webpack.Configuration = merge(
|
||||||
common,
|
common,
|
||||||
@ -11,12 +11,14 @@ const config: webpack.Configuration = merge(
|
|||||||
output: { pathinfo: false },
|
output: { pathinfo: false },
|
||||||
devtool: "eval-source-map",
|
devtool: "eval-source-map",
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: "./dist/",
|
// contentBase: "./dist/",
|
||||||
|
static: false,
|
||||||
port: 7776,
|
port: 7776,
|
||||||
|
host: "0.0.0.0",
|
||||||
hot: true,
|
hot: true,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.NamedModulesPlugin(),//Hot
|
// new webpack.NamedModulesPlugin(),//Hot
|
||||||
new webpack.HotModuleReplacementPlugin(),//Hot
|
new webpack.HotModuleReplacementPlugin(),//Hot
|
||||||
new HtmlWebPackPlugin({
|
new HtmlWebPackPlugin({
|
||||||
title: "webCAD",
|
title: "webCAD",
|
||||||
|
21
package.json
21
package.json
@ -23,9 +23,7 @@
|
|||||||
"@types/three": "^0.103.2",
|
"@types/three": "^0.103.2",
|
||||||
"@types/uglifyjs-webpack-plugin": "^1.1.0",
|
"@types/uglifyjs-webpack-plugin": "^1.1.0",
|
||||||
"@types/webpack": "^4.41.32",
|
"@types/webpack": "^4.41.32",
|
||||||
"@types/webpack-dev-server": "^3.11.6",
|
"@types/webpack-env": "^1.18.0",
|
||||||
"@types/webpack-env": "^1.15.2",
|
|
||||||
"@types/webpack-merge": "^4.1.5",
|
|
||||||
"awesome-typescript-loader": "^5.2.1",
|
"awesome-typescript-loader": "^5.2.1",
|
||||||
"cache-loader": "^4.1.0",
|
"cache-loader": "^4.1.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^4.1.6",
|
"fork-ts-checker-webpack-plugin": "^4.1.6",
|
||||||
@ -35,15 +33,18 @@
|
|||||||
"ts-node": "^8.10.2",
|
"ts-node": "^8.10.2",
|
||||||
"typescript": "^4.5.5",
|
"typescript": "^4.5.5",
|
||||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||||
"webpack": "^4.46.0",
|
"webpack": "^5.75.0",
|
||||||
"webpack-cli": "^3.3.12",
|
"webpack-cli": "^4.10.0",
|
||||||
"webpack-dev-server": "^3.11.3",
|
"webpack-dev-server": "^4.11.1",
|
||||||
"webpack-merge": "^4.2.2"
|
"webpack-merge": "^5.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jscad/modeling": "^2.7.1",
|
"@jscad/modeling": "^2.11.0",
|
||||||
"flatbush": "^3.3.0",
|
"flatbush": "^3.3.0",
|
||||||
"three": "^0.115.0",
|
"three": "npm:three-cf@0.122.5",
|
||||||
"webcad_ue4_api": "http://gitea.cf/cx/webcad-ue4-api/archive/0.2.3.tar.gz"
|
"js-angusj-clipper": "^1.2.1",
|
||||||
|
"polylabel": "^1.1.0",
|
||||||
|
"xaop": "^2.0.0",
|
||||||
|
"webcad_ue4_api": "http://gitea.cf/cx/webcad-ue4-api/archive/3.2.4.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
183
src/SimpleBoard.ts
Normal file
183
src/SimpleBoard.ts
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
import { CylinderGeometry, LineSegments, Matrix4, Mesh, MeshBasicMaterial, Vector2, Vector3 } from "three";
|
||||||
|
import { DbText, ExtrudeSolid, Polyline, TextAligen, boardUVGenerator2 } from "webcad_ue4_api";
|
||||||
|
import { ColorMaterial } from "./ColorPalette";
|
||||||
|
import { edgeMaterial } from "./Material";
|
||||||
|
|
||||||
|
function getVec(data: object): Vector3
|
||||||
|
{
|
||||||
|
return new Vector3(data["x"], data["y"], data["z"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BoardType
|
||||||
|
{
|
||||||
|
Layer = 0,
|
||||||
|
Vertical = 1,
|
||||||
|
Behind = 2
|
||||||
|
}
|
||||||
|
export class SimpleBoard
|
||||||
|
{
|
||||||
|
BoardName: string;
|
||||||
|
boardPts: any[];
|
||||||
|
boardBuls: any[];
|
||||||
|
xD: Vector3;
|
||||||
|
yD: Vector3;
|
||||||
|
zD: Vector3;
|
||||||
|
height: number;
|
||||||
|
width: number;
|
||||||
|
|
||||||
|
thickness: number;
|
||||||
|
pBase: Vector3;
|
||||||
|
SubBoardLocal: any[];
|
||||||
|
Drillings: any[];
|
||||||
|
DataID: number;
|
||||||
|
_BoardType: BoardType;
|
||||||
|
_CustomNumber: string;
|
||||||
|
_CustomNumberTextEntity: any;
|
||||||
|
|
||||||
|
constructor(boardData: any)
|
||||||
|
{
|
||||||
|
this.boardPts = boardData["Pts"];
|
||||||
|
this.boardBuls = boardData["Buls"];
|
||||||
|
this.pBase = getVec(boardData["BasePoint"]);
|
||||||
|
|
||||||
|
this.xD = getVec(boardData["XVec"]);
|
||||||
|
this.yD = getVec(boardData["YVec"]);
|
||||||
|
this.zD = getVec(boardData["ZVec"]);
|
||||||
|
|
||||||
|
this.SubBoardLocal = boardData["SubBoardLocal"] ?? [];
|
||||||
|
|
||||||
|
this.Drillings = boardData["Drillings"] ?? [];
|
||||||
|
|
||||||
|
this.height = boardData["L"];
|
||||||
|
this.width = boardData["W"];
|
||||||
|
this.thickness = boardData["H"];
|
||||||
|
|
||||||
|
this.BoardName = boardData["BoardName"];
|
||||||
|
this.DataID = boardData['DataID'];
|
||||||
|
|
||||||
|
this._BoardType = boardData['BoardType'];
|
||||||
|
this._CustomNumber = boardData['CustomNumber'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Conver2Ext(): ExtrudeSolid
|
||||||
|
{
|
||||||
|
let pts: Vector2[] = [];
|
||||||
|
let buls: number[] = [];
|
||||||
|
|
||||||
|
|
||||||
|
let boardMat = new Matrix4();
|
||||||
|
let matInv: Matrix4 = new Matrix4();
|
||||||
|
//InitBoardMat
|
||||||
|
|
||||||
|
this.pBase.add(this.zD.clone().multiplyScalar(-this.thickness));
|
||||||
|
|
||||||
|
boardMat.makeBasis(this.xD, this.yD, this.zD);
|
||||||
|
boardMat.setPosition(this.pBase);
|
||||||
|
matInv.getInverse(boardMat);
|
||||||
|
|
||||||
|
if (this.boardPts && this.boardPts.length !== 0)
|
||||||
|
for (let i = 0; i < this.boardPts.length; i++)
|
||||||
|
{
|
||||||
|
let pt = getVec(this.boardPts[i]);
|
||||||
|
if (this.boardPts[i].z !== undefined)
|
||||||
|
pt.applyMatrix4(matInv);
|
||||||
|
pts.push(new Vector2(pt.x, pt.y));
|
||||||
|
buls.push(this.boardBuls[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
pts.push(new Vector2(0, 0),
|
||||||
|
new Vector2(this.width, 0),
|
||||||
|
new Vector2(this.width, length),
|
||||||
|
new Vector2(0, length),
|
||||||
|
new Vector2(0, 0)
|
||||||
|
);
|
||||||
|
buls.push(0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
let ext = new ExtrudeSolid();
|
||||||
|
ext.OCSNoClone.copy(boardMat);
|
||||||
|
let pl = new Polyline(pts.map((p, i) => { return { pt: p, bul: buls[i] }; }));
|
||||||
|
ext.Thickness = this.thickness;
|
||||||
|
ext.ContourCurve = pl;
|
||||||
|
|
||||||
|
if (this.SubBoardLocal.length > 0)
|
||||||
|
ext.Grooves.push(...this.SubBoardLocal.map(sub => new SimpleBoard(sub).Conver2Ext()));
|
||||||
|
return ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
createBoard(boardMaterial: MeshBasicMaterial)
|
||||||
|
{
|
||||||
|
let ext = this.Conver2Ext();
|
||||||
|
if (this.BoardName === "地脚线")
|
||||||
|
Object.defineProperty(ext, "UCGenerator",
|
||||||
|
{
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
return boardUVGenerator2;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
//板件被镜像时.
|
||||||
|
// 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)[] = [new LineSegments(ext.EdgeGeometry, edgeMaterial)];
|
||||||
|
edges[0].applyMatrix4(ext.OCSNoClone);
|
||||||
|
|
||||||
|
if (this.Drillings.length > 0)
|
||||||
|
{
|
||||||
|
let dris = this.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 + this.thickness);
|
||||||
|
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);
|
||||||
|
|
||||||
|
// 自定义编号
|
||||||
|
this.createCustomNo();
|
||||||
|
mesh.add(this._CustomNumberTextEntity);
|
||||||
|
|
||||||
|
return { mesh, edges };
|
||||||
|
}
|
||||||
|
private createCustomNo()
|
||||||
|
{
|
||||||
|
if (!this._CustomNumberTextEntity)
|
||||||
|
{
|
||||||
|
this._CustomNumberTextEntity = new DbText();
|
||||||
|
this._CustomNumberTextEntity.TextAligen = TextAligen.Mid;
|
||||||
|
this._CustomNumberTextEntity.IsDoubleMesh = true;
|
||||||
|
this._CustomNumberTextEntity.IsFsText = this._BoardType === BoardType.Layer;
|
||||||
|
|
||||||
|
this._CustomNumberTextEntity.IsEmbedEntity = true;
|
||||||
|
}
|
||||||
|
if (this._BoardType === BoardType.Layer)
|
||||||
|
this._CustomNumberTextEntity.OCSNoClone.makeRotationZ(-Math.PI / 2).setPosition(this.width * 0.5, this.height * 0.5, this.thickness * 0.5);
|
||||||
|
else
|
||||||
|
this._CustomNumberTextEntity.OCSNoClone.identity().setPosition(this.width * 0.5, this.height * 0.5, this.thickness * 0.5);
|
||||||
|
|
||||||
|
this._CustomNumberTextEntity.TextString = this._CustomNumber?.toString() ?? "未编号";
|
||||||
|
}
|
||||||
|
}
|
@ -1,61 +1,14 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"L": 4408.678960586129,
|
"L": 2000,
|
||||||
"W": 4408.678960586129,
|
"W": 600,
|
||||||
"H": 18,
|
"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": "",
|
"CabName": "",
|
||||||
"BoardName": "",
|
"BoardName": "左侧板",
|
||||||
"BasePoint": {
|
"BasePoint": {
|
||||||
"x": -95.91743119266054,
|
"x": 778.2094240837696,
|
||||||
"y": 2910.9647449366785,
|
"y": 0,
|
||||||
"z": 1405.2625572161414
|
"z": 295.8115183248293
|
||||||
},
|
},
|
||||||
"XVec": {
|
"XVec": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
@ -72,123 +25,22 @@
|
|||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 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": [
|
"Pts": [
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 686,
|
"x": 600,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 686,
|
"x": 600,
|
||||||
"y": 444.76923076923117
|
"y": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 444.76923076923117
|
"y": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 0,
|
||||||
@ -202,141 +54,36 @@
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"SubBoardLocal": [],
|
"DataID": 3987342,
|
||||||
"SubBoardAssoc": null,
|
"Drillings": [
|
||||||
"Drillings": null
|
{
|
||||||
|
"x": 49,
|
||||||
|
"y": 987.4999999999999,
|
||||||
|
"r": 2.5,
|
||||||
|
"h": 11,
|
||||||
|
"f": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"L": 625.6923076923076,
|
"x": 549,
|
||||||
"W": 1349.3846153846157,
|
"y": 987.4999999999999,
|
||||||
"H": 5,
|
"r": 2.5,
|
||||||
"CabName": "",
|
"h": 11,
|
||||||
"BoardName": "",
|
"f": 0
|
||||||
"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": [
|
"BoardType": 1,
|
||||||
0,
|
"CustomNumber": 1
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"SubBoardLocal": [],
|
|
||||||
"SubBoardAssoc": null,
|
|
||||||
"Drillings": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"SubBoardAssoc": null,
|
|
||||||
"Drillings": null
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"L": 2000,
|
"L": 2000,
|
||||||
"W": 600,
|
"W": 600,
|
||||||
"H": 18,
|
"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": "",
|
"CabName": "",
|
||||||
"BoardName": "",
|
"BoardName": "右侧板",
|
||||||
"BasePoint": {
|
"BasePoint": {
|
||||||
"x": 1099.0825688073396,
|
"x": 1960.2094240837696,
|
||||||
"y": 288.2935779816515,
|
"y": 0,
|
||||||
"z": 1001.247706422018
|
"z": 295.8115183248293
|
||||||
},
|
},
|
||||||
"XVec": {
|
"XVec": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
@ -353,23 +100,22 @@
|
|||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"Grain": 0,
|
|
||||||
"Pts": [
|
"Pts": [
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 170.42201834862385,
|
"x": 600,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 170.42201834862385,
|
"x": 600,
|
||||||
"y": 144.00000000000023
|
"y": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 144.00000000000023
|
"y": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 0,
|
||||||
@ -383,20 +129,36 @@
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"SubBoardLocal": [],
|
"DataID": 3987343,
|
||||||
"SubBoardAssoc": null,
|
"Drillings": [
|
||||||
"Drillings": null
|
{
|
||||||
|
"x": 49,
|
||||||
|
"y": 987.4999999999999,
|
||||||
|
"r": 2.5,
|
||||||
|
"h": 11,
|
||||||
|
"f": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"L": 189.0974955047293,
|
"x": 549,
|
||||||
"W": 189.0974955047293,
|
"y": 987.4999999999999,
|
||||||
|
"r": 2.5,
|
||||||
|
"h": 11,
|
||||||
|
"f": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"BoardType": 1,
|
||||||
|
"CustomNumber": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L": 1162,
|
||||||
|
"W": 600,
|
||||||
"H": 18,
|
"H": 18,
|
||||||
"CabName": "",
|
"CabName": "",
|
||||||
"BoardName": "",
|
"BoardName": "活动层板",
|
||||||
"BasePoint": {
|
"BasePoint": {
|
||||||
"x": 1099.0825688073396,
|
"x": 1941.2094240837696,
|
||||||
"y": 234.6989586696538,
|
"y": 0,
|
||||||
"z": 1267.3595091283692
|
"z": 1304.8115183248292
|
||||||
},
|
},
|
||||||
"XVec": {
|
"XVec": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
@ -404,41 +166,47 @@
|
|||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"YVec": {
|
"YVec": {
|
||||||
|
"x": -1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 1
|
"z": 1
|
||||||
},
|
},
|
||||||
"ZVec": {
|
|
||||||
"x": 1,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"Grain": 0,
|
|
||||||
"Pts": [
|
"Pts": [
|
||||||
{
|
{
|
||||||
"x": 189.0974955047293,
|
"x": 0,
|
||||||
"y": 94.54874775236476
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": -1.4210854715202004e-14,
|
"x": 600,
|
||||||
"y": 94.54874775236478
|
"y": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 189.0974955047293,
|
"x": 600,
|
||||||
"y": 94.54874775236476
|
"y": 1162
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 1162
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Buls": [
|
"Buls": [
|
||||||
-0.9999999999999999,
|
0,
|
||||||
-0.9999999999999999,
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"SubBoardLocal": [],
|
"DataID": 3987344,
|
||||||
"SubBoardAssoc": null,
|
"Drillings": [],
|
||||||
"Drillings": null
|
"BoardType": 0,
|
||||||
}
|
"CustomNumber": 3
|
||||||
],
|
|
||||||
"SubBoardAssoc": null,
|
|
||||||
"Drillings": null
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { CylinderGeometry, EdgesGeometry, Geometry, LineSegments, Matrix4, Mesh, MeshBasicMaterial, Shape, Vector2, Vector3 } from 'three';
|
import { EdgesGeometry, Geometry, LineSegments, MeshBasicMaterial, Shape, Vector2 } from 'three';
|
||||||
import { boardUVGenerator2, ExtrudeSolid, Polyline } from 'webcad_ue4_api';
|
|
||||||
import { ColorMaterial } from './ColorPalette';
|
|
||||||
import { polar } from './GeUtils';
|
import { polar } from './GeUtils';
|
||||||
import { edgeMaterial } from './Material';
|
import { edgeMaterial } from './Material';
|
||||||
|
import { SimpleBoard } from './SimpleBoard';
|
||||||
//解析二维圆弧类.
|
//解析二维圆弧类.
|
||||||
export class Arc2d
|
export class Arc2d
|
||||||
{
|
{
|
||||||
@ -70,122 +69,11 @@ export function createPath(pts: Vector2[], buls: number[], shapeOut?: Shape): Sh
|
|||||||
}
|
}
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
export function getVec(data: object): Vector3
|
|
||||||
{
|
|
||||||
return new Vector3(data["x"], data["y"], data["z"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Conver2Ext(boardData: object): ExtrudeSolid
|
|
||||||
{
|
|
||||||
let pts: Vector2[] = [];
|
|
||||||
let buls: number[] = [];
|
|
||||||
let boardPts = boardData["Pts"];
|
|
||||||
let boardBuls = boardData["Buls"];
|
|
||||||
|
|
||||||
let boardHeight = boardData["H"];
|
|
||||||
|
|
||||||
let boardMat = new Matrix4();
|
|
||||||
let matInv: Matrix4 = new Matrix4();
|
|
||||||
//InitBoardMat
|
|
||||||
let xD = getVec(boardData["XVec"]);
|
|
||||||
let yD = getVec(boardData["YVec"]);
|
|
||||||
let ZD = getVec(boardData["ZVec"]);
|
|
||||||
let pBase = getVec(boardData["BasePoint"]);
|
|
||||||
pBase.add(ZD.clone().multiplyScalar(-boardHeight));
|
|
||||||
|
|
||||||
boardMat.makeBasis(xD, yD, ZD);
|
|
||||||
boardMat.setPosition(pBase);
|
|
||||||
matInv.getInverse(boardMat);
|
|
||||||
|
|
||||||
if (boardPts && boardPts.length !== 0)
|
|
||||||
for (let i = 0; i < boardPts.length; i++)
|
|
||||||
{
|
|
||||||
let pt = getVec(boardPts[i]);
|
|
||||||
if (boardPts[i].z !== undefined)
|
|
||||||
pt.applyMatrix4(matInv);
|
|
||||||
pts.push(new Vector2(pt.x, pt.y));
|
|
||||||
buls.push(boardBuls[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
let length = boardData["L"];
|
|
||||||
let width = boardData["W"];
|
|
||||||
pts.push(new Vector2(0, 0),
|
|
||||||
new Vector2(width, 0),
|
|
||||||
new Vector2(width, length),
|
|
||||||
new Vector2(0, length),
|
|
||||||
new Vector2(0, 0)
|
|
||||||
);
|
|
||||||
buls.push(0, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let ext = new ExtrudeSolid();
|
|
||||||
ext.OCSNoClone.copy(boardMat);
|
|
||||||
let pl = new Polyline(pts.map((p, i) => { return { pt: p, bul: buls[i] }; }));
|
|
||||||
ext.Thickness = boardHeight;
|
|
||||||
ext.ContourCurve = pl;
|
|
||||||
|
|
||||||
if (checkObjectArray(boardData, "SubBoardLocal"))
|
|
||||||
ext.Grooves.push(...boardData["SubBoardLocal"].map(Conver2Ext));
|
|
||||||
return ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建板件 暂时这么写
|
//创建板件 暂时这么写
|
||||||
export function createBoard(boardData: object, boardMaterial: MeshBasicMaterial)
|
|
||||||
{
|
|
||||||
let ext = Conver2Ext(boardData);
|
|
||||||
if (boardData["BoardName"] === "地脚线")
|
|
||||||
Object.defineProperty(ext, "UCGenerator",
|
|
||||||
{
|
|
||||||
get: function ()
|
|
||||||
{
|
|
||||||
return boardUVGenerator2;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//板件被镜像时.
|
|
||||||
// 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)[] = [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 };
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkObjectArray(obj: any, key: string)
|
|
||||||
{
|
|
||||||
return obj[key] && obj[key].length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createTemplateBoard(brDataList: any[], material: MeshBasicMaterial)
|
export function createTemplateBoard(brDataList: any[], material: MeshBasicMaterial)
|
||||||
{
|
{
|
||||||
@ -198,14 +86,15 @@ export function createTemplateBoard(brDataList: any[], material: MeshBasicMateri
|
|||||||
};
|
};
|
||||||
for (let d of brDataList)
|
for (let d of brDataList)
|
||||||
{
|
{
|
||||||
let { mesh, edges } = createBoard(d, material);
|
let board = new SimpleBoard(d);
|
||||||
|
let { mesh, edges } = board.createBoard(material);
|
||||||
meshs.push(mesh);
|
meshs.push(mesh);
|
||||||
edgesa.push(...edges);
|
edgesa.push(...edges);
|
||||||
|
|
||||||
if (d['DataID'])
|
if (board.DataID)
|
||||||
{
|
{
|
||||||
relations.blockMeshMap.set(d['DataID'], mesh.id);
|
relations.blockMeshMap.set(board.DataID, mesh.id);
|
||||||
relations.meshBlockMap.set(mesh.id, d['DataID']);
|
relations.meshBlockMap.set(mesh.id, board.DataID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { meshs, edgesa, relations };
|
return { meshs, edgesa, relations };
|
||||||
|
Loading…
Reference in New Issue
Block a user