Compare commits

...

27 Commits
v2 ... master

Author SHA1 Message Date
49a327cbee 手机端移动与拖动优化,调试环境优化 (#2)
Co-authored-by: xief <1789784602@qq.com>
Reviewed-on: #2
2025-04-07 16:18:41 +08:00
f22f1acd52 移除webpack,替换为vite,删除弃用文件 (#1)
Co-authored-by: xief <1789784602@qq.com>
Reviewed-on: #1
2024-05-23 09:45:08 +08:00
xief
f60054ca19 修改自定义编号判断 2023-07-31 17:57:16 +08:00
xief
a55986761e 修复autocad显示错误 2023-07-27 11:22:48 +08:00
xief
e5b944539e 修复双面编号问题 2023-07-18 09:19:03 +08:00
xief
27dd548309 替换问题数据源 2023-07-17 16:17:32 +08:00
xief
965ae43070 修复标注错误 2023-07-14 18:00:21 +08:00
xief
36541f1617 更新测试数据 2023-07-14 16:32:07 +08:00
xief
fba276362c 修复自定义编号不显示,添加双面显示 2023-07-14 10:41:41 +08:00
xief
66dbe5869e 修改自定义编号 2023-07-13 14:13:40 +08:00
xief
e70354267b 调整板初始化代码,新增自定义编号 2023-07-13 11:57:28 +08:00
xief
eb736bce84 更新配置 2022-03-04 10:27:23 +08:00
xief
40258eeaf4 Merge branch 'v2' into upgrade 2022-02-16 14:18:01 +08:00
xief
c586096fe0 更新版本号 2021-04-08 14:56:48 +08:00
xief
0aa70fdb14 新增鼠标选择回调事件 2021-03-17 15:53:32 +08:00
xief
93ac737777 支持材质自定义 2021-03-03 15:07:59 +08:00
xiefan
01110a8858 Merge remote-tracking branch 'origin/master' into select-block 2020-10-20 14:16:22 +08:00
xiefan
77f997b849 更新three版本 2020-10-20 14:16:04 +08:00
xiefan
23fa547a3a 修复类型错误 2020-10-20 14:03:21 +08:00
xiefan
d266b5ac2d Merge branch 'master' into select-block 2020-04-30 17:21:10 +08:00
xiefan
5bccd97ab1 修复选择无法取消 2020-04-03 10:32:08 +08:00
xiefan
caa39923dd 调整选择板代码 2020-04-03 10:17:02 +08:00
xiefan
35347e004e 调整板材选择 2020-04-02 17:24:43 +08:00
xiefan
2fd1b48d32 调整包配置 2020-04-01 16:25:47 +08:00
xiefan
a10bb71035 调整threejs类型 2020-04-01 16:12:28 +08:00
xiefan
1fbd3d6563 更新package配置,移除弃用文件 2020-04-01 15:47:30 +08:00
xiefan
fc4c46d280 新增通过ID选中板材 2020-04-01 14:15:29 +08:00
27 changed files with 1265 additions and 6736 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/node_modules /node_modules
/package-lock.json /package-lock.json
.history .history
/dist

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,37 +0,0 @@
import * as webpack from 'webpack';
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"]
},
//模块加载器设置
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: TS_LOADER,
},
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
]
},
plugins: [
]
}
export default config;

View File

@ -1,24 +0,0 @@
import path from 'path';
import * as webpack from 'webpack';
import merge from 'webpack-merge';
import common from './webpack.common';
const config: webpack.Configuration = merge(
common,
{
mode: "production",
entry: "./src/index.ts",
externals: {
'three': "THREE"
},
//输出设置
output: {
filename: "cad.js",
path: path.resolve(__dirname, './umd'),
library: "cad",
libraryTarget: "umd"
},
}
);
export default config;

View File

@ -1,29 +0,0 @@
import * as webpack from 'webpack';
import merge from 'webpack-merge';
import common from './webpack.common';
import HtmlWebPackPlugin from "html-webpack-plugin";
const config: webpack.Configuration = merge(
common,
{
mode: "development",
entry: "./src/ViewSrc/index.ts",
output: { pathinfo: false },
devtool: "eval-source-map",
devServer: {
contentBase: "./dist/",
port: 7776,
hot: true,
},
plugins: [
new webpack.NamedModulesPlugin(),//Hot
new webpack.HotModuleReplacementPlugin(),//Hot
new HtmlWebPackPlugin({
title: "webCAD",
// template: './src/index.html'
}),
]
}
);
export default config;

16
index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>CADViewComponent</title>
</head>
<body>
<script type="module" src="/src/ViewSrc/index.ts"></script>
</body>
</html>

483
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,15 +2,12 @@
"name": "cadview", "name": "cadview",
"version": "1.1.9", "version": "1.1.9",
"description": "", "description": "",
"main": "dist/index.js", "main": "src/index.ts",
"types": "dist/index.d.ts",
"private": true, "private": true,
"scripts": { "scripts": {
"t": "tsc --noEmit -w", "dev": "vite --host",
"build": "tsc", "build": "tsc && vite build",
"umd": "webpack --config ./config/webpack.umd.ts", "preview": "vite preview"
"dev": "webpack-dev-server --config ./config/webpack.view.ts",
"postinstall": "ts-node ./utils/rmtype.ts"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -19,32 +16,19 @@
"author": "cx", "author": "cx",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@types/hard-source-webpack-plugin": "^1.0.1",
"@types/node": "^13.13.52", "@types/node": "^13.13.52",
"@types/three": "^0.103.2", "@types/three": "^0.103.2",
"@types/uglifyjs-webpack-plugin": "^1.1.0", "typescript": "^5.0.2",
"@types/webpack": "^4.41.32", "vite": "^4.4.5"
"@types/webpack-dev-server": "^3.11.6",
"@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.6",
"hard-source-webpack-plugin": "^0.13.1",
"html-webpack-plugin": "^4.5.2",
"ts-loader": "^7.0.5",
"ts-node": "^8.10.2",
"typescript": "^4.5.5",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.3",
"webpack-merge": "^4.2.2"
}, },
"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"
},
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b"
} }

View File

