修改配置
This commit is contained in:
parent
1e40bb624f
commit
0f41ff6562
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
||||
/node_modules
|
||||
/dist
|
||||
|
@ -1,2 +1,3 @@
|
||||
# 显示板件的控件
|
||||
|
||||
显示板件的控件,使用例子请参照项目:`CADViewSample`
|
||||
使用例子请参照项目:[CADViewSample](http://git.cf/cx/CADViewSample)
|
||||
|
45
dist/CameraControls.d.ts
vendored
Normal file
45
dist/CameraControls.d.ts
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
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
Normal file
205
dist/CameraControls.js
vendored
Normal file
@ -0,0 +1,205 @@
|
||||
"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
Normal file
1
dist/CameraControls.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
46
dist/CameraUpdate.d.ts
vendored
Normal file
46
dist/CameraUpdate.d.ts
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
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
Normal file
172
dist/CameraUpdate.js
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
"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
Normal file
1
dist/CameraUpdate.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7
dist/ColorPalette.d.ts
vendored
Normal file
7
dist/ColorPalette.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
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
Normal file
286
dist/ColorPalette.js
vendored
Normal file
@ -0,0 +1,286 @@
|
||||
"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
Normal file
1
dist/ColorPalette.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
11
dist/Dimension.d.ts
vendored
Normal file
11
dist/Dimension.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
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
Normal file
46
dist/Dimension.js
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"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.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AAM,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
Normal file
10
dist/DrawDimension.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { Mesh } from "three";
|
||||
import { Dimension } from ".";
|
||||
/**
|
||||
* 绘制标注实体
|
||||
*
|
||||
* @export
|
||||
* @param {Box3} box
|
||||
* @returns 标注实体列表
|
||||
*/
|
||||
export declare function DrawDimension(brList: Mesh[]): Dimension[];
|
32
dist/DrawDimension.js
vendored
Normal file
32
dist/DrawDimension.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"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
Normal file
1
dist/DrawDimension.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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,SAA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C,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
Normal file
66
dist/GeUtils.d.ts
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
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
Normal file
258
dist/GeUtils.js
vendored
Normal file
@ -0,0 +1,258 @@
|
||||
"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
Normal file
1
dist/GeUtils.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
149
dist/KeyEnum.d.ts
vendored
Normal file
149
dist/KeyEnum.d.ts
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
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
Normal file
161
dist/KeyEnum.js
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
"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
Normal file
1
dist/KeyEnum.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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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,+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
Normal file
3
dist/Material.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { MeshBasicMaterial, LineBasicMaterial } from "three";
|
||||
export declare let boardMaterial: MeshBasicMaterial;
|
||||
export declare let edgeMaterial: LineBasicMaterial;
|
13
dist/Material.js
vendored
Normal file
13
dist/Material.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"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
Normal file
1
dist/Material.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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
Normal file
7
dist/Matrix2.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
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
Normal file
30
dist/Matrix2.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
"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
Normal file
1
dist/Matrix2.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Matrix2.js","sourceRoot":"","sources":["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A8BC"}
|
38
dist/Orbit.d.ts
vendored
Normal file
38
dist/Orbit.d.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
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
Normal file
81
dist/Orbit.js
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
"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
Normal file
1
dist/Orbit.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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,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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
Normal file
7
dist/PlaneExt.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
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
Normal file
36
dist/PlaneExt.js
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
"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
Normal file
1
dist/PlaneExt.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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
Normal file
12
dist/PointPick.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
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
Normal file
38
dist/PointPick.js
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
"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
Normal file
1
dist/PointPick.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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
Normal file
2
dist/RotateUV.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as THREE from 'three';
|
||||
export declare function RotateUVs(geo: THREE.Geometry): void;
|
20
dist/RotateUV.js
vendored
Normal file
20
dist/RotateUV.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"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
Normal file
1
dist/RotateUV.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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
Normal file
11
dist/Text.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
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
Normal file
35
dist/Text.js
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
"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("../node_modules/three/examples/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
Normal file
1
dist/Text.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.ts"],"names":[],"mappings":";;AAAA,iCAAuE;AACvE,iDAA+C;AAC/C,uCAAuC;AAGvC;IAGI,MAAM,CAAC,IAAI;QAEP,IAAG,CAAC,IAAI,CAAC,OAAO,EAChB;YACI,MAAM,CAAC,GAAG,OAAO,CAAC,uEAAuE,CAAC,CAAC;YAC3F,IAAI,MAAM,GAAG,IAAI,kBAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAED,YAAoB,SAAQ,YAAI;IAE5B;;;;;;OAMG;IACH,YAAY,GAAU,EAAC,SAAgB,CAAC;QAGpC,IAAI,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;QAEjC,IAAI,MAAM,GAAkB,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAC,GAAG,CAAC,CAAC;QACjE,IAAI,QAAQ,GAAG,IAAI,qBAAa,CAAC,MAAM,CAAC,CAAC;QAEzC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAE9B,KAAK,CAAC,QAAQ,EAAC,4BAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjD,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,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACJ;AAxBD,wBAwBC"}
|
58
dist/ThreeCSG.d.ts
vendored
Normal file
58
dist/ThreeCSG.d.ts
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
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
Normal file
476
dist/ThreeCSG.js
vendored
Normal file
@ -0,0 +1,476 @@
|
||||
"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
Normal file
1
dist/ThreeCSG.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/Utils.d.ts
vendored
Normal file
2
dist/Utils.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { Viewer } from ".";
|
||||
export declare function LoadBoard(view: Viewer, data: any[]): void;
|
23
dist/Utils.js
vendored
Normal file
23
dist/Utils.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
"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
Normal file
1
dist/Utils.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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
Normal file
32
dist/Viewer.d.ts
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
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
Normal file
142
dist/Viewer.js
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
"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
Normal file
1
dist/Viewer.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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,O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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
Normal file
22
dist/createBoard.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
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;
|
135
dist/createBoard.js
vendored
Normal file
135
dist/createBoard.js
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
"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);
|
||||
}
|
||||
for (let i = 0; i < boardPts.length; i++) {
|
||||
let pt = getVec(boardPts[i]);
|
||||
pt.applyMatrix4(matInv);
|
||||
pts.push(new THREE.Vector2(pt.x, pt.y));
|
||||
buls.push(boardBuls[i]);
|
||||
}
|
||||
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
Normal file
1
dist/createBoard.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
75
dist/data.d.ts
vendored
Normal file
75
dist/data.d.ts
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
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
Normal file
552
dist/data.js
vendored
Normal file
@ -0,0 +1,552 @@
|
||||
"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
Normal file
1
dist/data.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
9
dist/index.d.ts
vendored
Normal file
9
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
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
Normal file
15
dist/index.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"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
Normal file
1
dist/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
6901
package-lock.json
generated
6901
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user