10 Commits
1.0.0 ... 1.0.4

Author SHA1 Message Date
ChenX
2cd7f413da 更新版本号 2018-05-29 10:13:54 +08:00
ChenX
aed2217f2e 修正z轴为空的时候 判断错误的问题. 2018-05-29 10:13:37 +08:00
ChenX
98cd31e18c 保证格式统一. 2018-05-29 09:57:50 +08:00
ChenX
f138585a5c 更新版本号 2018-05-29 09:28:26 +08:00
ChenX
83207410ad 修正错误的判断 2018-05-29 09:27:09 +08:00
ChenX
28f91d7904 Merge branch 'master' of http://git.cf/cx/CADViewComponent 2018-05-29 09:26:04 +08:00
ChenX
10cc259261 对于空的pts 数组也支持 2018-05-29 09:26:01 +08:00
xf
cef0e8938b 更新包版本号 2018-05-29 09:25:45 +08:00
ChenX
3b032dfcad 更新支持无pts buls的数据, 支持无z轴的pts点表 2018-05-29 09:15:05 +08:00
xf
70e20e5a58 修复引用node_modules资源问题 2018-05-28 17:59:38 +08:00
9 changed files with 81 additions and 50 deletions

15
.vscode/settings.json vendored
View File

@@ -1,3 +1,16 @@
// 将设置放入此文件中以覆盖默认值和用户设置。
{
"editor.formatOnSave": true
"typescript.tsdk": "node_modules\\typescript\\lib",
//格式化设置
"editor.tabSize": 4,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
//格式设置
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.referencesCodeLens.enabled": true,
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"javascript.format.enable": true,
"files.insertFinalNewline": true,
"editor.detectIndentation": true,
}

2
dist/Text.js vendored
View File