@ -1,24 +1,24 @@
import * as THREE from 'three'; import * as THREE from 'three';
import { KeyBoard, MouseKey } from './KeyEnum';
import { Vector3 } from 'three'; import { Vector3 } from 'three';
import { equaln } from './GeUtils';
import { KeyBoard, MouseKey } from './KeyEnum';
import { Viewer } from './Viewer'; import { Viewer } from './Viewer';
//相机控制状态 //相机控制状态
export enum CameraControlState export enum CameraControlState
{ {
Null = 0, Pan = 1, Rotate = 2, Scale = 3 Null = 0, Pan = 1, Rotate = 2, Scale = 4
} }
export class CameraControls export class CameraControls
{ {
m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan]; m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale | CameraControlState.Pan, CameraControlState.Pan];
m_domElement: HTMLElement;//HTMLDocument m_domElement: HTMLElement;//HTMLDocument
//起始点击 //起始点击
m_StartClickPoint: THREE.Vector3 = new THREE.Vector3(); m_StartClickPoint: THREE.Vector3 = new THREE.Vector3();
m_EndClickPoint: THREE.Vector3 = new THREE.Vector3(); m_EndClickPoint: THREE.Vector3 = new THREE.Vector3();
m_DollyStart: THREE.Vector2 = new THREE.Vector2(); m_DollyStart: number;
m_DollyEnd: THREE.Vector2 = new THREE.Vector2();
m_KeyDown = new Map<KeyBoard, boolean>(); m_KeyDown = new Map<KeyBoard, boolean>();
m_MouseDown = new Map<MouseKey, boolean>(); m_MouseDown = new Map<MouseKey, boolean>();
@ -40,16 +40,16 @@ export class CameraControls
{ {
if (this.m_domElement) if (this.m_domElement)
{ {
this.m_domElement.addEventListener("mousedown", this.onMouseDown, false) this.m_domElement.addEventListener("mousedown", this.onMouseDown, false);
this.m_domElement.addEventListener("mousemove", this.onMouseMove, false) this.m_domElement.addEventListener("mousemove", this.onMouseMove, false);
this.m_domElement.addEventListener("mouseup", this.onMouseUp, false) this.m_domElement.addEventListener("mouseup", this.onMouseUp, false);
window.addEventListener("keydown", this.onKeyDown, false); window.addEventListener("keydown", this.onKeyDown, false);
window.addEventListener("keyup", this.onKeyUp, false); window.addEventListener("keyup", this.onKeyUp, false);
this.m_domElement.addEventListener('wheel', this.onMouseWheel, false); this.m_domElement.addEventListener('wheel', this.onMouseWheel, { passive: false });
this.m_domElement.addEventListener('touchstart', this.onTouchStart, false); this.m_domElement.addEventListener('touchstart', this.onTouchStart, { passive: false });
this.m_domElement.addEventListener('touchend', this.onTouchEnd, false); this.m_domElement.addEventListener('touchend', this.onTouchEnd, false);
this.m_domElement.addEventListener('touchmove', this.onTouchMove, false); this.m_domElement.addEventListener('touchmove', this.onTouchMove, { passive: false });
window.addEventListener("blur", this.onBlur, false); window.addEventListener("blur", this.onBlur, false);
} }
@ -62,7 +62,7 @@ export class CameraControls
{ {
this.m_KeyDown.clear(); this.m_KeyDown.clear();
this.m_MouseDown.clear(); this.m_MouseDown.clear();
} };
//触屏开始事件 //触屏开始事件
onTouchStart = (event: TouchEvent) => onTouchStart = (event: TouchEvent) =>
@ -76,15 +76,15 @@ export class CameraControls
var dx = event.touches[0].pageX - event.touches[1].pageX; var dx = event.touches[0].pageX - event.touches[1].pageX;
var dy = event.touches[0].pageY - event.touches[1].pageY; var dy = event.touches[0].pageY - event.touches[1].pageY;
var distance = Math.sqrt(dx * dx + dy * dy); var distance = Math.sqrt(dx * dx + dy * dy);
this.m_DollyStart.set(0, distance); this.m_DollyStart = distance;
} }
this.m_State = this.m_TouthTypeList[event.touches.length - 1]; this.m_State = this.m_TouthTypeList[event.touches.length - 1];
} }
} };
onTouchEnd = (event: TouchEvent) => onTouchEnd = (event: TouchEvent) =>
{ {
this.m_State = CameraControlState.Null; this.m_State = CameraControlState.Null;
} };
onTouchMove = (event: TouchEvent) => onTouchMove = (event: TouchEvent) =>
{ {
event.preventDefault(); event.preventDefault();
@ -93,40 +93,38 @@ export class CameraControls
this.m_EndClickPoint.set(event.touches[0].pageX, event.touches[0].pageY, 0); this.m_EndClickPoint.set(event.touches[0].pageX, event.touches[0].pageY, 0);
let vec = this.m_EndClickPoint.clone().sub(this.m_StartClickPoint); let vec = this.m_EndClickPoint.clone().sub(this.m_StartClickPoint);
switch (this.m_State)
{
case CameraControlState.Pan:
{
this.m_Viewer.Pan(vec);
break;
}
case CameraControlState.Scale:
{
var dx = event.touches[0].pageX - event.touches[1].pageX;
var dy = event.touches[0].pageY - event.touches[1].pageY;
var distance = Math.sqrt(dx * dx + dy * dy); if (this.m_State & CameraControlState.Pan)
this.m_DollyEnd.set(0, distance); {
if (distance > this.m_DollyStart.y) this.m_Viewer.Pan(vec);
{ }
this.m_Viewer.Zoom(0.95); if (this.m_State & CameraControlState.Scale)
} {
else var dx = event.touches[0].pageX - event.touches[1].pageX;
{ var dy = event.touches[0].pageY - event.touches[1].pageY;
this.m_Viewer.Zoom(1.05)
} var distance = Math.sqrt(dx * dx + dy * dy);
this.m_DollyStart.copy(this.m_DollyEnd); if (!equaln(this.m_DollyStart / distance, 1, 0.05))//轻微防抖
break; {
}
case CameraControlState.Rotate: if (distance > this.m_DollyStart)
{ {
this.m_Viewer.Rotate(vec.multiplyScalar(2)); this.m_Viewer.Zoom(0.95);
break;
} }
else
{
this.m_Viewer.Zoom(1.05);
}
this.m_DollyStart = distance;
}
}
if (this.m_State & CameraControlState.Rotate)
{
this.m_Viewer.Rotate(vec.multiplyScalar(2));
} }
this.m_StartClickPoint.copy(this.m_EndClickPoint); this.m_StartClickPoint.copy(this.m_EndClickPoint);
this.m_Viewer.m_bNeedUpdate = true; this.m_Viewer.m_bNeedUpdate = true;
} };
beginRotate() beginRotate()
{ {
this.m_State = CameraControlState.Rotate; this.m_State = CameraControlState.Rotate;
@ -178,13 +176,13 @@ export class CameraControls
break; break;
} }
} }
} };
onMouseUp = (event: MouseEvent) => onMouseUp = (event: MouseEvent) =>
{ {
event.preventDefault(); event.preventDefault();
this.m_State = CameraControlState.Null; this.m_State = CameraControlState.Null;
this.m_MouseDown.set(event.button, false); this.m_MouseDown.set(event.button, false);
} };
onMouseMove = (event: MouseEvent) => onMouseMove = (event: MouseEvent) =>
{ {
event.preventDefault(); event.preventDefault();
@ -195,28 +193,16 @@ export class CameraControls
(this.m_LeftUseRotate || (this.m_LeftUseRotate ||
(this.m_KeyDown.get(KeyBoard.Control)) (this.m_KeyDown.get(KeyBoard.Control))
) )
&& this.m_State == CameraControlState.Rotate && this.m_State & CameraControlState.Rotate
) )
{ {
this.m_Viewer.Rotate(changeVec); this.m_Viewer.Rotate(changeVec);
} }
switch (this.m_State) if (this.m_State & CameraControlState.Pan)
{ {
case CameraControlState.Pan: this.m_Viewer.Pan(changeVec);
{
this.m_Viewer.Pan(changeVec);
break;
}
case CameraControlState.Rotate:
{
break;
}
case CameraControlState.Scale:
{
break;
}
} }
} };
/** /**
* *
* *
@ -237,14 +223,14 @@ export class CameraControls
{ {
this.m_Viewer.Zoom(1.4, pt); this.m_Viewer.Zoom(1.4, pt);
} }
} };
//按键 //按键
onKeyDown = (event: KeyboardEvent) => onKeyDown = (event: KeyboardEvent) =>
{ {
this.m_KeyDown.set(event.keyCode, true); this.m_KeyDown.set(event.keyCode, true);
} };
onKeyUp = (event: KeyboardEvent) => onKeyUp = (event: KeyboardEvent) =>
{ {
this.m_KeyDown.set(event.keyCode, false); this.m_KeyDown.set(event.keyCode, false);
} };
} }

View File

@ -1,5 +1,5 @@
import * as THREE from 'three'; import * as THREE from 'three';
import { LineBasicMaterial, MeshBasicMaterial, Color } from 'three'; import { Color, LineBasicMaterial, MeshBasicMaterial } from 'three';
const ColorPalette = [ const ColorPalette = [
[255, 0, 0, 255], //----- 0 - lets make it red for an example [255, 0, 0, 255], //----- 0 - lets make it red for an example
//[255, 255, 255, 255],//----- 0 - ByBlock - White //[255, 255, 255, 255],//----- 0 - ByBlock - White
@ -284,7 +284,7 @@ export class ColorMaterial
{ {
if (this.m_BasicMaterialMap.has(index)) if (this.m_BasicMaterialMap.has(index))
return this.m_BasicMaterialMap.get(index); return this.m_BasicMaterialMap.get(index);
let mat = new MeshBasicMaterial({ color: this.GetColor(index) }); let mat = new MeshBasicMaterial({ color: this.GetColor(index), side: THREE.DoubleSide });
this.m_BasicMaterialMap.set(index, mat); this.m_BasicMaterialMap.set(index, mat);
return mat; return mat;
} }

View File

@ -1,4 +1,4 @@
import { Box3, Matrix4, Mesh, Vector3 } from "three"; import { Matrix4, Mesh, Vector3 } from "three";
import { Dimension, GetBoxArr } from "."; import { Dimension, GetBoxArr } from ".";
@ -19,7 +19,7 @@ export function DrawDimension(brList: Mesh[]): Dimension[]
new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
new Vector3(0, -1, 0), new Vector3(0, -1, 0),
new Vector3(0, 0, 1) new Vector3(0, 0, 1)
) );
mat4.setPosition(box.min.clone().add(new Vector3(size.x, -30))); mat4.setPosition(box.min.clone().add(new Vector3(size.x, -30)));
let textHeight = 45; let textHeight = 45;
@ -31,7 +31,7 @@ export function DrawDimension(brList: Mesh[]): Dimension[]
new Vector3(0, 0, -1), new Vector3(0, 0, -1),
new Vector3(1, 0, 0), new Vector3(1, 0, 0),
new Vector3(0, -1, 0) new Vector3(0, -1, 0)
) );
mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y))); mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y)));
dimz.applyMatrix4(mat4); dimz.applyMatrix4(mat4);
@ -40,7 +40,7 @@ export function DrawDimension(brList: Mesh[]): Dimension[]
new Vector3(0, 1, 0), new Vector3(0, 1, 0),
new Vector3(-1, 0, 0), new Vector3(-1, 0, 0),
new Vector3(0, 0, 1) new Vector3(0, 0, 1)
) );
mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y))); mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y)));
dimy.applyMatrix4(mat4); dimy.applyMatrix4(mat4);

View File

@ -1,4 +1,4 @@
import { Geometry, Vector, Vector2, Vector3, Box3, Matrix4, Object3D, Line, Mesh } from 'three'; import { Box3, Geometry, Line, Matrix4, Mesh, Object3D, Vector2, Vector3, type Vector } from 'three';
import { Matrix2 } from './Matrix2'; import { Matrix2 } from './Matrix2';
@ -112,7 +112,7 @@ export function getLoocAtUpVec(dir: Vector3): Vector3
{ {
if (dir.equals(cZeroVec)) if (dir.equals(cZeroVec))
{ {
throw ("zero vector") throw ("zero vector");
} }
let norm = dir.clone().normalize(); let norm = dir.clone().normalize();
if (norm.equals(cZAxis)) if (norm.equals(cZAxis))
@ -151,8 +151,8 @@ export function ptToString(v: Vector3, fractionDigits: number = 3): string
{ {
return v.toArray().map(o => return v.toArray().map(o =>
{ {
return o.toFixed(fractionDigits) return o.toFixed(fractionDigits);
}).join(",") }).join(",");
} }
export function midPoint(v1: Vector3, v2: Vector3): Vector3 export function midPoint(v1: Vector3, v2: Vector3): Vector3
@ -230,7 +230,7 @@ export function getProjectDist(v1: Vector3, v2: Vector3)
return { return {
h: dist * Math.cos(ang), h: dist * Math.cos(ang),
v: dist * Math.sin(ang) v: dist * Math.sin(ang)
} };
} }
//获得输入点在2线组成的4个区间的位置 //获得输入点在2线组成的4个区间的位置
export function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3) export function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3)
@ -255,10 +255,10 @@ export function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3
return { sp, ep }; return { sp, ep };
} else if (inputAng > ang1 && inputAng <= ang2) } else if (inputAng > ang1 && inputAng <= ang2)
{ {
return { sp: c.clone().add(l3), ep } return { sp: c.clone().add(l3), ep };
} else if (inputAng > ang2 && inputAng <= ang3) } else if (inputAng > ang2 && inputAng <= ang3)
{ {
return { sp: c.clone().add(l3), ep: c.clone().add(l4) } return { sp: c.clone().add(l3), ep: c.clone().add(l4) };
} else } else
{ {
return { sp, ep: c.clone().add(l4) }; return { sp, ep: c.clone().add(l4) };
@ -277,7 +277,7 @@ export function angleAndX(v: Vector3 | Vector2)
export function angleTo2Pi(an: number) export function angleTo2Pi(an: number)
{ {
an = an % (Math.PI * 2); an = an % (Math.PI * 2);
if (an < 0) an += Math.PI * 2 if (an < 0) an += Math.PI * 2;
return an; return an;
} }
export function updateGeometry(l: Line | Mesh, geometry: Geometry) export function updateGeometry(l: Line | Mesh, geometry: Geometry)

View File

@ -1,9 +1,9 @@
import * as THREE from 'three'; import * as THREE from 'three';
import { Vector3, Line3 } from "three"; import { Vector3, Line3, Plane } from "three";
export class PlaneExt extends THREE.Plane export class PlaneExt extends Plane
{ {
constructor(normal?: THREE.Vector3, constant?: number) constructor(normal?: Vector3, constant?: number)
{ {
super(normal, constant); super(normal, constant);
} }

185
src/SimpleBoard.ts Normal file
View File

@ -0,0 +1,185 @@
import { CylinderGeometry, LineSegments, Matrix4, Mesh, MeshBasicMaterial, Vector2, Vector3 } from "three";
import { ExtrudeSolid, Polyline, boardUVGenerator2 } from "webcad_ue4_api";
import { ColorMaterial } from "./ColorPalette";
import { edgeMaterial } from "./Material";
import { DbText } from "./Text";
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;
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, this.height),
new Vector2(0, this.height),
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);
// 自定义编号
if (this._CustomNumber)
{
mesh.add(this.createCustomNo());
}
mesh.applyMatrix4(ext.OCSNoClone);
mesh.updateWorldMatrix(false, true);
return { mesh, edges };
}
private createCustomNo()
{
let text = new DbText(this._CustomNumber?.toString(), 100);
let position = new Vector3(this.width * 0.5, this.height * 0.5, this.thickness * 0.5);
if (this._BoardType === BoardType.Layer)
{
text.applyMatrix4(new Matrix4().makeRotationZ(-Math.PI / 2).setPosition(position));
}
else
{
text.applyMatrix4(new Matrix4().setPosition(position));
}
// text.CreateDoubleMesh(this._BoardType === BoardType.Layer);
return text;
}
}

View File

@ -1,43 +1,59 @@
import { Font, FontLoader, Mesh, ShapeGeometry, Vector3 } from "three"; import { Font, FontLoader, Matrix4, Mesh, Shape, ShapeGeometry, Vector3 } from "three";
import f from "../resources/fonts/helvetiker_regular.typeface.json";
import { ColorMaterial } from "./ColorPalette"; import { ColorMaterial } from "./ColorPalette";
import { MoveMatrix } from "./GeUtils"; import { MoveMatrix } from "./GeUtils";
import { XAxis, XAxisN, YAxis, YAxisN, ZAxisN } from "./Utils";
class FontLoaderUtil class FontLoaderUtil
{ {
private static defFont: Font; private static defFont: Font;
static Load(): Font static Load(): Font
{
if (!this.defFont)
{ {
const f = require("../resources/fonts/helvetiker_regular.typeface.json"); if (!this.defFont)
let loader = new FontLoader(); {
this.defFont = loader.parse(f); let loader = new FontLoader();
this.defFont = loader.parse(f);
}
return this.defFont;
} }
return this.defFont;
}
} }
export class DbText extends Mesh export class DbText extends Mesh
{ {
/** /**
* *
* ,8()0 * ,8()0
* @param {string} str * @param {string} str
* @param {number} height * @param {number} height
* @memberof DbText * @memberof DbText
*/ */
constructor(str: string, height: number = 5) constructor(str: string, height: number = 5)
{ {
let font = FontLoaderUtil.Load(); let font = FontLoaderUtil.Load();
let shapes: THREE.Shape[] = font.generateShapes(str, height); let shapes: Shape[] = font.generateShapes(str, height);
let geometry = new ShapeGeometry(shapes); let geometry = new ShapeGeometry(shapes);
geometry.computeBoundingBox(); geometry.computeBoundingBox();
super(geometry, ColorMaterial.GetBasicMaterial(5)); super(geometry, ColorMaterial.GetBasicMaterial(5));
let center = geometry.boundingBox.getCenter(new Vector3()); let center = geometry.boundingBox.getCenter(new Vector3());
this.applyMatrix4(MoveMatrix(new Vector3(-center.x, 0, 0))); this.applyMatrix4(MoveMatrix(new Vector3(-center.x, 0, 0)));
} }
CreateDoubleMesh(IsFsText: boolean)
{
let mesh2 = new Mesh(this.geometry, ColorMaterial.GetBasicMaterial(5));
//左右视图时应该这样,俯视图是X,-Y,-Z(y+=(xxx)
if (IsFsText)
{
mesh2.applyMatrix4(new Matrix4().makeBasis(XAxis, YAxisN, ZAxisN));
}
else
{
mesh2.applyMatrix4(new Matrix4().makeBasis(XAxisN, YAxis, ZAxisN));
}
this.add(mesh2);
}
} }

