Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f138585a5c | ||
![]() |
83207410ad | ||
![]() |
28f91d7904 | ||
![]() |
10cc259261 | ||
![]() |
cef0e8938b | ||
![]() |
3b032dfcad | ||
![]() |
70e20e5a58 |
2
dist/Text.js
vendored
2
dist/Text.js
vendored
@@ -6,7 +6,7 @@ const GeUtils_1 = require("./GeUtils");
|
|||||||
class FontLoaderUtil {
|
class FontLoaderUtil {
|
||||||
static Load() {
|
static Load() {
|
||||||
if (!this.defFont) {
|
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();
|
let loader = new three_1.FontLoader();
|
||||||
this.defFont = loader.parse(f);
|
this.defFont = loader.parse(f);
|
||||||
}
|
}
|
||||||
|
2
dist/Text.js.map
vendored
2
dist/Text.js.map
vendored
@@ -1 +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,MA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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"}
|
9
dist/createBoard.js
vendored
9
dist/createBoard.js
vendored
@@ -80,12 +80,21 @@ function createBoard(boardData) {
|
|||||||
boardMat.setPosition(pBase);
|
boardMat.setPosition(pBase);
|
||||||
matInv.getInverse(boardMat, true);
|
matInv.getInverse(boardMat, true);
|
||||||
}
|
}
|
||||||
|
if (boardPts && boardPts.length !== 0)
|
||||||
for (let i = 0; i < boardPts.length; i++) {
|
for (let i = 0; i < boardPts.length; i++) {
|
||||||
let pt = getVec(boardPts[i]);
|
let pt = getVec(boardPts[i]);
|
||||||
|
if (pt.z !== undefined)
|
||||||
pt.applyMatrix4(matInv);
|
pt.applyMatrix4(matInv);
|
||||||
pts.push(new THREE.Vector2(pt.x, pt.y));
|
pts.push(new THREE.Vector2(pt.x, pt.y));
|
||||||
buls.push(boardBuls[i]);
|
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 sp = createPath(pts, buls);
|
||||||
let extrudeSettings = {
|
let extrudeSettings = {
|
||||||
steps: 1,
|
steps: 1,
|
||||||
|
2
dist/createBoard.js.map
vendored
2
dist/createBoard.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "cadview",
|
"name": "cadview",
|
||||||
"version": "1.0.0",
|
"version": "1.0.3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "cx",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^10.1.2",
|
"@types/node": "^10.1.2",
|
||||||
|
1
resources/fonts/helvetiker_regular.typeface.json
Normal file
1
resources/fonts/helvetiker_regular.typeface.json
Normal file
File diff suppressed because one or more lines are too long
19
src/Text.ts
19
src/Text.ts
@@ -2,15 +2,11 @@ import { Font, FontLoader, Mesh, ShapeGeometry, Vector3 } from "three";
|
|||||||
import { ColorMaterial } from "./ColorPalette";
|
import { ColorMaterial } from "./ColorPalette";
|
||||||
import { MoveMatrix } from "./GeUtils";
|
import { MoveMatrix } from "./GeUtils";
|
||||||
|
|
||||||
|
class FontLoaderUtil {
|
||||||
class FontLoaderUtil
|
|
||||||
{
|
|
||||||
private static defFont: Font;
|
private static defFont: Font;
|
||||||
static Load():Font
|
static Load(): Font {
|
||||||
{
|
if (!this.defFont) {
|
||||||
if(!this.defFont)
|
const f = require("../resources/fonts/helvetiker_regular.typeface.json");
|
||||||
{
|
|
||||||
const f = require("../node_modules/three/examples/fonts/helvetiker_regular.typeface.json");
|
|
||||||
let loader = new FontLoader();
|
let loader = new FontLoader();
|
||||||
this.defFont = loader.parse(f);
|
this.defFont = loader.parse(f);
|
||||||
}
|
}
|
||||||
@@ -18,8 +14,7 @@ class FontLoaderUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DbText extends Mesh
|
export class DbText extends Mesh {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 构造一个文本对象,8位点(中心点下面)在0点
|
* 构造一个文本对象,8位点(中心点下面)在0点
|
||||||
@@ -27,9 +22,7 @@ export class DbText extends Mesh
|
|||||||
* @param {number} height 文本高度
|
* @param {number} height 文本高度
|
||||||
* @memberof DbText
|
* @memberof DbText
|
||||||
*/
|
*/
|
||||||
constructor(str:string,height:number = 5)
|
constructor(str: string, height: number = 5) {
|
||||||
{
|
|
||||||
|
|
||||||
let font = FontLoaderUtil.Load();
|
let font = FontLoaderUtil.Load();
|
||||||
|
|
||||||
let shapes: THREE.Shape[] = font.generateShapes(str, height, 0.1);
|
let shapes: THREE.Shape[] = font.generateShapes(str, height, 0.1);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import { Geometry, LineSegments } from 'three';
|
import { Geometry, LineSegments, Vector2 } from 'three';
|
||||||
import { polar } from './GeUtils';
|
import { polar } from './GeUtils';
|
||||||
import { boardMaterial, edgeMaterial } from './Material';
|
import { boardMaterial, edgeMaterial } from './Material';
|
||||||
import { RotateUVs } from './RotateUV';
|
import { RotateUVs } from './RotateUV';
|
||||||
@@ -101,13 +101,28 @@ export function createBoard(boardData: object)
|
|||||||
matInv.getInverse(boardMat, true);
|
matInv.getInverse(boardMat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (boardPts && boardPts.length !== 0)
|
||||||
for (let i = 0; i < boardPts.length; i++)
|
for (let i = 0; i < boardPts.length; i++)
|
||||||
{
|
{
|
||||||
let pt = getVec(boardPts[i]);
|
let pt = getVec(boardPts[i]);
|
||||||
|
if (pt.z !== undefined)
|
||||||
pt.applyMatrix4(matInv);
|
pt.applyMatrix4(matInv);
|
||||||
pts.push(new THREE.Vector2(pt.x, pt.y));
|
pts.push(new THREE.Vector2(pt.x, pt.y));
|
||||||
buls.push(boardBuls[i]);
|
buls.push(boardBuls[i]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let length = boardData["L"];
|
||||||
|
let width = boardData["W"];
|
||||||
|
let height = boardData["H"];
|
||||||
|
pts.push(new Vector2(0, 0),
|
||||||
|
new Vector2(width, 0),
|
||||||
|
new Vector2(width, length),
|
||||||
|
new Vector2(0, length),
|
||||||
|
new Vector2(0, 0)
|
||||||
|
);
|
||||||
|
buls.push(0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
let sp = createPath(pts, buls);
|
let sp = createPath(pts, buls);
|
||||||
let extrudeSettings = {
|
let extrudeSettings = {
|
||||||
|
Reference in New Issue
Block a user