Compare commits
7 Commits
1.2.1
...
select-blo
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c586096fe0 | ||
![]() |
0aa70fdb14 | ||
![]() |
93ac737777 | ||
![]() |
01110a8858 | ||
![]() |
77f997b849 | ||
![]() |
23fa547a3a | ||
![]() |
e712b7b4e2 |
@ -2,26 +2,30 @@ import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
|
|||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||||
|
|
||||||
|
const TS_LOADER = [
|
||||||
|
{ loader: 'cache-loader', options: { cacheDirectory: "node_modules/.cache_loader" } },
|
||||||
|
{
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
transpileOnly: true,
|
||||||
|
experimentalWatchApi: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const config: webpack.Configuration = {
|
const config: webpack.Configuration = {
|
||||||
devtool: "source-map",
|
devtool: "source-map",
|
||||||
//项目需要解析的文件拓展名称
|
//项目需要解析的文件拓展名称
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".tsx", ".js", "json"]
|
extensions: [".ts", ".tsx", ".js", "json"]
|
||||||
},
|
},
|
||||||
externals: {
|
|
||||||
'three': "THREE"
|
|
||||||
},
|
|
||||||
//模块加载器设置
|
//模块加载器设置
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.tsx?$/,
|
test: /\.tsx?$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'ts-loader',
|
use: TS_LOADER,
|
||||||
options: {
|
|
||||||
transpileOnly: true,
|
|
||||||
experimentalWatchApi: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
||||||
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
||||||
|
@ -8,6 +8,9 @@ const config: webpack.Configuration = merge(
|
|||||||
{
|
{
|
||||||
mode: "production",
|
mode: "production",
|
||||||
entry: "./src/index.ts",
|
entry: "./src/index.ts",
|
||||||
|
externals: {
|
||||||
|
'three': "THREE"
|
||||||
|
},
|
||||||
//输出设置
|
//输出设置
|
||||||
output: {
|
output: {
|
||||||
filename: "cad.js",
|
filename: "cad.js",
|
||||||
|
@ -9,7 +9,7 @@ const config: webpack.Configuration = merge(
|
|||||||
mode: "development",
|
mode: "development",
|
||||||
entry: "./src/ViewSrc/index.ts",
|
entry: "./src/ViewSrc/index.ts",
|
||||||
output: { pathinfo: false },
|
output: { pathinfo: false },
|
||||||
devtool: "cheap-module-eval-source-map",
|
devtool: "eval-source-map",
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: "./dist/",
|
contentBase: "./dist/",
|
||||||
port: 7776,
|
port: 7776,
|
||||||
@ -26,6 +26,4 @@ const config: webpack.Configuration = merge(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
config.externals = {};
|
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
170
package-lock.json
generated
170
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cadview",
|
"name": "cadview",
|
||||||
"version": "1.2.0",
|
"version": "1.2.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -113,6 +113,12 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/json-schema": {
|
||||||
|
"version": "7.0.7",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/@types/json-schema/download/@types/json-schema-7.0.7.tgz?cache=0&sync_timestamp=1613378919536&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fjson-schema%2Fdownload%2F%40types%2Fjson-schema-7.0.7.tgz",
|
||||||
|
"integrity": "sha1-mKmTUWyFnrDVxMjwmDF6nqaNua0=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/mime": {
|
"@types/mime": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/@types/mime/download/@types/mime-2.0.1.tgz?cache=0&sync_timestamp=1588201894076&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fmime%2Fdownload%2F%40types%2Fmime-2.0.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/@types/mime/download/@types/mime-2.0.1.tgz?cache=0&sync_timestamp=1588201894076&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fmime%2Fdownload%2F%40types%2Fmime-2.0.1.tgz",
|
||||||
@ -1002,6 +1008,12 @@
|
|||||||
"integrity": "sha1-Uvq8xqYG0aADAoAmSO9o9jnaJow=",
|
"integrity": "sha1-Uvq8xqYG0aADAoAmSO9o9jnaJow=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"buffer-json": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/buffer-json/download/buffer-json-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-9z4TseQvGW/i/WfQAcfXEH7dfCM=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"buffer-xor": {
|
"buffer-xor": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
|
||||||
@ -1068,6 +1080,152 @@
|
|||||||
"unset-value": "^1.0.0"
|
"unset-value": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"cache-loader": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/cache-loader/download/cache-loader-4.1.0.tgz",
|
||||||
|
"integrity": "sha1-mUjK41OuwKH8ser9ojAIFuyFOH4=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"buffer-json": "^2.0.0",
|
||||||
|
"find-cache-dir": "^3.0.0",
|
||||||
|
"loader-utils": "^1.2.3",
|
||||||
|
"mkdirp": "^0.5.1",
|
||||||
|
"neo-async": "^2.6.1",
|
||||||
|
"schema-utils": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ajv": {
|
||||||
|
"version": "6.12.6",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/ajv/download/ajv-6.12.6.tgz",
|
||||||
|
"integrity": "sha1-uvWmLoArB9l3A0WG+MO69a3ybfQ=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"fast-deep-equal": "^3.1.1",
|
||||||
|
"fast-json-stable-stringify": "^2.0.0",
|
||||||
|
"json-schema-traverse": "^0.4.1",
|
||||||
|
"uri-js": "^4.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ajv-keywords": {
|
||||||
|
"version": "3.5.2",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/ajv-keywords/download/ajv-keywords-3.5.2.tgz?cache=0&sync_timestamp=1608059984992&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fajv-keywords%2Fdownload%2Fajv-keywords-3.5.2.tgz",
|
||||||
|
"integrity": "sha1-MfKdpatuANHC0yms97WSlhTVAU0=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"big.js": {
|
||||||
|
"version": "5.2.2",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/big.js/download/big.js-5.2.2.tgz",
|
||||||
|
"integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"emojis-list": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/emojis-list/download/emojis-list-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-VXBmIEatKeLpFucariYKvf9Pang=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"find-cache-dir": {
|
||||||
|
"version": "3.3.1",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.3.1.tgz",
|
||||||
|
"integrity": "sha1-ibM/rUpGcNqpT4Vff74x1thP6IA=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"commondir": "^1.0.1",
|
||||||
|
"make-dir": "^3.0.2",
|
||||||
|
"pkg-dir": "^4.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"find-up": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/find-up/download/find-up-4.1.0.tgz?cache=0&sync_timestamp=1597169884679&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffind-up%2Fdownload%2Ffind-up-4.1.0.tgz",
|
||||||
|
"integrity": "sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"locate-path": "^5.0.0",
|
||||||
|
"path-exists": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"json5": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/json5/download/json5-1.0.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjson5%2Fdownload%2Fjson5-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-d5+wAYYE+oVOrL9iUhgNg1Q+Pb4=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"minimist": "^1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loader-utils": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/loader-utils/download/loader-utils-1.4.0.tgz",
|
||||||
|
"integrity": "sha1-xXm140yzSxp07cbB+za/o3HVphM=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"big.js": "^5.2.2",
|
||||||
|
"emojis-list": "^3.0.0",
|
||||||
|
"json5": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"locate-path": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/locate-path/download/locate-path-5.0.0.tgz",
|
||||||
|
"integrity": "sha1-Gvujlq/WdqbUJQTQpno6frn2KqA=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"p-locate": "^4.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"make-dir": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/make-dir/download/make-dir-3.1.0.tgz",
|
||||||
|
"integrity": "sha1-QV6WcEazp/HRhSd9hKpYIDcmoT8=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"semver": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"p-locate": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/p-locate/download/p-locate-4.1.0.tgz",
|
||||||
|
"integrity": "sha1-o0KLtwiLOmApL2aRkni3wpetTwc=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"p-limit": "^2.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path-exists": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/path-exists/download/path-exists-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-UTvb4tO5XXdi6METfvoZXGxhtbM=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"pkg-dir": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/pkg-dir/download/pkg-dir-4.2.0.tgz?cache=0&sync_timestamp=1602859056682&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpkg-dir%2Fdownload%2Fpkg-dir-4.2.0.tgz",
|
||||||
|
"integrity": "sha1-8JkTPfft5CLoHR2ESCcO6z5CYfM=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"find-up": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schema-utils": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/schema-utils/download/schema-utils-2.7.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fschema-utils%2Fdownload%2Fschema-utils-2.7.1.tgz",
|
||||||
|
"integrity": "sha1-HKTzLRskxZDCA7jnpQvw6kzTlNc=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/json-schema": "^7.0.5",
|
||||||
|
"ajv": "^6.12.4",
|
||||||
|
"ajv-keywords": "^3.5.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"semver": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/semver/download/semver-6.3.0.tgz?cache=0&sync_timestamp=1606852064928&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-6.3.0.tgz",
|
||||||
|
"integrity": "sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"camel-case": {
|
"camel-case": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/camel-case/download/camel-case-4.1.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/camel-case/download/camel-case-4.1.1.tgz",
|
||||||
@ -2316,7 +2474,7 @@
|
|||||||
},
|
},
|
||||||
"for-in": {
|
"for-in": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "http://r.cnpmjs.org/for-in/download/for-in-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||||
"integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
|
"integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -5212,7 +5370,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"extend-shallow": {
|
"extend-shallow": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "http://r.cnpmjs.org/extend-shallow/download/extend-shallow-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
|
||||||
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
|
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -5797,9 +5955,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"three": {
|
"three": {
|
||||||
"version": "0.115.0",
|
"version": "0.120.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/three/download/three-0.115.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/three/download/three-0.120.1.tgz",
|
||||||
"integrity": "sha1-VA2ADDgbnaIzTAJPD75NI/hOsF4="
|
"integrity": "sha1-29iJT4q4fBCfFgKTPnx0DJgTc3c="
|
||||||
},
|
},
|
||||||
"through2": {
|
"through2": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cadview",
|
"name": "cadview",
|
||||||
"version": "1.2.0",
|
"version": "1.2.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"private": true,
|
"private": true,
|
||||||
@ -26,6 +26,7 @@
|
|||||||
"@types/webpack-env": "^1.15.2",
|
"@types/webpack-env": "^1.15.2",
|
||||||
"@types/webpack-merge": "^4.1.5",
|
"@types/webpack-merge": "^4.1.5",
|
||||||
"awesome-typescript-loader": "^5.2.1",
|
"awesome-typescript-loader": "^5.2.1",
|
||||||
|
"cache-loader": "^4.1.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^4.1.3",
|
"fork-ts-checker-webpack-plugin": "^4.1.3",
|
||||||
"hard-source-webpack-plugin": "^0.13.1",
|
"hard-source-webpack-plugin": "^0.13.1",
|
||||||
"html-webpack-plugin": "^4.2.1",
|
"html-webpack-plugin": "^4.2.1",
|
||||||
@ -39,7 +40,7 @@
|
|||||||
"webpack-merge": "^4.2.2"
|
"webpack-merge": "^4.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"three": "^0.115.0",
|
"three": "^0.120.1",
|
||||||
"wolfy87-eventemitter": "^5.2.9"
|
"wolfy87-eventemitter": "^5.2.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ export class CameraControls
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 窗体失去焦点时.
|
* 窗体失去焦点时.
|
||||||
*
|
|
||||||
* @memberof CameraControls
|
* @memberof CameraControls
|
||||||
*/
|
*/
|
||||||
onBlur = () =>
|
onBlur = () =>
|
||||||
@ -136,7 +135,7 @@ export class CameraControls
|
|||||||
|
|
||||||
//最后一次按中键的时间
|
//最后一次按中键的时间
|
||||||
lastMiddleClickTime = 0;
|
lastMiddleClickTime = 0;
|
||||||
//鼠标
|
//鼠标
|
||||||
onMouseDown = (event: MouseEvent) =>
|
onMouseDown = (event: MouseEvent) =>
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -220,12 +219,11 @@ export class CameraControls
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 鼠标滚轮事件
|
* 鼠标滚轮事件
|
||||||
*
|
*
|
||||||
* @memberof CameraControls
|
* @memberof CameraControls
|
||||||
*/
|
*/
|
||||||
onMouseWheel = (event: WheelEvent) =>
|
onMouseWheel = (event: WheelEvent) =>
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);
|
let pt = new THREE.Vector3(event.offsetX, event.offsetY, 0);
|
||||||
|
@ -30,7 +30,7 @@ export class DbText extends Mesh
|
|||||||
{
|
{
|
||||||
let font = FontLoaderUtil.Load();
|
let font = FontLoaderUtil.Load();
|
||||||
|
|
||||||
let shapes: THREE.Shape[] = font.generateShapes(str, height);
|
let shapes: Shape[] = font.generateShapes(str, height);
|
||||||
let geometry = new ShapeGeometry(shapes);
|
let geometry = new ShapeGeometry(shapes);
|
||||||
|
|
||||||
geometry.computeBoundingBox();
|
geometry.computeBoundingBox();
|
||||||
|
@ -71,7 +71,8 @@ export class ThreeBSP
|
|||||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2], uvs);
|
||||||
vertex.applyMatrix4(this.matrix);
|
vertex.applyMatrix4(this.matrix);
|
||||||
polygon.vertices.push(vertex);
|
polygon.vertices.push(vertex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw 'Invalid face type at index ' + i;
|
throw 'Invalid face type at index ' + i;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Object3D, Mesh } from "three";
|
import { Object3D, Mesh } from "three";
|
||||||
import { createTemplateBoard, DrawDimension, Viewer, selectMaterial } from ".";
|
import { createTemplateBoard, DrawDimension, Viewer } from ".";
|
||||||
|
|
||||||
function dispose(m: Object3D)
|
function dispose(m: Object3D)
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ export function LoadBoard(view: Viewer, data: any[], clear: boolean = true)
|
|||||||
|
|
||||||
if (data.length === 0) return;
|
if (data.length === 0) return;
|
||||||
//加板
|
//加板
|
||||||
let { meshs, edgesa, relations } = createTemplateBoard(data);
|
let { meshs, edgesa, relations } = createTemplateBoard(data, view._Settings.boardMaterial);
|
||||||
|
|
||||||
//加标注
|
//加标注
|
||||||
let dims = DrawDimension(meshs);
|
let dims = DrawDimension(meshs);
|
||||||
|
444
src/ViewSrc/data.json
Normal file
444
src/ViewSrc/data.json
Normal file
@ -0,0 +1,444 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"L": 4408.678960586129,
|
||||||
|
"W": 4408.678960586129,
|
||||||
|
"H": 18,
|
||||||
|
"CabName": "主卧",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": -82.91743119266054,
|
||||||
|
"y": 73.39449541284404,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 4408.678960586129,
|
||||||
|
"y": 2204.3394802930643
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 2204.3394802930648
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 4408.678960586129,
|
||||||
|
"y": 2204.3394802930643
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
-0.9999999999999999,
|
||||||
|
-0.9999999999999999,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [
|
||||||
|
{
|
||||||
|
"L": 633.2307692307686,
|
||||||
|
"W": 633.2307692307686,
|
||||||
|
"H": 5,
|
||||||
|
"CabName": "",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": -95.91743119266054,
|
||||||
|
"y": 2910.9647449366785,
|
||||||
|
"z": 1405.2625572161414
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 633.2307692307686,
|
||||||
|
"y": 316.6153846153843
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 316.61538461538436
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 633.2307692307686,
|
||||||
|
"y": 316.6153846153843
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
-0.9999999999999999,
|
||||||
|
-0.9999999999999999,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L": 557.8461538461524,
|
||||||
|
"W": 557.8461538461524,
|
||||||
|
"H": 5,
|
||||||
|
"CabName": "",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": -82.91743119266054,
|
||||||
|
"y": 3016.50320647514,
|
||||||
|
"z": 2257.1087110622957
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 557.8461538461524,
|
||||||
|
"y": 278.9230769230762
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 278.9230769230763
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 557.8461538461524,
|
||||||
|
"y": 278.9230769230762
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
-0.9999999999999999,
|
||||||
|
-0.9999999999999999,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L": 444.76923076923117,
|
||||||
|
"W": 686,
|
||||||
|
"H": 5,
|
||||||
|
"CabName": "",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": -95.91743119266054,
|
||||||
|
"y": 1689.7339757059085,
|
||||||
|
"z": 1556.0317879853721
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 686,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 686,
|
||||||
|
"y": 444.76923076923117
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 444.76923076923117
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L": 625.6923076923076,
|
||||||
|
"W": 1349.3846153846157,
|
||||||
|
"H": 5,
|
||||||
|
"CabName": "",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": -82.91743119266054,
|
||||||
|
"y": 1177.1185910905238,
|
||||||
|
"z": 2626.493326446911
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 1349.3846153846157,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 1349.3846153846157,
|
||||||
|
"y": 625.6923076923076
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 625.6923076923076
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L": 2000,
|
||||||
|
"W": 600,
|
||||||
|
"H": 18,
|
||||||
|
"CabName": "主卧",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": 1099.0825688073396,
|
||||||
|
"y": 73.39449541284404,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 600,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 600,
|
||||||
|
"y": 2000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 2000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [
|
||||||
|
{
|
||||||
|
"L": 144.00000000000023,
|
||||||
|
"W": 170.42201834862385,
|
||||||
|
"H": 5,
|
||||||
|
"CabName": "",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": 1099.0825688073396,
|
||||||
|
"y": 288.2935779816515,
|
||||||
|
"z": 1001.247706422018
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 170.42201834862385,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 170.42201834862385,
|
||||||
|
"y": 144.00000000000023
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 144.00000000000023
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L": 189.0974955047293,
|
||||||
|
"W": 189.0974955047293,
|
||||||
|
"H": 18,
|
||||||
|
"CabName": "",
|
||||||
|
"BoardName": "",
|
||||||
|
"BasePoint": {
|
||||||
|
"x": 1099.0825688073396,
|
||||||
|
"y": 234.6989586696538,
|
||||||
|
"z": 1267.3595091283692
|
||||||
|
},
|
||||||
|
"XVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"YVec": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"ZVec": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"Grain": 0,
|
||||||
|
"Pts": [
|
||||||
|
{
|
||||||
|
"x": 189.0974955047293,
|
||||||
|
"y": 94.54874775236476
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": -1.4210854715202004e-14,
|
||||||
|
"y": 94.54874775236478
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 189.0974955047293,
|
||||||
|
"y": 94.54874775236476
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Buls": [
|
||||||
|
-0.9999999999999999,
|
||||||
|
-0.9999999999999999,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"SubBoardLocal": [],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"SubBoardAssoc": null,
|
||||||
|
"Drillings": null
|
||||||
|
}
|
||||||
|
]
|
14
src/ViewSrc/index.html
Normal file
14
src/ViewSrc/index.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>WebCAD</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -1,6 +1,6 @@
|
|||||||
// import { Color, Face3, MeshBasicMaterial, Object3D, Vector2, Vector3 } from "three";
|
// import { Color, Face3, MeshBasicMaterial, Object3D, Vector2, Vector3 } from "three";
|
||||||
// import "./style.css";
|
// import "./style.css";
|
||||||
import { Vector3 } from "three";
|
import { Color, MeshBasicMaterial, Vector3 } from "three";
|
||||||
import { CameraControlState } from "../CameraControls";
|
import { CameraControlState } from "../CameraControls";
|
||||||
import { data } from "../data";
|
import { data } from "../data";
|
||||||
import { GetBox } from "../GeUtils";
|
import { GetBox } from "../GeUtils";
|
||||||
@ -25,7 +25,17 @@ el.style.width = "80%";
|
|||||||
el.style.height = "80%";
|
el.style.height = "80%";
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
let view = new Viewer(el);
|
let view = new Viewer(el, (settings) =>
|
||||||
|
{
|
||||||
|
settings.boardMaterial = new MeshBasicMaterial({
|
||||||
|
color: new Color(0.8, 0.8, 0.8),
|
||||||
|
polygonOffset: true,
|
||||||
|
polygonOffsetFactor: 1, // positive value pushes polygon further away
|
||||||
|
polygonOffsetUnits: 1,
|
||||||
|
transparent: true,
|
||||||
|
opacity: 0.5
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//修改这个顺序 改变1 2 3 个触摸点时的触发状态.
|
//修改这个顺序 改变1 2 3 个触摸点时的触发状态.
|
||||||
view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan];
|
view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan];
|
||||||
|
12
src/ViewSrc/style.css
Normal file
12
src/ViewSrc/style.css
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
body {
|
||||||
|
font-size: 11px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
background: #5C7080;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
@ -1,11 +1,18 @@
|
|||||||
|
|
||||||
import { Mesh, Raycaster, Scene, Vector3, WebGLRenderer, WebGLRendererParameters } from "three";
|
import { Mesh, MeshBasicMaterial, Raycaster, Scene, Vector3, WebGLRenderer, WebGLRendererParameters } from "three";
|
||||||
import { boardMaterial, CameraControls, PointPick, selectMaterial } from ".";
|
import { boardMaterial, CameraControls, PointPick, selectMaterial } from ".";
|
||||||
import { CameraUpdate } from "./CameraUpdate";
|
import { CameraUpdate } from "./CameraUpdate";
|
||||||
import { ColorMaterial } from "./ColorPalette";
|
import { ColorMaterial } from "./ColorPalette";
|
||||||
import { cZeroVec, GetBox, GetBoxArr } from "./GeUtils";
|
import { cZeroVec, GetBox, GetBoxArr } from "./GeUtils";
|
||||||
import { PlaneExt } from "./PlaneExt";
|
import { PlaneExt } from "./PlaneExt";
|
||||||
|
|
||||||
|
export class ViewerSettings
|
||||||
|
{
|
||||||
|
boardMaterial: MeshBasicMaterial = boardMaterial;
|
||||||
|
selectMaterial: MeshBasicMaterial = selectMaterial;
|
||||||
|
selectByPointCallback: (meshId: number) => void = () => { };
|
||||||
|
}
|
||||||
|
|
||||||
export class Viewer
|
export class Viewer
|
||||||
{
|
{
|
||||||
m_LookTarget: any;
|
m_LookTarget: any;
|
||||||
@ -20,13 +27,19 @@ export class Viewer
|
|||||||
|
|
||||||
m_Scene: Scene = new Scene();
|
m_Scene: Scene = new Scene();
|
||||||
|
|
||||||
|
_Settings = new ViewerSettings();
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {HTMLElement} canvasContainer 可以传入一个div或者一个画布
|
* @param {HTMLElement} canvasContainer 可以传入一个div或者一个画布
|
||||||
* @memberof Viewer
|
* @memberof Viewer
|
||||||
*/
|
*/
|
||||||
constructor(canvasContainer: HTMLElement)
|
constructor(canvasContainer: HTMLElement, setupAction: (settings: ViewerSettings) => void = null)
|
||||||
{
|
{
|
||||||
|
if (setupAction)
|
||||||
|
{
|
||||||
|
setupAction(this._Settings);
|
||||||
|
}
|
||||||
|
|
||||||
this.m_DomEl = canvasContainer;
|
this.m_DomEl = canvasContainer;
|
||||||
this.initRender(canvasContainer);
|
this.initRender(canvasContainer);
|
||||||
this.OnSize();
|
this.OnSize();
|
||||||
@ -193,11 +206,15 @@ export class Viewer
|
|||||||
{
|
{
|
||||||
let mesh = PointPick(this, x, y);
|
let mesh = PointPick(this, x, y);
|
||||||
if (this.oldMesh)
|
if (this.oldMesh)
|
||||||
this.oldMesh.material = boardMaterial;
|
this.oldMesh.material = this._Settings.boardMaterial;
|
||||||
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
|
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
|
||||||
{
|
{
|
||||||
this.oldMesh = mesh;
|
this.oldMesh = mesh;
|
||||||
mesh.material = selectMaterial;
|
mesh.material = this._Settings.selectMaterial;
|
||||||
|
if (this._Settings.selectByPointCallback)
|
||||||
|
{
|
||||||
|
this._Settings.selectByPointCallback(mesh.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.m_bNeedUpdate = true;
|
this.m_bNeedUpdate = true;
|
||||||
}
|
}
|
||||||
@ -207,7 +224,7 @@ export class Viewer
|
|||||||
{
|
{
|
||||||
let meshId = blockMeshMap.get(dataID);
|
let meshId = blockMeshMap.get(dataID);
|
||||||
if (this.oldMesh)
|
if (this.oldMesh)
|
||||||
this.oldMesh.material = boardMaterial;
|
this.oldMesh.material = this._Settings.boardMaterial;
|
||||||
this.m_Scene.children.forEach(obj =>
|
this.m_Scene.children.forEach(obj =>
|
||||||
{
|
{
|
||||||
if (obj instanceof Mesh)
|
if (obj instanceof Mesh)
|
||||||
@ -215,7 +232,7 @@ export class Viewer
|
|||||||
if (obj.id == meshId)
|
if (obj.id == meshId)
|
||||||
{
|
{
|
||||||
this.oldMesh = obj;
|
this.oldMesh = obj;
|
||||||
obj.material = selectMaterial;
|
obj.material = this._Settings.selectMaterial;
|
||||||
this.m_bNeedUpdate = true;
|
this.m_bNeedUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { CylinderGeometry, Geometry, LineSegments, Mesh, Shape, Vector2, Vector3, Matrix4, ExtrudeGeometry, EdgesGeometry } from 'three';
|
import { CylinderGeometry, Geometry, LineSegments, Mesh, Shape, Vector2, Vector3, Matrix4, ExtrudeGeometry, EdgesGeometry, MeshBasicMaterial } from 'three';
|
||||||
import { ColorMaterial } from './ColorPalette';
|
import { ColorMaterial } from './ColorPalette';
|
||||||
import { equalv3, polar } from './GeUtils';
|
import { equalv3, polar } from './GeUtils';
|
||||||
import { boardMaterial, edgeMaterial } from './Material';
|
import { edgeMaterial } from './Material';
|
||||||
import { RotateUVs } from './RotateUV';
|
import { RotateUVs } from './RotateUV';
|
||||||
import { ThreeBSP } from './ThreeCSG';
|
import { ThreeBSP } from './ThreeCSG';
|
||||||
//解析二维圆弧类.
|
//解析二维圆弧类.
|
||||||
@ -77,7 +77,7 @@ export function getVec(data: object): Vector3
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创建板件 暂时这么写
|
//创建板件 暂时这么写
|
||||||
export function createBoard(boardData: object)
|
export function createBoard(boardData: object, material: MeshBasicMaterial)
|
||||||
{
|
{
|
||||||
let pts: Vector2[] = [];
|
let pts: Vector2[] = [];
|
||||||
let buls: number[] = [];
|
let buls: number[] = [];
|
||||||
@ -151,7 +151,7 @@ export function createBoard(boardData: object)
|
|||||||
|
|
||||||
if (boardData["SubBoardLocal"])
|
if (boardData["SubBoardLocal"])
|
||||||
{
|
{
|
||||||
let subBoardList = boardData["SubBoardLocal"].map(d => createBoard(d));
|
let subBoardList = boardData["SubBoardLocal"].map(d => createBoard(d, material));
|
||||||
for (let br of subBoardList)
|
for (let br of subBoardList)
|
||||||
{
|
{
|
||||||
edges.push(...br.edges);
|
edges.push(...br.edges);
|
||||||
@ -190,7 +190,7 @@ export function createBoard(boardData: object)
|
|||||||
if (boardData["BoardName"] === "地脚线")
|
if (boardData["BoardName"] === "地脚线")
|
||||||
RotateUVs(ext);
|
RotateUVs(ext);
|
||||||
|
|
||||||
let mesh = new Mesh(ext, boardMaterial);
|
let mesh = new Mesh(ext, material);
|
||||||
mesh.userData = ZD;
|
mesh.userData = ZD;
|
||||||
edges.forEach(e => e.userData = ZD);
|
edges.forEach(e => e.userData = ZD);
|
||||||
return { mesh, edges };
|
return { mesh, edges };
|
||||||
@ -201,7 +201,7 @@ function checkObjectArray(obj: any, key: string)
|
|||||||
return obj[key] && obj[key].length > 0;
|
return obj[key] && obj[key].length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTemplateBoard(brDataList: any[])
|
export function createTemplateBoard(brDataList: any[], material: MeshBasicMaterial)
|
||||||
{
|
{
|
||||||
let meshs = [];
|
let meshs = [];
|
||||||
let edgesa = [];
|
let edgesa = [];
|
||||||
@ -212,7 +212,7 @@ export function createTemplateBoard(brDataList: any[])
|
|||||||
};
|
};
|
||||||
for (let d of brDataList)
|
for (let d of brDataList)
|
||||||
{
|
{
|
||||||
let { mesh, edges } = createBoard(d);
|
let { mesh, edges } = createBoard(d, material);
|
||||||
meshs.push(mesh);
|
meshs.push(mesh);
|
||||||
edgesa.push(...edges);
|
edgesa.push(...edges);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"target": "es5",
|
"target": "esnext",
|
||||||
"lib": [
|
"lib": [
|
||||||
"esnext",
|
"esnext",
|
||||||
"dom"
|
"dom"
|
||||||
|
Loading…
Reference in New Issue
Block a user