View File

@ -1,5 +1,12 @@
import { Object3D } from "three"; import { Object3D, Vector3 } from "three";
import { createTemplateBoard, DrawDimension, Viewer } from "."; import { DrawDimension, Viewer, createTemplateBoard } from ".";
export const XAxis = new Vector3(1, 0, 0);
export const XAxisN = new Vector3(-1, 0, 0);
export const YAxis = new Vector3(0, 1, 0);
export const YAxisN = new Vector3(0, -1, 0);
export const ZAxis = new Vector3(0, 0, 1);
export const ZAxisN = new Vector3(0, 0, -1);
function dispose(m: Object3D) function dispose(m: Object3D)
{ {
@ -21,7 +28,8 @@ export function LoadBoard(view: Viewer, data: any[], clear: boolean = true)
if (data.length === 0) return; if (data.length === 0) return;
//加板 //加板
let { meshs, edgesa } = createTemplateBoard(data); let { meshs, edgesa, relations } = createTemplateBoard(data, view._Settings.boardMaterial);
//加标注 //加标注
let dims = DrawDimension(meshs); let dims = DrawDimension(meshs);
@ -32,4 +40,6 @@ export function LoadBoard(view: Viewer, data: any[], clear: boolean = true)
view.ViewToSwiso(); view.ViewToSwiso();
view.ZoomAll(); view.ZoomAll();
view.Zoom(1.1); view.Zoom(1.1);
return relations;
} }

