fl-web-component 1.3.11 → 1.3.13
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 +6 -1
- package/dist/fl-web-component.common.js +153 -216
- 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 +234 -327
- package/packages/components/com-graphics/index.vue +17 -0
- package/patches/camera-controls+2.9.0.patch +63 -63
- package/src/utils/index.js +0 -18
- package/src/utils/threejs/measure-angle.js +9 -0
- package/src/utils/threejs/measure-area.js +10 -0
- package/src/utils/threejs/measure-distance.js +11 -0
|
@@ -1288,6 +1288,8 @@
|
|
|
1288
1288
|
threeMeasure.start();
|
|
1289
1289
|
break;
|
|
1290
1290
|
}
|
|
1291
|
+
// 添加键盘事件监听器
|
|
1292
|
+
document.addEventListener('keydown', this.handleMeasureKeyDown, false);
|
|
1291
1293
|
},
|
|
1292
1294
|
// 关闭测量
|
|
1293
1295
|
closeMeasure() {
|
|
@@ -1297,6 +1299,21 @@
|
|
|
1297
1299
|
threeMeasure = null;
|
|
1298
1300
|
// this.timeRender()
|
|
1299
1301
|
}
|
|
1302
|
+
// 移除键盘事件监听器
|
|
1303
|
+
document.removeEventListener('keydown', this.handleMeasureKeyDown, false);
|
|
1304
|
+
},
|
|
1305
|
+
handleMeasureKeyDown(event) {
|
|
1306
|
+
// 检查是否按下了ESC键
|
|
1307
|
+
const keyParam = {
|
|
1308
|
+
desc: event.key,
|
|
1309
|
+
keyCode: event.keyCode,
|
|
1310
|
+
event,
|
|
1311
|
+
};
|
|
1312
|
+
if (event.keyCode === 27) {
|
|
1313
|
+
// ESC键的键码是27
|
|
1314
|
+
this.closeMeasure();
|
|
1315
|
+
}
|
|
1316
|
+
this.$emit('keyDown', keyParam);
|
|
1300
1317
|
},
|
|
1301
1318
|
// 开启平移
|
|
1302
1319
|
/*
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
diff --git a/node_modules/camera-controls/dist/camera-controls.module.js b/node_modules/camera-controls/dist/camera-controls.module.js
|
|
2
|
-
index 08a8fd6..76089cb 100644
|
|
3
|
-
--- a/node_modules/camera-controls/dist/camera-controls.module.js
|
|
4
|
-
+++ b/node_modules/camera-controls/dist/camera-controls.module.js
|
|
5
|
-
@@ -1395,7 +1395,7 @@ class CameraControls extends EventDispatcher {
|
|
6
|
-
* @category Methods
|
|
7
|
-
*/
|
|
8
|
-
dolly(distance, enableTransition = false) {
|
|
9
|
-
- return this.dollyTo(this._sphericalEnd.radius - distance, enableTransition);
|
|
10
|
-
+ return this.dollyTo(this._sphericalEnd.radius - distance, this.minDistance, enableTransition);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Dolly in/out camera position to given distance.
|
|
14
|
-
@@ -1403,11 +1403,11 @@ class CameraControls extends EventDispatcher {
|
|
15
|
-
* @param enableTransition Whether to move smoothly or immediately.
|
|
16
|
-
* @category Methods
|
|
17
|
-
*/
|
|
18
|
-
- dollyTo(distance, enableTransition = false) {
|
|
19
|
-
+ dollyTo(distance, minDistance, enableTransition = false) {
|
|
20
|
-
this._isUserControllingDolly = false;
|
|
21
|
-
this._lastDollyDirection = DOLLY_DIRECTION.NONE;
|
|
22
|
-
this._changedDolly = 0;
|
|
23
|
-
- return this._dollyToNoClamp(clamp(distance, this.minDistance, this.maxDistance), enableTransition);
|
|
24
|
-
+ return this._dollyToNoClamp(clamp(distance, minDistance, this.maxDistance), enableTransition);
|
|
25
|
-
}
|
|
26
|
-
_dollyToNoClamp(distance, enableTransition = false) {
|
|
27
|
-
const lastRadius = this._sphericalEnd.radius;
|
|
28
|
-
@@ -1635,7 +1635,7 @@ class CameraControls extends EventDispatcher {
|
|
29
|
-
if (isPerspectiveCamera(this._camera)) {
|
|
30
|
-
const distance = this.getDistanceToFitBox(bbSize.x, bbSize.y, bbSize.z, cover);
|
|
31
|
-
promises.push(this.moveTo(center.x, center.y, center.z, enableTransition));
|
|
32
|
-
- promises.push(this.dollyTo(distance, enableTransition));
|
|
33
|
-
+ promises.push(this.dollyTo(distance, this.minDistance, enableTransition));
|
|
34
|
-
promises.push(this.setFocalOffset(0, 0, 0, enableTransition));
|
|
35
|
-
}
|
|
36
|
-
else if (isOrthographicCamera(this._camera)) {
|
|
37
|
-
@@ -1664,7 +1664,7 @@ class CameraControls extends EventDispatcher {
|
|
38
|
-
promises.push(this.moveTo(boundingSphere.center.x, boundingSphere.center.y, boundingSphere.center.z, enableTransition));
|
|
39
|
-
if (isPerspectiveCamera(this._camera)) {
|
|
40
|
-
const distanceToFit = this.getDistanceToFitSphere(boundingSphere.radius);
|
|
41
|
-
- promises.push(this.dollyTo(distanceToFit, enableTransition));
|
|
42
|
-
+ promises.push(this.dollyTo(distanceToFit, this.minDistance, enableTransition));
|
|
43
|
-
}
|
|
44
|
-
else if (isOrthographicCamera(this._camera)) {
|
|
45
|
-
const width = this._camera.right - this._camera.left;
|
|
46
|
-
@@ -1831,7 +1831,7 @@ class CameraControls extends EventDispatcher {
|
|
47
|
-
_zColumn.multiplyScalar(cameraToPoint.z);
|
|
48
|
-
_v3A.copy(_xColumn).add(_yColumn).add(_zColumn);
|
|
49
|
-
_v3A.z = _v3A.z + distance;
|
|
50
|
-
- this.dollyTo(distance, false);
|
|
51
|
-
+ this.dollyTo(distance, Number.EPSILON, false);
|
|
52
|
-
this.setFocalOffset(-_v3A.x, _v3A.y, -_v3A.z, false);
|
|
53
|
-
this.moveTo(targetX, targetY, targetZ, false);
|
|
54
|
-
}
|
|
55
|
-
@@ -2283,7 +2283,7 @@ class CameraControls extends EventDispatcher {
|
|
56
|
-
this.moveTo(obj.target[0], obj.target[1], obj.target[2], enableTransition);
|
|
57
|
-
_sphericalA.setFromVector3(_v3A.fromArray(obj.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace));
|
|
58
|
-
this.rotateTo(_sphericalA.theta, _sphericalA.phi, enableTransition);
|
|
59
|
-
- this.dollyTo(_sphericalA.radius, enableTransition);
|
|
60
|
-
+ this.dollyTo(_sphericalA.radius, this.minDistance, enableTransition);
|
|
61
|
-
this.zoomTo(obj.zoom, enableTransition);
|
|
62
|
-
this.setFocalOffset(obj.focalOffset[0], obj.focalOffset[1], obj.focalOffset[2], enableTransition);
|
|
63
|
-
this._needsUpdate = true;
|
|
1
|
+
diff --git a/node_modules/camera-controls/dist/camera-controls.module.js b/node_modules/camera-controls/dist/camera-controls.module.js
|
|
2
|
+
index 08a8fd6..76089cb 100644
|
|
3
|
+
--- a/node_modules/camera-controls/dist/camera-controls.module.js
|
|
4
|
+
+++ b/node_modules/camera-controls/dist/camera-controls.module.js
|
|
5
|
+
@@ -1395,7 +1395,7 @@ class CameraControls extends EventDispatcher {
|
|
6
|
+
* @category Methods
|
|
7
|
+
*/
|
|
8
|
+
dolly(distance, enableTransition = false) {
|
|
9
|
+
- return this.dollyTo(this._sphericalEnd.radius - distance, enableTransition);
|
|
10
|
+
+ return this.dollyTo(this._sphericalEnd.radius - distance, this.minDistance, enableTransition);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Dolly in/out camera position to given distance.
|
|
14
|
+
@@ -1403,11 +1403,11 @@ class CameraControls extends EventDispatcher {
|
|
15
|
+
* @param enableTransition Whether to move smoothly or immediately.
|
|
16
|
+
* @category Methods
|
|
17
|
+
*/
|
|
18
|
+
- dollyTo(distance, enableTransition = false) {
|
|
19
|
+
+ dollyTo(distance, minDistance, enableTransition = false) {
|
|
20
|
+
this._isUserControllingDolly = false;
|
|
21
|
+
this._lastDollyDirection = DOLLY_DIRECTION.NONE;
|
|
22
|
+
this._changedDolly = 0;
|
|
23
|
+
- return this._dollyToNoClamp(clamp(distance, this.minDistance, this.maxDistance), enableTransition);
|
|
24
|
+
+ return this._dollyToNoClamp(clamp(distance, minDistance, this.maxDistance), enableTransition);
|
|
25
|
+
}
|
|
26
|
+
_dollyToNoClamp(distance, enableTransition = false) {
|
|
27
|
+
const lastRadius = this._sphericalEnd.radius;
|
|
28
|
+
@@ -1635,7 +1635,7 @@ class CameraControls extends EventDispatcher {
|
|
29
|
+
if (isPerspectiveCamera(this._camera)) {
|
|
30
|
+
const distance = this.getDistanceToFitBox(bbSize.x, bbSize.y, bbSize.z, cover);
|
|
31
|
+
promises.push(this.moveTo(center.x, center.y, center.z, enableTransition));
|
|
32
|
+
- promises.push(this.dollyTo(distance, enableTransition));
|
|
33
|
+
+ promises.push(this.dollyTo(distance, this.minDistance, enableTransition));
|
|
34
|
+
promises.push(this.setFocalOffset(0, 0, 0, enableTransition));
|
|
35
|
+
}
|
|
36
|
+
else if (isOrthographicCamera(this._camera)) {
|
|
37
|
+
@@ -1664,7 +1664,7 @@ class CameraControls extends EventDispatcher {
|
|
38
|
+
promises.push(this.moveTo(boundingSphere.center.x, boundingSphere.center.y, boundingSphere.center.z, enableTransition));
|
|
39
|
+
if (isPerspectiveCamera(this._camera)) {
|
|
40
|
+
const distanceToFit = this.getDistanceToFitSphere(boundingSphere.radius);
|
|
41
|
+
- promises.push(this.dollyTo(distanceToFit, enableTransition));
|
|
42
|
+
+ promises.push(this.dollyTo(distanceToFit, this.minDistance, enableTransition));
|
|
43
|
+
}
|
|
44
|
+
else if (isOrthographicCamera(this._camera)) {
|
|
45
|
+
const width = this._camera.right - this._camera.left;
|
|
46
|
+
@@ -1831,7 +1831,7 @@ class CameraControls extends EventDispatcher {
|
|
47
|
+
_zColumn.multiplyScalar(cameraToPoint.z);
|
|
48
|
+
_v3A.copy(_xColumn).add(_yColumn).add(_zColumn);
|
|
49
|
+
_v3A.z = _v3A.z + distance;
|
|
50
|
+
- this.dollyTo(distance, false);
|
|
51
|
+
+ this.dollyTo(distance, Number.EPSILON, false);
|
|
52
|
+
this.setFocalOffset(-_v3A.x, _v3A.y, -_v3A.z, false);
|
|
53
|
+
this.moveTo(targetX, targetY, targetZ, false);
|
|
54
|
+
}
|
|
55
|
+
@@ -2283,7 +2283,7 @@ class CameraControls extends EventDispatcher {
|
|
56
|
+
this.moveTo(obj.target[0], obj.target[1], obj.target[2], enableTransition);
|
|
57
|
+
_sphericalA.setFromVector3(_v3A.fromArray(obj.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace));
|
|
58
|
+
this.rotateTo(_sphericalA.theta, _sphericalA.phi, enableTransition);
|
|
59
|
+
- this.dollyTo(_sphericalA.radius, enableTransition);
|
|
60
|
+
+ this.dollyTo(_sphericalA.radius, this.minDistance, enableTransition);
|
|
61
|
+
this.zoomTo(obj.zoom, enableTransition);
|
|
62
|
+
this.setFocalOffset(obj.focalOffset[0], obj.focalOffset[1], obj.focalOffset[2], enableTransition);
|
|
63
|
+
this._needsUpdate = true;
|
package/src/utils/index.js
CHANGED
|
@@ -374,24 +374,6 @@ function miniDevtool() {
|
|
|
374
374
|
if (document.readyState === 'loading') {
|
|
375
375
|
document.addEventListener('DOMContentLoaded', createPanel);
|
|
376
376
|
} else createPanel();
|
|
377
|
-
|
|
378
|
-
// 是否支持 WebGL
|
|
379
|
-
function hasWebGL() {
|
|
380
|
-
console.log('flversion', window.FLVersion)
|
|
381
|
-
console.log('userAgent:', navigator.userAgent);
|
|
382
|
-
console.log('has WebGLRenderingContext:', !!window.WebGLRenderingContext);
|
|
383
|
-
const c = document.createElement('canvas');
|
|
384
|
-
|
|
385
|
-
try {
|
|
386
|
-
const g1 = c.getContext('webgl');
|
|
387
|
-
const g2 = c.getContext('experimental-webgl');
|
|
388
|
-
const g3 = c.getContext('webgl2');
|
|
389
|
-
console.log('webgl contexts:', { g1: !!g1, g2: !!g2, g3: !!g3 });
|
|
390
|
-
} catch (e) {
|
|
391
|
-
console.error('getContext error', e);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
console.log('===========hasWebGL=======', hasWebGL());
|
|
395
377
|
}
|
|
396
378
|
|
|
397
379
|
export { screenshot, miniDevtool };
|
|
@@ -21,6 +21,9 @@ var MeasureAngle = function (renderer, scene, camera, width, height) {
|
|
|
21
21
|
this.width = width;
|
|
22
22
|
this.height = height;
|
|
23
23
|
this.firstTime = 0;
|
|
24
|
+
// 创建一个辅助平面来捕获鼠标事件
|
|
25
|
+
this.plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
|
|
26
|
+
|
|
24
27
|
// this.POINT_MATERIAL = new THREE.PointsMaterial({ color: 0xff5000, size: 1, opacity: 0.6, transparent: true, depthWrite: false, depthTest: false })
|
|
25
28
|
// this.LINE_MATERIAL = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 3, opacity: 0.8, transparent: true, side: THREE.DoubleSide, depthWrite: false, depthTest: false })
|
|
26
29
|
};
|
|
@@ -55,6 +58,12 @@ MeasureAngle.prototype = {
|
|
|
55
58
|
if (intersects.length > 0) {
|
|
56
59
|
return intersects[0].point;
|
|
57
60
|
}
|
|
61
|
+
// 如果没有交点,则创建一个在相机视图平面上的点
|
|
62
|
+
const ray = new THREE.Ray();
|
|
63
|
+
_this.raycaster.ray.intersectPlane(_this.plane, ray.origin);
|
|
64
|
+
if (ray.origin) {
|
|
65
|
+
return ray.origin;
|
|
66
|
+
}
|
|
58
67
|
return null;
|
|
59
68
|
},
|
|
60
69
|
createPoints(pos, config = { color: 0x009bea, size: 0.3 }) {
|
|
@@ -21,6 +21,9 @@ var MeasureArea = function (renderer, scene, camera, width, height) {
|
|
|
21
21
|
this.width = width;
|
|
22
22
|
this.height = height;
|
|
23
23
|
this.firstTime = 0;
|
|
24
|
+
|
|
25
|
+
// 创建一个辅助平面来捕获鼠标事件
|
|
26
|
+
this.plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
MeasureArea.prototype = {
|
|
@@ -53,6 +56,13 @@ MeasureArea.prototype = {
|
|
|
53
56
|
if (intersects.length > 0) {
|
|
54
57
|
return intersects[0].point;
|
|
55
58
|
}
|
|
59
|
+
|
|
60
|
+
// 如果没有交点,则创建一个在相机视图平面上的点
|
|
61
|
+
const ray = new THREE.Ray();
|
|
62
|
+
_this.raycaster.ray.intersectPlane(_this.plane, ray.origin);
|
|
63
|
+
if (ray.origin) {
|
|
64
|
+
return ray.origin;
|
|
65
|
+
}
|
|
56
66
|
return null;
|
|
57
67
|
},
|
|
58
68
|
createLine(p1, p2, config = { color: 0xff0000 }) {
|
|
@@ -19,6 +19,9 @@ var MeasureDistance = function (renderer, scene, camera, width, height) {
|
|
|
19
19
|
this.width = width;
|
|
20
20
|
this.height = height;
|
|
21
21
|
this.firstTime = 0;
|
|
22
|
+
|
|
23
|
+
// 创建一个辅助平面来捕获鼠标事件
|
|
24
|
+
this.plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
MeasureDistance.prototype = {
|
|
@@ -51,6 +54,14 @@ MeasureDistance.prototype = {
|
|
|
51
54
|
if (intersects.length > 0) {
|
|
52
55
|
return intersects[0].point;
|
|
53
56
|
}
|
|
57
|
+
|
|
58
|
+
// 如果没有交点,则创建一个在相机视图平面上的点
|
|
59
|
+
const ray = new THREE.Ray();
|
|
60
|
+
_this.raycaster.ray.intersectPlane(_this.plane, ray.origin);
|
|
61
|
+
if (ray.origin) {
|
|
62
|
+
return ray.origin;
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
return null;
|
|
55
66
|
},
|
|
56
67
|
createLine(p1, p2, config = { color: 0xff0000 }) {
|