fl-web-component 0.1.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fl-web-component.common.js +14751 -54489
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/dist/fl-web-component.umd.js +14751 -54489
- package/dist/fl-web-component.umd.js.map +1 -1
- package/dist/fl-web-component.umd.min.js +3 -3
- package/dist/fl-web-component.umd.min.js.map +1 -1
- package/package.json +28 -5
- package/packages/components/button/index.vue +18 -17
- package/packages/components/com-card/card-page.vue +51 -49
- package/packages/components/com-card/index.vue +20 -21
- package/packages/components/com-dialogWrapper/index.vue +18 -21
- package/packages/components/com-flcanvas/components/bspline.js +91 -0
- package/packages/components/com-flcanvas/components/entityFormatting.js +503 -0
- package/packages/components/com-flcanvas/components/round10.js +24 -0
- package/packages/components/com-flcanvas/index.vue +259 -0
- package/packages/components/com-formDialog/index.vue +76 -75
- package/packages/components/com-graphics/index.vue +1057 -226
- package/packages/components/com-graphics/per-control.vue +109 -0
- package/packages/components/com-graphics/pid.vue +168 -0
- package/packages/components/com-page/index.vue +33 -33
- package/packages/components/com-selectTree/index.vue +61 -63
- package/packages/components/com-table/column-default.vue +9 -14
- package/packages/components/com-table/column-dynamic.vue +4 -8
- package/packages/components/com-table/column-menu.vue +8 -8
- package/packages/components/com-table/column-slot.vue +4 -4
- package/packages/components/com-table/column.vue +7 -15
- package/packages/components/com-table/config.js +9 -9
- package/packages/components/com-table/index.vue +35 -35
- package/packages/components/com-table/table-page.vue +17 -17
- package/packages/components/com-tabs/index.vue +19 -19
- package/packages/components/com-treeDynamic/index.vue +45 -45
- package/packages/components/model/api/index.js +59 -67
- package/packages/components/model/api/mock/detecttree.js +38 -38
- package/packages/components/model/api/mock/getmodel-line.js +15830 -79332
- package/packages/components/model/api/mock/init.js +1 -1
- package/packages/components/model/api/mock/pbstree.js +486 -495
- package/packages/components/model/components/TextOverTooltip/index.vue +3 -3
- package/packages/components/model/components/annotation-toolbar.vue +4 -19
- package/packages/components/model/components/check-proofing-model.vue +26 -29
- package/packages/components/model/components/clipping-type.vue +22 -14
- package/packages/components/model/components/com-dialogWrapper/index.vue +22 -25
- package/packages/components/model/components/detect-panel.vue +38 -26
- package/packages/components/model/components/detect-tree.vue +9 -24
- package/packages/components/model/components/firstPer-panel.vue +23 -25
- package/packages/components/model/components/header-button.vue +31 -107
- package/packages/components/model/components/imageViewer/index.vue +34 -35
- package/packages/components/model/components/import-model.vue +127 -127
- package/packages/components/model/components/location-panel.vue +25 -29
- package/packages/components/model/components/measure-type.vue +15 -15
- package/packages/components/model/components/pbs-tree.vue +139 -144
- package/packages/components/model/components/proof-config.vue +2 -10
- package/packages/components/model/components/proof-for-pc.vue +35 -32
- package/packages/components/model/components/proof-history.vue +136 -154
- package/packages/components/model/components/proof-panel-detail.vue +166 -165
- package/packages/components/model/components/proof-panel.vue +281 -205
- package/packages/components/model/components/proof-project-user.vue +13 -50
- package/packages/components/model/components/proof-publish.vue +130 -130
- package/packages/components/model/components/proof-role.vue +93 -124
- package/packages/components/model/components/props-panel.vue +63 -54
- package/packages/components/model/index.vue +3225 -3213
- package/packages/components/model/utils/annotation-tool.js +75 -82
- package/packages/components/model/utils/cursor.js +15 -10
- package/packages/components/model/utils/detect-v1.js +23 -35
- package/packages/components/model/utils/index.js +25 -25
- package/packages/components/model/utils/threejs/measure-angle.js +180 -180
- package/packages/components/model/utils/threejs/measure-area.js +196 -184
- package/packages/components/model/utils/threejs/measure-distance.js +154 -152
- package/packages/components/model/utils/threejs/measure-volume.js +64 -61
- package/src/assets/test.png +0 -0
- package/src/assets/worker.glb +0 -0
- package/src/main.js +11 -8
- package/src/utils/flgltf-parser.js +141 -0
- package/src/utils/instance-parser.js +402 -0
- package/src/utils/mock.js +84746 -0
- package/src/utils/threejs/measure-angle.js +240 -0
- package/src/utils/threejs/measure-area.js +249 -0
- package/src/utils/threejs/measure-distance.js +195 -0
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fl-web-component",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vue-cli-service serve",
|
|
6
|
-
"lint": "vue
|
|
7
|
-
"
|
|
6
|
+
"lint": "eslint \"{src,packages}/**/*.{vue,js}\" --fix",
|
|
7
|
+
"prettier": "prettier --write \"packages/**/*.{js,css,less,scss,vue,html}\"",
|
|
8
|
+
"watch": "npm run lint && vue-cli-service build --watch --mode production --target lib --name fl-web-component ./src/main.js",
|
|
9
|
+
"build": "npm run lint && vue-cli-service build --target lib --name fl-web-component ./src/main.js"
|
|
8
10
|
},
|
|
9
11
|
"files": [
|
|
10
12
|
"dist",
|
|
@@ -14,22 +16,43 @@
|
|
|
14
16
|
],
|
|
15
17
|
"main": "dist/fl-web-component.common.js",
|
|
16
18
|
"dependencies": {
|
|
17
|
-
"camera-controls": "^2.
|
|
19
|
+
"camera-controls": "^2.9.0",
|
|
18
20
|
"core-js": "^3.6.5",
|
|
21
|
+
"dxf-parser": "^1.1.2",
|
|
19
22
|
"element-ui": "2.15.14",
|
|
20
23
|
"html2canvas": "^1.4.1",
|
|
24
|
+
"jspdf": "^3.0.1",
|
|
21
25
|
"konva": "^9.3.14",
|
|
22
26
|
"lodash": "^4.17.21",
|
|
23
27
|
"meshline": "^3.3.1",
|
|
24
|
-
"three": "^0.
|
|
28
|
+
"three": "^0.176.0",
|
|
25
29
|
"three.path": "^1.0.1",
|
|
26
30
|
"vue": "^2.6.11"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
33
|
+
"@babel/core": "^7.12.16",
|
|
34
|
+
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
|
35
|
+
"@babel/plugin-proposal-decorators": "^7.0.0",
|
|
36
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
|
|
37
|
+
"@babel/plugin-proposal-function-sent": "^7.0.0",
|
|
38
|
+
"@babel/plugin-proposal-json-strings": "^7.0.0",
|
|
39
|
+
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
|
|
40
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
|
41
|
+
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
|
42
|
+
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
|
|
43
|
+
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
|
44
|
+
"@babel/plugin-syntax-import-meta": "^7.0.0",
|
|
45
|
+
"@babel/plugin-syntax-jsx": "^7.17.12",
|
|
46
|
+
"@babel/plugin-transform-object-rest-spread": "^7.25.9",
|
|
47
|
+
"@babel/plugin-transform-runtime": "^7.0.0",
|
|
48
|
+
"@babel/preset-env": "^7.0.0",
|
|
49
|
+
"@babel/runtime-corejs2": "^7.18.3",
|
|
29
50
|
"@vue/cli-plugin-babel": "~4.4.0",
|
|
30
51
|
"@vue/cli-plugin-eslint": "~4.4.0",
|
|
31
52
|
"@vue/cli-service": "~4.4.0",
|
|
32
53
|
"babel-eslint": "^10.1.0",
|
|
54
|
+
"babel-loader": "^8.0.0",
|
|
55
|
+
"copy-webpack-plugin": "^4.0.1",
|
|
33
56
|
"eslint": "^6.7.2",
|
|
34
57
|
"eslint-plugin-vue": "^6.2.2",
|
|
35
58
|
"patch-package": "^6.4.7",
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
</div>
|
|
2
|
+
<div>
|
|
3
|
+
<button class="my-button" @click="handleClick">
|
|
4
|
+
{{ text }}
|
|
5
|
+
</button>
|
|
6
|
+
</div>
|
|
8
7
|
</template>
|
|
9
8
|
<script>
|
|
10
9
|
export default {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
name: 'MyButton',
|
|
11
|
+
props: {
|
|
12
|
+
text: { type: String, default: 'Click Me' },
|
|
13
|
+
},
|
|
14
|
+
methods: {
|
|
15
|
+
handleClick() {
|
|
16
|
+
this.$emit('click');
|
|
14
17
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
};
|
|
19
20
|
</script>
|
|
20
|
-
<style scoped>
|
|
21
|
+
<style lang="scss" scoped>
|
|
21
22
|
.my-button {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
padding: 8px 16px;
|
|
24
|
+
background: #42b983;
|
|
24
25
|
}
|
|
25
|
-
</style>
|
|
26
|
+
</style>
|
|
@@ -1,100 +1,102 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-pagination
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
<el-pagination
|
|
3
|
+
v-if="pageFlag"
|
|
4
|
+
:small="comCard.size == 'mini'"
|
|
5
|
+
:disabled="defaultPage.disabled"
|
|
6
|
+
:hide-on-single-page="defaultPage.single"
|
|
7
|
+
:pager-count="defaultPage.pagerCount"
|
|
8
|
+
:current-page.sync="defaultPage.currentPage"
|
|
9
|
+
:background="defaultPage.background"
|
|
10
|
+
:page-size="defaultPage.pageSize"
|
|
11
|
+
:page-sizes="defaultPage.pageSizes"
|
|
12
|
+
@size-change="sizeChange"
|
|
13
|
+
@prev-click="prevClick"
|
|
14
|
+
@next-click="nextClick"
|
|
15
|
+
@current-change="currentChange"
|
|
16
|
+
:layout="defaultPage.layout"
|
|
17
|
+
:total="defaultPage.total"
|
|
18
|
+
></el-pagination>
|
|
17
19
|
</template>
|
|
18
20
|
|
|
19
21
|
<script>
|
|
20
22
|
// import base from "../../utils/base.js";
|
|
21
23
|
|
|
22
24
|
export default {
|
|
23
|
-
name:
|
|
24
|
-
inject: [
|
|
25
|
+
name: 'comCard',
|
|
26
|
+
inject: ['comCard'],
|
|
25
27
|
// mixins: [base()],
|
|
26
|
-
data
|
|
28
|
+
data() {
|
|
27
29
|
return {
|
|
28
30
|
defaultPage: {
|
|
29
31
|
single: false,
|
|
30
32
|
total: 0, // 总页数
|
|
31
|
-
pagerCount: 7
|
|
33
|
+
pagerCount: 7, //超过多少条隐藏
|
|
32
34
|
currentPage: 1, // 当前页数
|
|
33
35
|
pageSize: 10, // 每页显示多少条
|
|
34
36
|
pageSizes: [10, 20, 30, 40, 50, 100],
|
|
35
37
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
36
|
-
background: true // 背景颜色
|
|
37
|
-
}
|
|
38
|
+
background: true, // 背景颜色
|
|
39
|
+
},
|
|
38
40
|
};
|
|
39
41
|
},
|
|
40
|
-
created
|
|
42
|
+
created() {
|
|
41
43
|
this.pageInit();
|
|
42
|
-
this.comCard.$emit(
|
|
44
|
+
this.comCard.$emit('on-load', this.defaultPage);
|
|
43
45
|
},
|
|
44
46
|
watch: {
|
|
45
47
|
'comCard.page': {
|
|
46
|
-
handler
|
|
48
|
+
handler() {
|
|
47
49
|
this.pageInit();
|
|
48
50
|
},
|
|
49
51
|
deep: true,
|
|
50
52
|
},
|
|
51
53
|
},
|
|
52
54
|
computed: {
|
|
53
|
-
pageFlag
|
|
54
|
-
return this.defaultPage.total != 0
|
|
55
|
-
}
|
|
55
|
+
pageFlag() {
|
|
56
|
+
return this.defaultPage.total != 0;
|
|
57
|
+
},
|
|
56
58
|
},
|
|
57
59
|
methods: {
|
|
58
|
-
pageInit
|
|
59
|
-
this.defaultPage = Object.assign(this.defaultPage, this.comCard.page)
|
|
60
|
+
pageInit() {
|
|
61
|
+
this.defaultPage = Object.assign(this.defaultPage, this.comCard.page);
|
|
60
62
|
this.updateValue();
|
|
61
63
|
},
|
|
62
|
-
updateValue
|
|
63
|
-
console.log('updateValue defaultPage', this.defaultPage)
|
|
64
|
-
this.comCard.$emit('update:page', this.defaultPage)
|
|
64
|
+
updateValue() {
|
|
65
|
+
console.log('updateValue defaultPage', this.defaultPage);
|
|
66
|
+
this.comCard.$emit('update:page', this.defaultPage);
|
|
65
67
|
},
|
|
66
68
|
//下一页事件
|
|
67
|
-
nextClick
|
|
68
|
-
console.log('nextClick', val)
|
|
69
|
-
this.comCard.$emit(
|
|
69
|
+
nextClick(val) {
|
|
70
|
+
console.log('nextClick', val);
|
|
71
|
+
this.comCard.$emit('next-click', val);
|
|
70
72
|
},
|
|
71
73
|
//上一页事件
|
|
72
|
-
prevClick
|
|
73
|
-
console.log('prevClick', val)
|
|
74
|
-
this.comCard.$emit(
|
|
74
|
+
prevClick(val) {
|
|
75
|
+
console.log('prevClick', val);
|
|
76
|
+
this.comCard.$emit('prev-click', val);
|
|
75
77
|
},
|
|
76
78
|
// 页大小回调
|
|
77
|
-
sizeChange
|
|
79
|
+
sizeChange(val) {
|
|
78
80
|
this.defaultPage.currentPage = 1;
|
|
79
81
|
this.defaultPage.pageSize = val;
|
|
80
82
|
this.updateValue();
|
|
81
|
-
console.log('sizeChange', val)
|
|
82
|
-
this.comCard.$emit(
|
|
83
|
-
this.comCard.$emit(
|
|
83
|
+
console.log('sizeChange', val);
|
|
84
|
+
this.comCard.$emit('on-load', this.defaultPage);
|
|
85
|
+
this.comCard.$emit('size-change', val);
|
|
84
86
|
},
|
|
85
87
|
// 页码回调
|
|
86
|
-
currentChange
|
|
88
|
+
currentChange(val) {
|
|
87
89
|
this.updateValue();
|
|
88
|
-
this.comCard.$emit(
|
|
89
|
-
this.comCard.$emit(
|
|
90
|
-
}
|
|
91
|
-
}
|
|
90
|
+
this.comCard.$emit('on-load', this.defaultPage);
|
|
91
|
+
this.comCard.$emit('current-change', val);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
92
94
|
};
|
|
93
95
|
</script>
|
|
94
96
|
|
|
95
97
|
<style lang="scss" scoped>
|
|
96
|
-
.el-pagination{
|
|
98
|
+
.el-pagination {
|
|
97
99
|
text-align: right;
|
|
98
100
|
padding: 15px 10px 15px 20px !important;
|
|
99
101
|
}
|
|
100
|
-
</style>
|
|
102
|
+
</style>
|
|
@@ -2,52 +2,51 @@
|
|
|
2
2
|
<div class="card-container">
|
|
3
3
|
<!-- 列表区域-->
|
|
4
4
|
<div class="card-list">
|
|
5
|
-
<el-card
|
|
5
|
+
<el-card
|
|
6
6
|
v-loading="loading"
|
|
7
7
|
class="card"
|
|
8
8
|
v-for="(item, index) in data"
|
|
9
9
|
:key="index"
|
|
10
10
|
:body-style="{ padding: '0px' }"
|
|
11
11
|
>
|
|
12
|
-
|
|
12
|
+
<slot :data="item"></slot>
|
|
13
13
|
</el-card>
|
|
14
14
|
</div>
|
|
15
15
|
<!-- 分页区域 -->
|
|
16
|
-
<card-page ref="cardPage">
|
|
17
|
-
</card-page>
|
|
16
|
+
<card-page ref="cardPage"> </card-page>
|
|
18
17
|
</div>
|
|
19
18
|
</template>
|
|
20
19
|
|
|
21
20
|
<script>
|
|
22
|
-
import CardPage from
|
|
21
|
+
import CardPage from './card-page';
|
|
23
22
|
|
|
24
23
|
export default {
|
|
25
|
-
name:
|
|
26
|
-
|
|
24
|
+
name: 'comCard',
|
|
25
|
+
provide() {
|
|
27
26
|
return {
|
|
28
|
-
comCard: this
|
|
27
|
+
comCard: this,
|
|
29
28
|
};
|
|
30
29
|
},
|
|
31
30
|
components: {
|
|
32
31
|
CardPage, //分页
|
|
33
32
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
props: {
|
|
34
|
+
data: {
|
|
35
|
+
type: Array,
|
|
36
|
+
default: () => [],
|
|
37
|
+
require: true,
|
|
38
|
+
},
|
|
39
|
+
loading: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
44
43
|
page: {
|
|
45
44
|
type: Object,
|
|
46
|
-
default
|
|
45
|
+
default() {
|
|
47
46
|
return {};
|
|
48
|
-
}
|
|
47
|
+
},
|
|
49
48
|
},
|
|
50
|
-
|
|
49
|
+
},
|
|
51
50
|
};
|
|
52
51
|
</script>
|
|
53
52
|
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
:width="popupWidth"
|
|
17
17
|
append-to-body
|
|
18
18
|
>
|
|
19
|
-
|
|
20
19
|
<!-- 弹窗title -->
|
|
21
20
|
<template slot="title">
|
|
22
21
|
<div class="custom_dialog_header">
|
|
23
22
|
<span class="el_dialog_title">{{ dialogTitle }}</span>
|
|
24
23
|
<div class="custom_dialog_menu" @click="dialogFullScreen = !dialogFullScreen">
|
|
25
|
-
<svg-icon :icon-class="dialogFullScreen?'exit-fullscreen':'fullscreen'" />
|
|
24
|
+
<svg-icon :icon-class="dialogFullScreen ? 'exit-fullscreen' : 'fullscreen'" />
|
|
26
25
|
</div>
|
|
27
26
|
</div>
|
|
28
27
|
</template>
|
|
@@ -48,38 +47,38 @@ export default {
|
|
|
48
47
|
/* 弹窗 title标题 */
|
|
49
48
|
dialogTitle: {
|
|
50
49
|
type: String,
|
|
51
|
-
default: '标题'
|
|
50
|
+
default: '标题',
|
|
52
51
|
},
|
|
53
52
|
/* 弹窗 width宽度 */
|
|
54
53
|
popupWidth: {
|
|
55
54
|
type: String,
|
|
56
|
-
default: '35%'
|
|
55
|
+
default: '35%',
|
|
57
56
|
},
|
|
58
57
|
/* 弹窗 显示隐藏状态 */
|
|
59
58
|
visible: {
|
|
60
59
|
type: Boolean,
|
|
61
|
-
default: false
|
|
62
|
-
}
|
|
60
|
+
default: false,
|
|
61
|
+
},
|
|
63
62
|
},
|
|
64
63
|
data() {
|
|
65
64
|
return {
|
|
66
65
|
openDialog: false,
|
|
67
|
-
dialogFullScreen: false
|
|
68
|
-
}
|
|
66
|
+
dialogFullScreen: false,
|
|
67
|
+
};
|
|
69
68
|
},
|
|
70
69
|
computed: {
|
|
71
70
|
dialogVisible: {
|
|
72
71
|
get() {
|
|
73
72
|
// 初始化数据
|
|
74
|
-
if (this.visible) Object.assign(this.$data, this.$options.data())
|
|
75
|
-
return this.visible
|
|
73
|
+
if (this.visible) Object.assign(this.$data, this.$options.data());
|
|
74
|
+
return this.visible;
|
|
76
75
|
},
|
|
77
76
|
set(val) {
|
|
78
77
|
// 当visible改变的时候,触发父组件的 updateVisible方法,
|
|
79
78
|
// 在该方法中更改传入子组件的 centerDialogVisible的值
|
|
80
|
-
this.$emit('updateVisible', val)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
79
|
+
this.$emit('updateVisible', val);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
83
82
|
},
|
|
84
83
|
watch: {},
|
|
85
84
|
created() {},
|
|
@@ -87,15 +86,13 @@ export default {
|
|
|
87
86
|
methods: {
|
|
88
87
|
/* 关闭弹窗 */
|
|
89
88
|
handleClose() {
|
|
90
|
-
this.$emit('handleClose')
|
|
89
|
+
this.$emit('handleClose');
|
|
91
90
|
},
|
|
92
91
|
/* 弹窗 确认 操作 */
|
|
93
92
|
handleSubmit() {
|
|
94
|
-
this.$emit('submitDialogData')
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
93
|
+
this.$emit('submitDialogData');
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
98
97
|
</script>
|
|
99
|
-
<style lang="scss" scoped>
|
|
100
|
-
|
|
101
|
-
</style>
|
|
98
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import round10 from './round10'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copied and ported to code standard as the b-spline library is not maintained any longer.
|
|
5
|
+
* Source:
|
|
6
|
+
* https://github.com/thibauts/b-spline
|
|
7
|
+
* Copyright (c) 2015 Thibaut Séguy <thibaut.seguy@gmail.com>
|
|
8
|
+
*/
|
|
9
|
+
export default (t, degree, points, knots, weights) => {
|
|
10
|
+
const n = points.length // points count
|
|
11
|
+
const d = points[0].length // point dimensionality
|
|
12
|
+
|
|
13
|
+
if ((t < 0) || (t > 1)) {
|
|
14
|
+
throw new Error('t out of bounds [0,1]: ' + t)
|
|
15
|
+
}
|
|
16
|
+
if (degree < 1) throw new Error('degree must be at least 1 (linear)')
|
|
17
|
+
if (degree > (n - 1)) throw new Error('degree must be less than or equal to point count - 1')
|
|
18
|
+
|
|
19
|
+
if (!weights) {
|
|
20
|
+
// build weight vector of length [n]
|
|
21
|
+
weights = []
|
|
22
|
+
for (let i = 0; i < n; i++) {
|
|
23
|
+
weights[i] = 1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!knots) {
|
|
28
|
+
// build knot vector of length [n + degree + 1]
|
|
29
|
+
knots = []
|
|
30
|
+
for (let i = 0; i < n + degree + 1; i++) {
|
|
31
|
+
knots[i] = i
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
if (knots.length !== n + degree + 1) throw new Error('bad knot vector length')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const domain = [
|
|
38
|
+
degree,
|
|
39
|
+
knots.length - 1 - degree
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
// remap t to the domain where the spline is defined
|
|
43
|
+
const low = knots[domain[0]]
|
|
44
|
+
const high = knots[domain[1]]
|
|
45
|
+
t = t * (high - low) + low
|
|
46
|
+
|
|
47
|
+
// Clamp to the upper & lower bounds instead of
|
|
48
|
+
// throwing an error like in the original lib
|
|
49
|
+
// https://github.com/bjnortier/dxf/issues/28
|
|
50
|
+
t = Math.max(t, low)
|
|
51
|
+
t = Math.min(t, high)
|
|
52
|
+
|
|
53
|
+
// find s (the spline segment) for the [t] value provided
|
|
54
|
+
let s
|
|
55
|
+
for (s = domain[0]; s < domain[1]; s++) {
|
|
56
|
+
if (t >= knots[s] && t <= knots[s + 1]) {
|
|
57
|
+
break
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// convert points to homogeneous coordinates
|
|
62
|
+
const v = []
|
|
63
|
+
for (let i = 0; i < n; i++) {
|
|
64
|
+
v[i] = []
|
|
65
|
+
for (let j = 0; j < d; j++) {
|
|
66
|
+
v[i][j] = points[i][j] * weights[i]
|
|
67
|
+
}
|
|
68
|
+
v[i][d] = weights[i]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// l (level) goes from 1 to the curve degree + 1
|
|
72
|
+
let alpha
|
|
73
|
+
for (let l = 1; l <= degree + 1; l++) {
|
|
74
|
+
// build level l of the pyramid
|
|
75
|
+
for (let i = s; i > s - degree - 1 + l; i--) {
|
|
76
|
+
alpha = (t - knots[i]) / (knots[i + degree + 1 - l] - knots[i])
|
|
77
|
+
|
|
78
|
+
// interpolate each component
|
|
79
|
+
for (let j = 0; j < d + 1; j++) {
|
|
80
|
+
v[i][j] = (1 - alpha) * v[i - 1][j] + alpha * v[i][j]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// convert back to cartesian and return
|
|
86
|
+
const result = []
|
|
87
|
+
for (let i = 0; i < d; i++) {
|
|
88
|
+
result[i] = round10(v[s][i] / v[s][d], -9)
|
|
89
|
+
}
|
|
90
|
+
return result
|
|
91
|
+
}
|