View File

@ -1,444 +1,197 @@
[ [
{ {
"L": 4408.678960586129, "DataID": 3996018,
"W": 4408.678960586129, "OrderNo": 20230727027642,
"H": 18, "L": 800,
"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, "W": 600,
"H": 18, "H": 18,
"CabName": "主卧", "BoardName": "层板",
"BoardName": "", "Grain": 0,
"BoardType": 0,
"CustomNumber": "",
"BasePoint": { "BasePoint": {
"x": 1099.0825688073396, "x": 1877.02062480031,
"y": 73.39449541284404, "y": -1.77635683940025e-13,
"z": 0 "z": 823.651271182857
}, },
"XVec": { "XVec": {
"x": 0, "x": 2.22044604925031e-16,
"y": 1, "y": 1,
"z": 0 "z": 0
}, },
"YVec": { "YVec": {
"x": -1,
"y": 2.22044604925031e-16,
"z": 0
},
"ZVec": {
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 1 "z": 1
}, },
"Pts": [],
"Buls": [],
"SubBoardLocal": [],
"SubBoardAssoc": [],
"Drillings": [
{
"x": 50,
"y": 766,
"r": 7.5,
"h": 13.5,
"f": 0
},
{
"x": 300,
"y": 766,
"r": 7.5,
"h": 13.5,
"f": 0
},
{
"x": 550,
"y": 766,
"r": 7.5,
"h": 13.5,
"f": 0
},
{
"x": 550,
"y": 34,
"r": 7.5,
"h": 13.5,
"f": 0
},
{
"x": 300,
"y": 34,
"r": 7.5,
"h": 13.5,
"f": 0
},
{
"x": 50,
"y": 34,
"r": 7.5,
"h": 13.5,
"f": 0
}
]
},
{
"DataID": 3996019,
"OrderNo": 20230727027642,
"L": 1200,
"W": 600,
"H": 18,
"BoardName": "右侧板",
"Grain": 0,
"BoardType": 0,
"CustomNumber": "",
"BasePoint": {
"x": 1895.02062480031,
"y": 0,
"z": 214.651271182857
},
"XVec": {
"x": 4.93038065763132e-32,
"y": 1,
"z": -2.22044604925031e-16
},
"YVec": {
"x": -2.22044604925031e-16,
"y": 2.22044604925031e-16,
"z": 1
},
"ZVec": { "ZVec": {
"x": 1, "x": 1,
"y": 0, "y": 0,
"z": 0 "z": 2.22044604925031e-16
}, },
"Pts": [],
"Buls": [],
"SubBoardLocal": [],
"SubBoardAssoc": [],
"Drillings": [
{
"x": 550,
"y": 600,
"r": 5,
"h": 13.5,
"f": 1
},
{
"x": 300,
"y": 600,
"r": 5,
"h": 13.5,
"f": 1
},
{
"x": 50,
"y": 600,
"r": 5,
"h": 13.5,
"f": 1
}
]
},
{
"DataID": 3996020,
"OrderNo": 20230727027642,
"L": 1200,
"W": 600,
"H": 18,
"BoardName": "左侧板",
"Grain": 0, "Grain": 0,
"Pts": [ "BoardType": 0,
"CustomNumber": "",
"BasePoint": {
"x": 1077.02062480031,
"y": 0,
"z": 214.651271182857
},
"XVec": {
"x": 4.93038065763132e-32,
"y": 1,
"z": -2.22044604925031e-16
},
"YVec": {
"x": -2.22044604925031e-16,
"y": 2.22044604925031e-16,
"z": 1
},
"ZVec": {
"x": 1,
"y": 0,
"z": 2.22044604925031e-16
},
"Pts": [],
"Buls": [],
"SubBoardLocal": [],
"SubBoardAssoc": [],
"Drillings": [
{ {
"x": 0, "x": 50,
"y": 0 "y": 600,
"r": 5,
"h": 13.5,
"f": 0
}, },
{ {
"x": 600, "x": 300,
"y": 0 "y": 600,
"r": 5,
"h": 13.5,
"f": 0
}, },
{ {
"x": 600, "x": 550,
"y": 2000 "y": 600,
}, "r": 5,
{ "h": 13.5,
"x": 0, "f": 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
} }
] ]

View File

@ -1,14 +0,0 @@
<!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>

View File

@ -1,10 +1,10 @@
// import { Color, Face3, MeshBasicMaterial, Object3D, Vector2, Vector3 } from "three"; // import { Color, Face3, MeshBasicMaterial, Object3D, Vector2, Vector3 } from "three";
// import "./style.css"; // import "./style.css";
import { Vector3 } from "three"; import { Color, MeshBasicMaterial, Vector3 } from "three";
import { CameraControlState } from "../CameraControls";
import { GetBox } from "../GeUtils"; import { GetBox } from "../GeUtils";
import { LoadBoard } from "../Utils"; import { LoadBoard } from "../Utils";
import { Viewer } from "../Viewer"; import { Viewer } from "../Viewer";
import data from "./data.json";
let btn = document.createElement("button"); let btn = document.createElement("button");
btn.innerHTML = "载入"; btn.innerHTML = "载入";
@ -20,22 +20,31 @@ document.body.appendChild(btn3);
let el = document.createElement("canvas"); let el = document.createElement("canvas");
el.style.width = "80%"; el.style.width = "100%";
el.style.height = "80%"; el.style.height = "80vh";
document.body.appendChild(el); document.body.appendChild(el);
let view = new Viewer(el); let view = new Viewer(el, (settings) =>
{
settings.boardMaterial = new MeshBasicMaterial({
color: new Color(0.8, 0.8, 0.8),
polygonOffset: true,
polygonOffsetFactor: 1, // positive value pushes polygon further away
polygonOffsetUnits: 1,
transparent: true,
opacity: 0.5
});
});
//修改这个顺序 改变1 2 3 个触摸点时的触发状态. //修改这个顺序 改变1 2 3 个触摸点时的触发状态.
view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan]; // view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan];
//例如,修改单指滑动为平移. //例如,修改单指滑动为平移.
view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Pan, CameraControlState.Scale, CameraControlState.Rotate]; // view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Pan, CameraControlState.Scale, CameraControlState.Rotate];
//加载 //加载
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();

View File

@ -1,199 +1,243 @@
import { Mesh, Raycaster, Scene, Vector3, WebGLRenderer, WebGLRendererParameters } from "three"; import { Mesh, MeshBasicMaterial, Raycaster, Scene, Vector3, WebGLRenderer, type WebGLRendererParameters } from "three";
import { boardMaterial, CameraControls, PointPick, selectMaterial } from "."; import { CameraControls, PointPick, boardMaterial, selectMaterial } from ".";
import { CameraUpdate } from "./CameraUpdate"; import { CameraUpdate } from "./CameraUpdate";
import { ColorMaterial } from "./ColorPalette"; import { ColorMaterial } from "./ColorPalette";
import { cZeroVec, GetBox, GetBoxArr } from "./GeUtils"; import { GetBox, GetBoxArr, cZeroVec } from "./GeUtils";
import { PlaneExt } from "./PlaneExt"; import { PlaneExt } from "./PlaneExt";
export class ViewerSettings
{
boardMaterial: MeshBasicMaterial = boardMaterial;
selectMaterial: MeshBasicMaterial = selectMaterial;
selectByPointCallback: (meshId: number) => void = () => { };
}
export class Viewer export class Viewer
{ {
m_LookTarget: any; m_LookTarget: any;
m_Camera: CameraUpdate = new CameraUpdate(); m_Camera: CameraUpdate = new CameraUpdate();
m_CameraCtrl: CameraControls; m_CameraCtrl: CameraControls;
m_bNeedUpdate: boolean = true; m_bNeedUpdate: boolean = true;
m_Render: WebGLRenderer;//渲染器 //暂时只用这个类型 m_Render: WebGLRenderer;//渲染器 //暂时只用这个类型
m_DomEl: HTMLElement; //画布容器 m_DomEl: HTMLElement; //画布容器
_Height: number; _Height: number = 0;
_Width: number; _Width: number = 0;
m_Scene: Scene = new Scene(); m_Scene: Scene = new Scene();
/** _Settings = new ViewerSettings();
* /**
* @param {HTMLElement} canvasContainer div或者一个画布 *
* @memberof Viewer * @param {HTMLElement} canvasContainer div或者一个画布
*/ * @memberof Viewer
constructor(canvasContainer: HTMLElement) */
{ constructor(canvasContainer: HTMLElement, setupAction: (settings: ViewerSettings) => void = null)
this.m_DomEl = canvasContainer;
this.initRender(canvasContainer);
this.OnSize();
this.StartRender();
this.m_CameraCtrl = new CameraControls(this);
window.addEventListener("resize", () =>
{ {
this.OnSize(); if (setupAction)
}); {
setupAction(this._Settings);
}
let oldMesh: Mesh; this.m_DomEl = canvasContainer;
this.m_Render.domElement.addEventListener("mousemove", (e: MouseEvent) => this.initRender(canvasContainer);
this.OnSize();
this.StartRender();
this.m_CameraCtrl = new CameraControls(this);
window.addEventListener("resize", () =>
{
this.OnSize();
});
this.m_Render.domElement.addEventListener("mousemove", (e: MouseEvent) =>
{
this.SelectByPoint(e.offsetX, e.offsetY);
});
}
//初始化render
initRender(canvasContainer: HTMLElement)
{ {
let mesh = PointPick(this, e.offsetX, e.offsetY); let params: WebGLRendererParameters = {
if (oldMesh) antialias: true,//antialias:true/false是否开启反锯齿
oldMesh.material = boardMaterial; precision: "highp",//precision:highp/mediump/lowp着色精度选择
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1)) alpha: true//alpha:true/false是否可以设置背景色透明
{ };
oldMesh = mesh; if (canvasContainer instanceof HTMLCanvasElement)
mesh.material = selectMaterial; {
} params.canvas = canvasContainer;
this.m_bNeedUpdate = true; this.m_Render = new WebGLRenderer(params);
}) }
} else
{
this.m_Render = new WebGLRenderer(params);
//加到画布
canvasContainer.appendChild(this.m_Render.domElement);
}
//初始化render this.m_Render.autoClear = true;
initRender(canvasContainer: HTMLElement)
{ //如果设置那么它希望所有的纹理和颜色都是预乘的伽玛。默认值为false。
let params: WebGLRendererParameters = { // this.m_Render.gammaInput = true;
antialias: true,//antialias:true/false是否开启反锯齿 // this.m_Render.gammaOutput = true;
precision: "highp",//precision:highp/mediump/lowp着色精度选择 // this.m_Render.shadowMap.enabled = true;
alpha: true//alpha:true/false是否可以设置背景色透明 // this.m_Render.toneMapping = ReinhardToneMapping;
//设置设备像素比。 这通常用于HiDPI设备以防止模糊输出画布。
this.m_Render.setPixelRatio(window.devicePixelRatio);
this.m_Render.physicallyCorrectLights = true;
//this.m_Render.toneMappingExposure = Math.pow(1, 5.0); // to allow for very bright scenes.
//设置它的背景色为黑色
this.m_Render.setClearColor(0xffffff, 1);
this.OnSize();
}
OnSize = (width?, height?) =>
{
this._Width = width ? width : this.m_DomEl.clientWidth;
this._Height = height ? height : this.m_DomEl.clientHeight;
//校验.成为2的倍数 避免外轮廓错误.
if (this._Width % 2 == 1)
this._Width -= 1;
if (this._Height % 2 == 1)
this._Height -= 1;
this.m_Render.setSize(this._Width, this._Height);
this.m_Camera.SetSize(this._Width, this._Height);
}; };
if (canvasContainer instanceof HTMLCanvasElement)
StartRender = () =>
{ {
params.canvas = canvasContainer; requestAnimationFrame(this.StartRender);
this.m_Render = new WebGLRenderer(params); if (this.m_Scene != null && this.m_bNeedUpdate)
} {
else this.Render();
this.m_bNeedUpdate = false;
}
};
Render()
{ {
this.m_Render = new WebGLRenderer(params); this.m_Render.render(this.m_Scene, this.m_Camera.Camera);
//加到画布
canvasContainer.appendChild(this.m_Render.domElement);
} }
this.m_Render.autoClear = true; ScreenToWorld(pt: Vector3, planVec?: Vector3)
//如果设置那么它希望所有的纹理和颜色都是预乘的伽玛。默认值为false。
// this.m_Render.gammaInput = true;
// this.m_Render.gammaOutput = true;
// this.m_Render.shadowMap.enabled = true;
// this.m_Render.toneMapping = ReinhardToneMapping;
//设置设备像素比。 这通常用于HiDPI设备以防止模糊输出画布。
this.m_Render.setPixelRatio(window.devicePixelRatio);
this.m_Render.physicallyCorrectLights = true;
//this.m_Render.toneMappingExposure = Math.pow(1, 5.0); // to allow for very bright scenes.
//设置它的背景色为黑色
this.m_Render.setClearColor(0xffffff, 1);
this.OnSize();
}
OnSize = (width?, height?) =>
{
this._Width = width ? width : this.m_DomEl.clientWidth;
this._Height = height ? height : this.m_DomEl.clientHeight;
//校验.成为2的倍数 避免外轮廓错误.
if (this._Width % 2 == 1)
this._Width -= 1;
if (this._Height % 2 == 1)
this._Height -= 1;
this.m_Render.setSize(this._Width, this._Height);
this.m_Camera.SetSize(this._Width, this._Height);
}
StartRender = () =>
{
requestAnimationFrame(this.StartRender);
if (this.m_Scene != null && this.m_bNeedUpdate)
{ {
this.Render(); //变换和求交点
this.m_bNeedUpdate = false; let plan = new PlaneExt(planVec || new Vector3(0, 0, 1));
let raycaster = new Raycaster();
// 射线从相机射线向屏幕点位置
raycaster.setFromCamera(
{
x: (pt.x / this._Width) * 2 - 1,
y: - (pt.y / this._Height) * 2 + 1
}
, this.m_Camera.Camera
);
plan.intersectRay(raycaster.ray, pt, true);
} }
} WorldToScreen(pt: Vector3)
Render() {
{ let widthHalf = this._Width * 0.5;
this.m_Render.render(this.m_Scene, this.m_Camera.Camera); let heightHalf = this._Height * 0.5;
}
ScreenToWorld(pt: Vector3, planVec?: Vector3) pt.project(this.m_Camera.Camera);
{
//变换和求交点
let plan = new PlaneExt(planVec || new Vector3(0, 0, 1));
let raycaster = new Raycaster();
// 射线从相机射线向屏幕点位置
raycaster.setFromCamera(
{
x: (pt.x / this._Width) * 2 - 1,
y: - (pt.y / this._Height) * 2 + 1
}
, this.m_Camera.Camera
)
plan.intersectRay(raycaster.ray, pt, true);
}
WorldToScreen(pt: Vector3)
{
let widthHalf = this._Width * 0.5;
let heightHalf = this._Height * 0.5;
pt.project(this.m_Camera.Camera); pt.x = (pt.x * widthHalf) + widthHalf;
pt.y = - (pt.y * heightHalf) + heightHalf;
}
pt.x = (pt.x * widthHalf) + widthHalf; /**
pt.y = - (pt.y * heightHalf) + heightHalf; * ()
} *
* @memberof Viewer
*/
UpdateLockTarget()
{
let renderList = this.m_Render.renderLists.get(this.m_Scene, this.m_Camera.Camera);
let box = GetBoxArr(renderList.opaque.map(o => o.object));
if (box)
this.m_LookTarget = box.getCenter(new Vector3());
else
this.m_LookTarget = cZeroVec;
}
Rotate(mouseMove: Vector3)
{
this.m_Camera.Rotate(mouseMove, this.m_LookTarget);
this.m_bNeedUpdate = true;
}
Pan(mouseMove: Vector3)
{
this.m_Camera.Pan(mouseMove);
this.m_bNeedUpdate = true;
}
Zoom(scale: number, center?: Vector3)
{
this.m_Camera.Zoom(scale, center);
this.m_bNeedUpdate = true;
}
ZoomAll()
{
this.m_Camera.ZoomExtensBox3(GetBox(this.m_Scene, true));
this.m_bNeedUpdate = true;
}
/** ViewToTop()
* () {
* this.m_Camera.LookAt(new Vector3(0, 0, -1));
* @memberof Viewer this.m_bNeedUpdate = true;
*/ }
UpdateLockTarget() ViewToFront()
{ {
let renderList = this.m_Render.renderLists.get(this.m_Scene, this.m_Camera.Camera); this.m_Camera.LookAt(new Vector3(0, 1, 0));
let box = GetBoxArr(renderList.opaque.map(o => o.object)); this.m_bNeedUpdate = true;
if (box) }
this.m_LookTarget = box.getCenter(new Vector3()); ViewToSwiso()
else {
this.m_LookTarget = cZeroVec; this.m_Camera.LookAt(new Vector3(1, 1, -1));
} this.m_bNeedUpdate = true;
Rotate(mouseMove: Vector3) }
{
this.m_Camera.Rotate(mouseMove, this.m_LookTarget);
this.m_bNeedUpdate = true;
}
Pan(mouseMove: Vector3)
{
this.m_Camera.Pan(mouseMove);
this.m_bNeedUpdate = true;
}
Zoom(scale: number, center?: Vector3)
{
this.m_Camera.Zoom(scale, center);
this.m_bNeedUpdate = true;
}
ZoomAll()
{
this.m_Camera.ZoomExtensBox3(GetBox(this.m_Scene, true));
this.m_bNeedUpdate = true;
}
ViewToTop() oldMesh: Mesh;
{ SelectByPoint(x: number, y: number)
this.m_Camera.LookAt(new Vector3(0, 0, -1)); {
this.m_bNeedUpdate = true; let mesh = PointPick(this, x, y);
} if (this.oldMesh)
ViewToFront() this.oldMesh.material = this._Settings.boardMaterial;
{ if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
this.m_Camera.LookAt(new Vector3(0, 1, 0)); {
this.m_bNeedUpdate = true; this.oldMesh = mesh;
} mesh.material = this._Settings.selectMaterial;
ViewToSwiso() if (this._Settings.selectByPointCallback)
{ {
this.m_Camera.LookAt(new Vector3(1, 1, -1)); this._Settings.selectByPointCallback(mesh.id);
this.m_bNeedUpdate = true; }
} }
this.m_bNeedUpdate = true;
}
SelectBlock(blockMeshMap: Map<number, number>, dataID: number)
{
if (blockMeshMap.has(dataID))
{
let meshId = blockMeshMap.get(dataID);
if (this.oldMesh)
this.oldMesh.material = this._Settings.boardMaterial;
this.m_Scene.children.forEach(obj =>
{
if (obj instanceof Mesh)
{
if (obj.id == meshId)
{
this.oldMesh = obj;
obj.material = this._Settings.selectMaterial;
this.m_bNeedUpdate = true;
}
}
});
}
}
} }

