@realsee/dnalogel 2.0.0-alpha.40 → 2.0.0-alpha.41
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/PanoMeasurePlugin/Controller/ViewController.d.ts +16 -0
- package/dist/PanoMeasurePlugin/Controller/index.d.ts +1 -1
- package/dist/PanoMeasurePlugin/index.js +232 -75
- package/dist/PanoMeasurePlugin/utils/constants.d.ts +4 -4
- package/dist/PanoMeasurePlugin/utils/distanceDom.d.ts +2 -2
- package/dist/PanoMeasurePlugin/utils/line.d.ts +3 -3
- package/dist/index.es.js +234 -77
- package/dist/index.js +234 -77
- package/dist/index.umd.js +234 -77
- package/docs/classes/Magnifier.html +4 -4
- package/docs/classes/ModelRoomLabelController.html +4 -4
- package/docs/enums/CameraMovementEffect.html +2 -2
- package/docs/enums/DIRECTION.html +1 -1
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/Rotation.html +2 -2
- package/docs/index.html +1 -1
- package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
- package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/FloorplanBounding.html +4 -4
- package/docs/interfaces/FloorplanData.html +2 -2
- package/docs/interfaces/FloorplanEntrance.html +7 -7
- package/docs/interfaces/FloorplanExtraObject.html +3 -3
- package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
- package/docs/interfaces/FloorplanFloorData.html +2 -2
- package/docs/interfaces/FloorplanImagePosition.html +2 -2
- package/docs/interfaces/FloorplanObserver.html +2 -2
- package/docs/interfaces/FloorplanOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanPosition.html +2 -2
- package/docs/interfaces/FloorplanRoomItem.html +6 -6
- package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
- package/docs/interfaces/FloorplanServerBounding.html +4 -4
- package/docs/interfaces/FloorplanServerComputedData.html +1 -1
- package/docs/interfaces/FloorplanServerData.html +2 -2
- package/docs/interfaces/FloorplanServerEntrance.html +7 -7
- package/docs/interfaces/FloorplanServerFloorData.html +2 -2
- package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
- package/docs/interfaces/FloorplanServerObserver.html +2 -2
- package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanServerPosition.html +2 -2
- package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
- package/docs/interfaces/ItemLabelPluginData.html +1 -1
- package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -1
- package/docs/interfaces/OpenParameter.html +2 -2
- package/docs/interfaces/PanoCompassPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
- package/docs/interfaces/PanoMeasureParameterType.html +1 -1
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginState.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
- package/docs/interfaces/Point.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -1
- package/docs/interfaces/RoomInfo.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/RoomRules.html +1 -1
- package/docs/interfaces/Rooms.html +1 -1
- package/docs/modules.html +18 -18
- package/libs/PanoMeasurePlugin/Controller/ViewController.d.ts +16 -0
- package/libs/PanoMeasurePlugin/Controller/ViewController.js +160 -0
- package/libs/PanoMeasurePlugin/Controller/WatchController.js +1 -0
- package/libs/PanoMeasurePlugin/Controller/index.d.ts +1 -1
- package/libs/PanoMeasurePlugin/Controller/index.js +2 -0
- package/libs/PanoMeasurePlugin/Model/line.js +5 -5
- package/libs/PanoMeasurePlugin/utils/constants.d.ts +4 -4
- package/libs/PanoMeasurePlugin/utils/distanceDom.d.ts +2 -2
- package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -3
- package/libs/PanoMeasurePlugin/utils/line.d.ts +3 -3
- package/libs/PanoMeasurePlugin/utils/line.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type Line from '../Model/line';
|
|
2
|
+
import BaseController, { IControllerParams } from './BaseController';
|
|
3
|
+
export default class ViewController extends BaseController {
|
|
4
|
+
type: string;
|
|
5
|
+
private highlightedLines;
|
|
6
|
+
private hammer?;
|
|
7
|
+
constructor(params: IControllerParams);
|
|
8
|
+
dispose(): void;
|
|
9
|
+
highlightLine(line: Line): void;
|
|
10
|
+
clearHighlightLines(): void;
|
|
11
|
+
private wantsTapGesture;
|
|
12
|
+
private chooseLine;
|
|
13
|
+
private highlightLines;
|
|
14
|
+
private lineRemoved;
|
|
15
|
+
private onCameraUpdate;
|
|
16
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { PanoMeasurePluginEvent } from '../typings/event.type';
|
|
|
3
3
|
import type { UserDistanceItem } from '../utils/distanceDom';
|
|
4
4
|
import Magnifier, { MagnifierParameter } from '../Modules/Magnifier';
|
|
5
5
|
import { Five, Subscribe } from '@realsee/five';
|
|
6
|
-
export declare type Mode = 'Watch' | 'Edit' | 'Mixed';
|
|
6
|
+
export declare type Mode = 'Watch' | 'Edit' | 'Mixed' | 'View';
|
|
7
7
|
export interface PanoMeasureParameterType {
|
|
8
8
|
openParams?: OpenParameter;
|
|
9
9
|
magnifierParams?: MagnifierParameter;
|
|
@@ -463,7 +463,7 @@ const lightLineOpts = {
|
|
|
463
463
|
pointsRenderOrder: 10,
|
|
464
464
|
};
|
|
465
465
|
|
|
466
|
-
function
|
|
466
|
+
function createLine(start, end, opts) {
|
|
467
467
|
var _a, _b, _c, _d, _e;
|
|
468
468
|
const lineWidth = (_a = opts === null || opts === void 0 ? void 0 : opts.lineWidth) !== null && _a !== void 0 ? _a : 2;
|
|
469
469
|
const lineColor = (_b = opts === null || opts === void 0 ? void 0 : opts.lineColor) !== null && _b !== void 0 ? _b : new THREE.Color(0xffffff);
|
|
@@ -486,10 +486,10 @@ function creatLine(start, end, opts) {
|
|
|
486
486
|
pointMaterial.map = opts.pointTexture;
|
|
487
487
|
return line$1;
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function createLineMesh(line, type) {
|
|
490
490
|
const [point, anotherPoint] = line.points;
|
|
491
491
|
const opts = type === 'light' ? lightLineOpts : normalLineOpts;
|
|
492
|
-
const fiveLine =
|
|
492
|
+
const fiveLine = createLine(point.position, anotherPoint.position, opts);
|
|
493
493
|
fiveLine.name = 'normalLine_' + line.id;
|
|
494
494
|
return fiveLine;
|
|
495
495
|
}
|
|
@@ -501,7 +501,7 @@ function isNDCPointInScreen(ndcPoint) {
|
|
|
501
501
|
return true;
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
-
function
|
|
504
|
+
function createContentDom() {
|
|
505
505
|
const contentDom = document.createElement('div');
|
|
506
506
|
contentDom.setAttribute('style', `backdrop-filter: blur(4px);-webkit-backdrop-filter: blur(4px);`);
|
|
507
507
|
contentDom.style.padding = '3px 6px';
|
|
@@ -529,7 +529,7 @@ function createContainerDom(line) {
|
|
|
529
529
|
containerDom.style.transformOrigin = 'left top';
|
|
530
530
|
return containerDom;
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function createDistanceItem(props) {
|
|
533
533
|
function handleClick() {
|
|
534
534
|
var _a;
|
|
535
535
|
// 线被选中时才高亮,外部手动触发高亮
|
|
@@ -603,7 +603,7 @@ function creatDistanceItem(props) {
|
|
|
603
603
|
}
|
|
604
604
|
const { line } = props;
|
|
605
605
|
const lineID = line.id;
|
|
606
|
-
const contentDom =
|
|
606
|
+
const contentDom = createContentDom();
|
|
607
607
|
const containerDom = createContainerDom(line);
|
|
608
608
|
const userDistanceItem = props.userDistanceItem;
|
|
609
609
|
const ndcPosition = new THREE.Vector3(0, 0, 0);
|
|
@@ -688,9 +688,9 @@ class Line {
|
|
|
688
688
|
throw new Error('无效的线段, 一个点无法构成线段');
|
|
689
689
|
this.hook = new five.Subscribe();
|
|
690
690
|
this.points = [point, anotherPoint];
|
|
691
|
-
this.mesh =
|
|
692
|
-
this.lightMesh =
|
|
693
|
-
this.distanceItem =
|
|
691
|
+
this.mesh = createLineMesh(this, 'normal');
|
|
692
|
+
this.lightMesh = createLineMesh(this, 'light');
|
|
693
|
+
this.distanceItem = createDistanceItem({
|
|
694
694
|
line: this,
|
|
695
695
|
clickCallback: () => this.hook.emit('selected', this),
|
|
696
696
|
userDistanceItem: this.model.params.userDistanceItemCreator
|
|
@@ -1422,6 +1422,227 @@ class EditController extends BaseController {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* 获取一点对于线段上最近的一点,
|
|
1427
|
+
* 如果可以是过直线垂线的垂足,不行的话取线段的两端
|
|
1428
|
+
* @param point
|
|
1429
|
+
* @param linePoints
|
|
1430
|
+
* @return
|
|
1431
|
+
*/
|
|
1432
|
+
function closestPointOnLine(point, linePoints) {
|
|
1433
|
+
const tA = point.x - linePoints[0].x;
|
|
1434
|
+
const tB = point.y - linePoints[0].y;
|
|
1435
|
+
const tC = linePoints[1].x - linePoints[0].x;
|
|
1436
|
+
const tD = linePoints[1].y - linePoints[0].y;
|
|
1437
|
+
// 设线段为 AB 线段,线段外一点为 P
|
|
1438
|
+
// tDot = AP 向量与 AB 向量乘积,tLenSq 为 |AB|平方。
|
|
1439
|
+
// tParam 是 AP 向量在 AB 向量投影向量 AC 与 AB 向量的比。
|
|
1440
|
+
const tDot = tA * tC + tB * tD;
|
|
1441
|
+
const tLenSq = tC * tC + tD * tD;
|
|
1442
|
+
const tParam = tDot / tLenSq;
|
|
1443
|
+
let tXx, tYy;
|
|
1444
|
+
if (tParam < 0 || samePointAt(linePoints[0], linePoints[1])) {
|
|
1445
|
+
tXx = linePoints[0].x;
|
|
1446
|
+
tYy = linePoints[0].y;
|
|
1447
|
+
}
|
|
1448
|
+
else if (tParam > 1) {
|
|
1449
|
+
tXx = linePoints[1].x;
|
|
1450
|
+
tYy = linePoints[1].y;
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
tXx = linePoints[0].x + tParam * tC;
|
|
1454
|
+
tYy = linePoints[0].y + tParam * tD;
|
|
1455
|
+
}
|
|
1456
|
+
return new THREE.Vector2(tXx, tYy);
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* 检查两个点是否位置相同
|
|
1460
|
+
* point: { x: number, y: number }
|
|
1461
|
+
* @param point1
|
|
1462
|
+
* @param point2
|
|
1463
|
+
* @return
|
|
1464
|
+
*/
|
|
1465
|
+
function samePointAt(point1, point2) {
|
|
1466
|
+
return point1.x === point2.x && point1.y === point2.y;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
function findAssociatedLines(line) {
|
|
1470
|
+
// 找跟这个线段相邻的线
|
|
1471
|
+
const mergeNextLine = (point, nextIndex, target) => {
|
|
1472
|
+
const nextLine = point.lines.find((line) => {
|
|
1473
|
+
const pointIndex = line.points.findIndex(({ id }) => id === point.id);
|
|
1474
|
+
if (pointIndex === nextIndex)
|
|
1475
|
+
return false;
|
|
1476
|
+
return true;
|
|
1477
|
+
});
|
|
1478
|
+
if (!nextLine)
|
|
1479
|
+
return target;
|
|
1480
|
+
const nextPoint = nextLine.points[nextIndex];
|
|
1481
|
+
if (!nextPoint)
|
|
1482
|
+
return target;
|
|
1483
|
+
return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
|
|
1484
|
+
};
|
|
1485
|
+
const rightLines = mergeNextLine(line.points[0], 1, []);
|
|
1486
|
+
const leftLines = mergeNextLine(line.points[0], 0, []);
|
|
1487
|
+
const lines = rightLines.concat(leftLines);
|
|
1488
|
+
return lines;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
class ViewController extends BaseController {
|
|
1492
|
+
constructor(params) {
|
|
1493
|
+
super(params);
|
|
1494
|
+
Object.defineProperty(this, "type", {
|
|
1495
|
+
enumerable: true,
|
|
1496
|
+
configurable: true,
|
|
1497
|
+
writable: true,
|
|
1498
|
+
value: 'view'
|
|
1499
|
+
});
|
|
1500
|
+
Object.defineProperty(this, "highlightedLines", {
|
|
1501
|
+
enumerable: true,
|
|
1502
|
+
configurable: true,
|
|
1503
|
+
writable: true,
|
|
1504
|
+
value: []
|
|
1505
|
+
});
|
|
1506
|
+
Object.defineProperty(this, "hammer", {
|
|
1507
|
+
enumerable: true,
|
|
1508
|
+
configurable: true,
|
|
1509
|
+
writable: true,
|
|
1510
|
+
value: void 0
|
|
1511
|
+
});
|
|
1512
|
+
Object.defineProperty(this, "wantsTapGesture", {
|
|
1513
|
+
enumerable: true,
|
|
1514
|
+
configurable: true,
|
|
1515
|
+
writable: true,
|
|
1516
|
+
value: (raycaster) => {
|
|
1517
|
+
// 不存在线
|
|
1518
|
+
if (this.model.lines.length === 0)
|
|
1519
|
+
return;
|
|
1520
|
+
const [target] = this.five.model.intersectRaycaster(raycaster);
|
|
1521
|
+
// 点击射线与模型没有交点
|
|
1522
|
+
if (!target)
|
|
1523
|
+
return;
|
|
1524
|
+
const camera = this.five.camera;
|
|
1525
|
+
const ndcTarget = target.point.clone().project(camera);
|
|
1526
|
+
const screenWidth = this.container.clientWidth;
|
|
1527
|
+
const screenHeight = this.container.clientHeight;
|
|
1528
|
+
const targetScreenPosition = new THREE.Vector2(ndcTarget.x * screenWidth, ndcTarget.y * screenHeight);
|
|
1529
|
+
// 把线的端点全部映射到屏幕上,过滤掉不在视野内的线,同时乘以屏幕宽 & 高
|
|
1530
|
+
const screenLines = this.model.lines
|
|
1531
|
+
.map((line) => {
|
|
1532
|
+
const [startPoint, endPoint] = line.points;
|
|
1533
|
+
const ndcStartPoint = startPoint.position.clone().project(camera);
|
|
1534
|
+
const ndcEndPoint = endPoint.position.clone().project(camera);
|
|
1535
|
+
if (!isNDCPointInScreen(ndcStartPoint) && !isNDCPointInScreen(ndcEndPoint))
|
|
1536
|
+
return null;
|
|
1537
|
+
const startScreenPosition = new THREE.Vector2(ndcStartPoint.x * screenWidth, ndcStartPoint.y * screenHeight);
|
|
1538
|
+
const endScreenPosition = new THREE.Vector2(ndcEndPoint.x * screenWidth, ndcEndPoint.y * screenHeight);
|
|
1539
|
+
return { id: line.id, points: [startScreenPosition, endScreenPosition] };
|
|
1540
|
+
})
|
|
1541
|
+
.filter((line) => !!line);
|
|
1542
|
+
if (screenLines.length === 0)
|
|
1543
|
+
return;
|
|
1544
|
+
// 找这些线距离鼠标点击位置最近的线
|
|
1545
|
+
const distanceLines = screenLines
|
|
1546
|
+
.map((line) => {
|
|
1547
|
+
const closestPoint = closestPointOnLine(targetScreenPosition, line.points);
|
|
1548
|
+
return { id: line.id, distance: closestPoint.distanceTo(targetScreenPosition) };
|
|
1549
|
+
})
|
|
1550
|
+
.sort((a, b) => a.distance - b.distance);
|
|
1551
|
+
const closestScreenLine = distanceLines[0];
|
|
1552
|
+
const closestLine = closestScreenLine.distance > 20
|
|
1553
|
+
? undefined
|
|
1554
|
+
: this.model.lines.find(({ id }) => id === closestScreenLine.id);
|
|
1555
|
+
if (this.highlightedLines.length > 0 && !closestLine) {
|
|
1556
|
+
this.clearHighlightLines();
|
|
1557
|
+
return false;
|
|
1558
|
+
}
|
|
1559
|
+
if (closestLine) {
|
|
1560
|
+
this.chooseLine(closestLine);
|
|
1561
|
+
return false;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
Object.defineProperty(this, "chooseLine", {
|
|
1566
|
+
enumerable: true,
|
|
1567
|
+
configurable: true,
|
|
1568
|
+
writable: true,
|
|
1569
|
+
value: (line) => {
|
|
1570
|
+
const highlightLines = findAssociatedLines(line);
|
|
1571
|
+
this.highlightLines(highlightLines);
|
|
1572
|
+
this.five.needsRender = true;
|
|
1573
|
+
this.hook.emit('selectedChange', highlightLines.map((line) => line.toCompletelyJson()));
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
Object.defineProperty(this, "lineRemoved", {
|
|
1577
|
+
enumerable: true,
|
|
1578
|
+
configurable: true,
|
|
1579
|
+
writable: true,
|
|
1580
|
+
value: (line) => {
|
|
1581
|
+
this.removeLine(line);
|
|
1582
|
+
// TODO: 这个逻辑不太好,改进一下
|
|
1583
|
+
this.hook.emit('selectedChange', this.model.lines.filter((line) => line.selected).map((line) => line.toCompletelyJson()));
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
Object.defineProperty(this, "onCameraUpdate", {
|
|
1587
|
+
enumerable: true,
|
|
1588
|
+
configurable: true,
|
|
1589
|
+
writable: true,
|
|
1590
|
+
value: () => {
|
|
1591
|
+
this.updateDistanceUI();
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
this.model.lines.forEach((line) => {
|
|
1595
|
+
line.distanceItem.appendTo(this.container);
|
|
1596
|
+
line.distanceItem.update(this.five);
|
|
1597
|
+
line.hook.on('selected', this.chooseLine);
|
|
1598
|
+
this.group.add(line.mesh);
|
|
1599
|
+
});
|
|
1600
|
+
const fiveElement = this.five.getElement();
|
|
1601
|
+
if (fiveElement) {
|
|
1602
|
+
const hammer = new Hammer__default["default"](fiveElement);
|
|
1603
|
+
this.hammer = hammer;
|
|
1604
|
+
}
|
|
1605
|
+
this.model.hook.on('lineRemoved', this.lineRemoved);
|
|
1606
|
+
this.five.on('cameraUpdate', this.onCameraUpdate);
|
|
1607
|
+
this.five.on('wantsTapGesture', this.wantsTapGesture);
|
|
1608
|
+
this.five.needsRender = true;
|
|
1609
|
+
}
|
|
1610
|
+
dispose() {
|
|
1611
|
+
var _a;
|
|
1612
|
+
super.dispose();
|
|
1613
|
+
this.model.hook.off('lineRemoved', this.lineRemoved);
|
|
1614
|
+
this.five.off('cameraUpdate', this.onCameraUpdate);
|
|
1615
|
+
this.five.off('wantsTapGesture', this.wantsTapGesture);
|
|
1616
|
+
this.five.needsRender = true;
|
|
1617
|
+
this.hook.emit('selectedChange', []);
|
|
1618
|
+
(_a = this.hammer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1619
|
+
}
|
|
1620
|
+
highlightLine(line) {
|
|
1621
|
+
if (line.selected)
|
|
1622
|
+
return;
|
|
1623
|
+
line.selected = true;
|
|
1624
|
+
this.group.add(line.lightMesh);
|
|
1625
|
+
line.distanceItem.highlight();
|
|
1626
|
+
this.five.needsRender = true;
|
|
1627
|
+
}
|
|
1628
|
+
clearHighlightLines() {
|
|
1629
|
+
if (this.group.children.length === 0)
|
|
1630
|
+
return;
|
|
1631
|
+
this.model.lines.forEach((line) => {
|
|
1632
|
+
line.selected = false;
|
|
1633
|
+
line.distanceItem.unHighlight();
|
|
1634
|
+
this.group.remove(line.lightMesh);
|
|
1635
|
+
});
|
|
1636
|
+
this.highlightedLines = [];
|
|
1637
|
+
this.five.needsRender = true;
|
|
1638
|
+
}
|
|
1639
|
+
highlightLines(lines) {
|
|
1640
|
+
this.clearHighlightLines();
|
|
1641
|
+
this.highlightedLines = lines;
|
|
1642
|
+
lines.forEach((line) => this.highlightLine(line));
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1425
1646
|
const svg = `
|
|
1426
1647
|
<svg class="fpm__delete-icon" width="16px" height="17px" viewBox="0 0 16 17" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
1427
1648
|
<defs>
|
|
@@ -1626,50 +1847,6 @@ class DeleteDom {
|
|
|
1626
1847
|
}
|
|
1627
1848
|
}
|
|
1628
1849
|
|
|
1629
|
-
/**
|
|
1630
|
-
* 获取一点对于线段上最近的一点,
|
|
1631
|
-
* 如果可以是过直线垂线的垂足,不行的话取线段的两端
|
|
1632
|
-
* @param point
|
|
1633
|
-
* @param linePoints
|
|
1634
|
-
* @return
|
|
1635
|
-
*/
|
|
1636
|
-
function closestPointOnLine(point, linePoints) {
|
|
1637
|
-
const tA = point.x - linePoints[0].x;
|
|
1638
|
-
const tB = point.y - linePoints[0].y;
|
|
1639
|
-
const tC = linePoints[1].x - linePoints[0].x;
|
|
1640
|
-
const tD = linePoints[1].y - linePoints[0].y;
|
|
1641
|
-
// 设线段为 AB 线段,线段外一点为 P
|
|
1642
|
-
// tDot = AP 向量与 AB 向量乘积,tLenSq 为 |AB|平方。
|
|
1643
|
-
// tParam 是 AP 向量在 AB 向量投影向量 AC 与 AB 向量的比。
|
|
1644
|
-
const tDot = tA * tC + tB * tD;
|
|
1645
|
-
const tLenSq = tC * tC + tD * tD;
|
|
1646
|
-
const tParam = tDot / tLenSq;
|
|
1647
|
-
let tXx, tYy;
|
|
1648
|
-
if (tParam < 0 || samePointAt(linePoints[0], linePoints[1])) {
|
|
1649
|
-
tXx = linePoints[0].x;
|
|
1650
|
-
tYy = linePoints[0].y;
|
|
1651
|
-
}
|
|
1652
|
-
else if (tParam > 1) {
|
|
1653
|
-
tXx = linePoints[1].x;
|
|
1654
|
-
tYy = linePoints[1].y;
|
|
1655
|
-
}
|
|
1656
|
-
else {
|
|
1657
|
-
tXx = linePoints[0].x + tParam * tC;
|
|
1658
|
-
tYy = linePoints[0].y + tParam * tD;
|
|
1659
|
-
}
|
|
1660
|
-
return new THREE.Vector2(tXx, tYy);
|
|
1661
|
-
}
|
|
1662
|
-
/**
|
|
1663
|
-
* 检查两个点是否位置相同
|
|
1664
|
-
* point: { x: number, y: number }
|
|
1665
|
-
* @param point1
|
|
1666
|
-
* @param point2
|
|
1667
|
-
* @return
|
|
1668
|
-
*/
|
|
1669
|
-
function samePointAt(point1, point2) {
|
|
1670
|
-
return point1.x === point2.x && point1.y === point2.y;
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
1850
|
function ndc2Screen(ndcPosition, containerSize) {
|
|
1674
1851
|
const left = ((ndcPosition.x + 1) / 2) * containerSize.width;
|
|
1675
1852
|
const top = (-(ndcPosition.y - 1) / 2) * containerSize.height;
|
|
@@ -1702,28 +1879,6 @@ function findClosestPoint(five, points, tapPoint, maxDistance) {
|
|
|
1702
1879
|
return ndcPoints[0];
|
|
1703
1880
|
}
|
|
1704
1881
|
|
|
1705
|
-
function findAssociatedLines(line) {
|
|
1706
|
-
// 找跟这个线段相邻的线
|
|
1707
|
-
const mergeNextLine = (point, nextIndex, target) => {
|
|
1708
|
-
const nextLine = point.lines.find((line) => {
|
|
1709
|
-
const pointIndex = line.points.findIndex(({ id }) => id === point.id);
|
|
1710
|
-
if (pointIndex === nextIndex)
|
|
1711
|
-
return false;
|
|
1712
|
-
return true;
|
|
1713
|
-
});
|
|
1714
|
-
if (!nextLine)
|
|
1715
|
-
return target;
|
|
1716
|
-
const nextPoint = nextLine.points[nextIndex];
|
|
1717
|
-
if (!nextPoint)
|
|
1718
|
-
return target;
|
|
1719
|
-
return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
|
|
1720
|
-
};
|
|
1721
|
-
const rightLines = mergeNextLine(line.points[0], 1, []);
|
|
1722
|
-
const leftLines = mergeNextLine(line.points[0], 0, []);
|
|
1723
|
-
const lines = rightLines.concat(leftLines);
|
|
1724
|
-
return lines;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
1882
|
class WatchController extends BaseController {
|
|
1728
1883
|
constructor(params) {
|
|
1729
1884
|
super(params);
|
|
@@ -1997,6 +2152,7 @@ class WatchController extends BaseController {
|
|
|
1997
2152
|
super.dispose();
|
|
1998
2153
|
this.deleteDom.dispose();
|
|
1999
2154
|
this.model.hook.off('lineRemoved', this.lineRemoved);
|
|
2155
|
+
this.model.lines.forEach((line) => line.hook.off('selected', this.chooseLine));
|
|
2000
2156
|
this.five.off('cameraUpdate', this.onCameraUpdate);
|
|
2001
2157
|
this.five.off('wantsPanGesture', this.wantsPanGesture);
|
|
2002
2158
|
this.five.off('wantsTapGesture', this.wantsTapGesture);
|
|
@@ -3785,6 +3941,7 @@ class MeasureController {
|
|
|
3785
3941
|
return new Error('不支持切换的Mode');
|
|
3786
3942
|
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
3787
3943
|
const controllerMap = {
|
|
3944
|
+
View: ViewController,
|
|
3788
3945
|
Watch: WatchController,
|
|
3789
3946
|
Edit: EditController,
|
|
3790
3947
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const normalLineOpts:
|
|
3
|
-
export declare const dashLineOpts:
|
|
4
|
-
export declare const lightLineOpts:
|
|
1
|
+
import type { ICreateLineOpts } from './line';
|
|
2
|
+
export declare const normalLineOpts: ICreateLineOpts;
|
|
3
|
+
export declare const dashLineOpts: ICreateLineOpts;
|
|
4
|
+
export declare const lightLineOpts: ICreateLineOpts;
|
|
@@ -2,7 +2,7 @@ import type Line from '../Model/line';
|
|
|
2
2
|
import type { Five } from '@realsee/five';
|
|
3
3
|
import type { LineCompletelyJson, PolylineCompletelyJson } from '../typings/data';
|
|
4
4
|
import { Vector3 } from 'three';
|
|
5
|
-
export declare type DistanceItem = ReturnType<typeof
|
|
5
|
+
export declare type DistanceItem = ReturnType<typeof createDistanceItem>;
|
|
6
6
|
export interface UserDistanceItem {
|
|
7
7
|
element: Element;
|
|
8
8
|
highlight: () => void;
|
|
@@ -17,7 +17,7 @@ export interface IDistanceItemProps {
|
|
|
17
17
|
userDistanceItem?: UserDistanceItem;
|
|
18
18
|
clickCallback?: (item: DistanceItem) => unknown;
|
|
19
19
|
}
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function createDistanceItem(props: IDistanceItemProps): {
|
|
21
21
|
lineID: string;
|
|
22
22
|
ndcPosition: Vector3;
|
|
23
23
|
update: (five: Five) => void;
|
|
@@ -2,7 +2,7 @@ import type Line from '../Model/line';
|
|
|
2
2
|
import { Line as FiveLine } from '@realsee/five/line';
|
|
3
3
|
import { Color, Texture, Vector3 } from 'three';
|
|
4
4
|
declare type ISetMaterialOpts = Parameters<FiveLine['setMaterial']>[0];
|
|
5
|
-
export interface
|
|
5
|
+
export interface ICreateLineOpts extends ISetMaterialOpts {
|
|
6
6
|
hasPoint?: boolean;
|
|
7
7
|
pointSize?: number;
|
|
8
8
|
lineWidth?: number;
|
|
@@ -12,6 +12,6 @@ export interface ICreatLineOpts extends ISetMaterialOpts {
|
|
|
12
12
|
lineColor?: Color | string | number;
|
|
13
13
|
pointColor?: Color | string | number;
|
|
14
14
|
}
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
15
|
+
export declare function createLine(start: Vector3, end: Vector3, opts?: ICreateLineOpts): FiveLine;
|
|
16
|
+
export declare function createLineMesh(line: Line, type: 'normal' | 'light'): FiveLine;
|
|
17
17
|
export {};
|