@@ -6,7 +6,7 @@ const GeUtils_1 = require("./GeUtils");
class FontLoaderUtil {
static Load() {
if (!this.defFont) {
const f = require("../node_modules/three/examples/fonts/helvetiker_regular.typeface.json");
const f = require("../resources/fonts/helvetiker_regular.typeface.json");
let loader = new three_1.FontLoader();
this.defFont = loader.parse(f);
}

2
dist/Text.js.map vendored
View File

@@ -1 +1 @@
{"version":3,"file":"Text.js","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AI,CAAC,OAAO,EAAE;YACjB,MAAM,CAAC,GAAG,OAAO,CAAC,qDAAqD,CAAC,CAAC;YACzE,IAAI,MAAM,GAAG,IAAI,kBAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAChC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED,YAAoB,SAAQ,YAAI;IAC9B;;;;;;OAMG;IACH,YAAY,GAAW,EAAE,SAAiB,CAAC;QACzC,IAAI,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;QAEjC,IAAI,MAAM,GAAkB,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAClE,IAAI,QAAQ,GAAG,IAAI,qBAAa,CAAC,MAAM,CAAC,CAAC;QAEzC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAE9B,KAAK,CAAC,QAAQ,EAAE,4BAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAElD,IAAI,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,eAAO,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,WAAW,CAAC,oBAAU,CAAC,IAAI,eAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF;AArBD,wBAqBC"}

19
dist/createBoard.js vendored
View File

@@ -80,11 +80,20 @@ function createBoard(boardData) {
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]);
if (boardPts && boardPts.length !== 0)
for (let i = 0; i < boardPts.length; i++) {
let pt = getVec(boardPts[i]);
if (boardPts[i].z !== undefined)
pt.applyMatrix4(matInv);
pts.push(new THREE.Vector2(pt.x, pt.y));
buls.push(boardBuls[i]);
}
else {
let length = boardData["L"];
let width = boardData["W"];
let height = boardData["H"];
pts.push(new three_1.Vector2(0, 0), new three_1.Vector2(width, 0), new three_1.Vector2(width, length), new three_1.Vector2(0, length), new three_1.Vector2(0, 0));
buls.push(0, 0, 0, 0, 0);
}
let sp = createPath(pts, buls);
let extrudeSettings = {

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +1,13 @@
{
"name": "cadview",
"version": "1.0.0",
"version": "1.0.4",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc"
},
"author": "",
"author": "cx",
"license": "ISC",
"devDependencies": {
"@types/node": "^10.1.2",

File diff suppressed because one or more lines are too long

View File

@@ -2,44 +2,37 @@ import { Font, FontLoader, Mesh, ShapeGeometry, Vector3 } from "three";
import { ColorMaterial } from "./ColorPalette";
import { MoveMatrix } from "./GeUtils";
class FontLoaderUtil
{
private static defFont:Font;
static Load():Font
{
if(!this.defFont)
{
const f = require("../node_modules/three/examples/fonts/helvetiker_regular.typeface.json");
let loader = new FontLoader();
this.defFont = loader.parse(f);
}
return this.defFont;
class FontLoaderUtil {
private static defFont: Font;
static Load(): Font {
if (!this.defFont) {
const f = require("../resources/fonts/helvetiker_regular.typeface.json");
let loader = new FontLoader();
this.defFont = loader.parse(f);
}
return this.defFont;
}
}
export class DbText extends Mesh
{
/**
*
* 构造一个文本对象,8位点(中心点下面)在0点
* @param {string} str 数字字符串
* @param {number} height 文本高度
* @memberof DbText
*/
constructor(str:string,height:number = 5)
{
export class DbText extends Mesh {
/**
*
* 构造一个文本对象,8位点(中心点下面)在0点
* @param {string} str 数字字符串
* @param {number} height 文本高度
* @memberof DbText
*/
constructor(str: string, height: number = 5) {
let font = FontLoaderUtil.Load();
let font = FontLoaderUtil.Load();
let shapes: THREE.Shape[] = font.generateShapes(str, height, 0.1);
let geometry = new ShapeGeometry(shapes);
let shapes: THREE.Shape[] = font.generateShapes(str, height,0.1);
let geometry = new ShapeGeometry(shapes);
geometry.computeBoundingBox();
geometry.computeBoundingBox();
super(geometry, ColorMaterial.GetLineMaterial(5));
super(geometry,ColorMaterial.GetLineMaterial(5));
let center = geometry.boundingBox.getCenter(new Vector3());
this.applyMatrix(MoveMatrix(new Vector3(-center.x,0,0)));
}
let center = geometry.boundingBox.getCenter(new Vector3());
this.applyMatrix(MoveMatrix(new Vector3(-center.x, 0, 0)));
}
}

View File

@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { Geometry, LineSegments } from 'three';
import { Geometry, LineSegments, Vector2 } from 'three';
import { polar } from './GeUtils';
import { boardMaterial, edgeMaterial } from './Material';
import { RotateUVs } from './RotateUV';
@@ -101,12 +101,27 @@ export function createBoard(boardData: object)
matInv.getInverse(boardMat, true);
}
for (let i = 0; i < boardPts.length; i++)
if (boardPts && boardPts.length !== 0)
for (let i = 0; i < boardPts.length; i++)
{
let pt = getVec(boardPts[i]);
if (boardPts[i].z !== undefined)
pt.applyMatrix4(matInv);
pts.push(new THREE.Vector2(pt.x, pt.y));
buls.push(boardBuls[i]);
}
else
{
let pt = getVec(boardPts[i]);
pt.applyMatrix4(matInv);
pts.push(new THREE.Vector2(pt.x, pt.y));
buls.push(boardBuls[i]);
let length = boardData["L"];
let width = boardData["W"];
let height = boardData["H"];
pts.push(new Vector2(0, 0),
new Vector2(width, 0),
new Vector2(width, length),
new Vector2(0, length),
new Vector2(0, 0)
);
buls.push(0, 0, 0, 0, 0);
}
let sp = createPath(pts, buls);