fl-web-component 1.3.1 → 1.3.2
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/README.md +3 -0
- package/dist/fl-web-component.common.js +49 -32
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +1 -1
- package/packages/components/com-flcanvas/index.vue +6 -1
- package/src/utils/threejs/measure-angle.js +175 -172
- package/src/utils/threejs/measure-area.js +185 -168
- package/src/utils/threejs/measure-distance.js +152 -146
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";#fl-model[data-v-070832d8]{width:100%;height:100%;cursor:pointer}[data-v-070832d8] .tips-label{width:50px;color:#000;font:12px Helvetica;padding:5px;text-align:center;vertical-align:middle;background-color:khaki}[data-v-070832d8] .measure-label{max-width:100px;margin-top:-1em;border:10px;border-radius:5px;padding:3px 10px;cursor:pointer;color:#009bea;background-color:#f4f4f4;box-shadow:0 1px 3px 1px rgba(0,0,0,.25)}[data-v-070832d8] .circle-tag{width:10px;height:10px;margin-top:5px;border-radius:50%;background-color:#ff5000}[data-v-070832d8] .measure-label-font{word-break:break-all}[data-v-070832d8] .mark-label-img{padding-top:5px;width:20px;height:20px}#konva-container[data-v-
|
|
1
|
+
@charset "UTF-8";#fl-model[data-v-070832d8]{width:100%;height:100%;cursor:pointer}[data-v-070832d8] .tips-label{width:50px;color:#000;font:12px Helvetica;padding:5px;text-align:center;vertical-align:middle;background-color:khaki}[data-v-070832d8] .measure-label{max-width:100px;margin-top:-1em;border:10px;border-radius:5px;padding:3px 10px;cursor:pointer;color:#009bea;background-color:#f4f4f4;box-shadow:0 1px 3px 1px rgba(0,0,0,.25)}[data-v-070832d8] .circle-tag{width:10px;height:10px;margin-top:5px;border-radius:50%;background-color:#ff5000}[data-v-070832d8] .measure-label-font{word-break:break-all}[data-v-070832d8] .mark-label-img{padding-top:5px;width:20px;height:20px}#konva-container[data-v-95b325ba]{z-index:3;width:100%;height:100%;cursor:pointer;overflow:hidden}span[data-v-f547d5c6]{font-weight:bolder}.text[data-v-f547d5c6]{margin-top:20px}.line[data-v-f547d5c6]{border-bottom:1px solid #dcdfe6;margin:20px 0}.center[data-v-f547d5c6]{display:flex;flex-direction:column;align-items:center}.center .cen span[data-v-f547d5c6],.center .top span[data-v-f547d5c6]{color:"#53a8ff";display:inline-block;width:30px;height:30px;text-align:center;line-height:30px;border:1px solid;padding:5px;margin-bottom:10px;background-color:#e9f3ff}.center .cen span[data-v-f547d5c6]{margin:10px}.button[data-v-f547d5c6]{display:flex;justify-content:end;margin-top:20px}@font-face{font-family:iconfont;src:url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff2?t=1646635700216) format("woff2"),url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff?t=1646635700216) format("woff"),url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.ttf?t=1646635700216) format("truetype")}.iconfont[data-v-f547d5c6]{font-family:iconfont!important;font-size:50px;font-style:normal;color:"#53a8ff";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-shubiao[data-v-f547d5c6]:before{content:""}#svg-tigger[data-v-0ec35ee4]{cursor:pointer;height:100%;width:100%}
|
package/package.json
CHANGED
|
@@ -283,7 +283,12 @@ var preTarget = [];
|
|
|
283
283
|
},
|
|
284
284
|
toPdf(name) {
|
|
285
285
|
// get data URL with default settings
|
|
286
|
-
|
|
286
|
+
konvaStage.scale({
|
|
287
|
+
x:2,
|
|
288
|
+
y:2
|
|
289
|
+
})
|
|
290
|
+
konvaStage.setX(0);
|
|
291
|
+
konvaStage.setY(750);
|
|
287
292
|
// open in new window
|
|
288
293
|
konvaLayer.getCanvas().setPixelRatio(1);
|
|
289
294
|
const jpegURL = konvaStage.toDataURL({
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer'
|
|
3
|
-
var _this = null
|
|
4
|
-
var MeasureAngle = function(renderer, scene, camera, width, height) {
|
|
5
|
-
this.renderer = renderer
|
|
6
|
-
this.scene = scene
|
|
7
|
-
this.camera = camera
|
|
8
|
-
this.pointArray = [] // 保存当前操作所添加的点
|
|
9
|
-
this.raycaster = new THREE.Raycaster()
|
|
10
|
-
this.points = [] // 保存页面中所添加的点
|
|
11
|
-
this.polyline = [] //保存页面中所添加的直线
|
|
12
|
-
this.labels = [] // 保存页面中所添加的文本
|
|
13
|
-
this.curves = [] // 保存页面所有的曲线
|
|
14
|
-
this.tempPoints = undefined
|
|
15
|
-
this.tempLine = undefined
|
|
16
|
-
this.tempLabel = undefined
|
|
17
|
-
this.tipsLabel = undefined
|
|
18
|
-
this.isCompleted = false
|
|
19
|
-
this.curveLine = undefined
|
|
20
|
-
this.timer = null
|
|
21
|
-
this.width = width
|
|
22
|
-
this.height = height
|
|
23
|
-
this.firstTime = 0
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer';
|
|
3
|
+
var _this = null;
|
|
4
|
+
var MeasureAngle = function (renderer, scene, camera, width, height) {
|
|
5
|
+
this.renderer = renderer;
|
|
6
|
+
this.scene = scene;
|
|
7
|
+
this.camera = camera;
|
|
8
|
+
this.pointArray = []; // 保存当前操作所添加的点
|
|
9
|
+
this.raycaster = new THREE.Raycaster();
|
|
10
|
+
this.points = []; // 保存页面中所添加的点
|
|
11
|
+
this.polyline = []; //保存页面中所添加的直线
|
|
12
|
+
this.labels = []; // 保存页面中所添加的文本
|
|
13
|
+
this.curves = []; // 保存页面所有的曲线
|
|
14
|
+
this.tempPoints = undefined;
|
|
15
|
+
this.tempLine = undefined;
|
|
16
|
+
this.tempLabel = undefined;
|
|
17
|
+
this.tipsLabel = undefined;
|
|
18
|
+
this.isCompleted = false;
|
|
19
|
+
this.curveLine = undefined;
|
|
20
|
+
this.timer = null;
|
|
21
|
+
this.width = width;
|
|
22
|
+
this.height = height;
|
|
23
|
+
this.firstTime = 0;
|
|
24
24
|
// this.POINT_MATERIAL = new THREE.PointsMaterial({ color: 0xff5000, size: 1, opacity: 0.6, transparent: true, depthWrite: false, depthTest: false })
|
|
25
25
|
// this.LINE_MATERIAL = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 3, opacity: 0.8, transparent: true, side: THREE.DoubleSide, depthWrite: false, depthTest: false })
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
MeasureAngle.prototype = {
|
|
29
29
|
start() {
|
|
30
|
-
_this = this
|
|
31
|
-
this.renderer.domElement.style.cursor = 'crosshair'
|
|
32
|
-
this.renderer.domElement.addEventListener('mouseup', this.click, false)
|
|
33
|
-
this.renderer.domElement.addEventListener('mousedown', this.mousedown, false)
|
|
34
|
-
this.renderer.domElement.addEventListener('mousemove',
|
|
35
|
-
this.renderer.domElement.addEventListener('contextmenu', this.rightClick, false)
|
|
30
|
+
_this = this;
|
|
31
|
+
this.renderer.domElement.style.cursor = 'crosshair';
|
|
32
|
+
this.renderer.domElement.addEventListener('mouseup', this.click, false);
|
|
33
|
+
this.renderer.domElement.addEventListener('mousedown', this.mousedown, false);
|
|
34
|
+
this.renderer.domElement.addEventListener('mousemove', this.mousemove, false);
|
|
35
|
+
this.renderer.domElement.addEventListener('contextmenu', this.rightClick, false);
|
|
36
36
|
},
|
|
37
37
|
updateParams(width, height) {
|
|
38
|
-
this.camera.aspect = width / height
|
|
39
|
-
this.camera.updateProjectionMatrix()
|
|
40
|
-
this.renderer.setSize(width, height, true)
|
|
41
|
-
this.width = width
|
|
42
|
-
this.height = height
|
|
38
|
+
this.camera.aspect = width / height;
|
|
39
|
+
this.camera.updateProjectionMatrix();
|
|
40
|
+
this.renderer.setSize(width, height, true);
|
|
41
|
+
this.width = width;
|
|
42
|
+
this.height = height;
|
|
43
43
|
},
|
|
44
44
|
getPosition(e) {
|
|
45
45
|
const mouse = new THREE.Vector2();
|
|
@@ -50,94 +50,94 @@ MeasureAngle.prototype = {
|
|
|
50
50
|
mouse.x = (canvasX / elRect.width) * 2.0 - 1.0;
|
|
51
51
|
mouse.y = -(canvasY / elRect.height) * 2.0 + 1.0;
|
|
52
52
|
|
|
53
|
-
_this.raycaster.setFromCamera(mouse, this.camera)
|
|
54
|
-
let intersects = _this.raycaster.intersectObjects(_this.scene.children, true)
|
|
55
|
-
if(intersects.length > 0) {
|
|
56
|
-
return intersects[0].point
|
|
53
|
+
_this.raycaster.setFromCamera(mouse, this.camera);
|
|
54
|
+
let intersects = _this.raycaster.intersectObjects(_this.scene.children, true);
|
|
55
|
+
if (intersects.length > 0) {
|
|
56
|
+
return intersects[0].point;
|
|
57
57
|
}
|
|
58
|
-
return null
|
|
59
|
-
},
|
|
60
|
-
createPoints(pos, config = {color: 0x009bea, size: 0.3}) {
|
|
61
|
-
const mesh = new THREE.MeshBasicMaterial({color: config.color || 0x009bea})
|
|
62
|
-
const geom = new THREE.SphereGeometry(config.size || 0.3, 28, 28)
|
|
63
|
-
const sphere = new THREE.Mesh(geom, mesh)
|
|
64
|
-
sphere.frustumCulled = false
|
|
65
|
-
sphere.position.set(pos.x, pos.y, pos.z)
|
|
66
|
-
return sphere
|
|
67
|
-
},
|
|
68
|
-
createLine(p1, p2, config={color: 0xff0000}) {
|
|
69
|
-
const lineMaterial = new THREE.LineBasicMaterial({ color: config.color, linewidth: 10 })
|
|
70
|
-
const lineGeometry = new THREE.BufferGeometry().setFromPoints([p1, p2])
|
|
71
|
-
const line = new THREE.Line(lineGeometry, lineMaterial)
|
|
72
|
-
line.frustumCulled = false
|
|
73
|
-
return line
|
|
58
|
+
return null;
|
|
59
|
+
},
|
|
60
|
+
createPoints(pos, config = { color: 0x009bea, size: 0.3 }) {
|
|
61
|
+
const mesh = new THREE.MeshBasicMaterial({ color: config.color || 0x009bea });
|
|
62
|
+
const geom = new THREE.SphereGeometry(config.size || 0.3, 28, 28);
|
|
63
|
+
const sphere = new THREE.Mesh(geom, mesh);
|
|
64
|
+
sphere.frustumCulled = false;
|
|
65
|
+
sphere.position.set(pos.x, pos.y, pos.z);
|
|
66
|
+
return sphere;
|
|
67
|
+
},
|
|
68
|
+
createLine(p1, p2, config = { color: 0xff0000 }) {
|
|
69
|
+
const lineMaterial = new THREE.LineBasicMaterial({ color: config.color, linewidth: 10 });
|
|
70
|
+
const lineGeometry = new THREE.BufferGeometry().setFromPoints([p1, p2]);
|
|
71
|
+
const line = new THREE.Line(lineGeometry, lineMaterial);
|
|
72
|
+
line.frustumCulled = false;
|
|
73
|
+
return line;
|
|
74
74
|
},
|
|
75
75
|
createLabel(name, text, position) {
|
|
76
|
-
const div = document.createElement('div')
|
|
77
|
-
div.className = name
|
|
78
|
-
div.textContent = text
|
|
79
|
-
const divLabel = new CSS2DObject(div)
|
|
80
|
-
divLabel.position.set(position.x, position.y, position.z)
|
|
81
|
-
return divLabel
|
|
76
|
+
const div = document.createElement('div');
|
|
77
|
+
div.className = name;
|
|
78
|
+
div.textContent = text;
|
|
79
|
+
const divLabel = new CSS2DObject(div);
|
|
80
|
+
divLabel.position.set(position.x, position.y, position.z);
|
|
81
|
+
return divLabel;
|
|
82
82
|
},
|
|
83
83
|
mousemove(e) {
|
|
84
|
-
if (_this.isCompleted || _this.pointArray.length === 0) return
|
|
85
|
-
|
|
84
|
+
if (_this.isCompleted || _this.pointArray.length === 0) return;
|
|
85
|
+
const point = _this.getPosition(e);
|
|
86
86
|
if (point) {
|
|
87
|
-
_this.pointArray.length === 1
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
87
|
+
_this.pointArray.length === 1
|
|
88
|
+
? _this.pointArray.push(point)
|
|
89
|
+
: _this.pointArray.splice(_this.pointArray.length - 1, 1, point);
|
|
90
|
+
const length = _this.pointArray.length;
|
|
91
|
+
const p1 = _this.pointArray[length - 2];
|
|
92
|
+
const p2 = _this.pointArray[length - 1];
|
|
91
93
|
if (_this.tempPoints) {
|
|
92
|
-
_this.tempPoints.position.set(point.x, point.y, point.z)
|
|
94
|
+
_this.tempPoints.position.set(point.x, point.y, point.z);
|
|
93
95
|
} else {
|
|
94
|
-
const geom = _this.createLabel('circle-tag', '', point)
|
|
95
|
-
_this.tempPoints = geom
|
|
96
|
-
_this.points.push(geom)
|
|
97
|
-
_this.scene.add(geom)
|
|
96
|
+
const geom = _this.createLabel('circle-tag', '', point);
|
|
97
|
+
_this.tempPoints = geom;
|
|
98
|
+
_this.points.push(geom);
|
|
99
|
+
_this.scene.add(geom);
|
|
98
100
|
}
|
|
99
101
|
if (_this.tempLine) {
|
|
100
|
-
_this.tempLine.geometry.setFromPoints([p1, p2])
|
|
102
|
+
_this.tempLine.geometry.setFromPoints([p1, p2]);
|
|
101
103
|
} else {
|
|
102
|
-
_this.tempLine = _this.createLine(p1, p2)
|
|
103
|
-
_this.polyline.push(_this.tempLine)
|
|
104
|
-
_this.scene.add(_this.tempLine)
|
|
104
|
+
_this.tempLine = _this.createLine(p1, p2);
|
|
105
|
+
_this.polyline.push(_this.tempLine);
|
|
106
|
+
_this.scene.add(_this.tempLine);
|
|
105
107
|
}
|
|
106
108
|
// 三点构成一个角
|
|
107
109
|
if (_this.pointArray.length === 3) {
|
|
108
|
-
const angle = _this.calculateAngle().toFixed(2) + '°'
|
|
109
|
-
const p0 = _this.pointArray[0]
|
|
110
|
-
const p1 = _this.pointArray[1]
|
|
111
|
-
const p2 = _this.pointArray[2]
|
|
112
|
-
const v1 = new THREE.Vector3((p0.x + p1.x) / 2, (p0.y + p1.y) / 2, (p0.z + p1.z) / 2)
|
|
113
|
-
const v2 = new THREE.Vector3((p1.x + p2.x) / 2, (p1.y + p2.y) / 2, (p1.z + p2.z) / 2)
|
|
114
|
-
const curve = new THREE.CatmullRomCurve3(
|
|
115
|
-
|
|
116
|
-
)
|
|
117
|
-
const points = curve.getPoints(50)
|
|
110
|
+
const angle = _this.calculateAngle().toFixed(2) + '°';
|
|
111
|
+
const p0 = _this.pointArray[0];
|
|
112
|
+
const p1 = _this.pointArray[1];
|
|
113
|
+
const p2 = _this.pointArray[2];
|
|
114
|
+
const v1 = new THREE.Vector3((p0.x + p1.x) / 2, (p0.y + p1.y) / 2, (p0.z + p1.z) / 2);
|
|
115
|
+
const v2 = new THREE.Vector3((p1.x + p2.x) / 2, (p1.y + p2.y) / 2, (p1.z + p2.z) / 2);
|
|
116
|
+
const curve = new THREE.CatmullRomCurve3([v1, v2]);
|
|
117
|
+
const points = curve.getPoints(50);
|
|
118
118
|
if (_this.tempLabel) {
|
|
119
|
-
_this.tempLabel.element.textContent = angle
|
|
120
|
-
_this.tempLabel.position.set(p1.x, p1.y, p1.z)
|
|
121
|
-
_this.curveLine.geometry.setFromPoints(points)
|
|
119
|
+
_this.tempLabel.element.textContent = angle;
|
|
120
|
+
_this.tempLabel.position.set(p1.x, p1.y, p1.z);
|
|
121
|
+
_this.curveLine.geometry.setFromPoints(points);
|
|
122
122
|
} else {
|
|
123
|
-
_this.tempLabel = _this.createLabel('measure-label', angle, p1)
|
|
124
|
-
_this.labels.push(_this.tempLabel)
|
|
125
|
-
_this.scene.add(_this.tempLabel)
|
|
126
|
-
|
|
123
|
+
_this.tempLabel = _this.createLabel('measure-label', angle, p1);
|
|
124
|
+
_this.labels.push(_this.tempLabel);
|
|
125
|
+
_this.scene.add(_this.tempLabel);
|
|
126
|
+
_this.createCurve(points);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
if (_this.tipsLabel) {
|
|
130
|
-
_this.tipsLabel.position.set(point.x + 0.1, point.y, point.z + 0.05)
|
|
130
|
+
_this.tipsLabel.position.set(point.x + 0.1, point.y, point.z + 0.05);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
createTipsLabel(label, position) {
|
|
135
|
-
const div = document.createElement('div')
|
|
136
|
-
div.className = 'tips-label'
|
|
137
|
-
div.textContent = label
|
|
138
|
-
const tipsLabel = new CSS2DObject(div)
|
|
139
|
-
tipsLabel.position.set(position.x + 0.1, position.y, position.z + 0.05)
|
|
140
|
-
return tipsLabel
|
|
135
|
+
const div = document.createElement('div');
|
|
136
|
+
div.className = 'tips-label';
|
|
137
|
+
div.textContent = label;
|
|
138
|
+
const tipsLabel = new CSS2DObject(div);
|
|
139
|
+
tipsLabel.position.set(position.x + 0.1, position.y, position.z + 0.05);
|
|
140
|
+
return tipsLabel;
|
|
141
141
|
},
|
|
142
142
|
mousedown() {
|
|
143
143
|
this.firstTime = new Date().getTime();
|
|
@@ -146,110 +146,113 @@ MeasureAngle.prototype = {
|
|
|
146
146
|
let lastTime = new Date().getTime();
|
|
147
147
|
if (lastTime - this.firstTime < 300) {
|
|
148
148
|
if (_this.isCompleted) {
|
|
149
|
-
_this.renderer.domElement.addEventListener('mousemove', _this.mousemove)
|
|
149
|
+
_this.renderer.domElement.addEventListener('mousemove', _this.mousemove);
|
|
150
150
|
}
|
|
151
|
-
clearTimeout(_this.timer)
|
|
151
|
+
clearTimeout(_this.timer);
|
|
152
152
|
_this.timer = setTimeout(() => {
|
|
153
|
-
_this.isCompleted = false
|
|
154
|
-
const point = _this.getPosition(e)
|
|
153
|
+
_this.isCompleted = false;
|
|
154
|
+
const point = _this.getPosition(e);
|
|
155
155
|
if (point) {
|
|
156
|
-
if(_this.tipsLabel) {
|
|
157
|
-
_this.tipsLabel.position.set(point.x + 0.1, point.y, point.z + 0.05)
|
|
156
|
+
if (_this.tipsLabel) {
|
|
157
|
+
_this.tipsLabel.position.set(point.x + 0.1, point.y, point.z + 0.05);
|
|
158
158
|
} else {
|
|
159
|
-
_this.tipsLabel = _this.createTipsLabel('左击绘制右击结束', point)
|
|
160
|
-
_this.scene.add(_this.tipsLabel)
|
|
159
|
+
_this.tipsLabel = _this.createTipsLabel('左击绘制右击结束', point);
|
|
160
|
+
_this.scene.add(_this.tipsLabel);
|
|
161
161
|
}
|
|
162
162
|
if (_this.tempPoints) {
|
|
163
|
-
_this.tempPoints.position.set(point.x, point.y, point.z)
|
|
164
|
-
_this.tempPoints = undefined
|
|
163
|
+
_this.tempPoints.position.set(point.x, point.y, point.z);
|
|
164
|
+
_this.tempPoints = undefined;
|
|
165
165
|
} else {
|
|
166
|
-
const geom =_this.createLabel('circle-tag', '', point)
|
|
167
|
-
_this.points.push(geom)
|
|
168
|
-
_this.scene.add(geom)
|
|
166
|
+
const geom = _this.createLabel('circle-tag', '', point);
|
|
167
|
+
_this.points.push(geom);
|
|
168
|
+
_this.scene.add(geom);
|
|
169
169
|
}
|
|
170
|
-
_this.tempLine = undefined
|
|
171
|
-
_this.tempLabel = undefined
|
|
172
|
-
_this.pointArray.push(point)
|
|
170
|
+
_this.tempLine = undefined;
|
|
171
|
+
_this.tempLabel = undefined;
|
|
172
|
+
_this.pointArray.push(point);
|
|
173
173
|
}
|
|
174
|
-
})
|
|
174
|
+
});
|
|
175
175
|
}
|
|
176
|
-
|
|
177
176
|
},
|
|
178
177
|
rightClick(e) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
_this.tipsLabel
|
|
178
|
+
_this.preventContextMenu(e);
|
|
179
|
+
if (_this.tipsLabel) {
|
|
180
|
+
_this.scene.remove(_this.tipsLabel);
|
|
181
|
+
_this.tipsLabel = undefined;
|
|
182
182
|
}
|
|
183
|
-
clearTimeout(_this.timer)
|
|
184
|
-
const point =
|
|
183
|
+
clearTimeout(_this.timer);
|
|
184
|
+
const point = _this.getPosition(e);
|
|
185
185
|
if (point) {
|
|
186
|
-
_this.isCompleted = true
|
|
187
|
-
_this.tempPoints = undefined
|
|
188
|
-
_this.tempLine = undefined
|
|
189
|
-
_this.tempLabel = undefined
|
|
190
|
-
_this.pointArray.splice(0)
|
|
191
|
-
_this.renderer.domElement.removeEventListener('mousemove', _this.mousemove)
|
|
186
|
+
_this.isCompleted = true;
|
|
187
|
+
_this.tempPoints = undefined;
|
|
188
|
+
_this.tempLine = undefined;
|
|
189
|
+
_this.tempLabel = undefined;
|
|
190
|
+
_this.pointArray.splice(0);
|
|
191
|
+
_this.renderer.domElement.removeEventListener('mousemove', _this.mousemove);
|
|
192
192
|
}
|
|
193
193
|
},
|
|
194
194
|
close() {
|
|
195
|
-
this.renderer.domElement.removeEventListener('mouseup', this.click, false)
|
|
196
|
-
this.renderer.domElement.removeEventListener('mousedown', this.mousedown, false)
|
|
197
|
-
this.renderer.domElement.removeEventListener('mousemove',
|
|
198
|
-
this.renderer.domElement.removeEventListener('contextmenu', this.rightClick, false)
|
|
199
|
-
this.remove(this.points)
|
|
200
|
-
this.remove(this.polyline)
|
|
201
|
-
this.remove(this.labels)
|
|
202
|
-
this.remove(this.curves)
|
|
203
|
-
this.pointArray.splice(0)
|
|
204
|
-
this.points.splice(0)
|
|
205
|
-
this.polyline.splice(0)
|
|
206
|
-
this.labels.splice(0)
|
|
207
|
-
this.curves.splice(0)
|
|
208
|
-
this.tempPoints = undefined
|
|
209
|
-
this.tempLabel = undefined
|
|
210
|
-
this.tempLine = undefined
|
|
211
|
-
this.scene.remove(this.tipsLabel)
|
|
212
|
-
this.tipsLabel = undefined
|
|
213
|
-
this.renderer.domElement.style.cursor = 'pointer'
|
|
195
|
+
this.renderer.domElement.removeEventListener('mouseup', this.click, false);
|
|
196
|
+
this.renderer.domElement.removeEventListener('mousedown', this.mousedown, false);
|
|
197
|
+
this.renderer.domElement.removeEventListener('mousemove', this.mousemove, false);
|
|
198
|
+
this.renderer.domElement.removeEventListener('contextmenu', this.rightClick, false);
|
|
199
|
+
this.remove(this.points);
|
|
200
|
+
this.remove(this.polyline);
|
|
201
|
+
this.remove(this.labels);
|
|
202
|
+
this.remove(this.curves);
|
|
203
|
+
this.pointArray.splice(0);
|
|
204
|
+
this.points.splice(0);
|
|
205
|
+
this.polyline.splice(0);
|
|
206
|
+
this.labels.splice(0);
|
|
207
|
+
this.curves.splice(0);
|
|
208
|
+
this.tempPoints = undefined;
|
|
209
|
+
this.tempLabel = undefined;
|
|
210
|
+
this.tempLine = undefined;
|
|
211
|
+
this.scene.remove(this.tipsLabel);
|
|
212
|
+
this.tipsLabel = undefined;
|
|
213
|
+
this.renderer.domElement.style.cursor = 'pointer';
|
|
214
214
|
},
|
|
215
215
|
remove(array) {
|
|
216
216
|
for (let index = 0; index < array.length; index++) {
|
|
217
|
-
const element = array[index]
|
|
217
|
+
const element = array[index];
|
|
218
218
|
if (element.geometry) {
|
|
219
|
-
element.geometry.dispose()
|
|
219
|
+
element.geometry.dispose();
|
|
220
220
|
}
|
|
221
|
-
this.scene.remove(element)
|
|
221
|
+
this.scene.remove(element);
|
|
222
222
|
}
|
|
223
223
|
},
|
|
224
224
|
calculateAngle() {
|
|
225
|
-
const p1 = _this.pointArray[1].clone()
|
|
226
|
-
const p2 = _this.pointArray[1].clone()
|
|
227
|
-
const dir0 = p1.sub(_this.pointArray[0]).clone()
|
|
228
|
-
const dir1 = p2.sub(_this.pointArray[2]).clone()
|
|
229
|
-
const angle = dir0.angleTo(dir1)
|
|
230
|
-
return angle * 180 / Math.PI
|
|
225
|
+
const p1 = _this.pointArray[1].clone();
|
|
226
|
+
const p2 = _this.pointArray[1].clone();
|
|
227
|
+
const dir0 = p1.sub(_this.pointArray[0]).clone();
|
|
228
|
+
const dir1 = p2.sub(_this.pointArray[2]).clone();
|
|
229
|
+
const angle = dir0.angleTo(dir1);
|
|
230
|
+
return (angle * 180) / Math.PI;
|
|
231
231
|
},
|
|
232
232
|
createCurve(points) {
|
|
233
|
-
const geom = new THREE.BufferGeometry().setFromPoints(points)
|
|
234
|
-
const material = new THREE.LineBasicMaterial({color: 0xff0000})
|
|
235
|
-
_this.curveLine = new THREE.Line(geom, material)
|
|
236
|
-
_this.curveLine.frustumCulled = false
|
|
237
|
-
_this.curves.push(_this.curveLine)
|
|
238
|
-
_this.scene.add(_this.curveLine)
|
|
233
|
+
const geom = new THREE.BufferGeometry().setFromPoints(points);
|
|
234
|
+
const material = new THREE.LineBasicMaterial({ color: 0xff0000 });
|
|
235
|
+
_this.curveLine = new THREE.Line(geom, material);
|
|
236
|
+
_this.curveLine.frustumCulled = false;
|
|
237
|
+
_this.curves.push(_this.curveLine);
|
|
238
|
+
_this.scene.add(_this.curveLine);
|
|
239
239
|
},
|
|
240
240
|
numberToString(num) {
|
|
241
241
|
if (num < 0.0001) {
|
|
242
|
-
return num.toString()
|
|
242
|
+
return num.toString();
|
|
243
243
|
}
|
|
244
|
-
let fractionDigits = 2
|
|
244
|
+
let fractionDigits = 2;
|
|
245
245
|
if (num < 0.01) {
|
|
246
|
-
fractionDigits = 4
|
|
246
|
+
fractionDigits = 4;
|
|
247
247
|
} else if (num < 0.1) {
|
|
248
|
-
fractionDigits = 3
|
|
248
|
+
fractionDigits = 3;
|
|
249
249
|
}
|
|
250
|
-
return num.toFixed(fractionDigits)
|
|
251
|
-
}
|
|
252
|
-
|
|
250
|
+
return num.toFixed(fractionDigits);
|
|
251
|
+
},
|
|
252
|
+
preventContextMenu(event) {
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
},
|
|
255
|
+
};
|
|
253
256
|
export default {
|
|
254
|
-
MeasureAngle
|
|
255
|
-
}
|
|
257
|
+
MeasureAngle,
|
|
258
|
+
};
|