Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
49a327cbee | |||
f22f1acd52 | |||
![]() |
f60054ca19 | ||
![]() |
a55986761e | ||
![]() |
e5b944539e | ||
![]() |
27dd548309 | ||
![]() |
965ae43070 | ||
![]() |
36541f1617 | ||
![]() |
fba276362c | ||
![]() |
66dbe5869e | ||
![]() |
e70354267b | ||
![]() |
eb736bce84 | ||
![]() |
40258eeaf4 | ||
![]() |
623fa9ac9a | ||
![]() |
c586096fe0 | ||
![]() |
0aa70fdb14 | ||
![]() |
93ac737777 | ||
![]() |
01110a8858 | ||
![]() |
77f997b849 | ||
![]() |
23fa547a3a | ||
![]() |
e712b7b4e2 | ||
![]() |
d266b5ac2d | ||
![]() |
85db279fab | ||
![]() |
5bccd97ab1 | ||
![]() |
caa39923dd | ||
![]() |
35347e004e | ||
![]() |
2fd1b48d32 | ||
![]() |
a10bb71035 | ||
![]() |
1fbd3d6563 | ||
![]() |
fc4c46d280 | ||
![]() |
d79d759091 | ||
![]() |
bda2b05204 | ||
![]() |
2ef48e17c6 | ||
![]() |
c99f7f8149 | ||
![]() |
563ea73750 | ||
![]() |
c1e9aac48b | ||
![]() |
fcf2a1eb73 | ||
![]() |
29a6dd0fff | ||
![]() |
256a7ea8a6 | ||
![]() |
1f0a91b75a | ||
![]() |
fa20fa5f48 | ||
![]() |
f72bb04ff5 | ||
![]() |
ffd1404d12 | ||
![]() |
128b1bcf70 | ||
![]() |
cbe28efb08 | ||
![]() |
4f3d7a6388 | ||
![]() |
35443367f3 | ||
![]() |
957107378e | ||
![]() |
2a17e619a2 | ||
![]() |
5fc8d4b0f4 | ||
![]() |
2a209becbb | ||
![]() |
e3c565a83d |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
||||
/node_modules
|
||||
/package-lock.json
|
||||
.history
|
||||
/dist
|
||||
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "启动 Chrome 并打开 localhost",
|
||||
"url": "http://localhost:666",
|
||||
"url": "http://localhost:7776",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
|
31
.vscode/settings.json
vendored
31
.vscode/settings.json
vendored
@ -3,8 +3,10 @@
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||
//格式化设置
|
||||
"editor.tabSize": 4,
|
||||
"editor.formatOnPaste": true,
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.insertSpaces": true,
|
||||
"editor.detectIndentation": false,
|
||||
//格式设置
|
||||
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
|
||||
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
|
||||
@ -12,5 +14,30 @@
|
||||
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
|
||||
"javascript.format.enable": 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)
|
||||
|
||||
|
||||
删除"@types/webpack-merge" 下的 node_modules/webpack 定义 坑爹导致项目跑不起来
|
||||
|
45
dist/CameraControls.d.ts
vendored
45
dist/CameraControls.d.ts
vendored
@ -1,45 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
import { KeyBoard, MouseKey } from './KeyEnum';
|
||||
import { Viewer } from './Viewer';
|
||||
export declare enum CameraControlState {
|
||||
Null = 0,
|
||||
Pan = 1,
|
||||
Rotate = 2,
|
||||
Scale = 3,
|
||||
}
|
||||
export declare class CameraControls {
|
||||
m_TouthTypeList: CameraControlState[];
|
||||
m_domElement: HTMLElement;
|
||||
m_StartClickPoint: THREE.Vector3;
|
||||
m_EndClickPoint: THREE.Vector3;
|
||||
m_DollyStart: THREE.Vector2;
|
||||
m_DollyEnd: THREE.Vector2;
|
||||
m_KeyDown: Map<KeyBoard, boolean>;
|
||||
m_MouseDown: Map<MouseKey, boolean>;
|
||||
m_State: CameraControlState;
|
||||
m_Viewer: Viewer;
|
||||
m_LeftUseRotate: boolean;
|
||||
constructor(viewer: Viewer);
|
||||
RegisterEvent(): void;
|
||||
/**
|
||||
* 窗体失去焦点时.
|
||||
*
|
||||
* @memberof CameraControls
|
||||
*/
|
||||
onBlur: () => void;
|
||||
onTouchStart: (event: TouchEvent) => void;
|
||||
onTouchEnd: (event: TouchEvent) => void;
|
||||
onTouchMove: (event: TouchEvent) => void;
|
||||
beginRotate(): void;
|
||||
onMouseDown: (event: MouseEvent) => void;
|
||||
onMouseUp: (event: MouseEvent) => void;
|
||||
onMouseMove: (event: MouseEvent) => void;
|
||||
/**
|
||||
* 鼠标滚轮事件
|
||||
*
|
||||
* @memberof CameraControls
|
||||
*/
|
||||
onMouseWheel: (event: WheelEvent) => void;
|
||||
onKeyDown: (event: KeyboardEvent) => void;
|
||||
onKeyUp: (event: KeyboardEvent) => void;
|
||||
}
|
205
dist/CameraControls.js
vendored
205
dist/CameraControls.js
vendored
@ -1,205 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const KeyEnum_1 = require("./KeyEnum");
|
||||
const three_1 = require("three");
|
||||
//控制类型
|
||||
var CameraControlsEnabled;
|
||||
(function (CameraControlsEnabled) {
|
||||
CameraControlsEnabled[CameraControlsEnabled["Rotate"] = 1] = "Rotate";
|
||||
CameraControlsEnabled[CameraControlsEnabled["Zoom"] = 2] = "Zoom";
|
||||
CameraControlsEnabled[CameraControlsEnabled["Pan"] = 4] = "Pan";
|
||||
})(CameraControlsEnabled || (CameraControlsEnabled = {}));
|
||||
//相机控制状态
|
||||
var CameraControlState;
|
||||
(function (CameraControlState) {
|
||||
CameraControlState[CameraControlState["Null"] = 0] = "Null";
|
||||
CameraControlState[CameraControlState["Pan"] = 1] = "Pan";
|
||||
CameraControlState[CameraControlState["Rotate"] = 2] = "Rotate";
|
||||
CameraControlState[CameraControlState["Scale"] = 3] = "Scale";
|
||||
})(CameraControlState = exports.CameraControlState || (exports.CameraControlState = {}));
|
||||
class CameraControls {
|
||||
constructor(viewer) {
|
||||
this.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan];
|
||||
//起始点击
|
||||
this.m_StartClickPoint = new THREE.Vector3();
|
||||
this.m_EndClickPoint = new THREE.Vector3();
|
||||
this.m_DollyStart = new THREE.Vector2();
|
||||
this.m_DollyEnd = new THREE.Vector2();
|
||||
this.m_KeyDown = new Map();
|
||||
this.m_MouseDown = new Map();
|
||||
//状态
|
||||
this.m_State = CameraControlState.Null;
|
||||
//左键使用旋转
|
||||
this.m_LeftUseRotate = true;
|
||||
/**
|
||||
* 窗体失去焦点时.
|
||||
*
|
||||
* @memberof CameraControls
|
||||
*/
|
||||
this.onBlur = () => {
|
||||
this.m_KeyDown.clear();
|
||||
this.m_MouseDown.clear();
|
||||
};
|
||||
//触屏开始事件
|
||||
this.onTouchStart = (event) => {
|
||||
this.m_Viewer.UpdateLockTarget();
|
||||
this.m_StartClickPoint.set(event.touches[0].pageX, event.touches[0].pageY, 0);
|
||||
if (event.touches.length < 4) {
|
||||
if (event.touches.length == 2) {
|
||||
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);
|
||||
this.m_DollyStart.set(0, distance);
|
||||
}
|
||||
this.m_State = this.m_TouthTypeList[event.touches.length - 1];
|
||||
}
|
||||
};
|
||||
this.onTouchEnd = (event) => {
|
||||
this.m_State = CameraControlState.Null;
|
||||
};
|
||||
this.onTouchMove = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.m_EndClickPoint.set(event.touches[0].pageX, event.touches[0].pageY, 0);
|
||||
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);
|
||||
this.m_DollyEnd.set(0, distance);
|
||||
if (distance > this.m_DollyStart.y) {
|
||||
this.m_Viewer.Zoom(0.95);
|
||||
}
|
||||
else {
|
||||
this.m_Viewer.Zoom(1.05);
|
||||
}
|
||||
this.m_DollyStart.copy(this.m_DollyEnd);
|
||||
break;
|
||||
}
|
||||
case CameraControlState.Rotate:
|
||||
{
|
||||
this.m_Viewer.Rotate(vec.multiplyScalar(2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.m_StartClickPoint.copy(this.m_EndClickPoint);
|
||||
this.m_Viewer.m_bNeedUpdate = true;
|
||||
};
|
||||
//鼠标
|
||||
this.onMouseDown = (event) => {
|
||||
event.preventDefault();
|
||||
let key = event.button;
|
||||
this.m_MouseDown.set(key, true);
|
||||
this.m_StartClickPoint.set(event.offsetX, event.offsetY, 0);
|
||||
switch (key) {
|
||||
case KeyEnum_1.MouseKey.Left:
|
||||
{
|
||||
if (this.m_LeftUseRotate) {
|
||||
this.beginRotate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyEnum_1.MouseKey.Middle:
|
||||
{
|
||||
if (this.m_KeyDown.get(KeyEnum_1.KeyBoard.Control)) {
|
||||
this.beginRotate();
|
||||
}
|
||||
else {
|
||||
this.m_State = CameraControlState.Pan;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyEnum_1.MouseKey.Right:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.onMouseUp = (event) => {
|
||||
event.preventDefault();
|
||||
this.m_State = CameraControlState.Null;
|
||||
this.m_MouseDown.set(event.button, false);
|
||||
};
|
||||
this.onMouseMove = (event) => {
|
||||
event.preventDefault();
|
||||
this.m_EndClickPoint.set(event.offsetX, event.offsetY, 0);
|
||||
let changeVec = this.m_EndClickPoint.clone().sub(this.m_StartClickPoint);
|
||||
this.m_StartClickPoint.copy(this.m_EndClickPoint);
|
||||
if ((this.m_LeftUseRotate ||
|
||||
(this.m_KeyDown.get(KeyEnum_1.KeyBoard.Control)))
|
||||
&& this.m_State == CameraControlState.Rotate) {
|
||||
this.m_Viewer.Rotate(changeVec);
|
||||
}
|
||||
switch (this.m_State) {
|
||||
case CameraControlState.Pan:
|
||||
{
|
||||
this.m_Viewer.Pan(changeVec);
|
||||
break;
|
||||
}
|
||||
case CameraControlState.Rotate:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CameraControlState.Scale:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 鼠标滚轮事件
|
||||
*
|
||||
* @memberof CameraControls
|
||||
*/
|
||||
this.onMouseWheel = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);
|
||||
this.m_Viewer.ScreenToWorld(pt, new three_1.Vector3().setFromMatrixColumn(this.m_Viewer.m_Camera.Camera.matrixWorld, 2));
|
||||
if (event.deltaY < 0) {
|
||||
this.m_Viewer.Zoom(0.6, pt);
|
||||
}
|
||||
else if (event.deltaY > 0) {
|
||||
this.m_Viewer.Zoom(1.4, pt);
|
||||
}
|
||||
};
|
||||
//按键
|
||||
this.onKeyDown = (event) => {
|
||||
this.m_KeyDown.set(event.keyCode, true);
|
||||
};
|
||||
this.onKeyUp = (event) => {
|
||||
this.m_KeyDown.set(event.keyCode, false);
|
||||
};
|
||||
this.m_Viewer = viewer;
|
||||
this.m_domElement = viewer.m_Render.domElement.parentElement;
|
||||
this.RegisterEvent();
|
||||
}
|
||||
RegisterEvent() {
|
||||
if (this.m_domElement) {
|
||||
this.m_domElement.addEventListener("mousedown", this.onMouseDown, false);
|
||||
this.m_domElement.addEventListener("mousemove", this.onMouseMove, false);
|
||||
this.m_domElement.addEventListener("mouseup", this.onMouseUp, false);
|
||||
window.addEventListener("keydown", this.onKeyDown, false);
|
||||
window.addEventListener("keyup", this.onKeyUp, false);
|
||||
this.m_domElement.addEventListener('wheel', this.onMouseWheel, false);
|
||||
this.m_domElement.addEventListener('touchstart', this.onTouchStart, false);
|
||||
this.m_domElement.addEventListener('touchend', this.onTouchEnd, false);
|
||||
this.m_domElement.addEventListener('touchmove', this.onTouchMove, false);
|
||||
window.addEventListener("blur", this.onBlur, false);
|
||||
}
|
||||
}
|
||||
beginRotate() {
|
||||
this.m_State = CameraControlState.Rotate;
|
||||
this.m_Viewer.UpdateLockTarget();
|
||||
}
|
||||
}
|
||||
exports.CameraControls = CameraControls;
|
||||
//# sourceMappingURL=CameraControls.js.map
|
1
dist/CameraControls.js.map
vendored
1
dist/CameraControls.js.map
vendored
File diff suppressed because one or more lines are too long
46
dist/CameraUpdate.d.ts
vendored
46
dist/CameraUpdate.d.ts
vendored
@ -1,46 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
/**
|
||||
*
|
||||
* 相机的控制.
|
||||
* ->切换相机
|
||||
* ->设置视口大小
|
||||
* ->旋转和移动相机.
|
||||
*
|
||||
* @export
|
||||
* @class ViewCameraManage
|
||||
*/
|
||||
export declare class CameraUpdate {
|
||||
private m_CurCamera;
|
||||
private m_CameraArray;
|
||||
private m_Width;
|
||||
private m_Height;
|
||||
private m_ViewHeight;
|
||||
private m_Target;
|
||||
private m_Direction;
|
||||
private m_Orbit;
|
||||
constructor();
|
||||
readonly Aspect: number;
|
||||
readonly Camera: THREE.Camera;
|
||||
ViewHeight: number;
|
||||
SetSize(width: number, height: number): void;
|
||||
/**
|
||||
* 平移相机.
|
||||
*
|
||||
* @param {THREE.Vector3} mouseMove
|
||||
* @memberof CameraControl
|
||||
*/
|
||||
Pan(mouseMove: THREE.Vector3): void;
|
||||
Rotate(mouseMove: THREE.Vector3, target: THREE.Vector3): void;
|
||||
Zoom(scale: number, scaleCenter?: THREE.Vector3): void;
|
||||
ZoomExtensBox3(box3: THREE.Box3): void;
|
||||
LookAt(dir: THREE.Vector3): void;
|
||||
UpdateUp(): void;
|
||||
/**
|
||||
* 根据视口大小,设置相机视口范围.
|
||||
*
|
||||
* @returns
|
||||
* @memberof CameraControl
|
||||
*/
|
||||
Update(): void;
|
||||
SwitchCamera(): void;
|
||||
}
|
172
dist/CameraUpdate.js
vendored
172
dist/CameraUpdate.js
vendored
@ -1,172 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const three_1 = require("three");
|
||||
const Orbit_1 = require("./Orbit");
|
||||
/**
|
||||
*
|
||||
* 相机的控制.
|
||||
* ->切换相机
|
||||
* ->设置视口大小
|
||||
* ->旋转和移动相机.
|
||||
*
|
||||
* @export
|
||||
* @class ViewCameraManage
|
||||
*/
|
||||
class CameraUpdate {
|
||||
constructor() {
|
||||
this.m_CameraArray = new Map();
|
||||
//视口显示的高度
|
||||
this.m_ViewHeight = 10;
|
||||
//观察的位置
|
||||
this.m_Target = new THREE.Vector3();
|
||||
//观察向量
|
||||
this.m_Direction = new THREE.Vector3(0, 0, -1);
|
||||
//观察的轨道.
|
||||
this.m_Orbit = new Orbit_1.Orbit();
|
||||
this.m_CameraArray.set(THREE.OrthographicCamera, new THREE.OrthographicCamera(-2, 2, 2, -2, -100000, 100000));
|
||||
this.m_CameraArray.set(THREE.PerspectiveCamera, new THREE.PerspectiveCamera(50, 1, 0.01, 10000));
|
||||
this.m_CurCamera = this.m_CameraArray.get(THREE.OrthographicCamera);
|
||||
this.m_Orbit.UpdateRoValue(this.m_Direction);
|
||||
this.UpdateUp();
|
||||
this.Update();
|
||||
}
|
||||
get Aspect() {
|
||||
return this.m_Width / this.m_Height;
|
||||
}
|
||||
get Camera() {
|
||||
return this.m_CurCamera;
|
||||
}
|
||||
get ViewHeight() {
|
||||
return this.m_ViewHeight;
|
||||
}
|
||||
set ViewHeight(height) {
|
||||
this.m_ViewHeight = THREE.Math.clamp(height, 1e-8, 1e8);
|
||||
}
|
||||
SetSize(width, height) {
|
||||
this.m_Width = width;
|
||||
this.m_Height = height;
|
||||
}
|
||||
/**
|
||||
* 平移相机.
|
||||
*
|
||||
* @param {THREE.Vector3} mouseMove
|
||||
* @memberof CameraControl
|
||||
*/
|
||||
Pan(mouseMove) {
|
||||
mouseMove.y *= -1;
|
||||
mouseMove.multiplyScalar(-this.m_ViewHeight / this.m_Height);
|
||||
mouseMove.applyQuaternion(this.Camera.quaternion);
|
||||
this.m_Target.add(mouseMove);
|
||||
this.Update();
|
||||
}
|
||||
Rotate(mouseMove, target) {
|
||||
this.m_Orbit.RoX -= mouseMove.y * 0.003;
|
||||
this.m_Orbit.RoZ -= mouseMove.x * 0.003;
|
||||
//缓存观察点
|
||||
let oldTargetFormCameraSpace = target.clone().applyMatrix4(this.Camera.matrixWorldInverse);
|
||||
this.m_Orbit.UpdateDirection(this.m_Direction);
|
||||
this.UpdateUp();
|
||||
this.Update();
|
||||
//-----还原观察点
|
||||
//得到新的观察点相对于相机的位置
|
||||
let newTargetFormCameraSpace = target.clone().applyMatrix4(this.Camera.matrixWorldInverse);
|
||||
//减去原先的位置. 得到观测点在相机内移动的向量
|
||||
newTargetFormCameraSpace.sub(oldTargetFormCameraSpace);
|
||||
//乘以相机的矩阵. 得到向量在世界坐标系的位置
|
||||
newTargetFormCameraSpace.applyMatrix4(this.Camera.matrix);
|
||||
//因为使用的是点变换,所以减去基点,得到向量
|
||||
newTargetFormCameraSpace.sub(this.Camera.position);
|
||||
//加上移动的向量. 使得观察点时钟在相机的某个位置
|
||||
this.m_Target.add(newTargetFormCameraSpace);
|
||||
this.Update();
|
||||
}
|
||||
Zoom(scale, scaleCenter) {
|
||||
if (this.Camera instanceof THREE.OrthographicCamera) {
|
||||
this.ViewHeight *= scale;
|
||||
if (scaleCenter) {
|
||||
this.m_Target.sub(scaleCenter);
|
||||
this.m_Target.multiplyScalar(scale);
|
||||
this.m_Target.add(scaleCenter);
|
||||
}
|
||||
}
|
||||
else if (this.Camera instanceof THREE.PerspectiveCamera) {
|
||||
let add = scale > 1 ? 1 : -1;
|
||||
add *= this.Camera.position.distanceTo(this.m_Target) / 10;
|
||||
this.m_Target.add(this.m_Direction.clone().multiplyScalar(-add));
|
||||
}
|
||||
this.Update();
|
||||
}
|
||||
ZoomExtensBox3(box3) {
|
||||
if (!box3)
|
||||
return;
|
||||
this.Camera.updateMatrixWorld(false);
|
||||
//变换到相机坐标系
|
||||
box3.applyMatrix4(this.Camera.matrixWorldInverse);
|
||||
//
|
||||
box3.getCenter(this.m_Target);
|
||||
//世界坐标系
|
||||
this.m_Target.applyMatrix4(this.Camera.matrix);
|
||||
//size
|
||||
let size = box3.getSize(new three_1.Vector3());
|
||||
//宽高比
|
||||
let aspectRatio = size.x / size.y;
|
||||
let viewAspectRatio = this.Aspect;
|
||||
//
|
||||
if (aspectRatio > viewAspectRatio) {
|
||||
this.m_ViewHeight = size.x / viewAspectRatio;
|
||||
}
|
||||
else {
|
||||
this.m_ViewHeight = size.y;
|
||||
}
|
||||
this.Update();
|
||||
}
|
||||
LookAt(dir) {
|
||||
this.m_Orbit.UpdateRoValue(dir);
|
||||
this.m_Direction.copy(dir);
|
||||
this.UpdateUp();
|
||||
this.Update();
|
||||
}
|
||||
UpdateUp() {
|
||||
Orbit_1.Orbit.ComputUpDirection(this.m_Direction, this.Camera.up);
|
||||
}
|
||||
/**
|
||||
* 根据视口大小,设置相机视口范围.
|
||||
*
|
||||
* @returns
|
||||
* @memberof CameraControl
|
||||
*/
|
||||
Update() {
|
||||
this.Camera.position.copy(this.m_Target);
|
||||
if (this.Camera instanceof THREE.OrthographicCamera) {
|
||||
this.Camera.left = this.Aspect * this.m_ViewHeight / -2;
|
||||
this.Camera.right = this.Aspect * this.m_ViewHeight / 2;
|
||||
this.Camera.bottom = this.m_ViewHeight / -2;
|
||||
this.Camera.top = this.m_ViewHeight / 2;
|
||||
this.Camera.position.sub(this.m_Direction);
|
||||
}
|
||||
else if (this.Camera instanceof THREE.PerspectiveCamera) {
|
||||
this.Camera.aspect = this.Aspect;
|
||||
let distens = (this.m_ViewHeight / 2) / (Math.tan(THREE.Math.degToRad(this.Camera.fov) / 2));
|
||||
this.Camera.position.sub(this.m_Direction.clone().multiplyScalar(distens));
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
this.Camera.lookAt(this.m_Target);
|
||||
this.Camera.updateProjectionMatrix();
|
||||
this.Camera.updateMatrixWorld(false);
|
||||
}
|
||||
SwitchCamera() {
|
||||
if (this.Camera instanceof THREE.OrthographicCamera) {
|
||||
this.m_CurCamera = this.m_CameraArray.get(THREE.PerspectiveCamera);
|
||||
}
|
||||
else {
|
||||
this.m_CurCamera = this.m_CameraArray.get(THREE.OrthographicCamera);
|
||||
}
|
||||
this.UpdateUp();
|
||||
this.Update();
|
||||
}
|
||||
}
|
||||
exports.CameraUpdate = CameraUpdate;
|
||||
//# sourceMappingURL=CameraUpdate.js.map
|
1
dist/CameraUpdate.js.map
vendored
1
dist/CameraUpdate.js.map
vendored
File diff suppressed because one or more lines are too long
7
dist/ColorPalette.d.ts
vendored
7
dist/ColorPalette.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
export declare class ColorMaterial {
|
||||
private constructor();
|
||||
private static m_LineMaterialMap;
|
||||
static GetLineMaterial(index: any): THREE.LineBasicMaterial;
|
||||
static GetColor(index: number): THREE.Color;
|
||||
}
|
286
dist/ColorPalette.js
vendored
286
dist/ColorPalette.js
vendored
@ -1,286 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const ColorPalette = [
|
||||
[255, 0, 0, 255],
|
||||
//[255, 255, 255, 255],//----- 0 - ByBlock - White
|
||||
[255, 0, 0, 255],
|
||||
// [255, 0, 0, 255], //----- 1 - Red
|
||||
[255, 255, 0, 255],
|
||||
[0, 255, 0, 255],
|
||||
[0, 255, 255, 255],
|
||||
[0, 0, 255, 255],
|
||||
[255, 0, 255, 255],
|
||||
// [255, 0, 0, 255], //----- 7 - More red Red
|
||||
// [255, 0, 0, 255], //----- 8 - More red Red
|
||||
// [255, 0, 0, 255], //----- 9 - More red Red
|
||||
[255, 255, 255, 255],
|
||||
[255, 255, 255, 255],
|
||||
[255, 255, 255, 255],
|
||||
[255, 0, 0, 255],
|
||||
[255, 127, 127, 255],
|
||||
[165, 0, 0, 255],
|
||||
[165, 82, 82, 255],
|
||||
[127, 0, 0, 255],
|
||||
[127, 63, 63, 255],
|
||||
[76, 0, 0, 255],
|
||||
[76, 38, 38, 255],
|
||||
[38, 0, 0, 255],
|
||||
[38, 19, 19, 255],
|
||||
[255, 63, 0, 255],
|
||||
[255, 159, 127, 255],
|
||||
[165, 41, 0, 255],
|
||||
[165, 103, 82, 255],
|
||||
[127, 31, 0, 255],
|
||||
[127, 79, 63, 255],
|
||||
[76, 19, 0, 255],
|
||||
[76, 47, 38, 255],
|
||||
[38, 9, 0, 255],
|
||||
[38, 23, 19, 255],
|
||||
[255, 127, 0, 255],
|
||||
[255, 191, 127, 255],
|
||||
[165, 82, 0, 255],
|
||||
[165, 124, 82, 255],
|
||||
[127, 63, 0, 255],
|
||||
[127, 95, 63, 255],
|
||||
[76, 38, 0, 255],
|
||||
[76, 57, 38, 255],
|
||||
[38, 19, 0, 255],
|
||||
[38, 28, 19, 255],
|
||||
[255, 191, 0, 255],
|
||||
[255, 223, 127, 255],
|
||||
[165, 124, 0, 255],
|
||||
[165, 145, 82, 255],
|
||||
[127, 95, 0, 255],
|
||||
[127, 111, 63, 255],
|
||||
[76, 57, 0, 255],
|
||||
[76, 66, 38, 255],
|
||||
[38, 28, 0, 255],
|
||||
[38, 33, 19, 255],
|
||||
[255, 255, 0, 255],
|
||||
[255, 255, 127, 255],
|
||||
[165, 165, 0, 255],
|
||||
[165, 165, 82, 255],
|
||||
[127, 127, 0, 255],
|
||||
[127, 127, 63, 255],
|
||||
[76, 76, 0, 255],
|
||||
[76, 76, 38, 255],
|
||||
[38, 38, 0, 255],
|
||||
[38, 38, 19, 255],
|
||||
[191, 255, 0, 255],
|
||||
[223, 255, 127, 255],
|
||||
[124, 165, 0, 255],
|
||||
[145, 165, 82, 255],
|
||||
[95, 127, 0, 255],
|
||||
[111, 127, 63, 255],
|
||||
[57, 76, 0, 255],
|
||||
[66, 76, 38, 255],
|
||||
[28, 38, 0, 255],
|
||||
[33, 38, 19, 255],
|
||||
[127, 255, 0, 255],
|
||||
[191, 255, 127, 255],
|
||||
[82, 165, 0, 255],
|
||||
[124, 165, 82, 255],
|
||||
[63, 127, 0, 255],
|
||||
[95, 127, 63, 255],
|
||||
[38, 76, 0, 255],
|
||||
[57, 76, 38, 255],
|
||||
[19, 38, 0, 255],
|
||||
[28, 38, 19, 255],
|
||||
[63, 255, 0, 255],
|
||||
[159, 255, 127, 255],
|
||||
[41, 165, 0, 255],
|
||||
[103, 165, 82, 255],
|
||||
[31, 127, 0, 255],
|
||||
[79, 127, 63, 255],
|
||||
[19, 76, 0, 255],
|
||||
[47, 76, 38, 255],
|
||||
[9, 38, 0, 255],
|
||||
[23, 38, 19, 255],
|
||||
[0, 255, 0, 255],
|
||||
[127, 255, 127, 255],
|
||||
[0, 165, 0, 255],
|
||||
[82, 165, 82, 255],
|
||||
[0, 127, 0, 255],
|
||||
[63, 127, 63, 255],
|
||||
[0, 76, 0, 255],
|
||||
[38, 76, 38, 255],
|
||||
[0, 38, 0, 255],
|
||||
[19, 38, 19, 255],
|
||||
[0, 255, 63, 255],
|
||||
[127, 255, 159, 255],
|
||||
[0, 165, 41, 255],
|
||||
[82, 165, 103, 255],
|
||||
[0, 127, 31, 255],
|
||||
[63, 127, 79, 255],
|
||||
[0, 76, 19, 255],
|
||||
[38, 76, 47, 255],
|
||||
[0, 38, 9, 255],
|
||||
[19, 38, 23, 255],
|
||||
[0, 255, 127, 255],
|
||||
[127, 255, 191, 255],
|
||||
[0, 165, 82, 255],
|
||||
[82, 165, 124, 255],
|
||||
[0, 127, 63, 255],
|
||||
[63, 127, 95, 255],
|
||||
[0, 76, 38, 255],
|
||||
[38, 76, 57, 255],
|
||||
[0, 38, 19, 255],
|
||||
[19, 38, 28, 255],
|
||||
[0, 255, 191, 255],
|
||||
[127, 255, 223, 255],
|
||||
[0, 165, 124, 255],
|
||||
[82, 165, 145, 255],
|
||||
[0, 127, 95, 255],
|
||||
[63, 127, 111, 255],
|
||||
[0, 76, 57, 255],
|
||||
[38, 76, 66, 255],
|
||||
[0, 38, 28, 255],
|
||||
[19, 38, 33, 255],
|
||||
[0, 255, 255, 255],
|
||||
[127, 255, 255, 255],
|
||||
[0, 165, 165, 255],
|
||||
[82, 165, 165, 255],
|
||||
[0, 127, 127, 255],
|
||||
[63, 127, 127, 255],
|
||||
[0, 76, 76, 255],
|
||||
[38, 76, 76, 255],
|
||||
[0, 38, 38, 255],
|
||||
[19, 38, 38, 255],
|
||||
[0, 191, 255, 255],
|
||||
[127, 223, 255, 255],
|
||||
[0, 124, 165, 255],
|
||||
[82, 145, 165, 255],
|
||||
[0, 95, 127, 255],
|
||||
[63, 111, 127, 255],
|
||||
[0, 57, 76, 255],
|
||||
[38, 66, 76, 255],
|
||||
[0, 28, 38, 255],
|
||||
[19, 33, 38, 255],
|
||||
[0, 127, 255, 255],
|
||||
[127, 191, 255, 255],
|
||||
[0, 82, 165, 255],
|
||||
[82, 124, 165, 255],
|
||||
[0, 63, 127, 255],
|
||||
[63, 95, 127, 255],
|
||||
[0, 38, 76, 255],
|
||||
[38, 57, 76, 255],
|
||||
[0, 19, 38, 255],
|
||||
[19, 28, 38, 255],
|
||||
[0, 63, 255, 255],
|
||||
[127, 159, 255, 255],
|
||||
[0, 41, 165, 255],
|
||||
[82, 103, 165, 255],
|
||||
[0, 31, 127, 255],
|
||||
[63, 79, 127, 255],
|
||||
[0, 19, 76, 255],
|
||||
[38, 47, 76, 255],
|
||||
[0, 9, 38, 255],
|
||||
[19, 23, 38, 255],
|
||||
[0, 0, 255, 255],
|
||||
[127, 127, 255, 255],
|
||||
[0, 0, 165, 255],
|
||||
[82, 82, 165, 255],
|
||||
[0, 0, 127, 255],
|
||||
[63, 63, 127, 255],
|
||||
[0, 0, 76, 255],
|
||||
[38, 38, 76, 255],
|
||||
[0, 0, 38, 255],
|
||||
[19, 19, 38, 255],
|
||||
[63, 0, 255, 255],
|
||||
[159, 127, 255, 255],
|
||||
[41, 0, 165, 255],
|
||||
[103, 82, 165, 255],
|
||||
[31, 0, 127, 255],
|
||||
[79, 63, 127, 255],
|
||||
[19, 0, 76, 255],
|
||||
[47, 38, 76, 255],
|
||||
[9, 0, 38, 255],
|
||||
[23, 19, 38, 255],
|
||||
[127, 0, 255, 255],
|
||||
[191, 127, 255, 255],
|
||||
[82, 0, 165, 255],
|
||||
[124, 82, 165, 255],
|
||||
[63, 0, 127, 255],
|
||||
[95, 63, 127, 255],
|
||||
[38, 0, 76, 255],
|
||||
[57, 38, 76, 255],
|
||||
[19, 0, 38, 255],
|
||||
[28, 19, 38, 255],
|
||||
[191, 0, 255, 255],
|
||||
[223, 127, 255, 255],
|
||||
[124, 0, 165, 255],
|
||||
[145, 82, 165, 255],
|
||||
[95, 0, 127, 255],
|
||||
[111, 63, 127, 255],
|
||||
[57, 0, 76, 255],
|
||||
[66, 38, 76, 255],
|
||||
[28, 0, 38, 255],
|
||||
[33, 19, 38, 255],
|
||||
[255, 0, 255, 255],
|
||||
[255, 127, 255, 255],
|
||||
[165, 0, 165, 255],
|
||||
[165, 82, 165, 255],
|
||||
[127, 0, 127, 255],
|
||||
[127, 63, 127, 255],
|
||||
[76, 0, 76, 255],
|
||||
[76, 38, 76, 255],
|
||||
[38, 0, 38, 255],
|
||||
[38, 19, 38, 255],
|
||||
[255, 0, 191, 255],
|
||||
[255, 127, 223, 255],
|
||||
[165, 0, 124, 255],
|
||||
[165, 82, 145, 255],
|
||||
[127, 0, 95, 255],
|
||||
[127, 63, 111, 255],
|
||||
[76, 0, 57, 255],
|
||||
[76, 38, 66, 255],
|
||||
[38, 0, 28, 255],
|
||||
[38, 19, 33, 255],
|
||||
[255, 0, 127, 255],
|
||||
[255, 127, 191, 255],
|
||||
[165, 0, 82, 255],
|
||||
[165, 82, 124, 255],
|
||||
[127, 0, 63, 255],
|
||||
[127, 63, 95, 255],
|
||||
[76, 0, 38, 255],
|
||||
[76, 38, 57, 255],
|
||||
[38, 0, 19, 255],
|
||||
[38, 19, 28, 255],
|
||||
[255, 0, 63, 255],
|
||||
[255, 127, 159, 255],
|
||||
[165, 0, 41, 255],
|
||||
[165, 82, 103, 255],
|
||||
[127, 0, 31, 255],
|
||||
[127, 63, 79, 255],
|
||||
[76, 0, 19, 255],
|
||||
[76, 38, 47, 255],
|
||||
[38, 0, 9, 255],
|
||||
[38, 19, 23, 255],
|
||||
[84, 84, 84, 255],
|
||||
[118, 118, 118, 255],
|
||||
[152, 152, 152, 255],
|
||||
[186, 186, 186, 255],
|
||||
[220, 220, 220, 255],
|
||||
[255, 255, 255, 255],
|
||||
[255, 255, 255, 255] //----- ByLayer - White
|
||||
];
|
||||
//颜色材质,对于二维图像来说可能有用,应该不对三维对象使用该材质
|
||||
class ColorMaterial {
|
||||
constructor() { }
|
||||
static GetLineMaterial(index) {
|
||||
if (this.m_LineMaterialMap.has(index))
|
||||
return this.m_LineMaterialMap.get(index);
|
||||
let mat = new THREE.LineBasicMaterial({ color: this.GetColor(index) });
|
||||
this.m_LineMaterialMap.set(index, mat);
|
||||
return mat;
|
||||
}
|
||||
static GetColor(index) {
|
||||
let rgb = ColorPalette[index];
|
||||
if (rgb)
|
||||
return new THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
|
||||
}
|
||||
}
|
||||
ColorMaterial.m_LineMaterialMap = new Map();
|
||||
exports.ColorMaterial = ColorMaterial;
|
||||
//# sourceMappingURL=ColorPalette.js.map
|
1
dist/ColorPalette.js.map
vendored
1
dist/ColorPalette.js.map
vendored
File diff suppressed because one or more lines are too long
11
dist/Dimension.d.ts
vendored
11
dist/Dimension.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
import { Group } from "three";
|
||||
/**
|
||||
* 标注实体
|
||||
*
|
||||
* @export
|
||||
* @class Dimension
|
||||
* @extends {Group}
|
||||
*/
|
||||
export declare class Dimension extends Group {
|
||||
constructor(length: number, textHeight?: number, mirror?: boolean, mirrorFoot?: boolean);
|
||||
}
|
46
dist/Dimension.js
vendored
46
dist/Dimension.js
vendored
@ -1,46 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const three_1 = require("three");
|
||||
const ColorPalette_1 = require("./ColorPalette");
|
||||
const Text_1 = require("./Text");
|
||||
const GeUtils_1 = require("./GeUtils");
|
||||
/**
|
||||
* 标注实体
|
||||
*
|
||||
* @export
|
||||
* @class Dimension
|
||||
* @extends {Group}
|
||||
*/
|
||||
class Dimension extends three_1.Group {
|
||||
constructor(length, textHeight = 25, mirror = false, mirrorFoot = false) {
|
||||
super();
|
||||
let footLength = 60;
|
||||
if (mirrorFoot) {
|
||||
footLength = -footLength;
|
||||
}
|
||||
//针脚几何体
|
||||
let lineGeo = new three_1.Geometry();
|
||||
lineGeo.vertices.push(new three_1.Vector3(), new three_1.Vector3(0, footLength, 0));
|
||||
//托盘几何体
|
||||
let lineGeo2 = new three_1.Geometry();
|
||||
lineGeo2.vertices.push(new three_1.Vector3(0, footLength), new three_1.Vector3(length, footLength, 0));
|
||||
let material = ColorPalette_1.ColorMaterial.GetLineMaterial(5);
|
||||
let line1 = new three_1.Line(lineGeo, material);
|
||||
let line2 = new three_1.Line(lineGeo, material);
|
||||
line2.position.x = length;
|
||||
let line3 = new three_1.Line(lineGeo2, material);
|
||||
let text = new Text_1.DbText(parseFloat(length.toFixed(2)).toString(), textHeight);
|
||||
if (mirror) {
|
||||
let roMat = new three_1.Matrix4().makeRotationZ(Math.PI);
|
||||
text.applyMatrix(roMat);
|
||||
text.applyMatrix(GeUtils_1.MoveMatrix(new three_1.Vector3(length * 0.5, footLength - textHeight * 0.1)));
|
||||
}
|
||||
else {
|
||||
text.applyMatrix(GeUtils_1.MoveMatrix(new three_1.Vector3(length * 0.5, footLength * 1.1)));
|
||||
}
|
||||
this.add(text);
|
||||
this.add(line1, line2, line3);
|
||||
}
|
||||
}
|
||||
exports.Dimension = Dimension;
|
||||
//# sourceMappingURL=Dimension.js.map
|
1
dist/Dimension.js.map
vendored
1
dist/Dimension.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Dimension.js","sourceRoot":"","sources":["../src/Dimension.ts"],"names":[],"mappings":";;AAAA,iCAAgE;AAChE,iDAA+C;AAC/C,iCAAgC;AAChC,uCAAuC;AAEvC;;;;;;GAMG;AACH,eAAuB,SAAQ,aAAK;IAGhC,YAAY,MAAc,EAAE,aAAqB,EAAE,EAAE,SAAkB,KAAK,EAAE,aAAsB,KAAK;QAErG,KAAK,EAAE,CAAC;QACR,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,UAAU,EACd;YACI,UAAU,GAAG,CAAC,UAAU,CAAC;SAC5B;QAED,OAAO;QACP,IAAI,OAAO,GAAG,IAAI,gBAAQ,EAAE,CAAC;QAC7B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,eAAO,EAAE,EAAE,IAAI,eAAO,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;QAEpE,OAAO;QACP,IAAI,QAAQ,GAAG,IAAI,gBAAQ,EAAE,CAAC;QAC9B,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,eAAO,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,IAAI,eAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;QAEvF,IAAI,QAAQ,GAAG,4BAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QAE/C,IAAI,KAAK,GAAG,IAAI,YAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACxC,IAAI,KAAK,GAAG,IAAI,YAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACxC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC;QAE1B,IAAI,KAAK,GAAG,IAAI,YAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEzC,IAAI,IAAI,GAAG,IAAI,aAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,CAAC;QAC5E,IAAI,MAAM,EACV;YACI,IAAI,KAAK,GAAG,IAAI,eAAO,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxB,IAAI,CAAC,WAAW,CAAC,oBAAU,CAAC,IAAI,eAAO,CAAC,MAAM,GAAG,GAAG,EAAE,UAAU,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1F;aAED;YACI,IAAI,CAAC,WAAW,CAAC,oBAAU,CAAC,IAAI,eAAO,CAAC,MAAM,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SAC7E;QAGD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEf,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;CACJ;AA7CD,8BA6CC"}
|
10
dist/DrawDimension.d.ts
vendored
10
dist/DrawDimension.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import { Mesh } from "three";
|
||||
import { Dimension } from ".";
|
||||
/**
|
||||
* 绘制标注实体
|
||||
*
|
||||
* @export
|
||||
* @param {Box3} box
|
||||
* @returns 标注实体列表
|
||||
*/
|
||||
export declare function DrawDimension(brList: Mesh[]): Dimension[];
|
32
dist/DrawDimension.js
vendored
32
dist/DrawDimension.js
vendored
@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const three_1 = require("three");
|
||||
const _1 = require(".");
|
||||
/**
|
||||
* 绘制标注实体
|
||||
*
|
||||
* @export
|
||||
* @param {Box3} box
|
||||
* @returns 标注实体列表
|
||||
*/
|
||||
function DrawDimension(brList) {
|
||||
let box = _1.GetBoxArr(brList);
|
||||
let size = box.getSize(new three_1.Vector3());
|
||||
let mat4 = new three_1.Matrix4();
|
||||
mat4.makeBasis(new three_1.Vector3(-1, 0, 0), new three_1.Vector3(0, -1, 0), new three_1.Vector3(0, 0, 1));
|
||||
mat4.setPosition(box.min.clone().add(new three_1.Vector3(size.x, -30)));
|
||||
let textHeight = 45;
|
||||
let dimx = new _1.Dimension(size.x, textHeight, true);
|
||||
dimx.applyMatrix(mat4);
|
||||
let dimz = new _1.Dimension(size.z, textHeight);
|
||||
mat4.makeBasis(new three_1.Vector3(0, 0, -1), new three_1.Vector3(1, 0, 0), new three_1.Vector3(0, -1, 0));
|
||||
mat4.setPosition(box.max.clone().add(new three_1.Vector3(30, -size.y)));
|
||||
dimz.applyMatrix(mat4);
|
||||
let dimy = new _1.Dimension(size.y, textHeight, true, true);
|
||||
mat4.makeBasis(new three_1.Vector3(0, 1, 0), new three_1.Vector3(-1, 0, 0), new three_1.Vector3(0, 0, 1));
|
||||
mat4.setPosition(box.max.clone().add(new three_1.Vector3(30, -size.y)));
|
||||
dimy.applyMatrix(mat4);
|
||||
return [dimx, dimy, dimz];
|
||||
}
|
||||
exports.DrawDimension = DrawDimension;
|
||||
//# sourceMappingURL=DrawDimension.js.map
|
1
dist/DrawDimension.js.map
vendored
1
dist/DrawDimension.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"DrawDimension.js","sourceRoot":"","sources":["../src/DrawDimension.ts"],"names":[],"mappings":";;AAAA,iCAAqD;AACrD,wBAAyC;AAGzC;;;;;;GAMG;AACH,uBAA8B,MAAc;IAExC,IAAI,GAAG,GAAG,YAAS,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,eAAO,EAAE,CAAC,CAAC;IAEtC,IAAI,IAAI,GAAG,IAAI,eAAO,EAAE,CAAC;IACzB,IAAI,CAAC,SAAS,CACV,IAAI,eAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrB,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EACrB,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACvB,CAAA;IACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,eAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEhE,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,IAAI,GAAG,IAAI,YAAS,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEvB,IAAI,IAAI,GAAG,IAAI,YAAS,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7C,IAAI,CAAC,SAAS,CACV,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EACrB,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACxB,CAAA;IACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,eAAO,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEvB,IAAI,IAAI,GAAG,IAAI,YAAS,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,SAAS,CACV,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,eAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrB,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACvB,CAAA;IACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,eAAO,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAGvB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AArCD,sCAqCC"}
|
66
dist/GeUtils.d.ts
vendored
66
dist/GeUtils.d.ts
vendored
@ -1,66 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
import { Geometry, Vector, Vector2, Vector3 } from 'three';
|
||||
export declare const cZeroVec: THREE.Vector3;
|
||||
export declare const cXAxis: THREE.Vector3;
|
||||
export declare const cYAxis: THREE.Vector3;
|
||||
export declare const cZAxis: THREE.Vector3;
|
||||
/**
|
||||
* 旋转一个点,旋转中心在原点
|
||||
*
|
||||
* @export
|
||||
* @param {Vector3} pt 点
|
||||
* @param {number} ang 角度.
|
||||
* @returns {Vector3} 返回pt不拷贝.
|
||||
*/
|
||||
export declare function rotatePoint(pt: Vector3, ang: number): Vector3;
|
||||
export declare function equaln(v1: number, v2: number, fuzz?: number): boolean;
|
||||
export declare function equal<T extends Vector>(v1: T, v2: T): boolean;
|
||||
export declare function fixAngle(an: number, fixAngle: number, fuzz?: number): number;
|
||||
/**
|
||||
* 按照极坐标的方式移动一个点
|
||||
*
|
||||
* @export
|
||||
* @template
|
||||
* @param {T} v 向量(2d,3d)
|
||||
* @param {number} an 角度
|
||||
* @param {number} dis 距离
|
||||
* @returns {T}
|
||||
*/
|
||||
export declare function polar<T extends Vector2 | Vector3>(v: T, an: number, dis: number): T;
|
||||
export declare function angle(v: Vector3 | Vector2): number;
|
||||
/**
|
||||
* 求两个向量的夹角,顺时针为负,逆时针为正
|
||||
*
|
||||
* @param {THREE.Vector3} v1
|
||||
* @param {THREE.Vector3} v2
|
||||
* @param {THREE.Vector3} [ref] 参考向量,如果为世界坐标系则为0,0,1
|
||||
* @returns
|
||||
*/
|
||||
export declare function angleTo(v1: THREE.Vector3, v2: THREE.Vector3, ref?: THREE.Vector3): number;
|
||||
export declare function getLoocAtUpVec(dir: THREE.Vector3): THREE.Vector3;
|
||||
export declare function createLookAtMat4(dir: THREE.Vector3): THREE.Matrix4;
|
||||
export declare function isParallelTo(v1: THREE.Vector3, v2: THREE.Vector3): boolean;
|
||||
export declare function ptToString(v: THREE.Vector3, fractionDigits?: number): string;
|
||||
export declare function midPoint(v1: THREE.Vector3, v2: THREE.Vector3): THREE.Vector3;
|
||||
export declare function midPoint2(v1: THREE.Vector2, v2: THREE.Vector2): THREE.Vector2;
|
||||
export declare function midPtCir(v1: THREE.Vector3, v2: THREE.Vector3): THREE.Vector3;
|
||||
export declare function GetBox(obj: THREE.Object3D, updateMatrix?: boolean): THREE.Box3;
|
||||
export declare function GetBoxArr(arr: Array<THREE.Object3D>): THREE.Box3;
|
||||
export declare function MoveMatrix(v: THREE.Vector3): THREE.Matrix4;
|
||||
export declare function getProjectDist(v1: Vector3, v2: Vector3): {
|
||||
h: number;
|
||||
v: number;
|
||||
};
|
||||
export declare function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3): {
|
||||
sp: THREE.Vector3;
|
||||
ep: THREE.Vector3;
|
||||
};
|
||||
export declare function angleAndX(v: Vector3 | Vector2): number;
|
||||
/**
|
||||
* 将角度调整为0-2pi之间
|
||||
*
|
||||
* @export
|
||||
* @param {number} an
|
||||
*/
|
||||
export declare function angleTo2Pi(an: number): number;
|
||||
export declare function updateGeometry(l: THREE.Line | THREE.Mesh, geometry: Geometry): void;
|
258
dist/GeUtils.js
vendored
258
dist/GeUtils.js
vendored
@ -1,258 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const three_1 = require("three");
|
||||
const Matrix2_1 = require("./Matrix2");
|
||||
exports.cZeroVec = new THREE.Vector3();
|
||||
exports.cXAxis = new THREE.Vector3(1, 0, 0);
|
||||
exports.cYAxis = new THREE.Vector3(0, 1, 0);
|
||||
exports.cZAxis = new THREE.Vector3(0, 0, 1);
|
||||
/**
|
||||
* 旋转一个点,旋转中心在原点
|
||||
*
|
||||
* @export
|
||||
* @param {Vector3} pt 点
|
||||
* @param {number} ang 角度.
|
||||
* @returns {Vector3} 返回pt不拷贝.
|
||||
*/
|
||||
function rotatePoint(pt, ang) {
|
||||
new Matrix2_1.Matrix2().setRotate(ang).applyVector(pt);
|
||||
return pt;
|
||||
}
|
||||
exports.rotatePoint = rotatePoint;
|
||||
function equaln(v1, v2, fuzz = 1e-3) {
|
||||
return Math.abs(v1 - v2) < fuzz;
|
||||
}
|
||||
exports.equaln = equaln;
|
||||
function equal(v1, v2) {
|
||||
return v1.distanceToSquared(v2) < 1e-8;
|
||||
}
|
||||
exports.equal = equal;
|
||||
function fixAngle(an, fixAngle, fuzz = 0.1) {
|
||||
if (an < 0)
|
||||
an += Math.PI * 2;
|
||||
an += fuzz;
|
||||
let rem = an % fixAngle;
|
||||
if (rem < fuzz * 2) {
|
||||
an -= rem;
|
||||
}
|
||||
else {
|
||||
an -= fuzz;
|
||||
}
|
||||
return an;
|
||||
}
|
||||
exports.fixAngle = fixAngle;
|
||||
/**
|
||||
* 按照极坐标的方式移动一个点
|
||||
*
|
||||
* @export
|
||||
* @template
|
||||
* @param {T} v 向量(2d,3d)
|
||||
* @param {number} an 角度
|
||||
* @param {number} dis 距离
|
||||
* @returns {T}
|
||||
*/
|
||||
function polar(v, an, dis) {
|
||||
v.x += Math.cos(an) * dis;
|
||||
v.y += Math.sin(an) * dis;
|
||||
return v;
|
||||
}
|
||||
exports.polar = polar;
|
||||
function angle(v) {
|
||||
if (equaln(v.y, 0) && v.x > 0)
|
||||
return 0;
|
||||
let angle = Math.atan2(v.y, v.x);
|
||||
if (angle < 0)
|
||||
angle += Math.PI * 2;
|
||||
return angle;
|
||||
}
|
||||
exports.angle = angle;
|
||||
/**
|
||||
* 求两个向量的夹角,顺时针为负,逆时针为正
|
||||
*
|
||||
* @param {THREE.Vector3} v1
|
||||
* @param {THREE.Vector3} v2
|
||||
* @param {THREE.Vector3} [ref] 参考向量,如果为世界坐标系则为0,0,1
|
||||
* @returns
|
||||
*/
|
||||
function angleTo(v1, v2, ref = new THREE.Vector3(0, 0, 1)) {
|
||||
if (!ref.equals(new three_1.Vector3(0, 0, 1))) {
|
||||
//任意轴坐标系. 使用相机的构造矩阵.
|
||||
ref.multiplyScalar(-1);
|
||||
let up = getLoocAtUpVec(ref);
|
||||
let refOcs = new THREE.Matrix4();
|
||||
refOcs.lookAt(exports.cZeroVec, ref, up);
|
||||
let refOcsInv = new THREE.Matrix4().getInverse(refOcs);
|
||||
v1.applyMatrix4(refOcsInv);
|
||||
v2.applyMatrix4(refOcsInv);
|
||||
v1.z = 0;
|
||||
v2.z = 0;
|
||||
}
|
||||
if (v1.equals(exports.cZeroVec) || v2.equals(exports.cZeroVec))
|
||||
return 0;
|
||||
let cv = new three_1.Vector3().crossVectors(v1, v2).normalize();
|
||||
return cv.z === 0 ? v1.angleTo(v2) : v1.angleTo(v2) * cv.z;
|
||||
}
|
||||
exports.angleTo = angleTo;
|
||||
function getLoocAtUpVec(dir) {
|
||||
if (dir.equals(exports.cZeroVec)) {
|
||||
throw ("zero vector");
|
||||
}
|
||||
let norm = dir.clone().normalize();
|
||||
if (norm.equals(exports.cZAxis)) {
|
||||
return new THREE.Vector3(0, 1, 0);
|
||||
}
|
||||
else if (norm.equals(exports.cZAxis.clone().negate())) {
|
||||
return new THREE.Vector3(0, -1, 0);
|
||||
}
|
||||
else {
|
||||
let xv = new THREE.Vector3();
|
||||
xv.crossVectors(exports.cZAxis, norm);
|
||||
let up = new THREE.Vector3();
|
||||
up.crossVectors(norm, xv);
|
||||
return up;
|
||||
}
|
||||
}
|
||||
exports.getLoocAtUpVec = getLoocAtUpVec;
|
||||
function createLookAtMat4(dir) {
|
||||
let up = getLoocAtUpVec(dir);
|
||||
let mat = new THREE.Matrix4();
|
||||
mat.lookAt(exports.cZeroVec, dir, up);
|
||||
return mat;
|
||||
}
|
||||
exports.createLookAtMat4 = createLookAtMat4;
|
||||
function isParallelTo(v1, v2) {
|
||||
return v1.clone().cross(v2).lengthSq() < 1e-9;
|
||||
}
|
||||
exports.isParallelTo = isParallelTo;
|
||||
function ptToString(v, fractionDigits = 3) {
|
||||
return v.toArray().map(o => {
|
||||
return o.toFixed(fractionDigits);
|
||||
}).join(",");
|
||||
}
|
||||
exports.ptToString = ptToString;
|
||||
function midPoint(v1, v2) {
|
||||
return v1.clone().add(v2).multiplyScalar(0.5);
|
||||
}
|
||||
exports.midPoint = midPoint;
|
||||
function midPoint2(v1, v2) {
|
||||
return v1.clone().add(v2).multiplyScalar(0.5);
|
||||
}
|
||||
exports.midPoint2 = midPoint2;
|
||||
function midPtCir(v1, v2) {
|
||||
let baseline = new three_1.Vector3(1, 0, 0);
|
||||
let outLine = v2.clone().sub(v1);
|
||||
let ang = angleTo(baseline, outLine) / 2;
|
||||
let midLine = rotatePoint(outLine, -ang);
|
||||
return v1.clone().add(midLine);
|
||||
}
|
||||
exports.midPtCir = midPtCir;
|
||||
function GetBox(obj, updateMatrix) {
|
||||
if (updateMatrix)
|
||||
obj.updateMatrixWorld(false);
|
||||
if (obj.hasOwnProperty("geometry")) {
|
||||
let geo = obj["geometry"];
|
||||
if (geo instanceof THREE.Geometry || geo instanceof THREE.BufferGeometry) {
|
||||
if (!geo.boundingBox)
|
||||
geo.computeBoundingBox();
|
||||
return geo.boundingBox.clone().applyMatrix4(obj.matrixWorld);
|
||||
}
|
||||
}
|
||||
else if (obj.children.length > 0) {
|
||||
let box = obj.children.reduce((sumBox, itemObj) => {
|
||||
let itemBox = GetBox(itemObj);
|
||||
if (itemBox)
|
||||
sumBox.union(itemBox);
|
||||
return sumBox;
|
||||
}, new THREE.Box3());
|
||||
// if (box) box.applyMatrix4(obj.matrixWorld);
|
||||
return box;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
exports.GetBox = GetBox;
|
||||
function GetBoxArr(arr) {
|
||||
if (arr.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return arr.map(o => {
|
||||
return GetBox(o);
|
||||
}).filter(o => {
|
||||
return o;
|
||||
}).reduce((sumBox, objBox) => {
|
||||
return sumBox.union(objBox);
|
||||
}, new THREE.Box3());
|
||||
}
|
||||
exports.GetBoxArr = GetBoxArr;
|
||||
function MoveMatrix(v) {
|
||||
let mat = new THREE.Matrix4();
|
||||
mat.makeTranslation(v.x, v.y, v.z);
|
||||
return mat;
|
||||
}
|
||||
exports.MoveMatrix = MoveMatrix;
|
||||
function getProjectDist(v1, v2) {
|
||||
let ang = v1.angleTo(v2);
|
||||
let dist = v1.length();
|
||||
return {
|
||||
h: dist * Math.cos(ang),
|
||||
v: dist * Math.sin(ang)
|
||||
};
|
||||
}
|
||||
exports.getProjectDist = getProjectDist;
|
||||
//获得输入点在2线组成的4个区间的位置
|
||||
function getPtPostion(sp, ep, c, inPt) {
|
||||
let l1 = sp.clone().sub(c);
|
||||
let l2 = ep.clone().sub(c);
|
||||
let l3 = l1.clone().negate();
|
||||
let l4 = l2.clone().negate();
|
||||
let inputLine = inPt.clone().sub(c);
|
||||
let ang1 = angleTo(l1, l2);
|
||||
let ang2 = Math.PI;
|
||||
let ang3 = ang2 + Math.abs(ang1);
|
||||
let inputAng = angleTo(l1, inputLine);
|
||||
if (ang1 * inputAng < 0) {
|
||||
inputAng = (Math.PI * 2 - Math.abs(inputAng));
|
||||
}
|
||||
ang1 = Math.abs(ang1);
|
||||
inputAng = Math.abs(inputAng);
|
||||
if (inputAng <= ang1) {
|
||||
return { sp, ep };
|
||||
}
|
||||
else if (inputAng > ang1 && inputAng <= ang2) {
|
||||
return { sp: c.clone().add(l3), ep };
|
||||
}
|
||||
else if (inputAng > ang2 && inputAng <= ang3) {
|
||||
return { sp: c.clone().add(l3), ep: c.clone().add(l4) };
|
||||
}
|
||||
else {
|
||||
return { sp, ep: c.clone().add(l4) };
|
||||
}
|
||||
}
|
||||
exports.getPtPostion = getPtPostion;
|
||||
function angleAndX(v) {
|
||||
return v.x ? Math.atan(v.y / v.x) : Math.PI / 2;
|
||||
}
|
||||
exports.angleAndX = angleAndX;
|
||||
/**
|
||||
* 将角度调整为0-2pi之间
|
||||
*
|
||||
* @export
|
||||
* @param {number} an
|
||||
*/
|
||||
function angleTo2Pi(an) {
|
||||
an = an % (Math.PI * 2);
|
||||
if (an < 0)
|
||||
an += Math.PI * 2;
|
||||
return an;
|
||||
}
|
||||
exports.angleTo2Pi = angleTo2Pi;
|
||||
function updateGeometry(l, geometry) {
|
||||
let geo = l.geometry;
|
||||
geo.dispose();
|
||||
l.geometry = geometry;
|
||||
geometry.verticesNeedUpdate = true;
|
||||
geometry.computeBoundingSphere();
|
||||
}
|
||||
exports.updateGeometry = updateGeometry;
|
||||
//# sourceMappingURL=GeUtils.js.map
|
1
dist/GeUtils.js.map
vendored
1
dist/GeUtils.js.map
vendored
File diff suppressed because one or more lines are too long
149
dist/KeyEnum.d.ts
vendored
149
dist/KeyEnum.d.ts
vendored
@ -1,149 +0,0 @@
|
||||
export declare enum MouseKey {
|
||||
Left = 0,
|
||||
Middle = 1,
|
||||
Right = 2,
|
||||
}
|
||||
export declare enum KeyBoard {
|
||||
Digit1 = 49,
|
||||
Digit2 = 50,
|
||||
Digit3 = 51,
|
||||
Digit4 = 52,
|
||||
Digit5 = 53,
|
||||
Digit6 = 54,
|
||||
Digit7 = 55,
|
||||
Digit8 = 56,
|
||||
Digit9 = 57,
|
||||
Digit0 = 58,
|
||||
KeyA = 65,
|
||||
KeyB = 66,
|
||||
KeyC = 67,
|
||||
KeyD = 68,
|
||||
KeyE = 69,
|
||||
KeyF = 70,
|
||||
KeyG = 71,
|
||||
KeyH = 72,
|
||||
KeyI = 73,
|
||||
KeyJ = 74,
|
||||
KeyK = 75,
|
||||
KeyL = 76,
|
||||
KeyM = 77,
|
||||
KeyN = 78,
|
||||
KeyO = 79,
|
||||
KeyP = 80,
|
||||
KeyQ = 81,
|
||||
KeyR = 82,
|
||||
KeyS = 83,
|
||||
KeyT = 84,
|
||||
KeyU = 85,
|
||||
KeyV = 86,
|
||||
KeyW = 87,
|
||||
KeyX = 88,
|
||||
KeyY = 89,
|
||||
KeyZ = 90,
|
||||
/**
|
||||
* 逗号
|
||||
*/
|
||||
Comma = 188,
|
||||
CommaChrome = 229,
|
||||
/**
|
||||
* 句号
|
||||
*/
|
||||
Period = 190,
|
||||
/**
|
||||
* 分号
|
||||
*/
|
||||
Semicolon = 186,
|
||||
/**
|
||||
* 引号
|
||||
*/
|
||||
Quote = 222,
|
||||
/**
|
||||
* 左括号
|
||||
*/
|
||||
BracketLeft = 219,
|
||||
/**
|
||||
* 右括号
|
||||
*/
|
||||
BracketRight = 220,
|
||||
/**
|
||||
* 反引号
|
||||
*/
|
||||
Backquote = 192,
|
||||
/**
|
||||
* 反斜杠
|
||||
*/
|
||||
Backslash = 220,
|
||||
/**
|
||||
* 减号
|
||||
*/
|
||||
Minus = 189,
|
||||
/**
|
||||
* 等号
|
||||
*/
|
||||
Equal = 187,
|
||||
IntlRo = 193,
|
||||
IntlYen = 255,
|
||||
Alt = 18,
|
||||
/**
|
||||
* 大写锁定
|
||||
*/
|
||||
CapsLock = 20,
|
||||
Control = 17,
|
||||
/**
|
||||
* win左键
|
||||
*/
|
||||
OSLeft = 91,
|
||||
/**
|
||||
* win右键
|
||||
*/
|
||||
OSRight = 92,
|
||||
Shift = 16,
|
||||
ContextMenu = 93,
|
||||
Enter = 13,
|
||||
Space = 32,
|
||||
Backspace = 8,
|
||||
Tab = 9,
|
||||
Delete = 46,
|
||||
End = 35,
|
||||
Home = 36,
|
||||
Insert = 45,
|
||||
PageDown = 34,
|
||||
PageUp = 33,
|
||||
ArrowDown = 40,
|
||||
ArrowLeft = 37,
|
||||
ArrowRight = 39,
|
||||
ArrowUp = 38,
|
||||
Escape = 27,
|
||||
PrintScreen = 44,
|
||||
ScrollLock = 145,
|
||||
Pause = 19,
|
||||
F1 = 112,
|
||||
F2 = 113,
|
||||
F3 = 114,
|
||||
F5 = 116,
|
||||
F6 = 117,
|
||||
F7 = 118,
|
||||
F8 = 119,
|
||||
F9 = 120,
|
||||
F10 = 121,
|
||||
F11 = 122,
|
||||
F12 = 123,
|
||||
NumLock = 114,
|
||||
Numpad0 = 96,
|
||||
Numpad1 = 97,
|
||||
Numpad2 = 98,
|
||||
Numpad3 = 99,
|
||||
Numpad4 = 100,
|
||||
Numpad5 = 101,
|
||||
Numpad6 = 102,
|
||||
Numpad7 = 103,
|
||||
Numpad8 = 104,
|
||||
Numpad9 = 105,
|
||||
NumpadAdd = 107,
|
||||
NumpadDivide = 111,
|
||||
NumpadEqual = 12,
|
||||
NumpadMultiply = 106,
|
||||
NumpadSubtract = 109,
|
||||
NumpadDot = 110,
|
||||
NumpadDot1 = 190,
|
||||
}
|
161
dist/KeyEnum.js
vendored
161
dist/KeyEnum.js
vendored
@ -1,161 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//鼠标类型
|
||||
var MouseKey;
|
||||
(function (MouseKey) {
|
||||
MouseKey[MouseKey["Left"] = 0] = "Left";
|
||||
MouseKey[MouseKey["Middle"] = 1] = "Middle";
|
||||
MouseKey[MouseKey["Right"] = 2] = "Right";
|
||||
})(MouseKey = exports.MouseKey || (exports.MouseKey = {}));
|
||||
var KeyBoard;
|
||||
(function (KeyBoard) {
|
||||
// 数字
|
||||
KeyBoard[KeyBoard["Digit1"] = 49] = "Digit1";
|
||||
KeyBoard[KeyBoard["Digit2"] = 50] = "Digit2";
|
||||
KeyBoard[KeyBoard["Digit3"] = 51] = "Digit3";
|
||||
KeyBoard[KeyBoard["Digit4"] = 52] = "Digit4";
|
||||
KeyBoard[KeyBoard["Digit5"] = 53] = "Digit5";
|
||||
KeyBoard[KeyBoard["Digit6"] = 54] = "Digit6";
|
||||
KeyBoard[KeyBoard["Digit7"] = 55] = "Digit7";
|
||||
KeyBoard[KeyBoard["Digit8"] = 56] = "Digit8";
|
||||
KeyBoard[KeyBoard["Digit9"] = 57] = "Digit9";
|
||||
KeyBoard[KeyBoard["Digit0"] = 58] = "Digit0";
|
||||
// 字母
|
||||
KeyBoard[KeyBoard["KeyA"] = 65] = "KeyA";
|
||||
KeyBoard[KeyBoard["KeyB"] = 66] = "KeyB";
|
||||
KeyBoard[KeyBoard["KeyC"] = 67] = "KeyC";
|
||||
KeyBoard[KeyBoard["KeyD"] = 68] = "KeyD";
|
||||
KeyBoard[KeyBoard["KeyE"] = 69] = "KeyE";
|
||||
KeyBoard[KeyBoard["KeyF"] = 70] = "KeyF";
|
||||
KeyBoard[KeyBoard["KeyG"] = 71] = "KeyG";
|
||||
KeyBoard[KeyBoard["KeyH"] = 72] = "KeyH";
|
||||
KeyBoard[KeyBoard["KeyI"] = 73] = "KeyI";
|
||||
KeyBoard[KeyBoard["KeyJ"] = 74] = "KeyJ";
|
||||
KeyBoard[KeyBoard["KeyK"] = 75] = "KeyK";
|
||||
KeyBoard[KeyBoard["KeyL"] = 76] = "KeyL";
|
||||
KeyBoard[KeyBoard["KeyM"] = 77] = "KeyM";
|
||||
KeyBoard[KeyBoard["KeyN"] = 78] = "KeyN";
|
||||
KeyBoard[KeyBoard["KeyO"] = 79] = "KeyO";
|
||||
KeyBoard[KeyBoard["KeyP"] = 80] = "KeyP";
|
||||
KeyBoard[KeyBoard["KeyQ"] = 81] = "KeyQ";
|
||||
KeyBoard[KeyBoard["KeyR"] = 82] = "KeyR";
|
||||
KeyBoard[KeyBoard["KeyS"] = 83] = "KeyS";
|
||||
KeyBoard[KeyBoard["KeyT"] = 84] = "KeyT";
|
||||
KeyBoard[KeyBoard["KeyU"] = 85] = "KeyU";
|
||||
KeyBoard[KeyBoard["KeyV"] = 86] = "KeyV";
|
||||
KeyBoard[KeyBoard["KeyW"] = 87] = "KeyW";
|
||||
KeyBoard[KeyBoard["KeyX"] = 88] = "KeyX";
|
||||
KeyBoard[KeyBoard["KeyY"] = 89] = "KeyY";
|
||||
KeyBoard[KeyBoard["KeyZ"] = 90] = "KeyZ";
|
||||
// 符号
|
||||
/**
|
||||
* 逗号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Comma"] = 188] = "Comma";
|
||||
KeyBoard[KeyBoard["CommaChrome"] = 229] = "CommaChrome";
|
||||
/**
|
||||
* 句号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Period"] = 190] = "Period";
|
||||
/**
|
||||
* 分号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Semicolon"] = 186] = "Semicolon";
|
||||
/**
|
||||
* 引号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Quote"] = 222] = "Quote";
|
||||
/**
|
||||
* 左括号
|
||||
*/
|
||||
KeyBoard[KeyBoard["BracketLeft"] = 219] = "BracketLeft";
|
||||
/**
|
||||
* 右括号
|
||||
*/
|
||||
KeyBoard[KeyBoard["BracketRight"] = 220] = "BracketRight";
|
||||
/**
|
||||
* 反引号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Backquote"] = 192] = "Backquote";
|
||||
/**
|
||||
* 反斜杠
|
||||
*/
|
||||
KeyBoard[KeyBoard["Backslash"] = 220] = "Backslash";
|
||||
/**
|
||||
* 减号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Minus"] = 189] = "Minus";
|
||||
/**
|
||||
* 等号
|
||||
*/
|
||||
KeyBoard[KeyBoard["Equal"] = 187] = "Equal";
|
||||
KeyBoard[KeyBoard["IntlRo"] = 193] = "IntlRo";
|
||||
KeyBoard[KeyBoard["IntlYen"] = 255] = "IntlYen";
|
||||
// 功能键
|
||||
KeyBoard[KeyBoard["Alt"] = 18] = "Alt";
|
||||
/**
|
||||
* 大写锁定
|
||||
*/
|
||||
KeyBoard[KeyBoard["CapsLock"] = 20] = "CapsLock";
|
||||
KeyBoard[KeyBoard["Control"] = 17] = "Control";
|
||||
/**
|
||||
* win左键
|
||||
*/
|
||||
KeyBoard[KeyBoard["OSLeft"] = 91] = "OSLeft";
|
||||
/**
|
||||
* win右键
|
||||
*/
|
||||
KeyBoard[KeyBoard["OSRight"] = 92] = "OSRight";
|
||||
KeyBoard[KeyBoard["Shift"] = 16] = "Shift";
|
||||
KeyBoard[KeyBoard["ContextMenu"] = 93] = "ContextMenu";
|
||||
KeyBoard[KeyBoard["Enter"] = 13] = "Enter";
|
||||
KeyBoard[KeyBoard["Space"] = 32] = "Space";
|
||||
KeyBoard[KeyBoard["Backspace"] = 8] = "Backspace";
|
||||
KeyBoard[KeyBoard["Tab"] = 9] = "Tab";
|
||||
KeyBoard[KeyBoard["Delete"] = 46] = "Delete";
|
||||
KeyBoard[KeyBoard["End"] = 35] = "End";
|
||||
KeyBoard[KeyBoard["Home"] = 36] = "Home";
|
||||
KeyBoard[KeyBoard["Insert"] = 45] = "Insert";
|
||||
KeyBoard[KeyBoard["PageDown"] = 34] = "PageDown";
|
||||
KeyBoard[KeyBoard["PageUp"] = 33] = "PageUp";
|
||||
KeyBoard[KeyBoard["ArrowDown"] = 40] = "ArrowDown";
|
||||
KeyBoard[KeyBoard["ArrowLeft"] = 37] = "ArrowLeft";
|
||||
KeyBoard[KeyBoard["ArrowRight"] = 39] = "ArrowRight";
|
||||
KeyBoard[KeyBoard["ArrowUp"] = 38] = "ArrowUp";
|
||||
KeyBoard[KeyBoard["Escape"] = 27] = "Escape";
|
||||
KeyBoard[KeyBoard["PrintScreen"] = 44] = "PrintScreen";
|
||||
KeyBoard[KeyBoard["ScrollLock"] = 145] = "ScrollLock";
|
||||
KeyBoard[KeyBoard["Pause"] = 19] = "Pause";
|
||||
// F数字
|
||||
KeyBoard[KeyBoard["F1"] = 112] = "F1";
|
||||
KeyBoard[KeyBoard["F2"] = 113] = "F2";
|
||||
KeyBoard[KeyBoard["F3"] = 114] = "F3";
|
||||
KeyBoard[KeyBoard["F5"] = 116] = "F5";
|
||||
KeyBoard[KeyBoard["F6"] = 117] = "F6";
|
||||
KeyBoard[KeyBoard["F7"] = 118] = "F7";
|
||||
KeyBoard[KeyBoard["F8"] = 119] = "F8";
|
||||
KeyBoard[KeyBoard["F9"] = 120] = "F9";
|
||||
KeyBoard[KeyBoard["F10"] = 121] = "F10";
|
||||
KeyBoard[KeyBoard["F11"] = 122] = "F11";
|
||||
KeyBoard[KeyBoard["F12"] = 123] = "F12";
|
||||
//数字键盘
|
||||
KeyBoard[KeyBoard["NumLock"] = 114] = "NumLock";
|
||||
KeyBoard[KeyBoard["Numpad0"] = 96] = "Numpad0";
|
||||
KeyBoard[KeyBoard["Numpad1"] = 97] = "Numpad1";
|
||||
KeyBoard[KeyBoard["Numpad2"] = 98] = "Numpad2";
|
||||
KeyBoard[KeyBoard["Numpad3"] = 99] = "Numpad3";
|
||||
KeyBoard[KeyBoard["Numpad4"] = 100] = "Numpad4";
|
||||
KeyBoard[KeyBoard["Numpad5"] = 101] = "Numpad5";
|
||||
KeyBoard[KeyBoard["Numpad6"] = 102] = "Numpad6";
|
||||
KeyBoard[KeyBoard["Numpad7"] = 103] = "Numpad7";
|
||||
KeyBoard[KeyBoard["Numpad8"] = 104] = "Numpad8";
|
||||
KeyBoard[KeyBoard["Numpad9"] = 105] = "Numpad9";
|
||||
KeyBoard[KeyBoard["NumpadAdd"] = 107] = "NumpadAdd";
|
||||
KeyBoard[KeyBoard["NumpadDivide"] = 111] = "NumpadDivide";
|
||||
KeyBoard[KeyBoard["NumpadEqual"] = 12] = "NumpadEqual";
|
||||
KeyBoard[KeyBoard["NumpadMultiply"] = 106] = "NumpadMultiply";
|
||||
KeyBoard[KeyBoard["NumpadSubtract"] = 109] = "NumpadSubtract";
|
||||
KeyBoard[KeyBoard["NumpadDot"] = 110] = "NumpadDot";
|
||||
KeyBoard[KeyBoard["NumpadDot1"] = 190] = "NumpadDot1";
|
||||
})(KeyBoard = exports.KeyBoard || (exports.KeyBoard = {}));
|
||||
//# sourceMappingURL=KeyEnum.js.map
|
1
dist/KeyEnum.js.map
vendored
1
dist/KeyEnum.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"KeyEnum.js","sourceRoot":"","sources":["../src/KeyEnum.ts"],"names":[],"mappings":";;AAAA,MAAM;AACN,IAAY,QAKX;AALD,WAAY,QAAQ;IAEhB,uCAAQ,CAAA;IACR,2CAAU,CAAA;IACV,yCAAS,CAAA;AACb,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB;AAED,IAAY,QA2JX;AA3JD,WAAY,QAAQ;IAEhB,KAAK;IACL,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,4CAAW,CAAA;IACX,KAAK;IACL,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IACT,wCAAS,CAAA;IAET,KAAK;IACL;;OAEG;IACH,2CAAW,CAAA;IACX,uDAAiB,CAAA;IACjB;;OAEG;IACH,6CAAY,CAAA;IACZ;;OAEG;IACH,mDAAe,CAAA;IACf;;OAEG;IACH,2CAAW,CAAA;IACX;;OAEG;IACH,uDAAiB,CAAA;IACjB;;OAEG;IACH,yDAAkB,CAAA;IAClB;;OAEG;IACH,mDAAe,CAAA;IACf;;OAEG;IACH,mDAAe,CAAA;IACf;;OAEG;IACH,2CAAW,CAAA;IACX;;OAEG;IACH,2CAAW,CAAA;IACX,6CAAY,CAAA;IACZ,+CAAa,CAAA;IACb,MAAM;IACN,sCAAQ,CAAA;IACR;;OAEG;IACH,gDAAa,CAAA;IACb,8CAAY,CAAA;IACZ;;OAEG;IACH,4CAAW,CAAA;IACX;;OAEG;IACH,8CAAY,CAAA;IACZ,0CAAU,CAAA;IAEV,sDAAgB,CAAA;IAChB,0CAAU,CAAA;IACV,0CAAU,CAAA;IACV,iDAAa,CAAA;IACb,qCAAO,CAAA;IACP,4CAAW,CAAA;IACX,sCAAQ,CAAA;IACR,wCAAS,CAAA;IACT,4CAAW,CAAA;IACX,gDAAa,CAAA;IACb,4CAAW,CAAA;IACX,kDAAc,CAAA;IACd,kDAAc,CAAA;IACd,oDAAe,CAAA;IACf,8CAAY,CAAA;IACZ,4CAAW,CAAA;IACX,sDAAgB,CAAA;IAChB,qDAAgB,CAAA;IAChB,0CAAU,CAAA;IAEV,MAAM;IACN,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,uCAAS,CAAA;IACT,uCAAS,CAAA;IACT,uCAAS,CAAA;IAET,MAAM;IACN,+CAAa,CAAA;IACb,8CAAY,CAAA;IACZ,8CAAY,CAAA;IACZ,8CAAY,CAAA;IACZ,8CAAY,CAAA;IACZ,+CAAa,CAAA;IACb,+CAAa,CAAA;IACb,+CAAa,CAAA;IACb,+CAAa,CAAA;IACb,+CAAa,CAAA;IACb,+CAAa,CAAA;IACb,mDAAe,CAAA;IACf,yDAAkB,CAAA;IAClB,sDAAgB,CAAA;IAChB,6DAAoB,CAAA;IACpB,6DAAoB,CAAA;IACpB,mDAAe,CAAA;IACf,qDAAgB,CAAA;AAEpB,CAAC,EA3JW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QA2JnB"}
|
3
dist/Material.d.ts
vendored
3
dist/Material.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { MeshBasicMaterial, LineBasicMaterial } from "three";
|
||||
export declare let boardMaterial: MeshBasicMaterial;
|
||||
export declare let edgeMaterial: LineBasicMaterial;
|
13
dist/Material.js
vendored
13
dist/Material.js
vendored
@ -1,13 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const three_1 = require("three");
|
||||
//板件的材质,使用这个材质避免板件将线覆盖.
|
||||
exports.boardMaterial = new three_1.MeshBasicMaterial({
|
||||
color: new three_1.Color(0.8, 0.8, 0.8),
|
||||
polygonOffset: true,
|
||||
polygonOffsetFactor: 1,
|
||||
polygonOffsetUnits: 1
|
||||
});
|
||||
//线框的材质
|
||||
exports.edgeMaterial = new three_1.LineBasicMaterial({ linewidth: 2, color: new three_1.Color(0, 0, 0) });
|
||||
//# sourceMappingURL=Material.js.map
|
1
dist/Material.js.map
vendored
1
dist/Material.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../src/Material.ts"],"names":[],"mappings":";;AAAA,iCAAoE;AAEpE,uBAAuB;AACZ,QAAA,aAAa,GAAG,IAAI,yBAAiB,CAAC;IAC7C,KAAK,EAAE,IAAI,aAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAC/B,aAAa,EAAE,IAAI;IACnB,mBAAmB,EAAE,CAAC;IACtB,kBAAkB,EAAE,CAAC;CACxB,CAAC,CAAC;AAEH,OAAO;AACI,QAAA,YAAY,GAAG,IAAI,yBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,aAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC"}
|
7
dist/Matrix2.d.ts
vendored
7
dist/Matrix2.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import { Vector2, Vector3 } from "three";
|
||||
export declare class Matrix2 {
|
||||
private el;
|
||||
set(n11: number, n12: number, n21: number, n22: number): this;
|
||||
applyVector(vec: Vector2 | Vector3): this;
|
||||
setRotate(theta: number): Matrix2;
|
||||
}
|
30
dist/Matrix2.js
vendored
30
dist/Matrix2.js
vendored
@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Matrix2 {
|
||||
constructor() {
|
||||
this.el = [1, 0, 0, 1];
|
||||
}
|
||||
set(n11, n12, n21, n22) {
|
||||
let te = this.el;
|
||||
te[0] = n11;
|
||||
te[1] = n21;
|
||||
te[2] = n12;
|
||||
te[3] = n22;
|
||||
return this;
|
||||
}
|
||||
applyVector(vec) {
|
||||
let x = vec.x, y = vec.y;
|
||||
let e = this.el;
|
||||
vec.x = e[0] * x + e[2] * y;
|
||||
vec.y = e[1] * x + e[3] * y;
|
||||
return this;
|
||||
}
|
||||
setRotate(theta) {
|
||||
let el = this.el;
|
||||
let c = Math.cos(theta), s = Math.sin(theta);
|
||||
this.set(c, -s, s, c);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
exports.Matrix2 = Matrix2;
|
||||
//# sourceMappingURL=Matrix2.js.map
|
1
dist/Matrix2.js.map
vendored
1
dist/Matrix2.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Matrix2.js","sourceRoot":"","sources":["../src/Matrix2.ts"],"names":[],"mappings":";;AAEA;IAAA;QAEY,OAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IA4B9B,CAAC;IA3BG,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW;QAElD,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAEjB,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACzB,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,WAAW,CAAC,GAAsB;QAE9B,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;QAChB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,SAAS,CAAC,KAAa;QAEnB,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE7C,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACV,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA9BD,0BA8BC"}
|
38
dist/Orbit.d.ts
vendored
38
dist/Orbit.d.ts
vendored
@ -1,38 +0,0 @@
|
||||
import * as THREE from "three";
|
||||
/**
|
||||
* 轨道控制的数学类,观察向量和角度的互相转换
|
||||
* 当x当抬头或者低头到90度时,触发万向锁.
|
||||
*
|
||||
* @class Orbit
|
||||
*/
|
||||
export declare class Orbit {
|
||||
private m_RoX;
|
||||
RoZ: number;
|
||||
RoX: number;
|
||||
/**
|
||||
* 使用旋转角度 计算观察向量
|
||||
*
|
||||
* @param {THREE.Vector3} [dir] 引用传入,如果传入,那么就不构造新的向量
|
||||
* @returns {THREE.Vector3} 返回观察向量
|
||||
* @memberof Orbit
|
||||
*/
|
||||
UpdateDirection(dir?: THREE.Vector3): THREE.Vector3;
|
||||
/**
|
||||
* 使用观察向量,计算旋转角度
|
||||
*
|
||||
* @param {THREE.Vector3} dir
|
||||
* @memberof Orbit
|
||||
*/
|
||||
UpdateRoValue(dir: THREE.Vector3): void;
|
||||
/**
|
||||
*
|
||||
* 根据观察向量 求头部的向量.
|
||||
*
|
||||
* @static
|
||||
* @param {THREE.Vector3} dir
|
||||
* @param {THREE.Vector3} [up]
|
||||
* @returns {THREE.Vector3}
|
||||
* @memberof Orbit
|
||||
*/
|
||||
static ComputUpDirection(dir: THREE.Vector3, up?: THREE.Vector3): THREE.Vector3;
|
||||
}
|
81
dist/Orbit.js
vendored
81
dist/Orbit.js
vendored
@ -1,81 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
/**
|
||||
* 轨道控制的数学类,观察向量和角度的互相转换
|
||||
* 当x当抬头或者低头到90度时,触发万向锁.
|
||||
*
|
||||
* @class Orbit
|
||||
*/
|
||||
class Orbit {
|
||||
constructor() {
|
||||
//抬头低头 正数抬头 负数低头
|
||||
this.m_RoX = 0;
|
||||
//身体旋转 0为正右边 逆时针旋转
|
||||
this.RoZ = 0;
|
||||
}
|
||||
get RoX() {
|
||||
return this.m_RoX;
|
||||
}
|
||||
set RoX(v) {
|
||||
this.m_RoX = THREE.Math.clamp(v, Math.PI * -0.5, Math.PI * 0.5);
|
||||
}
|
||||
/**
|
||||
* 使用旋转角度 计算观察向量
|
||||
*
|
||||
* @param {THREE.Vector3} [dir] 引用传入,如果传入,那么就不构造新的向量
|
||||
* @returns {THREE.Vector3} 返回观察向量
|
||||
* @memberof Orbit
|
||||
*/
|
||||
UpdateDirection(dir) {
|
||||
let rtDir = dir ? dir : new THREE.Vector3();
|
||||
rtDir.z = Math.sin(this.m_RoX);
|
||||
//归一化专用.
|
||||
let d = Math.abs(Math.cos(this.m_RoX));
|
||||
rtDir.x = Math.cos(this.RoZ) * d;
|
||||
rtDir.y = Math.sin(this.RoZ) * d;
|
||||
return rtDir;
|
||||
}
|
||||
/**
|
||||
* 使用观察向量,计算旋转角度
|
||||
*
|
||||
* @param {THREE.Vector3} dir
|
||||
* @memberof Orbit
|
||||
*/
|
||||
UpdateRoValue(dir) {
|
||||
dir.normalize();
|
||||
this.m_RoX = Math.asin(dir.z);
|
||||
if (dir.x < 1e-4 && dir.y < 1e-4)
|
||||
this.RoZ = Math.PI * 0.5;
|
||||
else
|
||||
this.RoZ = Math.atan2(dir.y, dir.x);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* 根据观察向量 求头部的向量.
|
||||
*
|
||||
* @static
|
||||
* @param {THREE.Vector3} dir
|
||||
* @param {THREE.Vector3} [up]
|
||||
* @returns {THREE.Vector3}
|
||||
* @memberof Orbit
|
||||
*/
|
||||
static ComputUpDirection(dir, up) {
|
||||
let upRes = up ? up : new THREE.Vector3();
|
||||
if (dir.equals(new THREE.Vector3(0, 0, -1))) {
|
||||
upRes.set(0, 1, 0);
|
||||
}
|
||||
else if (dir.equals(new THREE.Vector3(0, 0, 1))) {
|
||||
upRes.set(0, -1, 0);
|
||||
}
|
||||
else {
|
||||
let xv = new THREE.Vector3();
|
||||
xv.crossVectors(new THREE.Vector3(0, 0, 1), dir);
|
||||
upRes.crossVectors(dir, xv);
|
||||
upRes.normalize();
|
||||
}
|
||||
return upRes;
|
||||
}
|
||||
}
|
||||
exports.Orbit = Orbit;
|
||||
//# sourceMappingURL=Orbit.js.map
|
1
dist/Orbit.js.map
vendored
1
dist/Orbit.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Orbit.js","sourceRoot":"","sources":["../src/Orbit.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAE/B;;;;;GAKG;AACH;IAAA;QAEI,gBAAgB;QACR,UAAK,GAAW,CAAC,CAAC;QAE1B,kBAAkB;QAClB,QAAG,GAAW,CAAC,CAAC;IA+EpB,CAAC;IA7EG,IAAI,GAAG;QAEH,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,IAAI,GAAG,CAAC,CAAC;QAEL,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;OAMG;IACH,eAAe,CAAC,GAAmB;QAE/B,IAAI,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAE5C,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE/B,QAAQ;QACR,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAEvC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEjC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,GAAkB;QAE5B,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI;YAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;;YAEzB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAkB,EAAE,EAAkB;QAE3D,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC1C,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAC3C;YACI,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;aACI,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAC/C;YACI,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACvB;aAED;YACI,IAAI,EAAE,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAC7B,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACjD,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC5B,KAAK,CAAC,SAAS,EAAE,CAAC;SACrB;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AArFD,sBAqFC"}
|
7
dist/PlaneExt.d.ts
vendored
7
dist/PlaneExt.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
import { Vector3, Line3 } from "three";
|
||||
export declare class PlaneExt extends THREE.Plane {
|
||||
constructor(normal?: THREE.Vector3, constant?: number);
|
||||
intersectLine(line: Line3, optionalTarget?: Vector3, extendLine?: boolean): Vector3;
|
||||
intersectRay(ray: THREE.Ray, optionalTarget?: Vector3, extendLine?: boolean): Vector3;
|
||||
}
|
36
dist/PlaneExt.js
vendored
36
dist/PlaneExt.js
vendored
@ -1,36 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const three_1 = require("three");
|
||||
class PlaneExt extends THREE.Plane {
|
||||
constructor(normal, constant) {
|
||||
super(normal, constant);
|
||||
}
|
||||
intersectLine(line, optionalTarget, extendLine) {
|
||||
let v1 = new three_1.Vector3();
|
||||
let result = optionalTarget || new three_1.Vector3();
|
||||
let direction = line.delta(v1);
|
||||
let denominator = this.normal.dot(direction);
|
||||
if (denominator === 0) {
|
||||
// line is coplanar, return origin
|
||||
if (this.distanceToPoint(line.start) === 0) {
|
||||
return result.copy(line.start);
|
||||
}
|
||||
// Unsure if this is the correct method to handle this case.
|
||||
return undefined;
|
||||
}
|
||||
let t = -(line.start.dot(this.normal) + this.constant) / denominator;
|
||||
//If you not extendLine,check intersect point in Line
|
||||
if (!extendLine && (t < 0 || t > 1)) {
|
||||
return undefined;
|
||||
}
|
||||
return result.copy(direction).multiplyScalar(t).add(line.start);
|
||||
}
|
||||
intersectRay(ray, optionalTarget, extendLine) {
|
||||
// 从射线初始位置
|
||||
let line = new THREE.Line3(ray.origin.clone(), ray.origin.clone().add(ray.direction));
|
||||
return this.intersectLine(line, optionalTarget, extendLine);
|
||||
}
|
||||
}
|
||||
exports.PlaneExt = PlaneExt;
|
||||
//# sourceMappingURL=PlaneExt.js.map
|
1
dist/PlaneExt.js.map
vendored
1
dist/PlaneExt.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"PlaneExt.js","sourceRoot":"","sources":["../src/PlaneExt.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,iCAAuC;AAEvC,cAAsB,SAAQ,KAAK,CAAC,KAAK;IAErC,YAAY,MAAsB,EAAE,QAAiB;QAEjD,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,aAAa,CAAC,IAAW,EAAE,cAAwB,EAAE,UAAoB;QAErE,IAAI,EAAE,GAAG,IAAI,eAAO,EAAE,CAAC;QAEvB,IAAI,MAAM,GAAG,cAAc,IAAI,IAAI,eAAO,EAAE,CAAC;QAE7C,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAE/B,IAAI,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAI,WAAW,KAAK,CAAC,EACrB;YACI,kCAAkC;YAClC,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAC1C;gBACI,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAClC;YACD,4DAA4D;YAC5D,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,CAAC,GAAG,CAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC;QACtE,qDAAqD;QACrD,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACnC;YACI,OAAO,SAAS,CAAC;SACpB;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IACD,YAAY,CAAC,GAAc,EAAE,cAAwB,EAAE,UAAoB;QAEvE,UAAU;QACV,IAAI,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QACtF,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;CACJ;AA1CD,4BA0CC"}
|
12
dist/PointPick.d.ts
vendored
12
dist/PointPick.d.ts
vendored
@ -1,12 +0,0 @@
|
||||
import { Mesh } from "three";
|
||||
import { Viewer } from ".";
|
||||
/**
|
||||
* 点选
|
||||
*
|
||||
* @export
|
||||
* @param {Viewer} view
|
||||
* @param {number} ptx
|
||||
* @param {number} pty
|
||||
* @returns {(Mesh | undefined)}
|
||||
*/
|
||||
export declare function PointPick(view: Viewer, ptx: number, pty: number): Mesh | undefined;
|
38
dist/PointPick.js
vendored
38
dist/PointPick.js
vendored
@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const three_1 = require("three");
|
||||
/**
|
||||
* 点选
|
||||
*
|
||||
* @export
|
||||
* @param {Viewer} view
|
||||
* @param {number} ptx
|
||||
* @param {number} pty
|
||||
* @returns {(Mesh | undefined)}
|
||||
*/
|
||||
function PointPick(view, ptx, pty) {
|
||||
let raycaster = new three_1.Raycaster();
|
||||
raycaster.setFromCamera({
|
||||
x: (ptx / view._Width) * 2 - 1,
|
||||
y: -(pty / view._Height) * 2 + 1 //y轴相反
|
||||
}, view.m_Camera.Camera);
|
||||
//https://github.com/mrdoob/three.js/issues/14128
|
||||
raycaster.ray.origin.set((ptx / view._Width) * 2 - 1, -(pty / view._Height) * 2 + 1, -1).unproject(view.m_Camera.Camera);
|
||||
let minDis = Infinity;
|
||||
let minObj = undefined;
|
||||
view.m_Scene.children.forEach(obj => {
|
||||
if (obj instanceof three_1.Mesh) {
|
||||
let intersects = [];
|
||||
obj.raycast(raycaster, intersects);
|
||||
for (let i of intersects) {
|
||||
if (i.distance < minDis) {
|
||||
minObj = obj;
|
||||
minDis = i.distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return minObj;
|
||||
}
|
||||
exports.PointPick = PointPick;
|
||||
//# sourceMappingURL=PointPick.js.map
|
1
dist/PointPick.js.map
vendored
1
dist/PointPick.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"PointPick.js","sourceRoot":"","sources":["../src/PointPick.ts"],"names":[],"mappings":";;AAAA,iCAA2E;AAc3E;;;;;;;;GAQG;AACH,mBAA0B,IAAY,EAAE,GAAW,EAAE,GAAW;IAE5D,IAAI,SAAS,GAAG,IAAI,iBAAS,EAAE,CAAC;IAChC,SAAS,CAAC,aAAa,CAAC;QACpB,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAC9B,CAAC,EAAE,CAAE,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM;KAC3C,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEzB,iDAAiD;IACjD,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAG1H,IAAI,MAAM,GAAG,QAAQ,CAAC;IACtB,IAAI,MAAM,GAAG,SAAS,CAAC;IAEvB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAEhC,IAAI,GAAG,YAAY,YAAI,EACvB;YACI,IAAI,UAAU,GAAgB,EAAE,CAAC;YACjC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAEnC,KAAK,IAAI,CAAC,IAAI,UAAU,EACxB;gBACI,IAAI,CAAC,CAAC,QAAQ,GAAG,MAAM,EACvB;oBACI,MAAM,GAAG,GAAG,CAAC;oBACb,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC;iBACvB;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAlCD,8BAkCC"}
|
2
dist/RotateUV.d.ts
vendored
2
dist/RotateUV.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
export declare function RotateUVs(geo: THREE.Geometry): void;
|
20
dist/RotateUV.js
vendored
20
dist/RotateUV.js
vendored
@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Matrix2_1 = require("./Matrix2");
|
||||
const THREE = require("three");
|
||||
function RotateUVs(geo) {
|
||||
let roMat = new Matrix2_1.Matrix2();
|
||||
roMat.set(0, -1, 1, 0);
|
||||
let addV = new THREE.Vector2(1, 0);
|
||||
for (let uvs of geo.faceVertexUvs) {
|
||||
for (let uv of uvs) {
|
||||
for (let v of uv) {
|
||||
roMat.applyVector(v);
|
||||
v.add(addV);
|
||||
}
|
||||
}
|
||||
}
|
||||
geo.uvsNeedUpdate = true;
|
||||
}
|
||||
exports.RotateUVs = RotateUVs;
|
||||
//# sourceMappingURL=RotateUV.js.map
|
1
dist/RotateUV.js.map
vendored
1
dist/RotateUV.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"RotateUV.js","sourceRoot":"","sources":["../src/RotateUV.ts"],"names":[],"mappings":";;AAAA,uCAAoC;AACpC,+BAA+B;AAG/B,mBAA0B,GAAmB;IAEzC,IAAI,KAAK,GAAG,IAAI,iBAAO,EAAE,CAAC;IAC1B,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACX,CAAC,EAAE,CAAC,CAAC,CAAC;IAEV,IAAI,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEnC,KAAK,IAAI,GAAG,IAAI,GAAG,CAAC,aAAa,EACjC;QACI,KAAK,IAAI,EAAE,IAAI,GAAG,EAClB;YACI,KAAK,IAAI,CAAC,IAAI,EAAE,EAChB;gBACI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;gBACrB,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACf;SACJ;KACJ;IACD,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC;AAC7B,CAAC;AApBD,8BAoBC"}
|
11
dist/Text.d.ts
vendored
11
dist/Text.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
import { Mesh } from "three";
|
||||
export declare class DbText extends Mesh {
|
||||
/**
|
||||
*
|
||||
* 构造一个文本对象,8位点(中心点下面)在0点
|
||||
* @param {string} str 数字字符串
|
||||
* @param {number} height 文本高度
|
||||
* @memberof DbText
|
||||
*/
|
||||
constructor(str: string, height?: number);
|
||||
}
|
35
dist/Text.js
vendored
35
dist/Text.js
vendored
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const three_1 = require("three");
|
||||
const ColorPalette_1 = require("./ColorPalette");
|
||||
const GeUtils_1 = require("./GeUtils");
|
||||
class FontLoaderUtil {
|
||||
static Load() {
|
||||
if (!this.defFont) {
|
||||
const f = require("../resources/fonts/helvetiker_regular.typeface.json");
|
||||
let loader = new three_1.FontLoader();
|
||||
this.defFont = loader.parse(f);
|
||||
}
|
||||
return this.defFont;
|
||||
}
|
||||
}
|
||||
class DbText extends three_1.Mesh {
|
||||
/**
|
||||
*
|
||||
* 构造一个文本对象,8位点(中心点下面)在0点
|
||||
* @param {string} str 数字字符串
|
||||
* @param {number} height 文本高度
|
||||
* @memberof DbText
|
||||
*/
|
||||
constructor(str, height = 5) {
|
||||
let font = FontLoaderUtil.Load();
|
||||
let shapes = font.generateShapes(str, height, 0.1);
|
||||
let geometry = new three_1.ShapeGeometry(shapes);
|
||||
geometry.computeBoundingBox();
|
||||
super(geometry, ColorPalette_1.ColorMaterial.GetLineMaterial(5));
|
||||
let center = geometry.boundingBox.getCenter(new three_1.Vector3());
|
||||
this.applyMatrix(GeUtils_1.MoveMatrix(new three_1.Vector3(-center.x, 0, 0)));
|
||||
}
|
||||
}
|
||||
exports.DbText = DbText;
|
||||
//# sourceMappingURL=Text.js.map
|
1
dist/Text.js.map
vendored
1
dist/Text.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.ts"],"names":[],"mappings":";;AAAA,iCAAuE;AACvE,iDAA+C;AAC/C,uCAAuC;AAEvC;IAEE,MAAM,CAAC,IAAI;QACT,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,CAAC,GAAG,OAAO,CAAC,qDAAqD,CAAC,CAAC;YACzE,IAAI,MAAM,GAAG,IAAI,kBAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAChC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED,YAAoB,SAAQ,YAAI;IAC9B;;;;;;OAMG;IACH,YAAY,GAAW,EAAE,SAAiB,CAAC;QACzC,IAAI,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;QAEjC,IAAI,MAAM,GAAkB,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAClE,IAAI,QAAQ,GAAG,IAAI,qBAAa,CAAC,MAAM,CAAC,CAAC;QAEzC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAE9B,KAAK,CAAC,QAAQ,EAAE,4BAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAElD,IAAI,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,eAAO,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,WAAW,CAAC,oBAAU,CAAC,IAAI,eAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF;AArBD,wBAqBC"}
|
58
dist/ThreeCSG.d.ts
vendored
58
dist/ThreeCSG.d.ts
vendored
@ -1,58 +0,0 @@
|
||||
import * as THREE from "three";
|
||||
export declare class ThreeBSP {
|
||||
tree: Node;
|
||||
matrix: THREE.Matrix4;
|
||||
Node: typeof Node;
|
||||
Vertex: typeof Vertex;
|
||||
Polygon: typeof Polygon;
|
||||
constructor(geometry: any);
|
||||
subtract(other_tree: any): ThreeBSP;
|
||||
union(other_tree: any): ThreeBSP;
|
||||
intersect(other_tree: any): ThreeBSP;
|
||||
toGeometry(): THREE.Geometry;
|
||||
toMesh(material: any): THREE.Mesh;
|
||||
}
|
||||
export declare class Polygon {
|
||||
w: any;
|
||||
normal: any;
|
||||
vertices: any;
|
||||
constructor(vertices?: any, normal?: any, w?: any);
|
||||
calculateProperties(): this;
|
||||
clone(): Polygon;
|
||||
flip(): this;
|
||||
classifyVertex(vertex: any): 0 | 1 | 2;
|
||||
classifySide(polygon: any): 0 | 1 | 2 | 3;
|
||||
splitPolygon(polygon: any, coplanar_front: any, coplanar_back: any, front: any, back: any): void;
|
||||
}
|
||||
export declare class Vertex {
|
||||
uv: any;
|
||||
normal: any;
|
||||
z: any;
|
||||
y: any;
|
||||
x: any;
|
||||
constructor(x: number, y: number, z: number, normal: THREE.Vector3, uv: THREE.Vector2);
|
||||
clone(): Vertex;
|
||||
add(vertex: any): this;
|
||||
subtract(vertex: any): this;
|
||||
multiplyScalar(scalar: any): this;
|
||||
cross(vertex: any): this;
|
||||
normalize(): this;
|
||||
dot(vertex: any): number;
|
||||
lerp(a: any, t: any): this;
|
||||
interpolate(other: any, t: any): Vertex;
|
||||
applyMatrix4(m: any): this;
|
||||
}
|
||||
export declare class Node {
|
||||
divider: any;
|
||||
back: any;
|
||||
front: any;
|
||||
polygons: any[];
|
||||
constructor(polygons?: any);
|
||||
isConvex(polygons: any): boolean;
|
||||
build(polygons: any): void;
|
||||
allPolygons(): any[];
|
||||
clone(): Node;
|
||||
invert(): this;
|
||||
clipPolygons(polygons: any): any;
|
||||
clipTo(node: any): void;
|
||||
}
|
476
dist/ThreeCSG.js
vendored
476
dist/ThreeCSG.js
vendored
@ -1,476 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
/*jshint esversion: 6 */
|
||||
const EPSILON = 1e-5, COPLANAR = 0, //共面
|
||||
FRONT = 1, //前
|
||||
BACK = 2, SPANNING = 3;
|
||||
class ThreeBSP {
|
||||
constructor(geometry) {
|
||||
// Convert THREE.Geometry to ThreeBSP
|
||||
let i, _length_i, face, vertex, faceVertexUvs, uvs, polygon, polygons = [], tree;
|
||||
this.Polygon = Polygon;
|
||||
this.Vertex = Vertex;
|
||||
this.Node = Node;
|
||||
if (geometry instanceof THREE.Geometry) {
|
||||
this.matrix = new THREE.Matrix4();
|
||||
}
|
||||
else if (geometry instanceof THREE.Mesh) {
|
||||
// #todo: add hierarchy support
|
||||
geometry.updateMatrix();
|
||||
this.matrix = geometry.matrix.clone();
|
||||
geometry = geometry.geometry;
|
||||
}
|
||||
else if (geometry instanceof Node) {
|
||||
this.tree = geometry;
|
||||
this.matrix = new THREE.Matrix4();
|
||||
return this;
|
||||
}
|
||||
else {
|
||||
throw 'ThreeBSP: Given geometry is unsupported';
|
||||
}
|
||||
for (i = 0, _length_i = geometry.faces.length; i < _length_i; i++) {
|
||||
face = geometry.faces[i];
|
||||
faceVertexUvs = geometry.faceVertexUvs[0][i];
|
||||
polygon = new Polygon();
|
||||
if (face instanceof THREE.Face3) {
|
||||
vertex = geometry.vertices[face.a];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[0], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
vertex = geometry.vertices[face.b];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[1], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
vertex = geometry.vertices[face.c];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
}
|
||||
else if (typeof THREE.Face4) {
|
||||
vertex = geometry.vertices[face.a];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[0], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
vertex = geometry.vertices[face.b];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[1], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
vertex = geometry.vertices[face.c];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
vertex = geometry.vertices[face.d];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[3].x, faceVertexUvs[3].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[3], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
}
|
||||
else {
|
||||
throw 'Invalid face type at index ' + i;
|
||||
}
|
||||
polygon.calculateProperties();
|
||||
polygons.push(polygon);
|
||||
}
|
||||
this.tree = new Node(polygons);
|
||||
}
|
||||
//减
|
||||
subtract(other_tree) {
|
||||
let a = this.tree.clone(), b = other_tree.tree.clone();
|
||||
a.invert();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.build(b.allPolygons());
|
||||
a.invert();
|
||||
let bsp = new ThreeBSP(a);
|
||||
bsp.matrix = this.matrix;
|
||||
return bsp;
|
||||
}
|
||||
//结合
|
||||
union(other_tree) {
|
||||
let a = this.tree.clone(), b = other_tree.tree.clone();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.build(b.allPolygons());
|
||||
let bsp = new ThreeBSP(a);
|
||||
bsp.matrix = this.matrix;
|
||||
return bsp;
|
||||
}
|
||||
//相交
|
||||
intersect(other_tree) {
|
||||
let a = this.tree.clone(), b = other_tree.tree.clone();
|
||||
a.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
a.build(b.allPolygons());
|
||||
a.invert();
|
||||
let bsp = new ThreeBSP(a);
|
||||
bsp.matrix = this.matrix;
|
||||
return bsp;
|
||||
}
|
||||
toGeometry() {
|
||||
let i, j, matrix = new THREE.Matrix4().getInverse(this.matrix), geometry = new THREE.Geometry(), polygons = this.tree.allPolygons(), polygon_count = polygons.length, polygon, polygon_vertice_count, vertice_dict = {}, vertex_idx_a, vertex_idx_b, vertex_idx_c, vertex, face, verticeUvs;
|
||||
for (i = 0; i < polygon_count; i++) {
|
||||
polygon = polygons[i];
|
||||
polygon_vertice_count = polygon.vertices.length;
|
||||
for (j = 2; j < polygon_vertice_count; j++) {
|
||||
verticeUvs = [];
|
||||
vertex = polygon.vertices[0];
|
||||
verticeUvs.push(new THREE.Vector2(vertex.uv.x, vertex.uv.y));
|
||||
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
|
||||
vertex.applyMatrix4(matrix);
|
||||
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined') {
|
||||
vertex_idx_a = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z];
|
||||
}
|
||||
else {
|
||||
geometry.vertices.push(vertex);
|
||||
vertex_idx_a = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
|
||||
}
|
||||
vertex = polygon.vertices[j - 1];
|
||||
verticeUvs.push(new THREE.Vector2(vertex.uv.x, vertex.uv.y));
|
||||
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
|
||||
vertex.applyMatrix4(matrix);
|
||||
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined') {
|
||||
vertex_idx_b = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z];
|
||||
}
|
||||
else {
|
||||
geometry.vertices.push(vertex);
|
||||
vertex_idx_b = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
|
||||
}
|
||||
vertex = polygon.vertices[j];
|
||||
verticeUvs.push(new THREE.Vector2(vertex.uv.x, vertex.uv.y));
|
||||
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
|
||||
vertex.applyMatrix4(matrix);
|
||||
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined') {
|
||||
vertex_idx_c = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z];
|
||||
}
|
||||
else {
|
||||
geometry.vertices.push(vertex);
|
||||
vertex_idx_c = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
|
||||
}
|
||||
face = new THREE.Face3(vertex_idx_a, vertex_idx_b, vertex_idx_c, new THREE.Vector3(polygon.normal.x, polygon.normal.y, polygon.normal.z));
|
||||
geometry.faces.push(face);
|
||||
geometry.faceVertexUvs[0].push(verticeUvs);
|
||||
}
|
||||
}
|
||||
return geometry;
|
||||
}
|
||||
toMesh(material) {
|
||||
let geometry = this.toGeometry(), mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.position.setFromMatrixPosition(this.matrix);
|
||||
mesh.rotation.setFromRotationMatrix(this.matrix);
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
exports.ThreeBSP = ThreeBSP;
|
||||
//多边形
|
||||
class Polygon {
|
||||
constructor(vertices, normal, w) {
|
||||
if (!(vertices instanceof Array)) {
|
||||
vertices = [];
|
||||
}
|
||||
this.vertices = vertices;
|
||||
if (vertices.length > 0) {
|
||||
this.calculateProperties();
|
||||
}
|
||||
else {
|
||||
this.normal = this.w = undefined;
|
||||
}
|
||||
}
|
||||
calculateProperties() {
|
||||
let a = this.vertices[0], b = this.vertices[1], c = this.vertices[2];
|
||||
this.normal = b.clone().subtract(a).cross(c.clone().subtract(a)).normalize();
|
||||
this.w = this.normal.clone().dot(a);
|
||||
return this;
|
||||
}
|
||||
clone() {
|
||||
let i, vertice_count, polygon = new Polygon();
|
||||
for (i = 0, vertice_count = this.vertices.length; i < vertice_count; i++) {
|
||||
polygon.vertices.push(this.vertices[i].clone());
|
||||
}
|
||||
polygon.calculateProperties();
|
||||
return polygon;
|
||||
}
|
||||
flip() {
|
||||
let i, vertices = [];
|
||||
this.normal.multiplyScalar(-1);
|
||||
this.w *= -1;
|
||||
for (i = this.vertices.length - 1; i >= 0; i--) {
|
||||
vertices.push(this.vertices[i]);
|
||||
}
|
||||
this.vertices = vertices;
|
||||
return this;
|
||||
}
|
||||
//划分?
|
||||
classifyVertex(vertex) {
|
||||
let side_value = this.normal.dot(vertex) - this.w;
|
||||
if (side_value < -EPSILON) {
|
||||
return BACK;
|
||||
}
|
||||
else if (side_value > EPSILON) {
|
||||
return FRONT;
|
||||
}
|
||||
else {
|
||||
return COPLANAR;
|
||||
}
|
||||
}
|
||||
//划分边?
|
||||
classifySide(polygon) {
|
||||
let i, vertex, classification, num_positive = 0, num_negative = 0, vertice_count = polygon.vertices.length;
|
||||
for (i = 0; i < vertice_count; i++) {
|
||||
vertex = polygon.vertices[i];
|
||||
classification = this.classifyVertex(vertex);
|
||||
if (classification === FRONT) {
|
||||
num_positive++;
|
||||
}
|
||||
else if (classification === BACK) {
|
||||
num_negative++;
|
||||
}
|
||||
}
|
||||
if (num_positive > 0 && num_negative === 0) {
|
||||
return FRONT;
|
||||
}
|
||||
else if (num_positive === 0 && num_negative > 0) {
|
||||
return BACK;
|
||||
}
|
||||
else if (num_positive === 0 && num_negative === 0) {
|
||||
return COPLANAR;
|
||||
}
|
||||
else {
|
||||
return SPANNING;
|
||||
}
|
||||
}
|
||||
//分解 分离 区域?
|
||||
splitPolygon(polygon, coplanar_front, coplanar_back, front, back) {
|
||||
let classification = this.classifySide(polygon);
|
||||
if (classification === COPLANAR) {
|
||||
(this.normal.dot(polygon.normal) > 0 ? coplanar_front : coplanar_back).push(polygon);
|
||||
}
|
||||
else if (classification === FRONT) {
|
||||
front.push(polygon);
|
||||
}
|
||||
else if (classification === BACK) {
|
||||
back.push(polygon);
|
||||
}
|
||||
else {
|
||||
let vertice_count, i, j, ti, tj, vi, vj, t, v, f = [], b = [];
|
||||
for (i = 0, vertice_count = polygon.vertices.length; i < vertice_count; i++) {
|
||||
j = (i + 1) % vertice_count;
|
||||
vi = polygon.vertices[i];
|
||||
vj = polygon.vertices[j];
|
||||
ti = this.classifyVertex(vi);
|
||||
tj = this.classifyVertex(vj);
|
||||
if (ti != BACK)
|
||||
f.push(vi);
|
||||
if (ti != FRONT)
|
||||
b.push(vi);
|
||||
if ((ti | tj) === SPANNING) {
|
||||
t = (this.w - this.normal.dot(vi)) / this.normal.dot(vj.clone().subtract(vi));
|
||||
v = vi.interpolate(vj, t);
|
||||
f.push(v);
|
||||
b.push(v);
|
||||
}
|
||||
}
|
||||
if (f.length >= 3)
|
||||
front.push(new Polygon(f).calculateProperties());
|
||||
if (b.length >= 3)
|
||||
back.push(new Polygon(b).calculateProperties());
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Polygon = Polygon;
|
||||
class Vertex {
|
||||
constructor(x, y, z, normal, uv) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.normal = normal || new THREE.Vector3();
|
||||
this.uv = uv || new THREE.Vector2();
|
||||
}
|
||||
clone() {
|
||||
return new Vertex(this.x, this.y, this.z, this.normal.clone(), this.uv.clone());
|
||||
}
|
||||
add(vertex) {
|
||||
this.x += vertex.x;
|
||||
this.y += vertex.y;
|
||||
this.z += vertex.z;
|
||||
return this;
|
||||
}
|
||||
subtract(vertex) {
|
||||
this.x -= vertex.x;
|
||||
this.y -= vertex.y;
|
||||
this.z -= vertex.z;
|
||||
return this;
|
||||
}
|
||||
multiplyScalar(scalar) {
|
||||
this.x *= scalar;
|
||||
this.y *= scalar;
|
||||
this.z *= scalar;
|
||||
return this;
|
||||
}
|
||||
//×乘
|
||||
cross(vertex) {
|
||||
let x = this.x, y = this.y, z = this.z;
|
||||
this.x = y * vertex.z - z * vertex.y;
|
||||
this.y = z * vertex.x - x * vertex.z;
|
||||
this.z = x * vertex.y - y * vertex.x;
|
||||
return this;
|
||||
}
|
||||
normalize() {
|
||||
let length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
||||
this.x /= length;
|
||||
this.y /= length;
|
||||
this.z /= length;
|
||||
return this;
|
||||
}
|
||||
//点乘
|
||||
dot(vertex) {
|
||||
return this.x * vertex.x + this.y * vertex.y + this.z * vertex.z;
|
||||
}
|
||||
//线性插值
|
||||
lerp(a, t) {
|
||||
this.add(a.clone().subtract(this).multiplyScalar(t));
|
||||
this.normal.add(a.normal.clone().sub(this.normal).multiplyScalar(t));
|
||||
this.uv.add(a.uv.clone().sub(this.uv).multiplyScalar(t));
|
||||
return this;
|
||||
}
|
||||
//插值
|
||||
interpolate(other, t) {
|
||||
return this.clone().lerp(other, t);
|
||||
}
|
||||
applyMatrix4(m) {
|
||||
// input: THREE.Matrix4 affine matrix
|
||||
let x = this.x, y = this.y, z = this.z;
|
||||
let e = m.elements;
|
||||
this.x = e[0] * x + e[4] * y + e[8] * z + e[12];
|
||||
this.y = e[1] * x + e[5] * y + e[9] * z + e[13];
|
||||
this.z = e[2] * x + e[6] * y + e[10] * z + e[14];
|
||||
return this;
|
||||
}
|
||||
}
|
||||
exports.Vertex = Vertex;
|
||||
class Node {
|
||||
constructor(polygons) {
|
||||
let i, polygon_count, front = [], back = [];
|
||||
this.polygons = [];
|
||||
this.front = this.back = undefined;
|
||||
if (!(polygons instanceof Array) || polygons.length === 0)
|
||||
return;
|
||||
this.divider = polygons[0].clone();
|
||||
for (i = 0, polygon_count = polygons.length; i < polygon_count; i++) {
|
||||
this.divider.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
|
||||
}
|
||||
if (front.length > 0) {
|
||||
this.front = new Node(front);
|
||||
}
|
||||
if (back.length > 0) {
|
||||
this.back = new Node(back);
|
||||
}
|
||||
}
|
||||
//是凸的? 凸包?
|
||||
isConvex(polygons) {
|
||||
let i, j;
|
||||
for (i = 0; i < polygons.length; i++) {
|
||||
for (j = 0; j < polygons.length; j++) {
|
||||
if (i !== j && polygons[i].classifySide(polygons[j]) !== BACK) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
build(polygons) {
|
||||
let i, polygon_count, front = [], back = [];
|
||||
if (!this.divider) {
|
||||
this.divider = polygons[0].clone();
|
||||
}
|
||||
for (i = 0, polygon_count = polygons.length; i < polygon_count; i++) {
|
||||
this.divider.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
|
||||
}
|
||||
if (front.length > 0) {
|
||||
if (!this.front)
|
||||
this.front = new Node();
|
||||
this.front.build(front);
|
||||
}
|
||||
if (back.length > 0) {
|
||||
if (!this.back)
|
||||
this.back = new Node();
|
||||
this.back.build(back);
|
||||
}
|
||||
}
|
||||
allPolygons() {
|
||||
let polygons = this.polygons.slice();
|
||||
if (this.front)
|
||||
polygons = polygons.concat(this.front.allPolygons());
|
||||
if (this.back)
|
||||
polygons = polygons.concat(this.back.allPolygons());
|
||||
return polygons;
|
||||
}
|
||||
clone() {
|
||||
let node = new Node();
|
||||
node.divider = this.divider.clone();
|
||||
node.polygons = this.polygons.map(function (polygon) {
|
||||
return polygon.clone();
|
||||
});
|
||||
node.front = this.front && this.front.clone();
|
||||
node.back = this.back && this.back.clone();
|
||||
return node;
|
||||
}
|
||||
//反转
|
||||
invert() {
|
||||
let i, polygon_count, temp;
|
||||
for (i = 0, polygon_count = this.polygons.length; i < polygon_count; i++) {
|
||||
this.polygons[i].flip();
|
||||
}
|
||||
this.divider.flip();
|
||||
if (this.front)
|
||||
this.front.invert();
|
||||
if (this.back)
|
||||
this.back.invert();
|
||||
temp = this.front;
|
||||
this.front = this.back;
|
||||
this.back = temp;
|
||||
return this;
|
||||
}
|
||||
//
|
||||
clipPolygons(polygons) {
|
||||
let i, polygon_count, front, back;
|
||||
if (!this.divider)
|
||||
return polygons.slice();
|
||||
front = [];
|
||||
back = [];
|
||||
for (i = 0, polygon_count = polygons.length; i < polygon_count; i++) {
|
||||
this.divider.splitPolygon(polygons[i], front, back, front, back);
|
||||
}
|
||||
if (this.front)
|
||||
front = this.front.clipPolygons(front);
|
||||
if (this.back)
|
||||
back = this.back.clipPolygons(back);
|
||||
else
|
||||
back = [];
|
||||
return front.concat(back);
|
||||
}
|
||||
clipTo(node) {
|
||||
this.polygons = node.clipPolygons(this.polygons);
|
||||
if (this.front)
|
||||
this.front.clipTo(node);
|
||||
if (this.back)
|
||||
this.back.clipTo(node);
|
||||
}
|
||||
}
|
||||
exports.Node = Node;
|
||||
//# sourceMappingURL=ThreeCSG.js.map
|
1
dist/ThreeCSG.js.map
vendored
1
dist/ThreeCSG.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/Utils.d.ts
vendored
2
dist/Utils.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import { Viewer } from ".";
|
||||
export declare function LoadBoard(view: Viewer, data: any[]): void;
|
23
dist/Utils.js
vendored
23
dist/Utils.js
vendored
@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _1 = require(".");
|
||||
function LoadBoard(view, data) {
|
||||
view.m_Scene.children.forEach(obj => {
|
||||
let geo = obj["geometry"];
|
||||
if (geo)
|
||||
geo.dispose();
|
||||
});
|
||||
view.m_Scene.children.length = 0;
|
||||
//加板
|
||||
let { meshs, edgesa } = _1.createTemplateBoard(data);
|
||||
//加标注
|
||||
let dims = _1.DrawDimension(meshs);
|
||||
view.m_Scene.add(...meshs);
|
||||
view.m_Scene.add(...edgesa);
|
||||
view.m_Scene.add(...dims);
|
||||
view.ViewToSwiso();
|
||||
view.ZoomAll();
|
||||
view.Zoom(1.1);
|
||||
}
|
||||
exports.LoadBoard = LoadBoard;
|
||||
//# sourceMappingURL=Utils.js.map
|
1
dist/Utils.js.map
vendored
1
dist/Utils.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;AAAA,wBAA2E;AAG3E,mBAA0B,IAAY,EAAE,IAAW;IAE/C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAEhC,IAAI,GAAG,GAAG,GAAG,CAAC,UAAU,CAAa,CAAC;QACtC,IAAI,GAAG;YAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAEjC,IAAI;IACJ,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,sBAAmB,CAAC,IAAI,CAAC,CAAC;IAClD,KAAK;IACL,IAAI,IAAI,GAAG,gBAAa,CAAC,KAAK,CAAC,CAAC;IAEhC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAE1B,IAAI,CAAC,WAAW,EAAE,CAAC;IACnB,IAAI,CAAC,OAAO,EAAE,CAAC;IACf,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AArBD,8BAqBC"}
|
32
dist/Viewer.d.ts
vendored
32
dist/Viewer.d.ts
vendored
@ -1,32 +0,0 @@
|
||||
import * as THREE from "three";
|
||||
import { CameraUpdate } from "./CameraUpdate";
|
||||
export declare class Viewer {
|
||||
m_LookTarget: any;
|
||||
m_Camera: CameraUpdate;
|
||||
m_bNeedUpdate: boolean;
|
||||
m_Render: THREE.WebGLRenderer;
|
||||
m_DomEl: HTMLElement;
|
||||
_Height: number;
|
||||
_Width: number;
|
||||
m_Scene: THREE.Scene;
|
||||
constructor(canvasContainer: HTMLElement);
|
||||
initRender(canvasContainer: HTMLElement): void;
|
||||
OnSize: (width?: any, height?: any) => void;
|
||||
StartRender: () => void;
|
||||
Render(): void;
|
||||
ScreenToWorld(pt: THREE.Vector3, planVec?: THREE.Vector3): void;
|
||||
WorldToScreen(pt: THREE.Vector3): void;
|
||||
/**
|
||||
* 更新视角观测目标(物体中心)
|
||||
*
|
||||
* @memberof Viewer
|
||||
*/
|
||||
UpdateLockTarget(): void;
|
||||
Rotate(mouseMove: THREE.Vector3): void;
|
||||
Pan(mouseMove: THREE.Vector3): void;
|
||||
Zoom(scale: number, center?: THREE.Vector3): void;
|
||||
ZoomAll(): void;
|
||||
ViewToTop(): void;
|
||||
ViewToFront(): void;
|
||||
ViewToSwiso(): void;
|
||||
}
|
142
dist/Viewer.js
vendored
142
dist/Viewer.js
vendored
@ -1,142 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const CameraUpdate_1 = require("./CameraUpdate");
|
||||
const GeUtils_1 = require("./GeUtils");
|
||||
const PlaneExt_1 = require("./PlaneExt");
|
||||
const _1 = require(".");
|
||||
const three_1 = require("three");
|
||||
class Viewer {
|
||||
//构造
|
||||
constructor(canvasContainer) {
|
||||
this.m_Camera = new CameraUpdate_1.CameraUpdate();
|
||||
this.m_bNeedUpdate = true;
|
||||
this.m_Scene = new THREE.Scene();
|
||||
this.OnSize = (width, height) => {
|
||||
this._Width = width ? width : this.m_DomEl.scrollWidth;
|
||||
this._Height = height ? height : this.m_DomEl.scrollHeight;
|
||||
//校验.成为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);
|
||||
};
|
||||
this.StartRender = () => {
|
||||
requestAnimationFrame(this.StartRender);
|
||||
if (this.m_Scene != null && this.m_bNeedUpdate) {
|
||||
this.Render();
|
||||
this.m_bNeedUpdate = false;
|
||||
}
|
||||
};
|
||||
this.m_DomEl = canvasContainer;
|
||||
this.initRender(canvasContainer);
|
||||
this.OnSize();
|
||||
this.StartRender();
|
||||
new _1.CameraControls(this);
|
||||
window.addEventListener("resize", () => {
|
||||
this.OnSize();
|
||||
});
|
||||
//选中
|
||||
let selectMaterial = new three_1.MeshBasicMaterial({ color: new three_1.Color(0.1, 0.5, 0.5) });
|
||||
let oldMesh;
|
||||
this.m_Render.domElement.addEventListener("mousemove", (e) => {
|
||||
let mesh = _1.PointPick(this, e.offsetX, e.offsetY);
|
||||
if (oldMesh)
|
||||
oldMesh.material = _1.boardMaterial;
|
||||
if (mesh) {
|
||||
oldMesh = mesh;
|
||||
mesh.material = selectMaterial;
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
//初始化render
|
||||
initRender(canvasContainer) {
|
||||
this.m_Render = new THREE.WebGLRenderer({
|
||||
antialias: true,
|
||||
precision: "highp",
|
||||
alpha: true,
|
||||
});
|
||||
//加到画布
|
||||
canvasContainer.appendChild(this.m_Render.domElement);
|
||||
this.m_Render.autoClear = true;
|
||||
//如果设置,那么它希望所有的纹理和颜色都是预乘的伽玛。默认值为false。
|
||||
// this.m_Render.gammaInput = true;
|
||||
// this.m_Render.gammaOutput = true;
|
||||
// this.m_Render.shadowMap.enabled = true;
|
||||
// this.m_Render.toneMapping = THREE.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();
|
||||
}
|
||||
Render() {
|
||||
this.m_Render.render(this.m_Scene, this.m_Camera.Camera);
|
||||
}
|
||||
ScreenToWorld(pt, planVec) {
|
||||
//变换和求交点
|
||||
let plan = new PlaneExt_1.PlaneExt(planVec || new THREE.Vector3(0, 0, 1));
|
||||
let raycaster = new THREE.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) {
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 更新视角观测目标(物体中心)
|
||||
*
|
||||
* @memberof Viewer
|
||||
*/
|
||||
UpdateLockTarget() {
|
||||
let renderList = this.m_Render.renderLists.get(this.m_Scene, this.m_Camera.Camera);
|
||||
let box = GeUtils_1.GetBoxArr(renderList.opaque.map(o => o.object));
|
||||
if (box)
|
||||
this.m_LookTarget = box.getCenter(new THREE.Vector3());
|
||||
else
|
||||
this.m_LookTarget = GeUtils_1.cZeroVec;
|
||||
}
|
||||
Rotate(mouseMove) {
|
||||
this.m_Camera.Rotate(mouseMove, this.m_LookTarget);
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
Pan(mouseMove) {
|
||||
this.m_Camera.Pan(mouseMove);
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
Zoom(scale, center) {
|
||||
this.m_Camera.Zoom(scale, center);
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
ZoomAll() {
|
||||
this.m_Camera.ZoomExtensBox3(GeUtils_1.GetBox(this.m_Scene, true));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
ViewToTop() {
|
||||
this.m_Camera.LookAt(new THREE.Vector3(0, 0, -1));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
ViewToFront() {
|
||||
this.m_Camera.LookAt(new THREE.Vector3(0, 1, 0));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
ViewToSwiso() {
|
||||
this.m_Camera.LookAt(new THREE.Vector3(1, 1, -1));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
}
|
||||
exports.Viewer = Viewer;
|
||||
//# sourceMappingURL=Viewer.js.map
|
1
dist/Viewer.js.map
vendored
1
dist/Viewer.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Viewer.js","sourceRoot":"","sources":["../src/Viewer.ts"],"names":[],"mappings":";;AACA,+BAA+B;AAC/B,iDAA8C;AAC9C,uCAAwD;AACxD,yCAAsC;AACtC,wBAA6D;AAC7D,iCAAuD;AAEvD;IAaI,IAAI;IACJ,YAAY,eAA4B;QAXxC,aAAQ,GAAiB,IAAI,2BAAY,EAAE,CAAC;QAC5C,kBAAa,GAAY,IAAI,CAAC;QAO9B,YAAO,GAAgB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAqEzC,WAAM,GAAG,CAAC,KAAM,EAAE,MAAO,EAAE,EAAE;YAEzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;YACvD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;YAE3D,oBAAoB;YACpB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC;gBACpB,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;YACrB,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC;gBACrB,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;YAEtB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACjD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC,CAAA;QAED,gBAAW,GAAG,GAAG,EAAE;YAEf,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,EAC9C;gBACI,IAAI,CAAC,MAAM,EAAE,CAAC;gBACd,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;aAC9B;QACL,CAAC,CAAA;QAvFG,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,iBAAc,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE;YAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,IAAI;QACJ,IAAI,cAAc,GAAG,IAAI,yBAAiB,CAAC,EAAE,KAAK,EAAE,IAAI,aAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAEhF,IAAI,OAAa,CAAC;QAClB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAa,EAAE,EAAE;YAErE,IAAI,IAAI,GAAG,YAAS,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YACjD,IAAI,OAAO;gBACP,OAAO,CAAC,QAAQ,GAAG,gBAAa,CAAC;YACrC,IAAI,IAAI,EACR;gBACI,OAAO,GAAG,IAAI,CAAC;gBACf,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC;gBAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;aAC7B;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAED,WAAW;IACX,UAAU,CAAC,eAA4B;QAEnC,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,aAAa,CACnC;YACI,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,OAAO;YAClB,KAAK,EAAE,IAAI;SAKd,CACJ,CAAC;QACF,MAAM;QACN,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEtD,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;QAE/B,sCAAsC;QACtC,mCAAmC;QACnC,oCAAoC;QACpC,0CAA0C;QAC1C,yDAAyD;QACzD,kCAAkC;QAClC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,CAAC,uBAAuB,GAAG,IAAI,CAAC;QAC7C,2FAA2F;QAE3F,YAAY;QACZ,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAGzC,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;IA0BD,MAAM;QAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,aAAa,CAAC,EAAiB,EAAE,OAAuB;QAEpD,QAAQ;QACR,IAAI,IAAI,GAAG,IAAI,mBAAQ,CAAC,OAAO,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,SAAS,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACtC,gBAAgB;QAChB,SAAS,CAAC,aAAa,CACnB;YACI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;YAC/B,CAAC,EAAE,CAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;SACrC,EACC,IAAI,CAAC,QAAQ,CAAC,MAAM,CACzB,CAAA;QACD,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,aAAa,CAAC,EAAiB;QAE3B,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClC,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QAEpC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEjC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;QACtC,EAAE,CAAC,CAAC,GAAG,CAAE,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QAEZ,IAAI,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,GAAG,GAAG,mBAAS,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,IAAI,GAAG;YACH,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;;YAEvD,IAAI,CAAC,YAAY,GAAG,kBAAQ,CAAC;IACrC,CAAC;IACD,MAAM,CAAC,SAAwB;QAE3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACD,GAAG,CAAC,SAAwB;QAExB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,KAAa,EAAE,MAAsB;QAEtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACD,OAAO;QAEH,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IAED,SAAS;QAEL,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACD,WAAW;QAEP,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IACD,WAAW;QAEP,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;CACJ;AAzLD,wBAyLC"}
|
22
dist/createBoard.d.ts
vendored
22
dist/createBoard.d.ts
vendored
@ -1,22 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
import { Geometry, LineSegments } from 'three';
|
||||
export declare class Arc2d {
|
||||
m_StartAn: number;
|
||||
m_EndAn: number;
|
||||
m_StartPoint: THREE.Vector2;
|
||||
m_EndPoint: THREE.Vector2;
|
||||
m_Center: THREE.Vector2;
|
||||
m_Radius: number;
|
||||
constructor(p1: THREE.Vector2, p2: THREE.Vector2, bul: number);
|
||||
}
|
||||
export declare function createPath(pts: THREE.Vector2[], buls: number[], shapeOut?: THREE.Shape): THREE.Shape;
|
||||
export declare function getVec(data: object): THREE.Vector3;
|
||||
export declare function createBoard(boardData: object): {
|
||||
mesh: THREE.Mesh;
|
||||
edges: THREE.LineSegments[];
|
||||
};
|
||||
export declare function createTemplateBoard(brDataList: any[]): {
|
||||
meshs: any[];
|
||||
edgesa: any[];
|
||||
};
|
||||
export declare function createEdge(geo: Geometry): LineSegments;
|
144
dist/createBoard.js
vendored
144
dist/createBoard.js
vendored
@ -1,144 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const THREE = require("three");
|
||||
const three_1 = require("three");
|
||||
const GeUtils_1 = require("./GeUtils");
|
||||
const Material_1 = require("./Material");
|
||||
const RotateUV_1 = require("./RotateUV");
|
||||
const ThreeCSG_1 = require("./ThreeCSG");
|
||||
//解析二维圆弧类.
|
||||
class Arc2d {
|
||||
constructor(p1, p2, bul) {
|
||||
this.m_StartPoint = p1.clone();
|
||||
this.m_EndPoint = p2.clone();
|
||||
let vec = p2.clone().sub(p1);
|
||||
let len = vec.length();
|
||||
let an = vec.angle();
|
||||
this.m_Radius = len / Math.sin(2 * Math.atan(bul)) / 2;
|
||||
let allAngle = Math.atan(bul) * 4;
|
||||
let delDis = bul * len / 2;
|
||||
let toDis = this.m_Radius - delDis;
|
||||
an += Math.PI * 0.5;
|
||||
this.m_Center = p1.clone().add(p2);
|
||||
this.m_Center.multiplyScalar(0.5);
|
||||
GeUtils_1.polar(this.m_Center, an, toDis);
|
||||
this.m_StartAn = p1.clone().sub(this.m_Center).angle();
|
||||
this.m_EndAn = p2.clone().sub(this.m_Center).angle();
|
||||
if (bul < 0) {
|
||||
//一个神奇的特性 它需要这么做
|
||||
this.m_StartAn -= Math.PI;
|
||||
this.m_EndAn -= Math.PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Arc2d = Arc2d;
|
||||
//创建轮廓 通过点表和凸度
|
||||
function createPath(pts, buls, shapeOut) {
|
||||
let shape = shapeOut || new THREE.Shape();
|
||||
if (pts.length === 0)
|
||||
return shape;
|
||||
let firstPt = pts[0];
|
||||
shape.moveTo(firstPt.x, firstPt.y);
|
||||
for (let i = 0; i < pts.length - 1; i++) {
|
||||
let nextPt = pts[i + 1];
|
||||
if (buls[i] == 0) {
|
||||
shape.lineTo(nextPt.x, nextPt.y);
|
||||
}
|
||||
else {
|
||||
let pt = pts[i];
|
||||
//参考
|
||||
//http://www.dorodnic.com/blog/tag/three-js/ 绘制一个齿轮
|
||||
//https://www.kirupa.com/html5/drawing_circles_canvas.htm //html5
|
||||
let arc2 = new Arc2d(pt, nextPt, buls[i]);
|
||||
let cen = arc2.m_Center;
|
||||
shape.absarc(cen.x, cen.y, arc2.m_Radius, arc2.m_StartAn, arc2.m_EndAn, buls[i] < 0);
|
||||
}
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
exports.createPath = createPath;
|
||||
function getVec(data) {
|
||||
return new THREE.Vector3(data["x"], data["y"], data["z"]);
|
||||
}
|
||||
exports.getVec = getVec;
|
||||
//创建板件 暂时这么写
|
||||
function createBoard(boardData) {
|
||||
let pts = new Array();
|
||||
let buls = new Array();
|
||||
let boardPts = boardData["Pts"];
|
||||
let boardBuls = boardData["Buls"];
|
||||
let boardHeight = boardData["H"];
|
||||
let boardMat = new THREE.Matrix4();
|
||||
let matInv = new THREE.Matrix4();
|
||||
//InitBoardMat
|
||||
{
|
||||
let xD = getVec(boardData["XVec"]);
|
||||
let yD = getVec(boardData["YVec"]);
|
||||
let ZD = getVec(boardData["ZVec"]);
|
||||
let pBase = getVec(boardData["BasePoint"]);
|
||||
boardMat.makeBasis(xD, yD, ZD);
|
||||
boardMat.setPosition(pBase);
|
||||
matInv.getInverse(boardMat, true);
|
||||
}
|
||||
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 THREE.Vector2(pt.x, pt.y));
|
||||
buls.push(boardBuls[i]);
|
||||
}
|
||||
else {
|
||||
let length = boardData["L"];
|
||||
let width = boardData["W"];
|
||||
let height = boardData["H"];
|
||||
pts.push(new three_1.Vector2(0, 0), new three_1.Vector2(width, 0), new three_1.Vector2(width, length), new three_1.Vector2(0, length), new three_1.Vector2(0, 0));
|
||||
buls.push(0, 0, 0, 0, 0);
|
||||
}
|
||||
let sp = createPath(pts, buls);
|
||||
let extrudeSettings = {
|
||||
steps: 1,
|
||||
bevelEnabled: false,
|
||||
amount: boardHeight
|
||||
};
|
||||
let ext = new THREE.ExtrudeGeometry(sp, extrudeSettings);
|
||||
ext.computeBoundingSphere();
|
||||
ext.computeBoundingBox();
|
||||
ext.translate(0, 0, -boardHeight);
|
||||
ext.applyMatrix(boardMat);
|
||||
//外边.
|
||||
let edges = [createEdge(ext)];
|
||||
//差集
|
||||
if (boardData["SubBoardLocal"].length > 0) {
|
||||
let subBoardList = boardData["SubBoardLocal"].map(d => createBoard(d));
|
||||
let thisCsg = new ThreeCSG_1.ThreeBSP(ext);
|
||||
for (let br of subBoardList) {
|
||||
edges.push(...br.edges);
|
||||
let subCsg = new ThreeCSG_1.ThreeBSP(br.mesh);
|
||||
thisCsg = thisCsg.subtract(subCsg);
|
||||
}
|
||||
ext = thisCsg.toGeometry();
|
||||
}
|
||||
if (boardData["BoardName"] === "地脚线")
|
||||
RotateUV_1.RotateUVs(ext);
|
||||
let mesh = new THREE.Mesh(ext, Material_1.boardMaterial);
|
||||
return { mesh, edges };
|
||||
}
|
||||
exports.createBoard = createBoard;
|
||||
function createTemplateBoard(brDataList) {
|
||||
let meshs = [];
|
||||
let edgesa = [];
|
||||
for (let d of brDataList) {
|
||||
let { mesh, edges } = createBoard(d);
|
||||
meshs.push(mesh);
|
||||
edgesa.push(...edges);
|
||||
}
|
||||
return { meshs, edgesa };
|
||||
}
|
||||
exports.createTemplateBoard = createTemplateBoard;
|
||||
function createEdge(geo) {
|
||||
let edge = new THREE.EdgesGeometry(geo, 1);
|
||||
return new three_1.LineSegments(edge, Material_1.edgeMaterial);
|
||||
}
|
||||
exports.createEdge = createEdge;
|
||||
//# sourceMappingURL=createBoard.js.map
|
1
dist/createBoard.js.map
vendored
1
dist/createBoard.js.map
vendored
File diff suppressed because one or more lines are too long
75
dist/data.d.ts
vendored
75
dist/data.d.ts
vendored
@ -1,75 +0,0 @@
|
||||
export declare var data: ({
|
||||
"L": number;
|
||||
"W": number;
|
||||
"H": number;
|
||||
"BasePoint": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"XVec": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"YVec": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"ZVec": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"Pts": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
}[];
|
||||
"Buls": number[];
|
||||
"SubBoardLocal": any[];
|
||||
"SubBoardAssoc": any[];
|
||||
MaterialId?: undefined;
|
||||
Handle?: undefined;
|
||||
CabName?: undefined;
|
||||
BoardName?: undefined;
|
||||
Grain?: undefined;
|
||||
} | {
|
||||
"L": number;
|
||||
"W": number;
|
||||
"H": number;
|
||||
"MaterialId": string;
|
||||
"BasePoint": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"XVec": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"YVec": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"ZVec": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
};
|
||||
"Handle": string;
|
||||
"CabName": string;
|
||||
"BoardName": string;
|
||||
"Grain": number;
|
||||
"Pts": {
|
||||
"x": number;
|
||||
"y": number;
|
||||
"z": number;
|
||||
}[];
|
||||
"Buls": number[];
|
||||
"SubBoardLocal": any[];
|
||||
"SubBoardAssoc": any[];
|
||||
})[];
|
552
dist/data.js
vendored
552
dist/data.js
vendored
@ -1,552 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.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": []
|
||||
}
|
||||
];
|
||||
//# sourceMappingURL=data.js.map
|
1
dist/data.js.map
vendored
1
dist/data.js.map
vendored
File diff suppressed because one or more lines are too long
9
dist/index.d.ts
vendored
9
dist/index.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
export * from "./Viewer";
|
||||
export * from "./CameraControls";
|
||||
export * from "./GeUtils";
|
||||
export * from "./createBoard";
|
||||
export * from "./Dimension";
|
||||
export * from "./DrawDimension";
|
||||
export * from "./Material";
|
||||
export * from "./PointPick";
|
||||
export * from "./Utils";
|
15
dist/index.js
vendored
15
dist/index.js
vendored
@ -1,15 +0,0 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./Viewer"));
|
||||
__export(require("./CameraControls"));
|
||||
__export(require("./GeUtils"));
|
||||
__export(require("./createBoard"));
|
||||
__export(require("./Dimension"));
|
||||
__export(require("./DrawDimension"));
|
||||
__export(require("./Material"));
|
||||
__export(require("./PointPick"));
|
||||
__export(require("./Utils"));
|
||||
//# sourceMappingURL=index.js.map
|
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,8BAAyB;AACzB,sCAAiC;AACjC,+BAA0B;AAC1B,mCAA8B;AAC9B,iCAA4B;AAC5B,qCAAgC;AAChC,gCAA2B;AAC3B,iCAA2B;AAC3B,6BAAuB"}
|
16
index.html
Normal file
16
index.html
Normal 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>
|
7046
package-lock.json
generated
7046
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
50
package.json
50
package.json
@ -1,20 +1,34 @@
|
||||
{
|
||||
"name": "cadview",
|
||||
"version": "1.0.4",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"author": "cx",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/node": "^10.1.2",
|
||||
"@types/three": "^0.92.0",
|
||||
"typescript": "^2.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"three": "^0.92.0"
|
||||
}
|
||||
"name": "cadview",
|
||||
"version": "1.1.9",
|
||||
"description": "",
|
||||
"main": "src/index.ts",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://git.cf/cx/CADViewComponent.git"
|
||||
},
|
||||
"author": "cx",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.13.52",
|
||||
"@types/three": "^0.103.2",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jscad/modeling": "^2.11.0",
|
||||
"flatbush": "^3.3.0",
|
||||
"three": "npm:three-cf@0.122.5",
|
||||
"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"
|
||||
}
|
||||
|
@ -1,32 +1,24 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
import { KeyBoard, MouseKey } from './KeyEnum';
|
||||
import { Vector3 } from 'three';
|
||||
import { equaln } from './GeUtils';
|
||||
import { KeyBoard, MouseKey } from './KeyEnum';
|
||||
import { Viewer } from './Viewer';
|
||||
|
||||
//控制类型
|
||||
enum CameraControlsEnabled
|
||||
{
|
||||
Rotate = 1,
|
||||
Zoom = 2,
|
||||
Pan = 4,
|
||||
}
|
||||
|
||||
//相机控制状态
|
||||
export enum CameraControlState
|
||||
{
|
||||
Null = 0, Pan = 1, Rotate = 2, Scale = 3
|
||||
Null = 0, Pan = 1, Rotate = 2, Scale = 4
|
||||
}
|
||||
|
||||
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_StartClickPoint: THREE.Vector3 = new THREE.Vector3();
|
||||
m_EndClickPoint: THREE.Vector3 = new THREE.Vector3();
|
||||
m_DollyStart: THREE.Vector2 = new THREE.Vector2();
|
||||
m_DollyEnd: THREE.Vector2 = new THREE.Vector2();
|
||||
m_DollyStart: number;
|
||||
|
||||
m_KeyDown = new Map<KeyBoard, boolean>();
|
||||
m_MouseDown = new Map<MouseKey, boolean>();
|
||||
@ -48,30 +40,29 @@ export class CameraControls
|
||||
{
|
||||
if (this.m_domElement)
|
||||
{
|
||||
this.m_domElement.addEventListener("mousedown", this.onMouseDown, false)
|
||||
this.m_domElement.addEventListener("mousemove", this.onMouseMove, false)
|
||||
this.m_domElement.addEventListener("mouseup", this.onMouseUp, false)
|
||||
this.m_domElement.addEventListener("mousedown", this.onMouseDown, false);
|
||||
this.m_domElement.addEventListener("mousemove", this.onMouseMove, false);
|
||||
this.m_domElement.addEventListener("mouseup", this.onMouseUp, false);
|
||||
window.addEventListener("keydown", this.onKeyDown, 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('touchmove', this.onTouchMove, false);
|
||||
this.m_domElement.addEventListener('touchmove', this.onTouchMove, { passive: false });
|
||||
|
||||
window.addEventListener("blur", this.onBlur, false);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 窗体失去焦点时.
|
||||
*
|
||||
* @memberof CameraControls
|
||||
*/
|
||||
onBlur = () =>
|
||||
{
|
||||
this.m_KeyDown.clear();
|
||||
this.m_MouseDown.clear();
|
||||
}
|
||||
};
|
||||
|
||||
//触屏开始事件
|
||||
onTouchStart = (event: TouchEvent) =>
|
||||
@ -85,15 +76,15 @@ export class CameraControls
|
||||
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);
|
||||
this.m_DollyStart.set(0, distance);
|
||||
this.m_DollyStart = distance;
|
||||
}
|
||||
this.m_State = this.m_TouthTypeList[event.touches.length - 1];
|
||||
}
|
||||
}
|
||||
};
|
||||
onTouchEnd = (event: TouchEvent) =>
|
||||
{
|
||||
this.m_State = CameraControlState.Null;
|
||||
}
|
||||
};
|
||||
onTouchMove = (event: TouchEvent) =>
|
||||
{
|
||||
event.preventDefault();
|
||||
@ -102,46 +93,47 @@ export class CameraControls
|
||||
this.m_EndClickPoint.set(event.touches[0].pageX, event.touches[0].pageY, 0);
|
||||
|
||||
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);
|
||||
this.m_DollyEnd.set(0, distance);
|
||||
if (distance > this.m_DollyStart.y)
|
||||
{
|
||||
this.m_Viewer.Zoom(0.95);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Viewer.Zoom(1.05)
|
||||
}
|
||||
this.m_DollyStart.copy(this.m_DollyEnd);
|
||||
break;
|
||||
}
|
||||
case CameraControlState.Rotate:
|
||||
if (this.m_State & CameraControlState.Pan)
|
||||
{
|
||||
this.m_Viewer.Pan(vec);
|
||||
}
|
||||
if (this.m_State & 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 (!equaln(this.m_DollyStart / distance, 1, 0.05))//轻微防抖
|
||||
{
|
||||
|
||||
if (distance > this.m_DollyStart)
|
||||
{
|
||||
this.m_Viewer.Rotate(vec.multiplyScalar(2));
|
||||
break;
|
||||
this.m_Viewer.Zoom(0.95);
|
||||
}
|
||||
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_Viewer.m_bNeedUpdate = true;
|
||||
}
|
||||
};
|
||||
beginRotate()
|
||||
{
|
||||
this.m_State = CameraControlState.Rotate;
|
||||
this.m_Viewer.UpdateLockTarget();
|
||||
}
|
||||
//鼠标
|
||||
|
||||
//最后一次按中键的时间
|
||||
lastMiddleClickTime = 0;
|
||||
//鼠标
|
||||
onMouseDown = (event: MouseEvent) =>
|
||||
{
|
||||
event.preventDefault();
|
||||
@ -161,6 +153,14 @@ export class CameraControls
|
||||
}
|
||||
case MouseKey.Middle:
|
||||
{
|
||||
let curTime = Date.now();
|
||||
let t = curTime - this.lastMiddleClickTime;
|
||||
this.lastMiddleClickTime = curTime;
|
||||
if (t < 350)
|
||||
{
|
||||
this.m_Viewer.ZoomAll();
|
||||
return;
|
||||
}
|
||||
if (this.m_KeyDown.get(KeyBoard.Control))
|
||||
{
|
||||
this.beginRotate();
|
||||
@ -176,13 +176,13 @@ export class CameraControls
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
onMouseUp = (event: MouseEvent) =>
|
||||
{
|
||||
event.preventDefault();
|
||||
this.m_State = CameraControlState.Null;
|
||||
this.m_MouseDown.set(event.button, false);
|
||||
}
|
||||
};
|
||||
onMouseMove = (event: MouseEvent) =>
|
||||
{
|
||||
event.preventDefault();
|
||||
@ -193,36 +193,23 @@ export class CameraControls
|
||||
(this.m_LeftUseRotate ||
|
||||
(this.m_KeyDown.get(KeyBoard.Control))
|
||||
)
|
||||
&& this.m_State == CameraControlState.Rotate
|
||||
&& this.m_State & CameraControlState.Rotate
|
||||
)
|
||||
{
|
||||
this.m_Viewer.Rotate(changeVec);
|
||||
}
|
||||
switch (this.m_State)
|
||||
if (this.m_State & CameraControlState.Pan)
|
||||
{
|
||||
case CameraControlState.Pan:
|
||||
{
|
||||
this.m_Viewer.Pan(changeVec);
|
||||
break;
|
||||
}
|
||||
case CameraControlState.Rotate:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CameraControlState.Scale:
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.m_Viewer.Pan(changeVec);
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 鼠标滚轮事件
|
||||
*
|
||||
*
|
||||
* @memberof CameraControls
|
||||
*/
|
||||
onMouseWheel = (event: WheelEvent) =>
|
||||
{
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);
|
||||
@ -236,14 +223,14 @@ export class CameraControls
|
||||
{
|
||||
this.m_Viewer.Zoom(1.4, pt);
|
||||
}
|
||||
}
|
||||
};
|
||||
//按键
|
||||
onKeyDown = (event: KeyboardEvent) =>
|
||||
{
|
||||
this.m_KeyDown.set(event.keyCode, true);
|
||||
}
|
||||
};
|
||||
onKeyUp = (event: KeyboardEvent) =>
|
||||
{
|
||||
this.m_KeyDown.set(event.keyCode, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
import * as THREE from 'three';
|
||||
import { Vector3 } from 'three';
|
||||
import { Box3, Camera, MathUtils, OrthographicCamera, PerspectiveCamera, Vector3 } from 'three';
|
||||
import { Orbit } from './Orbit';
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 相机的控制.
|
||||
* ->切换相机
|
||||
* ->设置视口大小
|
||||
* ->旋转和移动相机.
|
||||
*
|
||||
*
|
||||
* @export
|
||||
* @class ViewCameraManage
|
||||
*/
|
||||
export class CameraUpdate
|
||||
{
|
||||
private m_CurCamera: THREE.Camera;
|
||||
private m_CameraArray: Map<any, THREE.Camera> = new Map<any, THREE.Camera>();
|
||||
private m_CurCamera: Camera;
|
||||
private m_CameraArray: Map<any, Camera> = new Map<any, Camera>();
|
||||
|
||||
//视口的画布大小
|
||||
private m_Width: number;
|
||||
@ -24,20 +23,23 @@ export class CameraUpdate
|
||||
private m_ViewHeight: number = 10;
|
||||
|
||||
//观察的位置
|
||||
private m_Target: THREE.Vector3 = new THREE.Vector3();
|
||||
private m_Target: Vector3 = new Vector3();
|
||||
//观察向量
|
||||
private m_Direction: THREE.Vector3 = new THREE.Vector3(0, 0, -1);
|
||||
private m_Direction: Vector3 = new Vector3(0, 0, -1);
|
||||
//观察的轨道.
|
||||
private m_Orbit: Orbit = new Orbit();
|
||||
|
||||
m_MinViewHeight = 10;
|
||||
m_MaxViewHeight = 3e4;
|
||||
|
||||
constructor()
|
||||
{
|
||||
this.m_CameraArray.set(THREE.OrthographicCamera, new THREE.OrthographicCamera(-2, 2, 2, -2,
|
||||
-100000, 100000));
|
||||
this.m_CameraArray.set(OrthographicCamera, new OrthographicCamera(-2, 2, 2, -2,
|
||||
-1e6, 1e6));
|
||||
|
||||
this.m_CameraArray.set(THREE.PerspectiveCamera, new THREE.PerspectiveCamera(50, 1, 0.01, 10000));
|
||||
this.m_CameraArray.set(PerspectiveCamera, new PerspectiveCamera(50, 1, 0.01, 10000));
|
||||
|
||||
this.m_CurCamera = this.m_CameraArray.get(THREE.OrthographicCamera);
|
||||
this.m_CurCamera = this.m_CameraArray.get(OrthographicCamera);
|
||||
|
||||
this.m_Orbit.UpdateRoValue(this.m_Direction);
|
||||
|
||||
@ -50,7 +52,7 @@ export class CameraUpdate
|
||||
return this.m_Width / this.m_Height;
|
||||
}
|
||||
|
||||
get Camera(): THREE.Camera
|
||||
get Camera(): Camera
|
||||
{
|
||||
return this.m_CurCamera;
|
||||
}
|
||||
@ -60,7 +62,7 @@ export class CameraUpdate
|
||||
}
|
||||
set ViewHeight(height)
|
||||
{
|
||||
this.m_ViewHeight = THREE.Math.clamp(height, 1e-8, 1e8);
|
||||
this.m_ViewHeight = MathUtils.clamp(height, this.m_MinViewHeight, this.m_MaxViewHeight);
|
||||
}
|
||||
|
||||
SetSize(width: number, height: number)
|
||||
@ -71,11 +73,11 @@ export class CameraUpdate
|
||||
|
||||
/**
|
||||
* 平移相机.
|
||||
*
|
||||
* @param {THREE.Vector3} mouseMove
|
||||
*
|
||||
* @param {Vector3} mouseMove
|
||||
* @memberof CameraControl
|
||||
*/
|
||||
Pan(mouseMove: THREE.Vector3)
|
||||
Pan(mouseMove: Vector3)
|
||||
{
|
||||
mouseMove.y *= -1;
|
||||
mouseMove.multiplyScalar(-this.m_ViewHeight / this.m_Height);
|
||||
@ -83,7 +85,7 @@ export class CameraUpdate
|
||||
this.m_Target.add(mouseMove);
|
||||
this.Update();
|
||||
}
|
||||
Rotate(mouseMove: THREE.Vector3, target: THREE.Vector3)
|
||||
Rotate(mouseMove: Vector3, target: Vector3)
|
||||
{
|
||||
this.m_Orbit.RoX -= mouseMove.y * 0.003;
|
||||
this.m_Orbit.RoZ -= mouseMove.x * 0.003;
|
||||
@ -109,19 +111,19 @@ export class CameraUpdate
|
||||
|
||||
this.Update();
|
||||
}
|
||||
Zoom(scale: number, scaleCenter?: THREE.Vector3)
|
||||
Zoom(scale: number, scaleCenter?: Vector3)
|
||||
{
|
||||
if (this.Camera instanceof THREE.OrthographicCamera)
|
||||
if (this.Camera instanceof OrthographicCamera)
|
||||
{
|
||||
this.ViewHeight *= scale;
|
||||
if (scaleCenter)
|
||||
if (scaleCenter && this.m_ViewHeight < this.m_MaxViewHeight)
|
||||
{
|
||||
this.m_Target.sub(scaleCenter);
|
||||
this.m_Target.multiplyScalar(scale);
|
||||
this.m_Target.add(scaleCenter);
|
||||
}
|
||||
}
|
||||
else if (this.Camera instanceof THREE.PerspectiveCamera)
|
||||
else if (this.Camera instanceof PerspectiveCamera)
|
||||
{
|
||||
let add = scale > 1 ? 1 : -1;
|
||||
add *= this.Camera.position.distanceTo(this.m_Target) / 10;
|
||||
@ -129,9 +131,9 @@ export class CameraUpdate
|
||||
}
|
||||
this.Update();
|
||||
}
|
||||
ZoomExtensBox3(box3: THREE.Box3)
|
||||
ZoomExtensBox3(box3: Box3)
|
||||
{
|
||||
if (!box3) return;
|
||||
if (!box3 || box3.isEmpty()) return;
|
||||
this.Camera.updateMatrixWorld(false);
|
||||
//变换到相机坐标系
|
||||
box3.applyMatrix4(this.Camera.matrixWorldInverse);
|
||||
@ -156,7 +158,7 @@ export class CameraUpdate
|
||||
}
|
||||
this.Update();
|
||||
}
|
||||
LookAt(dir: THREE.Vector3)
|
||||
LookAt(dir: Vector3)
|
||||
{
|
||||
this.m_Orbit.UpdateRoValue(dir);
|
||||
this.m_Direction.copy(dir);
|
||||
@ -170,15 +172,15 @@ export class CameraUpdate
|
||||
}
|
||||
/**
|
||||
* 根据视口大小,设置相机视口范围.
|
||||
*
|
||||
* @returns
|
||||
*
|
||||
* @returns
|
||||
* @memberof CameraControl
|
||||
*/
|
||||
Update()
|
||||
{
|
||||
this.Camera.position.copy(this.m_Target);
|
||||
|
||||
if (this.Camera instanceof THREE.OrthographicCamera)
|
||||
if (this.Camera instanceof OrthographicCamera)
|
||||
{
|
||||
this.Camera.left = this.Aspect * this.m_ViewHeight / -2;
|
||||
this.Camera.right = this.Aspect * this.m_ViewHeight / 2;
|
||||
@ -187,10 +189,10 @@ export class CameraUpdate
|
||||
|
||||
this.Camera.position.sub(this.m_Direction);
|
||||
}
|
||||
else if (this.Camera instanceof THREE.PerspectiveCamera)
|
||||
else if (this.Camera instanceof PerspectiveCamera)
|
||||
{
|
||||
this.Camera.aspect = this.Aspect;
|
||||
let distens = (this.m_ViewHeight / 2) / (Math.tan(THREE.Math.degToRad(this.Camera.fov) / 2));
|
||||
let distens = (this.m_ViewHeight / 2) / (Math.tan(MathUtils.degToRad(this.Camera.fov) / 2));
|
||||
|
||||
this.Camera.position.sub(this.m_Direction.clone().multiplyScalar(distens));
|
||||
}
|
||||
@ -206,13 +208,13 @@ export class CameraUpdate
|
||||
|
||||
SwitchCamera()
|
||||
{
|
||||
if (this.Camera instanceof THREE.OrthographicCamera)
|
||||
if (this.Camera instanceof OrthographicCamera)
|
||||
{
|
||||
this.m_CurCamera = this.m_CameraArray.get(THREE.PerspectiveCamera);
|
||||
this.m_CurCamera = this.m_CameraArray.get(PerspectiveCamera);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_CurCamera = this.m_CameraArray.get(THREE.OrthographicCamera);
|
||||
this.m_CurCamera = this.m_CameraArray.get(OrthographicCamera);
|
||||
}
|
||||
this.UpdateUp();
|
||||
this.Update();
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as THREE from 'three';
|
||||
import { Color, LineBasicMaterial, MeshBasicMaterial } from 'three';
|
||||
const ColorPalette = [
|
||||
[255, 0, 0, 255], //----- 0 - lets make it red for an example
|
||||
//[255, 255, 255, 255],//----- 0 - ByBlock - White
|
||||
@ -12,256 +13,256 @@ const ColorPalette = [
|
||||
// [255, 0, 0, 255], //----- 7 - More red Red
|
||||
// [255, 0, 0, 255], //----- 8 - More red Red
|
||||
// [255, 0, 0, 255], //----- 9 - More red Red
|
||||
[255, 255, 255, 255],//----- 7 - White
|
||||
[255, 255, 255, 255],//----- 8
|
||||
[255, 255, 255, 255],//----- 9
|
||||
[255, 0, 0, 255], //----- 10
|
||||
[255, 127, 127, 255],//----- 11
|
||||
[165, 0, 0, 255], //----- 12
|
||||
[165, 82, 82, 255], //----- 13
|
||||
[127, 0, 0, 255], //----- 14
|
||||
[127, 63, 63, 255], //----- 15
|
||||
[76, 0, 0, 255], //----- 16
|
||||
[76, 38, 38, 255], //----- 17
|
||||
[38, 0, 0, 255], //----- 18
|
||||
[38, 19, 19, 255], //----- 19
|
||||
[255, 63, 0, 255], //----- 20
|
||||
[255, 159, 127, 255],//----- 21
|
||||
[165, 41, 0, 255], //----- 22
|
||||
[165, 103, 82, 255], //----- 23
|
||||
[127, 31, 0, 255], //----- 24
|
||||
[127, 79, 63, 255], //----- 25
|
||||
[76, 19, 0, 255], //----- 26
|
||||
[76, 47, 38, 255], //----- 27
|
||||
[38, 9, 0, 255], //----- 28
|
||||
[38, 23, 19, 255], //----- 29
|
||||
[255, 127, 0, 255], //----- 30
|
||||
[255, 191, 127, 255],//----- 31
|
||||
[165, 82, 0, 255], //----- 32
|
||||
[165, 124, 82, 255], //----- 33
|
||||
[127, 63, 0, 255], //----- 34
|
||||
[127, 95, 63, 255], //----- 35
|
||||
[76, 38, 0, 255], //----- 36
|
||||
[76, 57, 38, 255], //----- 37
|
||||
[38, 19, 0, 255], //----- 38
|
||||
[38, 28, 19, 255], //----- 39
|
||||
[255, 191, 0, 255], //----- 40
|
||||
[255, 223, 127, 255],//----- 41
|
||||
[165, 124, 0, 255], //----- 42
|
||||
[165, 145, 82, 255], //----- 43
|
||||
[127, 95, 0, 255], //----- 44
|
||||
[127, 111, 63, 255], //----- 45
|
||||
[76, 57, 0, 255], //----- 46
|
||||
[76, 66, 38, 255], //----- 47
|
||||
[38, 28, 0, 255], //----- 48
|
||||
[38, 33, 19, 255], //----- 49
|
||||
[255, 255, 0, 255], //----- 50
|
||||
[255, 255, 127, 255],//----- 51
|
||||
[165, 165, 0, 255], //----- 52
|
||||
[165, 165, 82, 255], //----- 53
|
||||
[127, 127, 0, 255], //----- 54
|
||||
[127, 127, 63, 255], //----- 55
|
||||
[76, 76, 0, 255], //----- 56
|
||||
[76, 76, 38, 255], //----- 57
|
||||
[38, 38, 0, 255], //----- 58
|
||||
[38, 38, 19, 255], //----- 59
|
||||
[191, 255, 0, 255], //----- 60
|
||||
[223, 255, 127, 255],//----- 61
|
||||
[124, 165, 0, 255], //----- 62
|
||||
[145, 165, 82, 255], //----- 63
|
||||
[95, 127, 0, 255], //----- 64
|
||||
[111, 127, 63, 255], //----- 65
|
||||
[57, 76, 0, 255], //----- 66
|
||||
[66, 76, 38, 255], //----- 67
|
||||
[28, 38, 0, 255], //----- 68
|
||||
[33, 38, 19, 255], //----- 69
|
||||
[127, 255, 0, 255], //----- 70
|
||||
[191, 255, 127, 255],//----- 71
|
||||
[82, 165, 0, 255], //----- 72
|
||||
[124, 165, 82, 255], //----- 73
|
||||
[63, 127, 0, 255], //----- 74
|
||||
[95, 127, 63, 255], //----- 75
|
||||
[38, 76, 0, 255], //----- 76
|
||||
[57, 76, 38, 255], //----- 77
|
||||
[19, 38, 0, 255], //----- 78
|
||||
[28, 38, 19, 255], //----- 79
|
||||
[63, 255, 0, 255], //----- 80
|
||||
[159, 255, 127, 255],//----- 81
|
||||
[41, 165, 0, 255], //----- 82
|
||||
[103, 165, 82, 255], //----- 83
|
||||
[31, 127, 0, 255], //----- 84
|
||||
[79, 127, 63, 255], //----- 85
|
||||
[19, 76, 0, 255], //----- 86
|
||||
[47, 76, 38, 255], //----- 87
|
||||
[9, 38, 0, 255], //----- 88
|
||||
[23, 38, 19, 255], //----- 89
|
||||
[0, 255, 0, 255], //----- 90
|
||||
[127, 255, 127, 255],//----- 91
|
||||
[0, 165, 0, 255], //----- 92
|
||||
[82, 165, 82, 255], //----- 93
|
||||
[0, 127, 0, 255], //----- 94
|
||||
[63, 127, 63, 255], //----- 95
|
||||
[0, 76, 0, 255], //----- 96
|
||||
[38, 76, 38, 255], //----- 97
|
||||
[0, 38, 0, 255], //----- 98
|
||||
[19, 38, 19, 255], //----- 99
|
||||
[0, 255, 63, 255], //----- 100
|
||||
[127, 255, 159, 255],//----- 101
|
||||
[0, 165, 41, 255], //----- 102
|
||||
[82, 165, 103, 255], //----- 103
|
||||
[0, 127, 31, 255], //----- 104
|
||||
[63, 127, 79, 255], //----- 105
|
||||
[0, 76, 19, 255], //----- 106
|
||||
[38, 76, 47, 255], //----- 107
|
||||
[0, 38, 9, 255], //----- 108
|
||||
[19, 38, 23, 255], //----- 109
|
||||
[0, 255, 127, 255], //----- 110
|
||||
[127, 255, 191, 255],//----- 111
|
||||
[0, 165, 82, 255], //----- 112
|
||||
[82, 165, 124, 255], //----- 113
|
||||
[0, 127, 63, 255], //----- 114
|
||||
[63, 127, 95, 255], //----- 115
|
||||
[0, 76, 38, 255], //----- 116
|
||||
[38, 76, 57, 255], //----- 117
|
||||
[0, 38, 19, 255], //----- 118
|
||||
[19, 38, 28, 255], //----- 119
|
||||
[0, 255, 191, 255], //----- 120
|
||||
[127, 255, 223, 255],//----- 121
|
||||
[0, 165, 124, 255], //----- 122
|
||||
[82, 165, 145, 255], //----- 123
|
||||
[0, 127, 95, 255], //----- 124
|
||||
[63, 127, 111, 255], //----- 125
|
||||
[0, 76, 57, 255], //----- 126
|
||||
[38, 76, 66, 255], //----- 127
|
||||
[0, 38, 28, 255], //----- 128
|
||||
[19, 38, 33, 255], //----- 129
|
||||
[0, 255, 255, 255], //----- 130
|
||||
[127, 255, 255, 255],//----- 131
|
||||
[0, 165, 165, 255], //----- 132
|
||||
[82, 165, 165, 255], //----- 133
|
||||
[0, 127, 127, 255], //----- 134
|
||||
[63, 127, 127, 255], //----- 135
|
||||
[0, 76, 76, 255], //----- 136
|
||||
[38, 76, 76, 255], //----- 137
|
||||
[0, 38, 38, 255], //----- 138
|
||||
[19, 38, 38, 255], //----- 139
|
||||
[0, 191, 255, 255], //----- 140
|
||||
[127, 223, 255, 255],//----- 141
|
||||
[0, 124, 165, 255], //----- 142
|
||||
[82, 145, 165, 255], //----- 143
|
||||
[0, 95, 127, 255], //----- 144
|
||||
[63, 111, 127, 255], //----- 145
|
||||
[0, 57, 76, 255], //----- 146
|
||||
[38, 66, 76, 255], //----- 147
|
||||
[0, 28, 38, 255], //----- 148
|
||||
[19, 33, 38, 255], //----- 149
|
||||
[0, 127, 255, 255], //----- 150
|
||||
[127, 191, 255, 255],//----- 151
|
||||
[0, 82, 165, 255], //----- 152
|
||||
[82, 124, 165, 255], //----- 153
|
||||
[0, 63, 127, 255], //----- 154
|
||||
[63, 95, 127, 255], //----- 155
|
||||
[0, 38, 76, 255], //----- 156
|
||||
[38, 57, 76, 255], //----- 157
|
||||
[0, 19, 38, 255], //----- 158
|
||||
[19, 28, 38, 255], //----- 159
|
||||
[0, 63, 255, 255], //----- 160
|
||||
[127, 159, 255, 255],//----- 161
|
||||
[0, 41, 165, 255], //----- 162
|
||||
[82, 103, 165, 255], //----- 163
|
||||
[0, 31, 127, 255], //----- 164
|
||||
[63, 79, 127, 255], //----- 165
|
||||
[0, 19, 76, 255], //----- 166
|
||||
[38, 47, 76, 255], //----- 167
|
||||
[0, 9, 38, 255], //----- 168
|
||||
[19, 23, 38, 255], //----- 169
|
||||
[0, 0, 255, 255], //----- 170
|
||||
[127, 127, 255, 255],//----- 171
|
||||
[0, 0, 165, 255], //----- 172
|
||||
[82, 82, 165, 255], //----- 173
|
||||
[0, 0, 127, 255], //----- 174
|
||||
[63, 63, 127, 255], //----- 175
|
||||
[0, 0, 76, 255], //----- 176
|
||||
[38, 38, 76, 255], //----- 177
|
||||
[0, 0, 38, 255], //----- 178
|
||||
[19, 19, 38, 255], //----- 179
|
||||
[63, 0, 255, 255], //----- 180
|
||||
[159, 127, 255, 255],//----- 181
|
||||
[41, 0, 165, 255], //----- 182
|
||||
[103, 82, 165, 255], //----- 183
|
||||
[31, 0, 127, 255], //----- 184
|
||||
[79, 63, 127, 255], //----- 185
|
||||
[19, 0, 76, 255], //----- 186
|
||||
[47, 38, 76, 255], //----- 187
|
||||
[9, 0, 38, 255], //----- 188
|
||||
[23, 19, 38, 255], //----- 189
|
||||
[127, 0, 255, 255], //----- 190
|
||||
[191, 127, 255, 255],//----- 191
|
||||
[82, 0, 165, 255], //----- 192
|
||||
[124, 82, 165, 255], //----- 193
|
||||
[63, 0, 127, 255], //----- 194
|
||||
[95, 63, 127, 255], //----- 195
|
||||
[38, 0, 76, 255], //----- 196
|
||||
[57, 38, 76, 255], //----- 197
|
||||
[19, 0, 38, 255], //----- 198
|
||||
[28, 19, 38, 255], //----- 199
|
||||
[191, 0, 255, 255], //----- 200
|
||||
[223, 127, 255, 255],//----- 201
|
||||
[124, 0, 165, 255], //----- 202
|
||||
[145, 82, 165, 255], //----- 203
|
||||
[95, 0, 127, 255], //----- 204
|
||||
[111, 63, 127, 255], //----- 205
|
||||
[57, 0, 76, 255], //----- 206
|
||||
[66, 38, 76, 255], //----- 207
|
||||
[28, 0, 38, 255], //----- 208
|
||||
[33, 19, 38, 255], //----- 209
|
||||
[255, 0, 255, 255], //----- 210
|
||||
[255, 127, 255, 255],//----- 211
|
||||
[165, 0, 165, 255], //----- 212
|
||||
[165, 82, 165, 255], //----- 213
|
||||
[127, 0, 127, 255], //----- 214
|
||||
[127, 63, 127, 255], //----- 215
|
||||
[76, 0, 76, 255], //----- 216
|
||||
[76, 38, 76, 255], //----- 217
|
||||
[38, 0, 38, 255], //----- 218
|
||||
[38, 19, 38, 255], //----- 219
|
||||
[255, 0, 191, 255], //----- 220
|
||||
[255, 127, 223, 255],//----- 221
|
||||
[165, 0, 124, 255], //----- 222
|
||||
[165, 82, 145, 255], //----- 223
|
||||
[127, 0, 95, 255], //----- 224
|
||||
[127, 63, 111, 255], //----- 225
|
||||
[76, 0, 57, 255], //----- 226
|
||||
[76, 38, 66, 255], //----- 227
|
||||
[38, 0, 28, 255], //----- 228
|
||||
[38, 19, 33, 255], //----- 229
|
||||
[255, 0, 127, 255], //----- 230
|
||||
[255, 127, 191, 255],//----- 231
|
||||
[165, 0, 82, 255], //----- 232
|
||||
[165, 82, 124, 255], //----- 233
|
||||
[127, 0, 63, 255], //----- 234
|
||||
[127, 63, 95, 255], //----- 235
|
||||
[76, 0, 38, 255], //----- 236
|
||||
[76, 38, 57, 255], //----- 237
|
||||
[38, 0, 19, 255], //----- 238
|
||||
[38, 19, 28, 255], //----- 239
|
||||
[255, 0, 63, 255], //----- 240
|
||||
[255, 127, 159, 255],//----- 241
|
||||
[165, 0, 41, 255], //----- 242
|
||||
[165, 82, 103, 255], //----- 243
|
||||
[127, 0, 31, 255], //----- 244
|
||||
[127, 63, 79, 255], //----- 245
|
||||
[76, 0, 19, 255], //----- 246
|
||||
[76, 38, 47, 255], //----- 247
|
||||
[38, 0, 9, 255], //----- 248
|
||||
[38, 19, 23, 255], //----- 249
|
||||
[84, 84, 84, 255], //----- 250
|
||||
[118, 118, 118, 255],//----- 251
|
||||
[152, 152, 152, 255],//----- 252
|
||||
[186, 186, 186, 255],//----- 253
|
||||
[220, 220, 220, 255],//----- 254
|
||||
[255, 255, 255, 255],//----- 255
|
||||
[255, 255, 255, 255] //----- ByLayer - White
|
||||
// [255, 255, 255, 255],//----- 7 - White
|
||||
// [255, 255, 255, 255],//----- 8
|
||||
// [255, 255, 255, 255],//----- 9
|
||||
// [255, 0, 0, 255], //----- 10
|
||||
// [255, 127, 127, 255],//----- 11
|
||||
// [165, 0, 0, 255], //----- 12
|
||||
// [165, 82, 82, 255], //----- 13
|
||||
// [127, 0, 0, 255], //----- 14
|
||||
// [127, 63, 63, 255], //----- 15
|
||||
// [76, 0, 0, 255], //----- 16
|
||||
// [76, 38, 38, 255], //----- 17
|
||||
// [38, 0, 0, 255], //----- 18
|
||||
// [38, 19, 19, 255], //----- 19
|
||||
// [255, 63, 0, 255], //----- 20
|
||||
// [255, 159, 127, 255],//----- 21
|
||||
// [165, 41, 0, 255], //----- 22
|
||||
// [165, 103, 82, 255], //----- 23
|
||||
// [127, 31, 0, 255], //----- 24
|
||||
// [127, 79, 63, 255], //----- 25
|
||||
// [76, 19, 0, 255], //----- 26
|
||||
// [76, 47, 38, 255], //----- 27
|
||||
// [38, 9, 0, 255], //----- 28
|
||||
// [38, 23, 19, 255], //----- 29
|
||||
// [255, 127, 0, 255], //----- 30
|
||||
// [255, 191, 127, 255],//----- 31
|
||||
// [165, 82, 0, 255], //----- 32
|
||||
// [165, 124, 82, 255], //----- 33
|
||||
// [127, 63, 0, 255], //----- 34
|
||||
// [127, 95, 63, 255], //----- 35
|
||||
// [76, 38, 0, 255], //----- 36
|
||||
// [76, 57, 38, 255], //----- 37
|
||||
// [38, 19, 0, 255], //----- 38
|
||||
// [38, 28, 19, 255], //----- 39
|
||||
// [255, 191, 0, 255], //----- 40
|
||||
// [255, 223, 127, 255],//----- 41
|
||||
// [165, 124, 0, 255], //----- 42
|
||||
// [165, 145, 82, 255], //----- 43
|
||||
// [127, 95, 0, 255], //----- 44
|
||||
// [127, 111, 63, 255], //----- 45
|
||||
// [76, 57, 0, 255], //----- 46
|
||||
// [76, 66, 38, 255], //----- 47
|
||||
// [38, 28, 0, 255], //----- 48
|
||||
// [38, 33, 19, 255], //----- 49
|
||||
// [255, 255, 0, 255], //----- 50
|
||||
// [255, 255, 127, 255],//----- 51
|
||||
// [165, 165, 0, 255], //----- 52
|
||||
// [165, 165, 82, 255], //----- 53
|
||||
// [127, 127, 0, 255], //----- 54
|
||||
// [127, 127, 63, 255], //----- 55
|
||||
// [76, 76, 0, 255], //----- 56
|
||||
// [76, 76, 38, 255], //----- 57
|
||||
// [38, 38, 0, 255], //----- 58
|
||||
// [38, 38, 19, 255], //----- 59
|
||||
// [191, 255, 0, 255], //----- 60
|
||||
// [223, 255, 127, 255],//----- 61
|
||||
// [124, 165, 0, 255], //----- 62
|
||||
// [145, 165, 82, 255], //----- 63
|
||||
// [95, 127, 0, 255], //----- 64
|
||||
// [111, 127, 63, 255], //----- 65
|
||||
// [57, 76, 0, 255], //----- 66
|
||||
// [66, 76, 38, 255], //----- 67
|
||||
// [28, 38, 0, 255], //----- 68
|
||||
// [33, 38, 19, 255], //----- 69
|
||||
// [127, 255, 0, 255], //----- 70
|
||||
// [191, 255, 127, 255],//----- 71
|
||||
// [82, 165, 0, 255], //----- 72
|
||||
// [124, 165, 82, 255], //----- 73
|
||||
// [63, 127, 0, 255], //----- 74
|
||||
// [95, 127, 63, 255], //----- 75
|
||||
// [38, 76, 0, 255], //----- 76
|
||||
// [57, 76, 38, 255], //----- 77
|
||||
// [19, 38, 0, 255], //----- 78
|
||||
// [28, 38, 19, 255], //----- 79
|
||||
// [63, 255, 0, 255], //----- 80
|
||||
// [159, 255, 127, 255],//----- 81
|
||||
// [41, 165, 0, 255], //----- 82
|
||||
// [103, 165, 82, 255], //----- 83
|
||||
// [31, 127, 0, 255], //----- 84
|
||||
// [79, 127, 63, 255], //----- 85
|
||||
// [19, 76, 0, 255], //----- 86
|
||||
// [47, 76, 38, 255], //----- 87
|
||||
// [9, 38, 0, 255], //----- 88
|
||||
// [23, 38, 19, 255], //----- 89
|
||||
// [0, 255, 0, 255], //----- 90
|
||||
// [127, 255, 127, 255],//----- 91
|
||||
// [0, 165, 0, 255], //----- 92
|
||||
// [82, 165, 82, 255], //----- 93
|
||||
// [0, 127, 0, 255], //----- 94
|
||||
// [63, 127, 63, 255], //----- 95
|
||||
// [0, 76, 0, 255], //----- 96
|
||||
// [38, 76, 38, 255], //----- 97
|
||||
// [0, 38, 0, 255], //----- 98
|
||||
// [19, 38, 19, 255], //----- 99
|
||||
// [0, 255, 63, 255], //----- 100
|
||||
// [127, 255, 159, 255],//----- 101
|
||||
// [0, 165, 41, 255], //----- 102
|
||||
// [82, 165, 103, 255], //----- 103
|
||||
// [0, 127, 31, 255], //----- 104
|
||||
// [63, 127, 79, 255], //----- 105
|
||||
// [0, 76, 19, 255], //----- 106
|
||||
// [38, 76, 47, 255], //----- 107
|
||||
// [0, 38, 9, 255], //----- 108
|
||||
// [19, 38, 23, 255], //----- 109
|
||||
// [0, 255, 127, 255], //----- 110
|
||||
// [127, 255, 191, 255],//----- 111
|
||||
// [0, 165, 82, 255], //----- 112
|
||||
// [82, 165, 124, 255], //----- 113
|
||||
// [0, 127, 63, 255], //----- 114
|
||||
// [63, 127, 95, 255], //----- 115
|
||||
// [0, 76, 38, 255], //----- 116
|
||||
// [38, 76, 57, 255], //----- 117
|
||||
// [0, 38, 19, 255], //----- 118
|
||||
// [19, 38, 28, 255], //----- 119
|
||||
// [0, 255, 191, 255], //----- 120
|
||||
// [127, 255, 223, 255],//----- 121
|
||||
// [0, 165, 124, 255], //----- 122
|
||||
// [82, 165, 145, 255], //----- 123
|
||||
// [0, 127, 95, 255], //----- 124
|
||||
// [63, 127, 111, 255], //----- 125
|
||||
// [0, 76, 57, 255], //----- 126
|
||||
// [38, 76, 66, 255], //----- 127
|
||||
// [0, 38, 28, 255], //----- 128
|
||||
// [19, 38, 33, 255], //----- 129
|
||||
// [0, 255, 255, 255], //----- 130
|
||||
// [127, 255, 255, 255],//----- 131
|
||||
// [0, 165, 165, 255], //----- 132
|
||||
// [82, 165, 165, 255], //----- 133
|
||||
// [0, 127, 127, 255], //----- 134
|
||||
// [63, 127, 127, 255], //----- 135
|
||||
// [0, 76, 76, 255], //----- 136
|
||||
// [38, 76, 76, 255], //----- 137
|
||||
// [0, 38, 38, 255], //----- 138
|
||||
// [19, 38, 38, 255], //----- 139
|
||||
// [0, 191, 255, 255], //----- 140
|
||||
// [127, 223, 255, 255],//----- 141
|
||||
// [0, 124, 165, 255], //----- 142
|
||||
// [82, 145, 165, 255], //----- 143
|
||||
// [0, 95, 127, 255], //----- 144
|
||||
// [63, 111, 127, 255], //----- 145
|
||||
// [0, 57, 76, 255], //----- 146
|
||||
// [38, 66, 76, 255], //----- 147
|
||||
// [0, 28, 38, 255], //----- 148
|
||||
// [19, 33, 38, 255], //----- 149
|
||||
// [0, 127, 255, 255], //----- 150
|
||||
// [127, 191, 255, 255],//----- 151
|
||||
// [0, 82, 165, 255], //----- 152
|
||||
// [82, 124, 165, 255], //----- 153
|
||||
// [0, 63, 127, 255], //----- 154
|
||||
// [63, 95, 127, 255], //----- 155
|
||||
// [0, 38, 76, 255], //----- 156
|
||||
// [38, 57, 76, 255], //----- 157
|
||||
// [0, 19, 38, 255], //----- 158
|
||||
// [19, 28, 38, 255], //----- 159
|
||||
// [0, 63, 255, 255], //----- 160
|
||||
// [127, 159, 255, 255],//----- 161
|
||||
// [0, 41, 165, 255], //----- 162
|
||||
// [82, 103, 165, 255], //----- 163
|
||||
// [0, 31, 127, 255], //----- 164
|
||||
// [63, 79, 127, 255], //----- 165
|
||||
// [0, 19, 76, 255], //----- 166
|
||||
// [38, 47, 76, 255], //----- 167
|
||||
// [0, 9, 38, 255], //----- 168
|
||||
// [19, 23, 38, 255], //----- 169
|
||||
// [0, 0, 255, 255], //----- 170
|
||||
// [127, 127, 255, 255],//----- 171
|
||||
// [0, 0, 165, 255], //----- 172
|
||||
// [82, 82, 165, 255], //----- 173
|
||||
// [0, 0, 127, 255], //----- 174
|
||||
// [63, 63, 127, 255], //----- 175
|
||||
// [0, 0, 76, 255], //----- 176
|
||||
// [38, 38, 76, 255], //----- 177
|
||||
// [0, 0, 38, 255], //----- 178
|
||||
// [19, 19, 38, 255], //----- 179
|
||||
// [63, 0, 255, 255], //----- 180
|
||||
// [159, 127, 255, 255],//----- 181
|
||||
// [41, 0, 165, 255], //----- 182
|
||||
// [103, 82, 165, 255], //----- 183
|
||||
// [31, 0, 127, 255], //----- 184
|
||||
// [79, 63, 127, 255], //----- 185
|
||||
// [19, 0, 76, 255], //----- 186
|
||||
// [47, 38, 76, 255], //----- 187
|
||||
// [9, 0, 38, 255], //----- 188
|
||||
// [23, 19, 38, 255], //----- 189
|
||||
// [127, 0, 255, 255], //----- 190
|
||||
// [191, 127, 255, 255],//----- 191
|
||||
// [82, 0, 165, 255], //----- 192
|
||||
// [124, 82, 165, 255], //----- 193
|
||||
// [63, 0, 127, 255], //----- 194
|
||||
// [95, 63, 127, 255], //----- 195
|
||||
// [38, 0, 76, 255], //----- 196
|
||||
// [57, 38, 76, 255], //----- 197
|
||||
// [19, 0, 38, 255], //----- 198
|
||||
// [28, 19, 38, 255], //----- 199
|
||||
// [191, 0, 255, 255], //----- 200
|
||||
// [223, 127, 255, 255],//----- 201
|
||||
// [124, 0, 165, 255], //----- 202
|
||||
// [145, 82, 165, 255], //----- 203
|
||||
// [95, 0, 127, 255], //----- 204
|
||||
// [111, 63, 127, 255], //----- 205
|
||||
// [57, 0, 76, 255], //----- 206
|
||||
// [66, 38, 76, 255], //----- 207
|
||||
// [28, 0, 38, 255], //----- 208
|
||||
// [33, 19, 38, 255], //----- 209
|
||||
// [255, 0, 255, 255], //----- 210
|
||||
// [255, 127, 255, 255],//----- 211
|
||||
// [165, 0, 165, 255], //----- 212
|
||||
// [165, 82, 165, 255], //----- 213
|
||||
// [127, 0, 127, 255], //----- 214
|
||||
// [127, 63, 127, 255], //----- 215
|
||||
// [76, 0, 76, 255], //----- 216
|
||||
// [76, 38, 76, 255], //----- 217
|
||||
// [38, 0, 38, 255], //----- 218
|
||||
// [38, 19, 38, 255], //----- 219
|
||||
// [255, 0, 191, 255], //----- 220
|
||||
// [255, 127, 223, 255],//----- 221
|
||||
// [165, 0, 124, 255], //----- 222
|
||||
// [165, 82, 145, 255], //----- 223
|
||||
// [127, 0, 95, 255], //----- 224
|
||||
// [127, 63, 111, 255], //----- 225
|
||||
// [76, 0, 57, 255], //----- 226
|
||||
// [76, 38, 66, 255], //----- 227
|
||||
// [38, 0, 28, 255], //----- 228
|
||||
// [38, 19, 33, 255], //----- 229
|
||||
// [255, 0, 127, 255], //----- 230
|
||||
// [255, 127, 191, 255],//----- 231
|
||||
// [165, 0, 82, 255], //----- 232
|
||||
// [165, 82, 124, 255], //----- 233
|
||||
// [127, 0, 63, 255], //----- 234
|
||||
// [127, 63, 95, 255], //----- 235
|
||||
// [76, 0, 38, 255], //----- 236
|
||||
// [76, 38, 57, 255], //----- 237
|
||||
// [38, 0, 19, 255], //----- 238
|
||||
// [38, 19, 28, 255], //----- 239
|
||||
// [255, 0, 63, 255], //----- 240
|
||||
// [255, 127, 159, 255],//----- 241
|
||||
// [165, 0, 41, 255], //----- 242
|
||||
// [165, 82, 103, 255], //----- 243
|
||||
// [127, 0, 31, 255], //----- 244
|
||||
// [127, 63, 79, 255], //----- 245
|
||||
// [76, 0, 19, 255], //----- 246
|
||||
// [76, 38, 47, 255], //----- 247
|
||||
// [38, 0, 9, 255], //----- 248
|
||||
// [38, 19, 23, 255], //----- 249
|
||||
// [84, 84, 84, 255], //----- 250
|
||||
// [118, 118, 118, 255],//----- 251
|
||||
// [152, 152, 152, 255],//----- 252
|
||||
// [186, 186, 186, 255],//----- 253
|
||||
// [220, 220, 220, 255],//----- 254
|
||||
// [255, 255, 255, 255],//----- 255
|
||||
// [255, 255, 255, 255] //----- ByLayer - White
|
||||
];
|
||||
|
||||
|
||||
@ -270,19 +271,28 @@ export class ColorMaterial
|
||||
{
|
||||
private constructor() { }
|
||||
private static m_LineMaterialMap = new Map<number, THREE.LineBasicMaterial>();
|
||||
static GetLineMaterial(index): THREE.LineBasicMaterial
|
||||
static GetLineMaterial(index): LineBasicMaterial
|
||||
{
|
||||
if (this.m_LineMaterialMap.has(index))
|
||||
return this.m_LineMaterialMap.get(index);
|
||||
let mat = new THREE.LineBasicMaterial({ color: this.GetColor(index) });
|
||||
let mat = new LineBasicMaterial({ color: this.GetColor(index) });
|
||||
this.m_LineMaterialMap.set(index, mat);
|
||||
return mat;
|
||||
}
|
||||
private static m_BasicMaterialMap = new Map<number, MeshBasicMaterial>();
|
||||
static GetBasicMaterial(index: number): MeshBasicMaterial
|
||||
{
|
||||
if (this.m_BasicMaterialMap.has(index))
|
||||
return this.m_BasicMaterialMap.get(index);
|
||||
let mat = new MeshBasicMaterial({ color: this.GetColor(index), side: THREE.DoubleSide });
|
||||
this.m_BasicMaterialMap.set(index, mat);
|
||||
return mat;
|
||||
}
|
||||
|
||||
static GetColor(index: number)
|
||||
{
|
||||
let rgb = ColorPalette[index];
|
||||
if (rgb)
|
||||
return new THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
|
||||
return new Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import { MoveMatrix } from "./GeUtils";
|
||||
|
||||
/**
|
||||
* 标注实体
|
||||
*
|
||||
* @export
|
||||
* @class Dimension
|
||||
* @extends {Group}
|
||||
@ -42,12 +41,12 @@ export class Dimension extends Group
|
||||
if (mirror)
|
||||
{
|
||||
let roMat = new Matrix4().makeRotationZ(Math.PI);
|
||||
text.applyMatrix(roMat);
|
||||
text.applyMatrix(MoveMatrix(new Vector3(length * 0.5, footLength - textHeight * 0.1)));
|
||||
text.applyMatrix4(roMat);
|
||||
text.applyMatrix4(MoveMatrix(new Vector3(length * 0.5, footLength - textHeight * 0.1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
text.applyMatrix(MoveMatrix(new Vector3(length * 0.5, footLength * 1.1)));
|
||||
text.applyMatrix4(MoveMatrix(new Vector3(length * 0.5, footLength * 1.1)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Box3, Vector3, Matrix4, Mesh } from "three";
|
||||
import { Matrix4, Mesh, Vector3 } from "three";
|
||||
import { Dimension, GetBoxArr } from ".";
|
||||
|
||||
|
||||
/**
|
||||
* 绘制标注实体
|
||||
*
|
||||
*
|
||||
* @export
|
||||
* @param {Box3} box
|
||||
* @param {Box3} box
|
||||
* @returns 标注实体列表
|
||||
*/
|
||||
export function DrawDimension(brList: Mesh[]): Dimension[]
|
||||
@ -19,30 +19,30 @@ export function DrawDimension(brList: Mesh[]): Dimension[]
|
||||
new Vector3(-1, 0, 0),
|
||||
new Vector3(0, -1, 0),
|
||||
new Vector3(0, 0, 1)
|
||||
)
|
||||
);
|
||||
mat4.setPosition(box.min.clone().add(new Vector3(size.x, -30)));
|
||||
|
||||
let textHeight = 45;
|
||||
let dimx = new Dimension(size.x, textHeight, true);
|
||||
dimx.applyMatrix(mat4);
|
||||
dimx.applyMatrix4(mat4);
|
||||
|
||||
let dimz = new Dimension(size.z, textHeight);
|
||||
mat4.makeBasis(
|
||||
new Vector3(0, 0, -1),
|
||||
new Vector3(1, 0, 0),
|
||||
new Vector3(0, -1, 0)
|
||||
)
|
||||
);
|
||||
mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y)));
|
||||
dimz.applyMatrix(mat4);
|
||||
dimz.applyMatrix4(mat4);
|
||||
|
||||
let dimy = new Dimension(size.y, textHeight, true, true);
|
||||
mat4.makeBasis(
|
||||
new Vector3(0, 1, 0),
|
||||
new Vector3(-1, 0, 0),
|
||||
new Vector3(0, 0, 1)
|
||||
)
|
||||
);
|
||||
mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y)));
|
||||
dimy.applyMatrix(mat4);
|
||||
dimy.applyMatrix4(mat4);
|
||||
|
||||
|
||||
return [dimx, dimy, dimz];
|
||||
|
153
src/GeUtils.ts
153
src/GeUtils.ts
@ -1,16 +1,15 @@
|
||||
import * as THREE from 'three';
|
||||
import { Geometry, Vector, Vector2, Vector3 } from 'three';
|
||||
import { Box3, Geometry, Line, Matrix4, Mesh, Object3D, Vector2, Vector3, type Vector } from 'three';
|
||||
import { Matrix2 } from './Matrix2';
|
||||
|
||||
|
||||
export const cZeroVec = new THREE.Vector3();
|
||||
export const cXAxis = new THREE.Vector3(1, 0, 0);
|
||||
export const cYAxis = new THREE.Vector3(0, 1, 0);
|
||||
export const cZAxis = new THREE.Vector3(0, 0, 1);
|
||||
export const cZeroVec = new Vector3();
|
||||
export const cXAxis = new Vector3(1, 0, 0);
|
||||
export const cYAxis = new Vector3(0, 1, 0);
|
||||
export const cZAxis = new Vector3(0, 0, 1);
|
||||
|
||||
/**
|
||||
* 旋转一个点,旋转中心在原点
|
||||
*
|
||||
*
|
||||
* @export
|
||||
* @param {Vector3} pt 点
|
||||
* @param {number} ang 角度.
|
||||
@ -26,6 +25,12 @@ export function equaln(v1: number, v2: number, fuzz = 1e-3)
|
||||
{
|
||||
return Math.abs(v1 - v2) < fuzz;
|
||||
}
|
||||
|
||||
export function equalv3(v1: Vector3, v2: Vector3, fuzz = 1e-8)
|
||||
{
|
||||
return equaln(v1.x, v2.x, fuzz) && equaln(v1.y, v2.y, fuzz) && equaln(v1.z, v2.z, fuzz);
|
||||
}
|
||||
|
||||
export function equal<T extends Vector>(v1: T, v2: T)
|
||||
{
|
||||
return v1.distanceToSquared(v2) < 1e-8;
|
||||
@ -50,13 +55,13 @@ export function fixAngle(an: number, fixAngle: number, fuzz: number = 0.1)
|
||||
|
||||
/**
|
||||
* 按照极坐标的方式移动一个点
|
||||
*
|
||||
*
|
||||
* @export
|
||||
* @template
|
||||
* @template
|
||||
* @param {T} v 向量(2d,3d)
|
||||
* @param {number} an 角度
|
||||
* @param {number} dis 距离
|
||||
* @returns {T}
|
||||
* @returns {T}
|
||||
*/
|
||||
export function polar<T extends Vector2 | Vector3>(v: T, an: number, dis: number): T
|
||||
{
|
||||
@ -76,22 +81,22 @@ export function angle(v: Vector3 | Vector2)
|
||||
|
||||
/**
|
||||
* 求两个向量的夹角,顺时针为负,逆时针为正
|
||||
*
|
||||
* @param {THREE.Vector3} v1
|
||||
* @param {THREE.Vector3} v2
|
||||
* @param {THREE.Vector3} [ref] 参考向量,如果为世界坐标系则为0,0,1
|
||||
* @returns
|
||||
*
|
||||
* @param {Vector3} v1
|
||||
* @param {Vector3} v2
|
||||
* @param {Vector3} [ref] 参考向量,如果为世界坐标系则为0,0,1
|
||||
* @returns
|
||||
*/
|
||||
export function angleTo(v1: THREE.Vector3, v2: THREE.Vector3, ref: THREE.Vector3 = new THREE.Vector3(0, 0, 1))
|
||||
export function angleTo(v1: Vector3, v2: Vector3, ref: Vector3 = new Vector3(0, 0, 1))
|
||||
{
|
||||
if (!ref.equals(new Vector3(0, 0, 1)))
|
||||
{
|
||||
//任意轴坐标系. 使用相机的构造矩阵.
|
||||
ref.multiplyScalar(-1);
|
||||
let up = getLoocAtUpVec(ref);
|
||||
let refOcs = new THREE.Matrix4();
|
||||
let refOcs = new Matrix4();
|
||||
refOcs.lookAt(cZeroVec, ref, up);
|
||||
let refOcsInv = new THREE.Matrix4().getInverse(refOcs);
|
||||
let refOcsInv = new Matrix4().getInverse(refOcs);
|
||||
v1.applyMatrix4(refOcsInv);
|
||||
v2.applyMatrix4(refOcsInv);
|
||||
v1.z = 0;
|
||||
@ -103,63 +108,63 @@ export function angleTo(v1: THREE.Vector3, v2: THREE.Vector3, ref: THREE.Vector3
|
||||
return cv.z === 0 ? v1.angleTo(v2) : v1.angleTo(v2) * cv.z;
|
||||
}
|
||||
|
||||
export function getLoocAtUpVec(dir: THREE.Vector3): THREE.Vector3
|
||||
export function getLoocAtUpVec(dir: Vector3): Vector3
|
||||
{
|
||||
if (dir.equals(cZeroVec))
|
||||
{
|
||||
throw ("zero vector")
|
||||
throw ("zero vector");
|
||||
}
|
||||
let norm = dir.clone().normalize();
|
||||
if (norm.equals(cZAxis))
|
||||
{
|
||||
return new THREE.Vector3(0, 1, 0);
|
||||
return new Vector3(0, 1, 0);
|
||||
}
|
||||
else if (norm.equals(cZAxis.clone().negate()))
|
||||
{
|
||||
return new THREE.Vector3(0, -1, 0);
|
||||
return new Vector3(0, -1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
let xv: THREE.Vector3 = new THREE.Vector3();
|
||||
let xv: Vector3 = new Vector3();
|
||||
xv.crossVectors(cZAxis, norm);
|
||||
|
||||
let up = new THREE.Vector3();
|
||||
let up = new Vector3();
|
||||
up.crossVectors(norm, xv);
|
||||
return up;
|
||||
}
|
||||
}
|
||||
|
||||
export function createLookAtMat4(dir: THREE.Vector3): THREE.Matrix4
|
||||
export function createLookAtMat4(dir: Vector3): Matrix4
|
||||
{
|
||||
let up = getLoocAtUpVec(dir);
|
||||
let mat = new THREE.Matrix4();
|
||||
let mat = new Matrix4();
|
||||
mat.lookAt(cZeroVec, dir, up);
|
||||
return mat;
|
||||
}
|
||||
|
||||
export function isParallelTo(v1: THREE.Vector3, v2: THREE.Vector3)
|
||||
export function isParallelTo(v1: Vector3, v2: Vector3)
|
||||
{
|
||||
return v1.clone().cross(v2).lengthSq() < 1e-9;
|
||||
}
|
||||
|
||||
export function ptToString(v: THREE.Vector3, fractionDigits: number = 3): string
|
||||
export function ptToString(v: Vector3, fractionDigits: number = 3): string
|
||||
{
|
||||
return v.toArray().map(o =>
|
||||
{
|
||||
return o.toFixed(fractionDigits)
|
||||
}).join(",")
|
||||
return o.toFixed(fractionDigits);
|
||||
}).join(",");
|
||||
}
|
||||
|
||||
export function midPoint(v1: THREE.Vector3, v2: THREE.Vector3): THREE.Vector3
|
||||
export function midPoint(v1: Vector3, v2: Vector3): Vector3
|
||||
{
|
||||
return v1.clone().add(v2).multiplyScalar(0.5);
|
||||
}
|
||||
export function midPoint2(v1: THREE.Vector2, v2: THREE.Vector2): THREE.Vector2
|
||||
export function midPoint2(v1: Vector2, v2: Vector2): Vector2
|
||||
{
|
||||
return v1.clone().add(v2).multiplyScalar(0.5);
|
||||
}
|
||||
|
||||
export function midPtCir(v1: THREE.Vector3, v2: THREE.Vector3)
|
||||
export function midPtCir(v1: Vector3, v2: Vector3)
|
||||
{
|
||||
let baseline = new Vector3(1, 0, 0);
|
||||
let outLine = v2.clone().sub(v1);
|
||||
@ -168,56 +173,52 @@ export function midPtCir(v1: THREE.Vector3, v2: THREE.Vector3)
|
||||
return v1.clone().add(midLine);
|
||||
}
|
||||
|
||||
export function GetBox(obj: THREE.Object3D, updateMatrix?: boolean): THREE.Box3
|
||||
/**
|
||||
* 获得Three对象的包围盒.
|
||||
* @param obj
|
||||
* @param [updateMatrix] 是否应该更新对象矩阵
|
||||
* @returns box
|
||||
*/
|
||||
export function GetBox(obj: Object3D, updateMatrix?: boolean): Box3
|
||||
{
|
||||
let box = new Box3();
|
||||
if (updateMatrix) obj.updateMatrixWorld(false);
|
||||
if (obj.hasOwnProperty("geometry"))
|
||||
if (!obj.visible) return box;
|
||||
|
||||
obj.traverse(o =>
|
||||
{
|
||||
let geo = obj["geometry"];
|
||||
if (geo instanceof THREE.Geometry || geo instanceof THREE.BufferGeometry)
|
||||
//因为实体Erase时,实体仍然保存在Scene中.
|
||||
if (o.visible === false)
|
||||
return;
|
||||
|
||||
//@ts-ignore
|
||||
let geo = o.geometry as BufferGeometry;
|
||||
if (geo)
|
||||
{
|
||||
if (!geo.boundingBox)
|
||||
geo.computeBoundingBox();
|
||||
return geo.boundingBox.clone().applyMatrix4(obj.matrixWorld);
|
||||
box.union(geo.boundingBox.clone().applyMatrix4(o.matrixWorld));
|
||||
}
|
||||
}
|
||||
else if (obj.children.length > 0)
|
||||
{
|
||||
let box = obj.children.reduce((sumBox, itemObj) =>
|
||||
{
|
||||
let itemBox = GetBox(itemObj);
|
||||
if (itemBox)
|
||||
sumBox.union(itemBox);
|
||||
return sumBox;
|
||||
}, new THREE.Box3())
|
||||
// if (box) box.applyMatrix4(obj.matrixWorld);
|
||||
return box;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
});
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
export function GetBoxArr(arr: Array<THREE.Object3D>): THREE.Box3
|
||||
export function GetBoxArr(arr: Array<Object3D>): Box3
|
||||
{
|
||||
if (arr.length == 0)
|
||||
let box = new Box3();
|
||||
for (let o of arr)
|
||||
{
|
||||
return null;
|
||||
let b = GetBox(o);
|
||||
if (!b.isEmpty())
|
||||
box.union(b);
|
||||
}
|
||||
return arr.map(o =>
|
||||
{
|
||||
return GetBox(o);
|
||||
}).filter(o =>
|
||||
{
|
||||
return o;
|
||||
}).reduce((sumBox: THREE.Box3, objBox: THREE.Box3) =>
|
||||
{
|
||||
return sumBox.union(objBox)
|
||||
}, new THREE.Box3());
|
||||
return box;
|
||||
}
|
||||
|
||||
export function MoveMatrix(v: THREE.Vector3): THREE.Matrix4
|
||||
export function MoveMatrix(v: Vector3): Matrix4
|
||||
{
|
||||
let mat = new THREE.Matrix4();
|
||||
let mat = new Matrix4();
|
||||
mat.makeTranslation(v.x, v.y, v.z);
|
||||
return mat;
|
||||
}
|
||||
@ -229,7 +230,7 @@ export function getProjectDist(v1: Vector3, v2: Vector3)
|
||||
return {
|
||||
h: dist * Math.cos(ang),
|
||||
v: dist * Math.sin(ang)
|
||||
}
|
||||
};
|
||||
}
|
||||
//获得输入点在2线组成的4个区间的位置
|
||||
export function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3)
|
||||
@ -254,10 +255,10 @@ export function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3
|
||||
return { sp, ep };
|
||||
} 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)
|
||||
{
|
||||
return { sp: c.clone().add(l3), ep: c.clone().add(l4) }
|
||||
return { sp: c.clone().add(l3), ep: c.clone().add(l4) };
|
||||
} else
|
||||
{
|
||||
return { sp, ep: c.clone().add(l4) };
|
||||
@ -269,19 +270,19 @@ export function angleAndX(v: Vector3 | Vector2)
|
||||
}
|
||||
/**
|
||||
* 将角度调整为0-2pi之间
|
||||
*
|
||||
*
|
||||
* @export
|
||||
* @param {number} an
|
||||
* @param {number} an
|
||||
*/
|
||||
export function angleTo2Pi(an: number)
|
||||
{
|
||||
an = an % (Math.PI * 2);
|
||||
if (an < 0) an += Math.PI * 2
|
||||
if (an < 0) an += Math.PI * 2;
|
||||
return an;
|
||||
}
|
||||
export function updateGeometry(l: THREE.Line | THREE.Mesh, geometry: Geometry)
|
||||
export function updateGeometry(l: Line | Mesh, geometry: Geometry)
|
||||
{
|
||||
let geo = l.geometry as THREE.Geometry;
|
||||
let geo = l.geometry as Geometry;
|
||||
geo.dispose();
|
||||
l.geometry = geometry;
|
||||
geometry.verticesNeedUpdate = true;
|
||||
|
@ -8,6 +8,13 @@ export let boardMaterial = new MeshBasicMaterial({
|
||||
polygonOffsetUnits: 1
|
||||
});
|
||||
|
||||
export let selectMaterial = new MeshBasicMaterial({
|
||||
color: new Color(0.1, 0.5, 0.5),
|
||||
polygonOffset: true,
|
||||
polygonOffsetFactor: 1, // positive value pushes polygon further away
|
||||
polygonOffsetUnits: 1
|
||||
});
|
||||
|
||||
//线框的材质
|
||||
export let edgeMaterial = new LineBasicMaterial({ linewidth: 2, color: new Color(0, 0, 0) });
|
||||
|
||||
|
44
src/Orbit.ts
44
src/Orbit.ts
@ -1,9 +1,9 @@
|
||||
import * as THREE from "three";
|
||||
import { MathUtils, Vector3 } from "three";
|
||||
|
||||
/**
|
||||
* 轨道控制的数学类,观察向量和角度的互相转换
|
||||
* 当x当抬头或者低头到90度时,触发万向锁.
|
||||
*
|
||||
*
|
||||
* @class Orbit
|
||||
*/
|
||||
export class Orbit
|
||||
@ -20,19 +20,19 @@ export class Orbit
|
||||
}
|
||||
set RoX(v)
|
||||
{
|
||||
this.m_RoX = THREE.Math.clamp(v, Math.PI * -0.5, Math.PI * 0.5);
|
||||
this.m_RoX = MathUtils.clamp(v, Math.PI * -0.5, Math.PI * 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用旋转角度 计算观察向量
|
||||
*
|
||||
* @param {THREE.Vector3} [dir] 引用传入,如果传入,那么就不构造新的向量
|
||||
* @returns {THREE.Vector3} 返回观察向量
|
||||
*
|
||||
* @param {Vector3} [dir] 引用传入,如果传入,那么就不构造新的向量
|
||||
* @returns {Vector3} 返回观察向量
|
||||
* @memberof Orbit
|
||||
*/
|
||||
UpdateDirection(dir?: THREE.Vector3): THREE.Vector3
|
||||
UpdateDirection(dir?: Vector3): Vector3
|
||||
{
|
||||
let rtDir = dir ? dir : new THREE.Vector3();
|
||||
let rtDir = dir ? dir : new Vector3();
|
||||
|
||||
rtDir.z = Math.sin(this.m_RoX);
|
||||
|
||||
@ -47,11 +47,11 @@ export class Orbit
|
||||
|
||||
/**
|
||||
* 使用观察向量,计算旋转角度
|
||||
*
|
||||
* @param {THREE.Vector3} dir
|
||||
*
|
||||
* @param {Vector3} dir
|
||||
* @memberof Orbit
|
||||
*/
|
||||
UpdateRoValue(dir: THREE.Vector3)
|
||||
UpdateRoValue(dir: Vector3)
|
||||
{
|
||||
dir.normalize();
|
||||
this.m_RoX = Math.asin(dir.z);
|
||||
@ -62,30 +62,30 @@ export class Orbit
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 根据观察向量 求头部的向量.
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @param {THREE.Vector3} dir
|
||||
* @param {THREE.Vector3} [up]
|
||||
* @returns {THREE.Vector3}
|
||||
* @param {Vector3} dir
|
||||
* @param {Vector3} [up]
|
||||
* @returns {Vector3}
|
||||
* @memberof Orbit
|
||||
*/
|
||||
static ComputUpDirection(dir: THREE.Vector3, up?: THREE.Vector3): THREE.Vector3
|
||||
static ComputUpDirection(dir: Vector3, up?: Vector3): Vector3
|
||||
{
|
||||
let upRes = up ? up : new THREE.Vector3();
|
||||
if (dir.equals(new THREE.Vector3(0, 0, -1)))
|
||||
let upRes = up ? up : new Vector3();
|
||||
if (dir.equals(new Vector3(0, 0, -1)))
|
||||
{
|
||||
upRes.set(0, 1, 0);
|
||||
}
|
||||
else if (dir.equals(new THREE.Vector3(0, 0, 1)))
|
||||
else if (dir.equals(new Vector3(0, 0, 1)))
|
||||
{
|
||||
upRes.set(0, -1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
let xv = new THREE.Vector3();
|
||||
xv.crossVectors(new THREE.Vector3(0, 0, 1), dir);
|
||||
let xv = new Vector3();
|
||||
xv.crossVectors(new Vector3(0, 0, 1), dir);
|
||||
upRes.crossVectors(dir, xv);
|
||||
upRes.normalize();
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
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);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { Matrix2 } from './Matrix2';
|
||||
import * as THREE from 'three';
|
||||
import { Geometry, Vector2 } from 'three';
|
||||
|
||||
|
||||
export function RotateUVs(geo: THREE.Geometry)
|
||||
export function RotateUVs(geo: Geometry)
|
||||
{
|
||||
let roMat = new Matrix2();
|
||||
roMat.set(0, -1,
|
||||
1, 0);
|
||||
|
||||
let addV = new THREE.Vector2(1, 0);
|
||||
let addV = new Vector2(1, 0);
|
||||
|
||||
for (let uvs of geo.faceVertexUvs)
|
||||
{
|
||||
|
185
src/SimpleBoard.ts
Normal file
185
src/SimpleBoard.ts
Normal 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;
|
||||
}
|
||||
}
|
75
src/Text.ts
75
src/Text.ts
@ -1,38 +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 { MoveMatrix } from "./GeUtils";
|
||||
import { XAxis, XAxisN, YAxis, YAxisN, ZAxisN } from "./Utils";
|
||||
|
||||
class FontLoaderUtil {
|
||||
private static defFont: Font;
|
||||
static Load(): Font {
|
||||
if (!this.defFont) {
|
||||
const f = require("../resources/fonts/helvetiker_regular.typeface.json");
|
||||
let loader = new FontLoader();
|
||||
this.defFont = loader.parse(f);
|
||||
class FontLoaderUtil
|
||||
{
|
||||
private static defFont: Font;
|
||||
static Load(): Font
|
||||
{
|
||||
if (!this.defFont)
|
||||
{
|
||||
let loader = new FontLoader();
|
||||
this.defFont = loader.parse(f);
|
||||
}
|
||||
return this.defFont;
|
||||
}
|
||||
return this.defFont;
|
||||
}
|
||||
}
|
||||
|
||||
export class DbText extends Mesh {
|
||||
/**
|
||||
*
|
||||
* 构造一个文本对象,8位点(中心点下面)在0点
|
||||
* @param {string} str 数字字符串
|
||||
* @param {number} height 文本高度
|
||||
* @memberof DbText
|
||||
*/
|
||||
constructor(str: string, height: number = 5) {
|
||||
let font = FontLoaderUtil.Load();
|
||||
export class DbText extends Mesh
|
||||
{
|
||||
/**
|
||||
*
|
||||
* 构造一个文本对象,8位点(中心点下面)在0点
|
||||
* @param {string} str 数字字符串
|
||||
* @param {number} height 文本高度
|
||||
* @memberof DbText
|
||||
*/
|
||||
constructor(str: string, height: number = 5)
|
||||
{
|
||||
let font = FontLoaderUtil.Load();
|
||||
|
||||
let shapes: THREE.Shape[] = font.generateShapes(str, height, 0.1);
|
||||
let geometry = new ShapeGeometry(shapes);
|
||||
let shapes: Shape[] = font.generateShapes(str, height);
|
||||
let geometry = new ShapeGeometry(shapes);
|
||||
|
||||
geometry.computeBoundingBox();
|
||||
geometry.computeBoundingBox();
|
||||
|
||||
super(geometry, ColorMaterial.GetLineMaterial(5));
|
||||
super(geometry, ColorMaterial.GetBasicMaterial(5));
|
||||
|
||||
let center = geometry.boundingBox.getCenter(new Vector3());
|
||||
this.applyMatrix(MoveMatrix(new Vector3(-center.x, 0, 0)));
|
||||
}
|
||||
let center = geometry.boundingBox.getCenter(new Vector3());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -71,32 +71,8 @@ export class ThreeBSP
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
} else if (typeof THREE.Face4)
|
||||
{
|
||||
vertex = geometry.vertices[face.a];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[0].x, faceVertexUvs[0].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[0], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
|
||||
vertex = geometry.vertices[face.b];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[1].x, faceVertexUvs[1].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[1], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
|
||||
vertex = geometry.vertices[face.c];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[2].x, faceVertexUvs[2].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
|
||||
vertex = geometry.vertices[face.d];
|
||||
uvs = faceVertexUvs ? new THREE.Vector2(faceVertexUvs[3].x, faceVertexUvs[3].y) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[3], uvs);
|
||||
vertex.applyMatrix4(this.matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
throw 'Invalid face type at index ' + i;
|
||||
}
|
||||
|
40
src/Utils.ts
40
src/Utils.ts
@ -1,17 +1,35 @@
|
||||
import { Viewer, createTemplateBoard, createEdge, DrawDimension } from ".";
|
||||
import { Geometry } from "three";
|
||||
import { Object3D, Vector3 } from "three";
|
||||
import { DrawDimension, Viewer, createTemplateBoard } from ".";
|
||||
|
||||
export function LoadBoard(view: Viewer, data: any[])
|
||||
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)
|
||||
{
|
||||
view.m_Scene.children.forEach(obj =>
|
||||
{
|
||||
let geo = obj["geometry"] as Geometry;
|
||||
if (geo) geo.dispose();
|
||||
})
|
||||
view.m_Scene.children.length = 0;
|
||||
//@ts-ignore
|
||||
if (m.geometry)
|
||||
//@ts-ignore
|
||||
m.geometry.dispose();
|
||||
|
||||
m.children.forEach(o => dispose(o));
|
||||
}
|
||||
|
||||
export function LoadBoard(view: Viewer, data: any[], clear: boolean = true)
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
dispose(view.m_Scene);
|
||||
view.m_Scene.children.length = 0;
|
||||
}
|
||||
|
||||
if (data.length === 0) return;
|
||||
//加板
|
||||
let { meshs, edgesa } = createTemplateBoard(data);
|
||||
let { meshs, edgesa, relations } = createTemplateBoard(data, view._Settings.boardMaterial);
|
||||
|
||||
//加标注
|
||||
let dims = DrawDimension(meshs);
|
||||
|
||||
@ -22,4 +40,6 @@ export function LoadBoard(view: Viewer, data: any[])
|
||||
view.ViewToSwiso();
|
||||
view.ZoomAll();
|
||||
view.Zoom(1.1);
|
||||
|
||||
return relations;
|
||||
}
|
||||
|
197
src/ViewSrc/data.json
Normal file
197
src/ViewSrc/data.json
Normal file
@ -0,0 +1,197 @@
|
||||
[
|
||||
{
|
||||
"DataID": 3996018,
|
||||
"OrderNo": 20230727027642,
|
||||
"L": 800,
|
||||
"W": 600,
|
||||
"H": 18,
|
||||
"BoardName": "层板",
|
||||
"Grain": 0,
|
||||
"BoardType": 0,
|
||||
"CustomNumber": "",
|
||||
"BasePoint": {
|
||||
"x": 1877.02062480031,
|
||||
"y": -1.77635683940025e-13,
|
||||
"z": 823.651271182857
|
||||
},
|
||||
"XVec": {
|
||||
"x": 2.22044604925031e-16,
|
||||
"y": 1,
|
||||
"z": 0
|
||||
},
|
||||
"YVec": {
|
||||
"x": -1,
|
||||
"y": 2.22044604925031e-16,
|
||||
"z": 0
|
||||
},
|
||||
"ZVec": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"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": {
|
||||
"x": 1,
|
||||
"y": 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,
|
||||
"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": 50,
|
||||
"y": 600,
|
||||
"r": 5,
|
||||
"h": 13.5,
|
||||
"f": 0
|
||||
},
|
||||
{
|
||||
"x": 300,
|
||||
"y": 600,
|
||||
"r": 5,
|
||||
"h": 13.5,
|
||||
"f": 0
|
||||
},
|
||||
{
|
||||
"x": 550,
|
||||
"y": 600,
|
||||
"r": 5,
|
||||
"h": 13.5,
|
||||
"f": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
104
src/ViewSrc/index.ts
Normal file
104
src/ViewSrc/index.ts
Normal file
@ -0,0 +1,104 @@
|
||||
// import { Color, Face3, MeshBasicMaterial, Object3D, Vector2, Vector3 } from "three";
|
||||
// import "./style.css";
|
||||
import { Color, MeshBasicMaterial, Vector3 } from "three";
|
||||
import { GetBox } from "../GeUtils";
|
||||
import { LoadBoard } from "../Utils";
|
||||
import { Viewer } from "../Viewer";
|
||||
import data from "./data.json";
|
||||
|
||||
let btn = document.createElement("button");
|
||||
btn.innerHTML = "载入";
|
||||
document.body.appendChild(btn);
|
||||
|
||||
let btn2 = document.createElement("button");
|
||||
btn2.innerHTML = "清理";
|
||||
document.body.appendChild(btn2);
|
||||
|
||||
let btn3 = document.createElement("button");
|
||||
btn3.innerHTML = "爆炸图";
|
||||
document.body.appendChild(btn3);
|
||||
|
||||
let el = document.createElement("canvas");
|
||||
|
||||
el.style.width = "100%";
|
||||
el.style.height = "80vh";
|
||||
document.body.appendChild(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 个触摸点时的触发状态.
|
||||
// view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan];
|
||||
//例如,修改单指滑动为平移.
|
||||
// view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Pan, CameraControlState.Scale, CameraControlState.Rotate];
|
||||
|
||||
//加载
|
||||
btn.onclick = () =>
|
||||
{
|
||||
console.time();
|
||||
for (let i = 0; i < 1; i++)
|
||||
LoadBoard(view, data);
|
||||
console.timeEnd();
|
||||
};
|
||||
|
||||
btn2.onclick = () =>
|
||||
{
|
||||
// LoadBoard(view, []);
|
||||
};
|
||||
|
||||
btn3.onclick = () =>
|
||||
{
|
||||
let box = GetBox(view.m_Scene);
|
||||
|
||||
let cen = box.getCenter(new Vector3());
|
||||
let m = [];
|
||||
for (let obj of view.m_Scene.children)
|
||||
{
|
||||
if (obj.userData && obj.userData instanceof Vector3)
|
||||
{
|
||||
let objCen = GetBox(obj).getCenter(new Vector3());
|
||||
|
||||
let v = objCen.clone().sub(cen);
|
||||
|
||||
let zv = obj.userData as Vector3;
|
||||
if (zv instanceof Vector3)
|
||||
{
|
||||
let d = zv.dot(v);
|
||||
// m.set(obj, zv.clone().multiplyScalar(d));
|
||||
m.push([obj, zv.clone().multiplyScalar(d)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let count = 0;
|
||||
|
||||
let t = setInterval(() =>
|
||||
{
|
||||
for (let [o, v] of m)
|
||||
{
|
||||
o.position.add(
|
||||
v.clone().multiplyScalar(1.5 / 120)
|
||||
);
|
||||
o.updateMatrix();
|
||||
}
|
||||
|
||||
view.ZoomAll();
|
||||
|
||||
view.m_bNeedUpdate = true;
|
||||
|
||||
count++;
|
||||
|
||||
if (count === 60)
|
||||
clearInterval(t);
|
||||
}, 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;
|
||||
}
|
159
src/Viewer.ts
159
src/Viewer.ts
@ -1,71 +1,80 @@
|
||||
|
||||
import * as THREE from "three";
|
||||
import { Mesh, MeshBasicMaterial, Raycaster, Scene, Vector3, WebGLRenderer, type WebGLRendererParameters } from "three";
|
||||
import { CameraControls, PointPick, boardMaterial, selectMaterial } from ".";
|
||||
import { CameraUpdate } from "./CameraUpdate";
|
||||
import { ColorMaterial } from "./ColorPalette";
|
||||
import { GetBox, GetBoxArr, cZeroVec } from "./GeUtils";
|
||||
import { PlaneExt } from "./PlaneExt";
|
||||
import { PointPick, boardMaterial, CameraControls } from ".";
|
||||
import { MeshBasicMaterial, Color, Mesh } from "three";
|
||||
|
||||
export class ViewerSettings
|
||||
{
|
||||
boardMaterial: MeshBasicMaterial = boardMaterial;
|
||||
selectMaterial: MeshBasicMaterial = selectMaterial;
|
||||
selectByPointCallback: (meshId: number) => void = () => { };
|
||||
}
|
||||
|
||||
export class Viewer
|
||||
{
|
||||
m_LookTarget: any;
|
||||
m_Camera: CameraUpdate = new CameraUpdate();
|
||||
m_CameraCtrl: CameraControls;
|
||||
m_bNeedUpdate: boolean = true;
|
||||
m_Render: THREE.WebGLRenderer;//渲染器 //暂时只用这个类型
|
||||
m_Render: WebGLRenderer;//渲染器 //暂时只用这个类型
|
||||
m_DomEl: HTMLElement; //画布容器
|
||||
|
||||
_Height: number;
|
||||
_Width: number;
|
||||
_Height: number = 0;
|
||||
_Width: number = 0;
|
||||
|
||||
m_Scene: THREE.Scene = new THREE.Scene();
|
||||
m_Scene: Scene = new Scene();
|
||||
|
||||
//构造
|
||||
constructor(canvasContainer: HTMLElement)
|
||||
_Settings = new ViewerSettings();
|
||||
/**
|
||||
*
|
||||
* @param {HTMLElement} canvasContainer 可以传入一个div或者一个画布
|
||||
* @memberof Viewer
|
||||
*/
|
||||
constructor(canvasContainer: HTMLElement, setupAction: (settings: ViewerSettings) => void = null)
|
||||
{
|
||||
if (setupAction)
|
||||
{
|
||||
setupAction(this._Settings);
|
||||
}
|
||||
|
||||
this.m_DomEl = canvasContainer;
|
||||
this.initRender(canvasContainer);
|
||||
this.OnSize();
|
||||
this.StartRender();
|
||||
new CameraControls(this);
|
||||
this.m_CameraCtrl = new CameraControls(this);
|
||||
window.addEventListener("resize", () =>
|
||||
{
|
||||
this.OnSize();
|
||||
});
|
||||
|
||||
//选中
|
||||
let selectMaterial = new MeshBasicMaterial({ color: new Color(0.1, 0.5, 0.5) });
|
||||
|
||||
let oldMesh: Mesh;
|
||||
this.m_Render.domElement.addEventListener("mousemove", (e: MouseEvent) =>
|
||||
{
|
||||
let mesh = PointPick(this, e.offsetX, e.offsetY);
|
||||
if (oldMesh)
|
||||
oldMesh.material = boardMaterial;
|
||||
if (mesh)
|
||||
{
|
||||
oldMesh = mesh;
|
||||
mesh.material = selectMaterial;
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
})
|
||||
this.SelectByPoint(e.offsetX, e.offsetY);
|
||||
});
|
||||
}
|
||||
|
||||
//初始化render
|
||||
initRender(canvasContainer: HTMLElement)
|
||||
{
|
||||
this.m_Render = new THREE.WebGLRenderer(
|
||||
{
|
||||
antialias: true,//antialias:true/false是否开启反锯齿
|
||||
precision: "highp",//precision:highp/mediump/lowp着色精度选择
|
||||
alpha: true,//alpha:true/false是否可以设置背景色透明
|
||||
// premultipliedAlpha: false,//?
|
||||
// stencil: false,//?
|
||||
// preserveDrawingBuffer: true,//preserveDrawingBuffer:true/false是否保存绘图缓冲
|
||||
// maxLights: 1//maxLights:最大灯光数
|
||||
}
|
||||
);
|
||||
//加到画布
|
||||
canvasContainer.appendChild(this.m_Render.domElement);
|
||||
let params: WebGLRendererParameters = {
|
||||
antialias: true,//antialias:true/false是否开启反锯齿
|
||||
precision: "highp",//precision:highp/mediump/lowp着色精度选择
|
||||
alpha: true//alpha:true/false是否可以设置背景色透明
|
||||
};
|
||||
if (canvasContainer instanceof HTMLCanvasElement)
|
||||
{
|
||||
params.canvas = canvasContainer;
|
||||
this.m_Render = new WebGLRenderer(params);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Render = new WebGLRenderer(params);
|
||||
//加到画布
|
||||
canvasContainer.appendChild(this.m_Render.domElement);
|
||||
}
|
||||
|
||||
this.m_Render.autoClear = true;
|
||||
|
||||
@ -73,7 +82,7 @@ export class Viewer
|
||||
// this.m_Render.gammaInput = true;
|
||||
// this.m_Render.gammaOutput = true;
|
||||
// this.m_Render.shadowMap.enabled = true;
|
||||
// this.m_Render.toneMapping = THREE.ReinhardToneMapping;
|
||||
// this.m_Render.toneMapping = ReinhardToneMapping;
|
||||
//设置设备像素比。 这通常用于HiDPI设备,以防止模糊输出画布。
|
||||
this.m_Render.setPixelRatio(window.devicePixelRatio);
|
||||
this.m_Render.physicallyCorrectLights = true;
|
||||
@ -88,8 +97,8 @@ export class Viewer
|
||||
|
||||
OnSize = (width?, height?) =>
|
||||
{
|
||||
this._Width = width ? width : this.m_DomEl.scrollWidth;
|
||||
this._Height = height ? height : this.m_DomEl.scrollHeight;
|
||||
this._Width = width ? width : this.m_DomEl.clientWidth;
|
||||
this._Height = height ? height : this.m_DomEl.clientHeight;
|
||||
|
||||
//校验.成为2的倍数 避免外轮廓错误.
|
||||
if (this._Width % 2 == 1)
|
||||
@ -99,7 +108,7 @@ export class Viewer
|
||||
|
||||
this.m_Render.setSize(this._Width, this._Height);
|
||||
this.m_Camera.SetSize(this._Width, this._Height);
|
||||
}
|
||||
};
|
||||
|
||||
StartRender = () =>
|
||||
{
|
||||
@ -109,17 +118,17 @@ export class Viewer
|
||||
this.Render();
|
||||
this.m_bNeedUpdate = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
Render()
|
||||
{
|
||||
this.m_Render.render(this.m_Scene, this.m_Camera.Camera);
|
||||
}
|
||||
|
||||
ScreenToWorld(pt: THREE.Vector3, planVec?: THREE.Vector3)
|
||||
ScreenToWorld(pt: Vector3, planVec?: Vector3)
|
||||
{
|
||||
//变换和求交点
|
||||
let plan = new PlaneExt(planVec || new THREE.Vector3(0, 0, 1));
|
||||
let raycaster = new THREE.Raycaster();
|
||||
let plan = new PlaneExt(planVec || new Vector3(0, 0, 1));
|
||||
let raycaster = new Raycaster();
|
||||
// 射线从相机射线向屏幕点位置
|
||||
raycaster.setFromCamera(
|
||||
{
|
||||
@ -127,10 +136,10 @@ export class Viewer
|
||||
y: - (pt.y / this._Height) * 2 + 1
|
||||
}
|
||||
, this.m_Camera.Camera
|
||||
)
|
||||
);
|
||||
plan.intersectRay(raycaster.ray, pt, true);
|
||||
}
|
||||
WorldToScreen(pt: THREE.Vector3)
|
||||
WorldToScreen(pt: Vector3)
|
||||
{
|
||||
let widthHalf = this._Width * 0.5;
|
||||
let heightHalf = this._Height * 0.5;
|
||||
@ -143,7 +152,7 @@ export class Viewer
|
||||
|
||||
/**
|
||||
* 更新视角观测目标(物体中心)
|
||||
*
|
||||
*
|
||||
* @memberof Viewer
|
||||
*/
|
||||
UpdateLockTarget()
|
||||
@ -151,21 +160,21 @@ export class Viewer
|
||||
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 THREE.Vector3());
|
||||
this.m_LookTarget = box.getCenter(new Vector3());
|
||||
else
|
||||
this.m_LookTarget = cZeroVec;
|
||||
}
|
||||
Rotate(mouseMove: THREE.Vector3)
|
||||
Rotate(mouseMove: Vector3)
|
||||
{
|
||||
this.m_Camera.Rotate(mouseMove, this.m_LookTarget);
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
Pan(mouseMove: THREE.Vector3)
|
||||
Pan(mouseMove: Vector3)
|
||||
{
|
||||
this.m_Camera.Pan(mouseMove);
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
Zoom(scale: number, center?: THREE.Vector3)
|
||||
Zoom(scale: number, center?: Vector3)
|
||||
{
|
||||
this.m_Camera.Zoom(scale, center);
|
||||
this.m_bNeedUpdate = true;
|
||||
@ -178,17 +187,57 @@ export class Viewer
|
||||
|
||||
ViewToTop()
|
||||
{
|
||||
this.m_Camera.LookAt(new THREE.Vector3(0, 0, -1));
|
||||
this.m_Camera.LookAt(new Vector3(0, 0, -1));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
ViewToFront()
|
||||
{
|
||||
this.m_Camera.LookAt(new THREE.Vector3(0, 1, 0));
|
||||
this.m_Camera.LookAt(new Vector3(0, 1, 0));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
ViewToSwiso()
|
||||
{
|
||||
this.m_Camera.LookAt(new THREE.Vector3(1, 1, -1));
|
||||
this.m_Camera.LookAt(new Vector3(1, 1, -1));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
|
||||
oldMesh: Mesh;
|
||||
SelectByPoint(x: number, y: number)
|
||||
{
|
||||
let mesh = PointPick(this, x, y);
|
||||
if (this.oldMesh)
|
||||
this.oldMesh.material = this._Settings.boardMaterial;
|
||||
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
|
||||
{
|
||||
this.oldMesh = mesh;
|
||||
mesh.material = this._Settings.selectMaterial;
|
||||
if (this._Settings.selectByPointCallback)
|
||||
{
|
||||
this._Settings.selectByPointCallback(mesh.id);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,22 @@
|
||||
import * as THREE from 'three';
|
||||
import { Geometry, LineSegments, Vector2 } from 'three';
|
||||
import { EdgesGeometry, Geometry, LineSegments, MeshBasicMaterial, Shape, Vector2 } from 'three';
|
||||
import { polar } from './GeUtils';
|
||||
import { boardMaterial, edgeMaterial } from './Material';
|
||||
import { RotateUVs } from './RotateUV';
|
||||
import { ThreeBSP } from './ThreeCSG';
|
||||
import { edgeMaterial } from './Material';
|
||||
import { SimpleBoard } from './SimpleBoard';
|
||||
//解析二维圆弧类.
|
||||
export class Arc2d
|
||||
{
|
||||
m_StartAn: number;
|
||||
m_EndAn: number;
|
||||
m_StartPoint: THREE.Vector2;
|
||||
m_EndPoint: THREE.Vector2;
|
||||
m_Center: THREE.Vector2;
|
||||
m_StartPoint: Vector2;
|
||||
m_EndPoint: Vector2;
|
||||
m_Center: Vector2;
|
||||
m_Radius: number;
|
||||
constructor(p1: THREE.Vector2, p2: THREE.Vector2, bul: number)
|
||||
constructor(p1: Vector2, p2: Vector2, bul: number)
|
||||
{
|
||||
this.m_StartPoint = p1.clone();
|
||||
this.m_EndPoint = p2.clone();
|
||||
|
||||
let vec: THREE.Vector2 = p2.clone().sub(p1);
|
||||
let vec: Vector2 = p2.clone().sub(p1);
|
||||
let len = vec.length();
|
||||
let an = vec.angle();
|
||||
this.m_Radius = len / Math.sin(2 * Math.atan(bul)) / 2;
|
||||
@ -43,10 +41,10 @@ export class Arc2d
|
||||
}
|
||||
}
|
||||
|
||||
//创建轮廓 通过点表和凸度
|
||||
export function createPath(pts: THREE.Vector2[], buls: number[], shapeOut?: THREE.Shape): THREE.Shape
|
||||
//创建轮廓 通过点表和凸度
|
||||
export function createPath(pts: Vector2[], buls: number[], shapeOut?: Shape): Shape
|
||||
{
|
||||
let shape = shapeOut || new THREE.Shape();
|
||||
let shape = shapeOut || new Shape();
|
||||
if (pts.length === 0) return shape;
|
||||
let firstPt = pts[0];
|
||||
|
||||
@ -56,7 +54,7 @@ export function createPath(pts: THREE.Vector2[], buls: number[], shapeOut?: THRE
|
||||
let nextPt = pts[i + 1];
|
||||
if (buls[i] == 0)
|
||||
{
|
||||
shape.lineTo(nextPt.x, nextPt.y)
|
||||
shape.lineTo(nextPt.x, nextPt.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -71,111 +69,39 @@ export function createPath(pts: THREE.Vector2[], buls: number[], shapeOut?: THRE
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
export function getVec(data: object): THREE.Vector3
|
||||
{
|
||||
return new THREE.Vector3(data["x"], data["y"], data["z"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//创建板件 暂时这么写
|
||||
export function createBoard(boardData: object)
|
||||
{
|
||||
let pts: THREE.Vector2[] = new Array();
|
||||
let buls: number[] = new Array();
|
||||
let boardPts = boardData["Pts"];
|
||||
let boardBuls = boardData["Buls"];
|
||||
|
||||
let boardHeight = boardData["H"];
|
||||
|
||||
let boardMat = new THREE.Matrix4();
|
||||
let matInv: THREE.Matrix4 = new THREE.Matrix4();
|
||||
//InitBoardMat
|
||||
{
|
||||
|
||||
let xD = getVec(boardData["XVec"]);
|
||||
let yD = getVec(boardData["YVec"]);
|
||||
let ZD = getVec(boardData["ZVec"]);
|
||||
let pBase = getVec(boardData["BasePoint"]);
|
||||
|
||||
boardMat.makeBasis(xD, yD, ZD);
|
||||
boardMat.setPosition(pBase);
|
||||
matInv.getInverse(boardMat, true);
|
||||
}
|
||||
|
||||
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 THREE.Vector2(pt.x, pt.y));
|
||||
buls.push(boardBuls[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
let length = boardData["L"];
|
||||
let width = boardData["W"];
|
||||
let height = boardData["H"];
|
||||
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 sp = createPath(pts, buls);
|
||||
let extrudeSettings = {
|
||||
steps: 1,
|
||||
bevelEnabled: false,
|
||||
amount: boardHeight
|
||||
};
|
||||
|
||||
let ext = new THREE.ExtrudeGeometry(sp, extrudeSettings) as Geometry;
|
||||
ext.computeBoundingSphere();
|
||||
ext.computeBoundingBox();
|
||||
ext.translate(0, 0, -boardHeight)
|
||||
ext.applyMatrix(boardMat);
|
||||
|
||||
//外边.
|
||||
let edges = [createEdge(ext)];
|
||||
//差集
|
||||
if (boardData["SubBoardLocal"].length > 0)
|
||||
{
|
||||
let subBoardList = boardData["SubBoardLocal"].map(d => createBoard(d));
|
||||
let thisCsg = new ThreeBSP(ext);
|
||||
|
||||
for (let br of subBoardList)
|
||||
{
|
||||
edges.push(...br.edges);
|
||||
let subCsg = new ThreeBSP(br.mesh);
|
||||
thisCsg = thisCsg.subtract(subCsg);
|
||||
}
|
||||
ext = thisCsg.toGeometry();
|
||||
}
|
||||
|
||||
if (boardData["BoardName"] === "地脚线")
|
||||
RotateUVs(ext);
|
||||
|
||||
let mesh = new THREE.Mesh(ext, boardMaterial);
|
||||
return { mesh, edges };
|
||||
}
|
||||
|
||||
export function createTemplateBoard(brDataList: any[])
|
||||
export function createTemplateBoard(brDataList: any[], material: MeshBasicMaterial)
|
||||
{
|
||||
let meshs = [];
|
||||
let edgesa = [];
|
||||
|
||||
let relations = {
|
||||
blockMeshMap: new Map<number, number>(),
|
||||
meshBlockMap: new Map<number, number>()
|
||||
};
|
||||
for (let d of brDataList)
|
||||
{
|
||||
let { mesh, edges } = createBoard(d);
|
||||
let board = new SimpleBoard(d);
|
||||
let { mesh, edges } = board.createBoard(material);
|
||||
meshs.push(mesh);
|
||||
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
|
||||
{
|
||||
let edge = new THREE.EdgesGeometry(geo, 1);
|
||||
let edge = new EdgesGeometry(geo, 1);
|
||||
return new LineSegments(edge, edgeMaterial);
|
||||
}
|
||||
|
550
src/data.ts
550
src/data.ts
@ -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
1
src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
@ -1,21 +1,33 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"outDir": "./dist",
|
||||
"target": "esnext",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
],
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"module": "commonjs",
|
||||
"sourceMap": true,
|
||||
"module": "ESNext",
|
||||
"target": "ES2020",
|
||||
"noLib": false,
|
||||
"skipLibCheck": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"verbatimModuleSyntax":true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"esModuleInterop": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
// "strict": true,
|
||||
// "noUnusedLocals": true,
|
||||
// "noUnusedParameters": true,
|
||||
// "noFallthroughCasesInSwitch": true,
|
||||
|
||||
"jsx": "react",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*"
|
||||
"./src/**/*",
|
||||
"./config/**/*"
|
||||
]
|
||||
}
|
||||
|
112
utils/copy_type.ts
Normal file
112
utils/copy_type.ts
Normal file
@ -0,0 +1,112 @@
|
||||
import * as path from 'path';
|
||||
import * as http from 'https';
|
||||
import * as fs from "fs";
|
||||
|
||||
//修正d.ts中类型定义出现错误的问题,临时修复,因为d.ts并不能完全快速的合并我们的类型修复PR.
|
||||
|
||||
/**
|
||||
* 下载文件到指定的文件地址
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} filePath
|
||||
*/
|
||||
function downLoadFile(url: string, filePath: string)
|
||||
{
|
||||
if (fs.existsSync(filePath))
|
||||
fs.unlinkSync(filePath);
|
||||
else
|
||||
fs.mkdirSync(path.dirname(filePath));
|
||||
let file = fs.createWriteStream(filePath);
|
||||
http.get(url, function (response)
|
||||
{
|
||||
response.pipe(file);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文件.
|
||||
*
|
||||
* @param {*} source 目标文件的地址
|
||||
* @param {*} targetFile 拷贝到新的地址
|
||||
*/
|
||||
function copyFileSync(source: string, targetFile: string)
|
||||
{
|
||||
//if target is a directory a new file with the same name will be created
|
||||
if (fs.existsSync(targetFile))
|
||||
{
|
||||
if (fs.lstatSync(targetFile).isDirectory())
|
||||
{
|
||||
targetFile = path.join(targetFile, path.basename(source));
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
||||
console.log('targetFile: ', targetFile);
|
||||
}
|
||||
|
||||
function copyFolderRecursiveSync(source, target)
|
||||
{
|
||||
let files = [];
|
||||
//check if folder needs to be created or integrated
|
||||
let targetFolder = path.join(target, path.basename(source));
|
||||
if (!fs.existsSync(targetFolder))
|
||||
{
|
||||
fs.mkdirSync(targetFolder);
|
||||
}
|
||||
//copy
|
||||
if (fs.lstatSync(source).isDirectory())
|
||||
{
|
||||
files = fs.readdirSync(source);
|
||||
files.forEach(function (file)
|
||||
{
|
||||
let curSource = path.join(source, file);
|
||||
if (fs.lstatSync(curSource).isDirectory())
|
||||
{
|
||||
copyFolderRecursiveSync(curSource, targetFolder);
|
||||
} else
|
||||
{
|
||||
copyFileSync(curSource, targetFolder);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// copyFolderRecursiveSync("./@types/", "./node_modules/");
|
||||
|
||||
function downloadTypes(downFiles)
|
||||
{
|
||||
let filePath = path.resolve("./node_modules/@types/" + downFiles.name) + "\\";
|
||||
console.log('filePath: ', filePath);
|
||||
for (let file of downFiles.files)
|
||||
{
|
||||
console.log(downFiles.urlPath + file);
|
||||
try
|
||||
{
|
||||
downLoadFile(downFiles.urlPath + file, filePath + file);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log('error: ', error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
downloadTypes({
|
||||
name: "three",
|
||||
urlPath: "https://gitee.com/BearCAD/DefinitelyType2/raw/master/three/",
|
||||
files: [
|
||||
// "index.d.ts",
|
||||
// "three-core.d.ts",
|
||||
// "three-outlinepass.d.ts",
|
||||
// "three-smaapass.d.ts"
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
downloadTypes({
|
||||
name: "jquery",
|
||||
urlPath: "https://gitee.com/BearCAD/DefinitelyType2/raw/master/jquery/",
|
||||
files: [
|
||||
"index.d.ts"
|
||||
]
|
||||
});
|
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);
|
||||
});
|
258
yarn.lock
Normal file
258
yarn.lock
Normal file
@ -0,0 +1,258 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@esbuild/android-arm64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.18.19.tgz#8735b552b8e0b9a943460d37fbc976b9d9cd4b4e"
|
||||
integrity sha512-4+jkUFQxZkQfQOOxfGVZB38YUWHMJX2ihZwF+2nh8m7bHdWXpixiurgGRN3c/KMSwlltbYI0/i929jwBRMFzbA==
|
||||
|
||||
"@esbuild/android-arm@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.18.19.tgz#efd1f33583a893c0cc57f25b1d081af8cdc6bfd9"
|
||||
integrity sha512-1uOoDurJYh5MNqPqpj3l/TQCI1V25BXgChEldCB7D6iryBYqYKrbZIhYO5AI9fulf66sM8UJpc3UcCly2Tv28w==
|
||||
|
||||
"@esbuild/android-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.18.19.tgz#d9f35722701a97a2ef69c7a84f1ee2aef2a306a7"
|
||||
integrity sha512-ae5sHYiP/Ogj2YNrLZbWkBmyHIDOhPgpkGvFnke7XFGQldBDWvc/AyYwSLpNuKw9UNkgnLlB/jPpnBmlF3G9Bg==
|
||||
|
||||
"@esbuild/darwin-arm64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.18.19.tgz#8cb81b971ee5231acc7de07225f6e18562c359e4"
|
||||
integrity sha512-HIpQvNQWFYROmWDANMRL+jZvvTQGOiTuwWBIuAsMaQrnStedM+nEKJBzKQ6bfT9RFKH2wZ+ej+DY7+9xHBTFPg==
|
||||
|
||||
"@esbuild/darwin-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.18.19.tgz#81024ab64232dd323f03796d449f018b59f04ca9"
|
||||
integrity sha512-m6JdvXJQt0thNLIcWOeG079h2ivhYH4B5sVCgqb/B29zTcFd7EE8/J1nIUHhdtwGeItdUeqKaqqb4towwxvglQ==
|
||||
|
||||
"@esbuild/freebsd-arm64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.19.tgz#9fa91e3b08d10c0adfa71b37372a7627b26e9686"
|
||||
integrity sha512-G0p4EFMPZhGn/xVNspUyMQbORH3nlKTV0bFNHPIwLraBuAkTeMyxNviTe0ZXUbIXQrR1lrwniFjNFU4s+x7veQ==
|
||||
|
||||
"@esbuild/freebsd-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.18.19.tgz#ef6f5a85c1bb029fb0076da5b223e50b353e615c"
|
||||
integrity sha512-hBxgRlG42+W+j/1/cvlnSa+3+OBKeDCyO7OG2ICya1YJaSCYfSpuG30KfOnQHI7Ytgu4bRqCgrYXxQEzy0zM5Q==
|
||||
|
||||
"@esbuild/linux-arm64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.18.19.tgz#0cef913dcdc1efb1bb04406a8e5f5668b721d89e"
|
||||
integrity sha512-X8g33tczY0GsJq3lhyBrjnFtaKjWVpp1gMq5IlF9BQJ3TUfSK74nQnz9mRIEejmcV+OIYn6bkOJeUaU1Knrljg==
|
||||
|
||||
"@esbuild/linux-arm@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.18.19.tgz#39ea874c8e5177b83903bec1883a43f3c163627a"
|
||||
integrity sha512-qtWyoQskfJlb9MD45mvzCEKeO4uCnDZ7lPFeNqbfaaJHqBiH9qA5Vu2EuckqYZuFMJWy1l4dxTf9NOulCVfUjg==
|
||||
|
||||
"@esbuild/linux-ia32@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.18.19.tgz#283cd3c3d8380e8fab90583fa86ca1fcc9b9ec57"
|
||||
integrity sha512-SAkRWJgb+KN+gOhmbiE6/wu23D6HRcGQi15cB13IVtBZZgXxygTV5GJlUAKLQ5Gcx0gtlmt+XIxEmSqA6sZTOw==
|
||||
|
||||
"@esbuild/linux-loong64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.18.19.tgz#1c69d7928a55b26326398d31d2ac9c82d2297f1b"
|
||||
integrity sha512-YLAslaO8NsB9UOxBchos82AOMRDbIAWChwDKfjlGrHSzS3v1kxce7dGlSTsrb0PJwo1KYccypN3VNjQVLtz7LA==
|
||||
|
||||
"@esbuild/linux-mips64el@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.18.19.tgz#b25b352e7645885fa1d01182116c506a78fe4733"
|
||||
integrity sha512-vSYFtlYds/oTI8aflEP65xo3MXChMwBOG1eWPGGKs/ev9zkTeXVvciU+nifq8J1JYMz+eQ4J9JDN0O2RKF8+1Q==
|
||||
|
||||
"@esbuild/linux-ppc64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.18.19.tgz#568b5a051f47af732c4314e697bb559a14b3d811"
|
||||
integrity sha512-tgG41lRVwlzqO9tv9l7aXYVw35BxKXLtPam1qALScwSqPivI8hjkZLNH0deaaSCYCFT9cBIdB+hUjWFlFFLL9A==
|
||||
|
||||
"@esbuild/linux-riscv64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.18.19.tgz#020729b47ca63321667297d1610bab81cd08a65c"
|
||||
integrity sha512-EgBZFLoN1S5RuB4cCJI31pBPsjE1nZ+3+fHRjguq9Ibrzo29bOLSBcH1KZJvRNh5qtd+fcYIGiIUia8Jw5r1lQ==
|
||||
|
||||
"@esbuild/linux-s390x@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.18.19.tgz#ed5cca8dac130d2f736914f9efad5fa15c238c20"
|
||||
integrity sha512-q1V1rtHRojAzjSigZEqrcLkpfh5K09ShCoIsdTakozVBnM5rgV58PLFticqDp5UJ9uE0HScov9QNbbl8HBo6QQ==
|
||||
|
||||
"@esbuild/linux-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.18.19.tgz#f8023a38ae02b46c60a134ccbc7ae377b3bec66f"
|
||||
integrity sha512-D0IiYjpZRXxGZLQfsydeAD7ZWqdGyFLBj5f2UshJpy09WPs3qizDCsEr8zyzcym6Woj/UI9ZzMIXwvoXVtyt0A==
|
||||
|
||||
"@esbuild/netbsd-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.18.19.tgz#8fd667c535db0a5b346afa2d74ff1fb53477427f"
|
||||
integrity sha512-3tt3SOS8L3D54R8oER41UdDshlBIAjYhdWRPiZCTZ1E41+shIZBpTjaW5UaN/jD1ENE/Ok5lkeqhoNMbxstyxw==
|
||||
|
||||
"@esbuild/openbsd-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.18.19.tgz#354d5b54a6bffa381cb513e878880192e07004be"
|
||||
integrity sha512-MxbhcuAYQPlfln1EMc4T26OUoeg/YQc6wNoEV8xvktDKZhLtBxjkoeESSo9BbPaGKhAPzusXYj5n8n5A8iZSrA==
|
||||
|
||||
"@esbuild/sunos-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.18.19.tgz#e2de98bd961e04f76f6acf5970263efc7051def5"
|
||||
integrity sha512-m0/UOq1wj25JpWqOJxoWBRM9VWc3c32xiNzd+ERlYstUZ6uwx5SZsQUtkiFHaYmcaoj+f6+Tfcl7atuAz3idwQ==
|
||||
|
||||
"@esbuild/win32-arm64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.18.19.tgz#9dca55f0dcbbdb50bf36353d1114f5f71c269275"
|
||||
integrity sha512-L4vb6pcoB1cEcXUHU6EPnUhUc4+/tcz4OqlXTWPcSQWxegfmcOprhmIleKKwmMNQVc4wrx/+jB7tGkjjDmiupg==
|
||||
|
||||
"@esbuild/win32-ia32@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.18.19.tgz#db6ea4467e87e6d3fc2177dea35e81f26f7a061d"
|
||||
integrity sha512-rQng7LXSKdrDlNDb7/v0fujob6X0GAazoK/IPd9C3oShr642ri8uIBkgM37/l8B3Rd5sBQcqUXoDdEy75XC/jg==
|
||||
|
||||
"@esbuild/win32-x64@0.18.19":
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.18.19.tgz#6105755d7097e0d7e22f893c3e62f143d8137bd0"
|
||||
integrity sha512-z69jhyG20Gq4QL5JKPLqUT+eREuqnDAFItLbza4JCmpvUnIlY73YNjd5djlO7kBiiZnvTnJuAbOjIoZIOa1GjA==
|
||||
|
||||
"@jscad/modeling@^2.11.0":
|
||||
version "2.12.0"
|
||||
resolved "https://registry.npmmirror.com/@jscad/modeling/-/modeling-2.12.0.tgz#66cdc08316a5c8a922e9f29f8339bf4d64a454f7"
|
||||
integrity sha512-TeAGX4QPEX+sBfeTMa04HwGL+lpdirqXt9JJKYi0r+UGgcwlsCtOs7dS23WGEAGu5QZgGNF4NJsr9DRPIWoaDQ==
|
||||
|
||||
"@types/node@^13.13.52":
|
||||
version "13.13.52"
|
||||
resolved "https://registry.npmmirror.com/@types/node/-/node-13.13.52.tgz#03c13be70b9031baaed79481c0c0cfb0045e53f7"
|
||||
integrity sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==
|
||||
|
||||
"@types/three@^0.103.2":
|
||||
version "0.103.2"
|
||||
resolved "https://registry.npmmirror.com/@types/three/-/three-0.103.2.tgz#f7d49130001c551941a0ded757def810579aafc4"
|
||||
integrity sha512-zhtf0Qs5wLJpIn1+VWCpzSgpKayj/GSWZ6woiuz09FW59KEDeLpnBkYz6lbblVpRmGdlnG8nd0unaASshOvcXw==
|
||||
dependencies:
|
||||
three "*"
|
||||
|
||||
esbuild@^0.18.10:
|
||||
version "0.18.19"
|
||||
resolved "https://registry.npmmirror.com/esbuild/-/esbuild-0.18.19.tgz#c763ccfd50b7b1322d13232cd91f2bd36ffde56b"
|
||||
integrity sha512-ra3CaIKCzJp5bU5BDfrCc0FRqKj71fQi+gbld0aj6lN0ifuX2fWJYPgLVLGwPfA+ruKna+OWwOvf/yHj6n+i0g==
|
||||
optionalDependencies:
|
||||
"@esbuild/android-arm" "0.18.19"
|
||||
"@esbuild/android-arm64" "0.18.19"
|
||||
"@esbuild/android-x64" "0.18.19"
|
||||
"@esbuild/darwin-arm64" "0.18.19"
|
||||
"@esbuild/darwin-x64" "0.18.19"
|
||||
"@esbuild/freebsd-arm64" "0.18.19"
|
||||
"@esbuild/freebsd-x64" "0.18.19"
|
||||
"@esbuild/linux-arm" "0.18.19"
|
||||
"@esbuild/linux-arm64" "0.18.19"
|
||||
"@esbuild/linux-ia32" "0.18.19"
|
||||
"@esbuild/linux-loong64" "0.18.19"
|
||||
"@esbuild/linux-mips64el" "0.18.19"
|
||||
"@esbuild/linux-ppc64" "0.18.19"
|
||||
"@esbuild/linux-riscv64" "0.18.19"
|
||||
"@esbuild/linux-s390x" "0.18.19"
|
||||
"@esbuild/linux-x64" "0.18.19"
|
||||
"@esbuild/netbsd-x64" "0.18.19"
|
||||
"@esbuild/openbsd-x64" "0.18.19"
|
||||
"@esbuild/sunos-x64" "0.18.19"
|
||||
"@esbuild/win32-arm64" "0.18.19"
|
||||
"@esbuild/win32-ia32" "0.18.19"
|
||||
"@esbuild/win32-x64" "0.18.19"
|
||||
|
||||
flatbush@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.npmmirror.com/flatbush/-/flatbush-3.3.0.tgz#b68c9149107ae86d2bce6373491f404ba4f4534e"
|
||||
integrity sha512-F3EzQvKpdmXUbFwWxLKBpytOFEGYQMCTBLuqZ4GEajFOEAvnOIBiyxW3OFSZXIOtpCS8teN6bFEpNZtnVXuDQA==
|
||||
dependencies:
|
||||
flatqueue "^1.2.0"
|
||||
|
||||
flatqueue@^1.2.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.npmmirror.com/flatqueue/-/flatqueue-1.2.1.tgz#82f501758fc5925742fbeb478637230456157ef2"
|
||||
integrity sha512-X86TpWS1rGuY7m382HuA9vngLeDuWA9lJvhEG+GfgKMV5onSvx5a71cl7GMbXzhWtlN9dGfqOBrpfqeOtUfGYQ==
|
||||
|
||||
fsevents@~2.3.2:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
|
||||
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
|
||||
|
||||
js-angusj-clipper@^1.2.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.npmmirror.com/js-angusj-clipper/-/js-angusj-clipper-1.3.1.tgz#433ad90228a2ade6df1a3befcf5892217bfd0832"
|
||||
integrity sha512-/qru4QXxN/gBbQjL4WaFl296YSM8kh5XKpNuNqfZhJ4t4Hw3KeLc5ERj3XHAeLi6pBrqeh6o9PFZUpS3QThEEQ==
|
||||
|
||||
nanoid@^3.3.6:
|
||||
version "3.3.6"
|
||||
resolved "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
|
||||
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
|
||||
|
||||
picocolors@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
|
||||
integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==
|
||||
|
||||
polylabel@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmmirror.com/polylabel/-/polylabel-1.1.0.tgz#9483e64fc7a12a49f43e07e7a06752214ed2a8e7"
|
||||
integrity sha512-bxaGcA40sL3d6M4hH72Z4NdLqxpXRsCFk8AITYg6x1rn1Ei3izf00UMLklerBZTO49aPA3CYrIwVulx2Bce2pA==
|
||||
dependencies:
|
||||
tinyqueue "^2.0.3"
|
||||
|
||||
postcss@^8.4.26:
|
||||
version "8.4.27"
|
||||
resolved "https://registry.npmmirror.com/postcss/-/postcss-8.4.27.tgz#234d7e4b72e34ba5a92c29636734349e0d9c3057"
|
||||
integrity sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==
|
||||
dependencies:
|
||||
nanoid "^3.3.6"
|
||||
picocolors "^1.0.0"
|
||||
source-map-js "^1.0.2"
|
||||
|
||||
rollup@^3.25.2:
|
||||
version "3.27.2"
|
||||
resolved "https://registry.npmmirror.com/rollup/-/rollup-3.27.2.tgz#59adc973504408289be89e5978e938ce852c9520"
|
||||
integrity sha512-YGwmHf7h2oUHkVBT248x0yt6vZkYQ3/rvE5iQuVBh3WO8GcJ6BNeOkpoX1yMHIiBm18EMLjBPIoUDkhgnyxGOQ==
|
||||
optionalDependencies:
|
||||
fsevents "~2.3.2"
|
||||
|
||||
source-map-js@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
|
||||
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
|
||||
|
||||
three@*:
|
||||
version "0.137.5"
|
||||
resolved "https://registry.npmmirror.com/three/-/three-0.137.5.tgz#a1e34bedd0412f2d8797112973dfadac78022ce6"
|
||||
integrity sha512-rTyr+HDFxjnN8+N/guZjDgfVxgHptZQpf6xfL/Mo7a5JYIFwK6tAq3bzxYYB4Ae0RosDZlDuP+X5aXDXz+XnHQ==
|
||||
|
||||
"three@npm:three-cf@0.122.5":
|
||||
version "0.122.5"
|
||||
resolved "https://registry.npmmirror.com/three-cf/-/three-cf-0.122.5.tgz#d5b5fdbce59aac870983b7dbf2b6f0b8efd008cb"
|
||||
integrity sha512-GBY8xE/f5AyDWiPqmCjU0xgR052C5IbfTzFfh/lIsIHTt5G9a5QtPzspimlW4Y6jUmyWlrqbxe/ycnY0bGhB/A==
|
||||
|
||||
tinyqueue@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.npmmirror.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08"
|
||||
integrity sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA==
|
||||
|
||||
typescript@^5.0.2:
|
||||
version "5.1.6"
|
||||
resolved "https://registry.npmmirror.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
|
||||
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
|
||||
|
||||
vite@^4.4.5:
|
||||
version "4.4.8"
|
||||
resolved "https://registry.npmmirror.com/vite/-/vite-4.4.8.tgz#31e4a438f8748695c68bd57ffd262ba93540fdf7"
|
||||
integrity sha512-LONawOUUjxQridNWGQlNizfKH89qPigK36XhMI7COMGztz8KNY0JHim7/xDd71CZwGT4HtSRgI7Hy+RlhG0Gvg==
|
||||
dependencies:
|
||||
esbuild "^0.18.10"
|
||||
postcss "^8.4.26"
|
||||
rollup "^3.25.2"
|
||||
optionalDependencies:
|
||||
fsevents "~2.3.2"
|
||||
|
||||
"webcad_ue4_api@http://gitea.cf/cx/webcad-ue4-api/archive/3.2.4.tar.gz":
|
||||
version "0.3.12"
|
||||
resolved "http://gitea.cf/cx/webcad-ue4-api/archive/3.2.4.tar.gz#c5901b2d85434f03f8128aa230fd3fe82fe63ab6"
|
||||
|
||||
xaop@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.npmmirror.com/xaop/-/xaop-2.1.0.tgz#1d7108c6e2f6bd459dc4f0f64296f0be3cc0f53d"
|
||||
integrity sha512-/ovWCaQIet3a3VnoVeN1/pNPqCrS/JifF28N7crPhq8BXEWx4Da2o+LYCCxnTWGAjGp5+2W2hd0HIpVESounSQ==
|
Loading…
Reference in New Issue
Block a user