View File

@ -1,8 +1,7 @@
import { CylinderGeometry, EdgesGeometry, Geometry, LineSegments, Matrix4, Mesh, 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 { boardMaterial, edgeMaterial } from './Material'; import { edgeMaterial } from './Material';
import { SimpleBoard } from './SimpleBoard';
//解析二维圆弧类. //解析二维圆弧类.
export class Arc2d export class Arc2d
{ {
@ -70,134 +69,35 @@ 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)
{
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];
// }
//边 export function createTemplateBoard(brDataList: any[], material: MeshBasicMaterial)
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[])
{ {
let meshs = []; let meshs = [];
let edgesa = []; let edgesa = [];
let relations = {
blockMeshMap: new Map<number, number>(),
meshBlockMap: new Map<number, number>()
};
for (let d of brDataList) for (let d of brDataList)
{ {
let { mesh, edges } = createBoard(d); let board = new SimpleBoard(d);
let { mesh, edges } = board.createBoard(material);
meshs.push(mesh); meshs.push(mesh);
edgesa.push(...edges); edgesa.push(...edges);
if (board.DataID)
{
relations.blockMeshMap.set(board.DataID, mesh.id);
relations.meshBlockMap.set(mesh.id, board.DataID);
}
} }
return { meshs, edgesa }; return { meshs, edgesa, relations };
} }
export function createEdge(geo: Geometry): LineSegments export function createEdge(geo: Geometry): LineSegments

View File

@ -1,550 +0,0 @@
export var data =
[
{
"L": 100.0,
"W": 800.0,
"H": 18.0,
"BasePoint": {
"x": 2076.407626150509,
"y": 1942.2104819571228,
"z": 1882.0
},
"XVec": {
"x": 1.0,
"y": 4.930380657631324e-32,
"z": -2.220446049250313e-16
},
"YVec": {
"x": 2.220446049250313e-16,
"y": 2.220446049250313e-16,
"z": 1.0
},
"ZVec": {
"x": 9.860761315262648e-32,
"y": -1.0,
"z": 2.220446049250313e-16
},
"Pts": [
{
"x": 2076.407626150509,
"y": 1942.2104819571228,
"z": 1882.0
},
{
"x": 2876.407626150509,
"y": 1942.2104819571228,
"z": 1881.9999999999998
},
{
"x": 2876.407626150509,
"y": 1942.2104819571228,
"z": 1981.9999999999998
},
{
"x": 2076.407626150509,
"y": 1942.2104819571228,
"z": 1982.0
},
{
"x": 2076.407626150509,
"y": 1942.2104819571228,
"z": 1882.0
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 800.0,
"W": 100.00000000000068,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2876.407626150509,
"y": 1960.2104819571226,
"z": 1900.0000000000005
},
"XVec": {
"x": 4.440892098500626e-16,
"y": 1.0,
"z": 2.2204460492503124e-16
},
"YVec": {
"x": -1.0,
"y": 4.440892098500626e-16,
"z": 2.220446049250314e-16
},
"ZVec": {
"x": 2.220446049250313e-16,
"y": -2.220446049250313e-16,
"z": 1.0
},
"Handle": "293",
"CabName": "1.标准柜上梁1",
"BoardName": "",
"Grain": 0,
"Pts": [
{
"x": 2876.407626150509,
"y": 1960.2104819571228,
"z": 1900.0000000000005
},
{
"x": 2876.407626150509,
"y": 2060.210481957123,
"z": 1900.0000000000005
},
{
"x": 2076.407626150509,
"y": 2060.210481957123,
"z": 1900.0000000000005
},
{
"x": 2076.407626150509,
"y": 1960.210481957123,
"z": 1900.0000000000005
},
{
"x": 2876.407626150509,
"y": 1960.2104819571228,
"z": 1900.0000000000005
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 1899.9999999999998,
"W": 800.0,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2076.407626150509,
"y": 2060.2104819571225,
"z": -1.816324868286756e-13
},
"XVec": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"YVec": {
"x": 0.0,
"y": 4.440892098500626e-16,
"z": 1.0
},
"ZVec": {
"x": 0.0,
"y": -1.0,
"z": 4.440892098500626e-16
},
"Handle": "291",
"CabName": "1.标准柜上梁1",
"BoardName": "背板",
"Grain": 0,
"Pts": [
{
"x": 2076.407626150509,
"y": 2060.2104819571225,
"z": -1.021405182655144e-13
},
{
"x": 2876.407626150509,
"y": 2060.2104819571225,
"z": -1.816324868286756e-13
},
{
"x": 2876.407626150509,
"y": 2060.210481957123,
"z": 1899.9999999999996
},
{
"x": 2076.407626150509,
"y": 2060.210481957123,
"z": 1899.9999999999998
},
{
"x": 2076.407626150509,
"y": 2060.2104819571225,
"z": -1.021405182655144e-13
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 800.0,
"W": 482.0000000000002,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2876.407626150509,
"y": 1578.210481957122,
"z": 97.99999999999999
},
"XVec": {
"x": 4.440892098500626e-16,
"y": 1.0,
"z": 0.0
},
"YVec": {
"x": -1.0,
"y": 4.440892098500626e-16,
"z": 0.0
},
"ZVec": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"Handle": "290",
"CabName": "1.标准柜上梁1",
"BoardName": "底板",
"Grain": 0,
"Pts": [
{
"x": 2876.407626150509,
"y": 1578.210481957122,
"z": 97.99999999999999
},
{
"x": 2876.407626150509,
"y": 2060.2104819571225,
"z": 97.99999999999999
},
{
"x": 2076.407626150509,
"y": 2060.2104819571225,
"z": 97.99999999999999
},
{
"x": 2076.407626150509,
"y": 1578.2104819571226,
"z": 97.99999999999999
},
{
"x": 2876.407626150509,
"y": 1578.210481957122,
"z": 97.99999999999999
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 80.0,
"W": 800.0,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2076.407626150509,
"y": 1578.2104819571223,
"z": 0.0
},
"XVec": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"YVec": {
"x": 0.0,
"y": 4.440892098500626e-16,
"z": 1.0
},
"ZVec": {
"x": 0.0,
"y": -1.0,
"z": 4.440892098500626e-16
},
"Handle": "28E",
"CabName": "1.标准柜上梁1",
"BoardName": "地脚线",
"Grain": 1,
"Pts": [
{
"x": 2076.407626150509,
"y": 1578.2104819571223,
"z": 0.0
},
{
"x": 2876.407626150509,
"y": 1578.2104819571223,
"z": 0.0
},
{
"x": 2876.407626150509,
"y": 1578.2104819571223,
"z": 80.0
},
{
"x": 2076.407626150509,
"y": 1578.2104819571223,
"z": 80.0
},
{
"x": 2076.407626150509,
"y": 1578.2104819571223,
"z": 0.0
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 800.0,
"W": 482.0,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2876.4076261505085,
"y": 1478.210481957122,
"z": 1999.9999999999996
},
"XVec": {
"x": 4.440892098500626e-16,
"y": 1.0,
"z": 0.0
},
"YVec": {
"x": -1.0,
"y": 4.440892098500626e-16,
"z": 0.0
},
"ZVec": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"Handle": "28C",
"CabName": "1.标准柜上梁1",
"BoardName": "顶板",
"Grain": 0,
"Pts": [
{
"x": 2076.407626150509,
"y": 1960.2104819571223,
"z": 1999.9999999999996
},
{
"x": 2076.407626150509,
"y": 1478.2104819571226,
"z": 1999.9999999999996
},
{
"x": 2876.407626150509,
"y": 1478.210481957122,
"z": 1999.9999999999996
},
{
"x": 2876.4076261505085,
"y": 1960.210481957122,
"z": 1999.9999999999996
},
{
"x": 2076.407626150509,
"y": 1960.2104819571223,
"z": 1999.9999999999996
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 1999.9999999999996,
"W": 600.0,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2894.4076261505094,
"y": 1478.2104819571223,
"z": -2.2737367544323197e-13
},
"XVec": {
"x": 4.930380657631324e-32,
"y": 1.0,
"z": -2.220446049250313e-16
},
"YVec": {
"x": -2.220446049250313e-16,
"y": 2.220446049250313e-16,
"z": 1.0
},
"ZVec": {
"x": 1.0,
"y": 0.0,
"z": 2.220446049250313e-16
},
"Handle": "28B",
"CabName": "1.标准柜上梁1",
"BoardName": "右侧板",
"Grain": 0,
"Pts": [
{
"x": 2894.407626150509,
"y": 1960.2104819571228,
"z": 1899.9999999999989
},
{
"x": 2894.407626150509,
"y": 1960.2104819571228,
"z": 1999.9999999999994
},
{
"x": 2894.407626150509,
"y": 1478.2104819571228,
"z": 1999.9999999999994
},
{
"x": 2894.4076261505094,
"y": 1478.2104819571223,
"z": -1.816324868286755e-13
},
{
"x": 2894.4076261505094,
"y": 2078.2104819571225,
"z": -6.274980535181384e-13
},
{
"x": 2894.407626150509,
"y": 2078.2104819571229,
"z": 1899.9999999999973
},
{
"x": 2894.407626150509,
"y": 1960.2104819571228,
"z": 1899.9999999999989
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
},
{
"L": 1999.9999999999996,
"W": 600.0,
"H": 18.0,
"MaterialId": "EE",
"BasePoint": {
"x": 2076.4076261505094,
"y": 1478.2104819571223,
"z": 1.0097419586828951e-28
},
"XVec": {
"x": 4.930380657631324e-32,
"y": 1.0,
"z": -2.220446049250313e-16
},
"YVec": {
"x": -2.220446049250313e-16,
"y": 2.220446049250313e-16,
"z": 1.0
},
"ZVec": {
"x": 1.0,
"y": 0.0,
"z": 2.220446049250313e-16
},
"Handle": "288",
"CabName": "1.标准柜上梁1",
"BoardName": "左侧板",
"Grain": 0,
"Pts": [
{
"x": 2076.407626150509,
"y": 1960.2104819571228,
"z": 1899.999999999999
},
{
"x": 2076.407626150509,
"y": 1960.2104819571228,
"z": 1999.9999999999996
},
{
"x": 2076.407626150509,
"y": 1478.2104819571228,
"z": 1999.9999999999996
},
{
"x": 2076.4076261505094,
"y": 1478.2104819571223,
"z": 1.0097419586828951e-28
},
{
"x": 2076.4076261505094,
"y": 2078.2104819571225,
"z": -4.4586556668946279e-13
},
{
"x": 2076.407626150509,
"y": 2078.2104819571229,
"z": 1899.9999999999978
},
{
"x": 2076.407626150509,
"y": 1960.2104819571228,
"z": 1899.999999999999
}
],
"Buls": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
],
"SubBoardLocal": [],
"SubBoardAssoc": []
}
]

1
src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@ -2,21 +2,27 @@
"compilerOptions": { "compilerOptions": {
"outDir": "./dist", "outDir": "./dist",
"sourceMap": true, "sourceMap": true,
"module": "commonjs", "module": "ESNext",
"target": "es2020", "target": "ES2020",
"noLib": false, "noLib": false,
"moduleResolution": "node",
"skipLibCheck": true, "skipLibCheck": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"verbatimModuleSyntax":true,
/* Bundler mode */
"moduleResolution": "bundler",
"esModuleInterop": true, "esModuleInterop": true,
"lib": [ "allowImportingTsExtensions": true,
"esnext", "resolveJsonModule": true,
"dom" "isolatedModules": true,
], "noEmit": true,
"types": [
"node", /* Linting */
"webpack-env", // "strict": true,
"webpack-dev-server", // "noUnusedLocals": true,
], // "noUnusedParameters": true,
// "noFallthroughCasesInSwitch": true,
"jsx": "react", "jsx": "react",
"experimentalDecorators": true "experimentalDecorators": true
}, },

File diff suppressed because one or more lines are too long

5215
yarn.lock

File diff suppressed because it is too large Load Diff