@realsee/dnalogel 2.0.0-alpha.39 → 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/ItemLabelPlugin/index.js +2 -4
- 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 +236 -81
- package/dist/index.js +236 -81
- package/dist/index.umd.js +236 -81
- 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/ItemLabelPlugin/ItemLabelComponent.js +2 -4
- 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 +2 -2
package/dist/index.es.js
CHANGED
|
@@ -377,7 +377,7 @@ const CSS3DRenderPlugin = (five) => {
|
|
|
377
377
|
};
|
|
378
378
|
};
|
|
379
379
|
|
|
380
|
-
function createLine(point1, point2, color = new Vector3$1(1, 1, 1), dashed = false) {
|
|
380
|
+
function createLine$1(point1, point2, color = new Vector3$1(1, 1, 1), dashed = false) {
|
|
381
381
|
const line = new Line$1(point1, point2);
|
|
382
382
|
line.setMaterial({ dashed, color, linewidth: 1 });
|
|
383
383
|
line.remove(line.points);
|
|
@@ -413,7 +413,7 @@ const PanoCursorRaycasterPlugin = (five) => {
|
|
|
413
413
|
const helperCenterPoint = movePointTowardsCamera(point, fixDistance);
|
|
414
414
|
const p = helperCenterPoint;
|
|
415
415
|
const pointAxesHelperMesh = new Group();
|
|
416
|
-
pointAxesHelperMesh.add(createLine(new Vector3$1(p.x + halfLength, p.y, p.z), new Vector3$1(p.x - halfLength, p.y, p.z), new Vector3$1(1, 0, 0)), createLine(new Vector3$1(p.x, p.y + halfLength, p.z), new Vector3$1(p.x, p.y - halfLength, p.z), new Vector3$1(0, 1, 0)), createLine(new Vector3$1(p.x, p.y, p.z + halfLength), new Vector3$1(p.x, p.y, p.z - halfLength), new Vector3$1(0, 0, 1)));
|
|
416
|
+
pointAxesHelperMesh.add(createLine$1(new Vector3$1(p.x + halfLength, p.y, p.z), new Vector3$1(p.x - halfLength, p.y, p.z), new Vector3$1(1, 0, 0)), createLine$1(new Vector3$1(p.x, p.y + halfLength, p.z), new Vector3$1(p.x, p.y - halfLength, p.z), new Vector3$1(0, 1, 0)), createLine$1(new Vector3$1(p.x, p.y, p.z + halfLength), new Vector3$1(p.x, p.y, p.z - halfLength), new Vector3$1(0, 0, 1)));
|
|
417
417
|
five.scene.add(pointAxesHelperMesh);
|
|
418
418
|
five.needsRender = true;
|
|
419
419
|
// 清理函数
|
|
@@ -9909,7 +9909,7 @@ const lightLineOpts = {
|
|
|
9909
9909
|
pointsRenderOrder: 10,
|
|
9910
9910
|
};
|
|
9911
9911
|
|
|
9912
|
-
function
|
|
9912
|
+
function createLine(start, end, opts) {
|
|
9913
9913
|
var _a, _b, _c, _d, _e;
|
|
9914
9914
|
const lineWidth = (_a = opts === null || opts === void 0 ? void 0 : opts.lineWidth) !== null && _a !== void 0 ? _a : 2;
|
|
9915
9915
|
const lineColor = (_b = opts === null || opts === void 0 ? void 0 : opts.lineColor) !== null && _b !== void 0 ? _b : new Color(0xffffff);
|
|
@@ -9932,10 +9932,10 @@ function creatLine(start, end, opts) {
|
|
|
9932
9932
|
pointMaterial.map = opts.pointTexture;
|
|
9933
9933
|
return line;
|
|
9934
9934
|
}
|
|
9935
|
-
function
|
|
9935
|
+
function createLineMesh(line, type) {
|
|
9936
9936
|
const [point, anotherPoint] = line.points;
|
|
9937
9937
|
const opts = type === 'light' ? lightLineOpts : normalLineOpts;
|
|
9938
|
-
const fiveLine =
|
|
9938
|
+
const fiveLine = createLine(point.position, anotherPoint.position, opts);
|
|
9939
9939
|
fiveLine.name = 'normalLine_' + line.id;
|
|
9940
9940
|
return fiveLine;
|
|
9941
9941
|
}
|
|
@@ -9947,7 +9947,7 @@ function isNDCPointInScreen(ndcPoint) {
|
|
|
9947
9947
|
return true;
|
|
9948
9948
|
}
|
|
9949
9949
|
|
|
9950
|
-
function
|
|
9950
|
+
function createContentDom() {
|
|
9951
9951
|
const contentDom = document.createElement('div');
|
|
9952
9952
|
contentDom.setAttribute('style', `backdrop-filter: blur(4px);-webkit-backdrop-filter: blur(4px);`);
|
|
9953
9953
|
contentDom.style.padding = '3px 6px';
|
|
@@ -9975,7 +9975,7 @@ function createContainerDom(line) {
|
|
|
9975
9975
|
containerDom.style.transformOrigin = 'left top';
|
|
9976
9976
|
return containerDom;
|
|
9977
9977
|
}
|
|
9978
|
-
function
|
|
9978
|
+
function createDistanceItem(props) {
|
|
9979
9979
|
function handleClick() {
|
|
9980
9980
|
var _a;
|
|
9981
9981
|
// 线被选中时才高亮,外部手动触发高亮
|
|
@@ -10049,7 +10049,7 @@ function creatDistanceItem(props) {
|
|
|
10049
10049
|
}
|
|
10050
10050
|
const { line } = props;
|
|
10051
10051
|
const lineID = line.id;
|
|
10052
|
-
const contentDom =
|
|
10052
|
+
const contentDom = createContentDom();
|
|
10053
10053
|
const containerDom = createContainerDom(line);
|
|
10054
10054
|
const userDistanceItem = props.userDistanceItem;
|
|
10055
10055
|
const ndcPosition = new Vector3$1(0, 0, 0);
|
|
@@ -10134,9 +10134,9 @@ class Line {
|
|
|
10134
10134
|
throw new Error('无效的线段, 一个点无法构成线段');
|
|
10135
10135
|
this.hook = new Subscribe();
|
|
10136
10136
|
this.points = [point, anotherPoint];
|
|
10137
|
-
this.mesh =
|
|
10138
|
-
this.lightMesh =
|
|
10139
|
-
this.distanceItem =
|
|
10137
|
+
this.mesh = createLineMesh(this, 'normal');
|
|
10138
|
+
this.lightMesh = createLineMesh(this, 'light');
|
|
10139
|
+
this.distanceItem = createDistanceItem({
|
|
10140
10140
|
line: this,
|
|
10141
10141
|
clickCallback: () => this.hook.emit('selected', this),
|
|
10142
10142
|
userDistanceItem: this.model.params.userDistanceItemCreator
|
|
@@ -10849,6 +10849,227 @@ class EditController extends BaseController {
|
|
|
10849
10849
|
}
|
|
10850
10850
|
}
|
|
10851
10851
|
|
|
10852
|
+
/**
|
|
10853
|
+
* 获取一点对于线段上最近的一点,
|
|
10854
|
+
* 如果可以是过直线垂线的垂足,不行的话取线段的两端
|
|
10855
|
+
* @param point
|
|
10856
|
+
* @param linePoints
|
|
10857
|
+
* @return
|
|
10858
|
+
*/
|
|
10859
|
+
function closestPointOnLine(point, linePoints) {
|
|
10860
|
+
const tA = point.x - linePoints[0].x;
|
|
10861
|
+
const tB = point.y - linePoints[0].y;
|
|
10862
|
+
const tC = linePoints[1].x - linePoints[0].x;
|
|
10863
|
+
const tD = linePoints[1].y - linePoints[0].y;
|
|
10864
|
+
// 设线段为 AB 线段,线段外一点为 P
|
|
10865
|
+
// tDot = AP 向量与 AB 向量乘积,tLenSq 为 |AB|平方。
|
|
10866
|
+
// tParam 是 AP 向量在 AB 向量投影向量 AC 与 AB 向量的比。
|
|
10867
|
+
const tDot = tA * tC + tB * tD;
|
|
10868
|
+
const tLenSq = tC * tC + tD * tD;
|
|
10869
|
+
const tParam = tDot / tLenSq;
|
|
10870
|
+
let tXx, tYy;
|
|
10871
|
+
if (tParam < 0 || samePointAt(linePoints[0], linePoints[1])) {
|
|
10872
|
+
tXx = linePoints[0].x;
|
|
10873
|
+
tYy = linePoints[0].y;
|
|
10874
|
+
}
|
|
10875
|
+
else if (tParam > 1) {
|
|
10876
|
+
tXx = linePoints[1].x;
|
|
10877
|
+
tYy = linePoints[1].y;
|
|
10878
|
+
}
|
|
10879
|
+
else {
|
|
10880
|
+
tXx = linePoints[0].x + tParam * tC;
|
|
10881
|
+
tYy = linePoints[0].y + tParam * tD;
|
|
10882
|
+
}
|
|
10883
|
+
return new Vector2$1(tXx, tYy);
|
|
10884
|
+
}
|
|
10885
|
+
/**
|
|
10886
|
+
* 检查两个点是否位置相同
|
|
10887
|
+
* point: { x: number, y: number }
|
|
10888
|
+
* @param point1
|
|
10889
|
+
* @param point2
|
|
10890
|
+
* @return
|
|
10891
|
+
*/
|
|
10892
|
+
function samePointAt(point1, point2) {
|
|
10893
|
+
return point1.x === point2.x && point1.y === point2.y;
|
|
10894
|
+
}
|
|
10895
|
+
|
|
10896
|
+
function findAssociatedLines(line) {
|
|
10897
|
+
// 找跟这个线段相邻的线
|
|
10898
|
+
const mergeNextLine = (point, nextIndex, target) => {
|
|
10899
|
+
const nextLine = point.lines.find((line) => {
|
|
10900
|
+
const pointIndex = line.points.findIndex(({ id }) => id === point.id);
|
|
10901
|
+
if (pointIndex === nextIndex)
|
|
10902
|
+
return false;
|
|
10903
|
+
return true;
|
|
10904
|
+
});
|
|
10905
|
+
if (!nextLine)
|
|
10906
|
+
return target;
|
|
10907
|
+
const nextPoint = nextLine.points[nextIndex];
|
|
10908
|
+
if (!nextPoint)
|
|
10909
|
+
return target;
|
|
10910
|
+
return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
|
|
10911
|
+
};
|
|
10912
|
+
const rightLines = mergeNextLine(line.points[0], 1, []);
|
|
10913
|
+
const leftLines = mergeNextLine(line.points[0], 0, []);
|
|
10914
|
+
const lines = rightLines.concat(leftLines);
|
|
10915
|
+
return lines;
|
|
10916
|
+
}
|
|
10917
|
+
|
|
10918
|
+
class ViewController extends BaseController {
|
|
10919
|
+
constructor(params) {
|
|
10920
|
+
super(params);
|
|
10921
|
+
Object.defineProperty(this, "type", {
|
|
10922
|
+
enumerable: true,
|
|
10923
|
+
configurable: true,
|
|
10924
|
+
writable: true,
|
|
10925
|
+
value: 'view'
|
|
10926
|
+
});
|
|
10927
|
+
Object.defineProperty(this, "highlightedLines", {
|
|
10928
|
+
enumerable: true,
|
|
10929
|
+
configurable: true,
|
|
10930
|
+
writable: true,
|
|
10931
|
+
value: []
|
|
10932
|
+
});
|
|
10933
|
+
Object.defineProperty(this, "hammer", {
|
|
10934
|
+
enumerable: true,
|
|
10935
|
+
configurable: true,
|
|
10936
|
+
writable: true,
|
|
10937
|
+
value: void 0
|
|
10938
|
+
});
|
|
10939
|
+
Object.defineProperty(this, "wantsTapGesture", {
|
|
10940
|
+
enumerable: true,
|
|
10941
|
+
configurable: true,
|
|
10942
|
+
writable: true,
|
|
10943
|
+
value: (raycaster) => {
|
|
10944
|
+
// 不存在线
|
|
10945
|
+
if (this.model.lines.length === 0)
|
|
10946
|
+
return;
|
|
10947
|
+
const [target] = this.five.model.intersectRaycaster(raycaster);
|
|
10948
|
+
// 点击射线与模型没有交点
|
|
10949
|
+
if (!target)
|
|
10950
|
+
return;
|
|
10951
|
+
const camera = this.five.camera;
|
|
10952
|
+
const ndcTarget = target.point.clone().project(camera);
|
|
10953
|
+
const screenWidth = this.container.clientWidth;
|
|
10954
|
+
const screenHeight = this.container.clientHeight;
|
|
10955
|
+
const targetScreenPosition = new Vector2$1(ndcTarget.x * screenWidth, ndcTarget.y * screenHeight);
|
|
10956
|
+
// 把线的端点全部映射到屏幕上,过滤掉不在视野内的线,同时乘以屏幕宽 & 高
|
|
10957
|
+
const screenLines = this.model.lines
|
|
10958
|
+
.map((line) => {
|
|
10959
|
+
const [startPoint, endPoint] = line.points;
|
|
10960
|
+
const ndcStartPoint = startPoint.position.clone().project(camera);
|
|
10961
|
+
const ndcEndPoint = endPoint.position.clone().project(camera);
|
|
10962
|
+
if (!isNDCPointInScreen(ndcStartPoint) && !isNDCPointInScreen(ndcEndPoint))
|
|
10963
|
+
return null;
|
|
10964
|
+
const startScreenPosition = new Vector2$1(ndcStartPoint.x * screenWidth, ndcStartPoint.y * screenHeight);
|
|
10965
|
+
const endScreenPosition = new Vector2$1(ndcEndPoint.x * screenWidth, ndcEndPoint.y * screenHeight);
|
|
10966
|
+
return { id: line.id, points: [startScreenPosition, endScreenPosition] };
|
|
10967
|
+
})
|
|
10968
|
+
.filter((line) => !!line);
|
|
10969
|
+
if (screenLines.length === 0)
|
|
10970
|
+
return;
|
|
10971
|
+
// 找这些线距离鼠标点击位置最近的线
|
|
10972
|
+
const distanceLines = screenLines
|
|
10973
|
+
.map((line) => {
|
|
10974
|
+
const closestPoint = closestPointOnLine(targetScreenPosition, line.points);
|
|
10975
|
+
return { id: line.id, distance: closestPoint.distanceTo(targetScreenPosition) };
|
|
10976
|
+
})
|
|
10977
|
+
.sort((a, b) => a.distance - b.distance);
|
|
10978
|
+
const closestScreenLine = distanceLines[0];
|
|
10979
|
+
const closestLine = closestScreenLine.distance > 20
|
|
10980
|
+
? undefined
|
|
10981
|
+
: this.model.lines.find(({ id }) => id === closestScreenLine.id);
|
|
10982
|
+
if (this.highlightedLines.length > 0 && !closestLine) {
|
|
10983
|
+
this.clearHighlightLines();
|
|
10984
|
+
return false;
|
|
10985
|
+
}
|
|
10986
|
+
if (closestLine) {
|
|
10987
|
+
this.chooseLine(closestLine);
|
|
10988
|
+
return false;
|
|
10989
|
+
}
|
|
10990
|
+
}
|
|
10991
|
+
});
|
|
10992
|
+
Object.defineProperty(this, "chooseLine", {
|
|
10993
|
+
enumerable: true,
|
|
10994
|
+
configurable: true,
|
|
10995
|
+
writable: true,
|
|
10996
|
+
value: (line) => {
|
|
10997
|
+
const highlightLines = findAssociatedLines(line);
|
|
10998
|
+
this.highlightLines(highlightLines);
|
|
10999
|
+
this.five.needsRender = true;
|
|
11000
|
+
this.hook.emit('selectedChange', highlightLines.map((line) => line.toCompletelyJson()));
|
|
11001
|
+
}
|
|
11002
|
+
});
|
|
11003
|
+
Object.defineProperty(this, "lineRemoved", {
|
|
11004
|
+
enumerable: true,
|
|
11005
|
+
configurable: true,
|
|
11006
|
+
writable: true,
|
|
11007
|
+
value: (line) => {
|
|
11008
|
+
this.removeLine(line);
|
|
11009
|
+
// TODO: 这个逻辑不太好,改进一下
|
|
11010
|
+
this.hook.emit('selectedChange', this.model.lines.filter((line) => line.selected).map((line) => line.toCompletelyJson()));
|
|
11011
|
+
}
|
|
11012
|
+
});
|
|
11013
|
+
Object.defineProperty(this, "onCameraUpdate", {
|
|
11014
|
+
enumerable: true,
|
|
11015
|
+
configurable: true,
|
|
11016
|
+
writable: true,
|
|
11017
|
+
value: () => {
|
|
11018
|
+
this.updateDistanceUI();
|
|
11019
|
+
}
|
|
11020
|
+
});
|
|
11021
|
+
this.model.lines.forEach((line) => {
|
|
11022
|
+
line.distanceItem.appendTo(this.container);
|
|
11023
|
+
line.distanceItem.update(this.five);
|
|
11024
|
+
line.hook.on('selected', this.chooseLine);
|
|
11025
|
+
this.group.add(line.mesh);
|
|
11026
|
+
});
|
|
11027
|
+
const fiveElement = this.five.getElement();
|
|
11028
|
+
if (fiveElement) {
|
|
11029
|
+
const hammer = new Hammer(fiveElement);
|
|
11030
|
+
this.hammer = hammer;
|
|
11031
|
+
}
|
|
11032
|
+
this.model.hook.on('lineRemoved', this.lineRemoved);
|
|
11033
|
+
this.five.on('cameraUpdate', this.onCameraUpdate);
|
|
11034
|
+
this.five.on('wantsTapGesture', this.wantsTapGesture);
|
|
11035
|
+
this.five.needsRender = true;
|
|
11036
|
+
}
|
|
11037
|
+
dispose() {
|
|
11038
|
+
var _a;
|
|
11039
|
+
super.dispose();
|
|
11040
|
+
this.model.hook.off('lineRemoved', this.lineRemoved);
|
|
11041
|
+
this.five.off('cameraUpdate', this.onCameraUpdate);
|
|
11042
|
+
this.five.off('wantsTapGesture', this.wantsTapGesture);
|
|
11043
|
+
this.five.needsRender = true;
|
|
11044
|
+
this.hook.emit('selectedChange', []);
|
|
11045
|
+
(_a = this.hammer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
11046
|
+
}
|
|
11047
|
+
highlightLine(line) {
|
|
11048
|
+
if (line.selected)
|
|
11049
|
+
return;
|
|
11050
|
+
line.selected = true;
|
|
11051
|
+
this.group.add(line.lightMesh);
|
|
11052
|
+
line.distanceItem.highlight();
|
|
11053
|
+
this.five.needsRender = true;
|
|
11054
|
+
}
|
|
11055
|
+
clearHighlightLines() {
|
|
11056
|
+
if (this.group.children.length === 0)
|
|
11057
|
+
return;
|
|
11058
|
+
this.model.lines.forEach((line) => {
|
|
11059
|
+
line.selected = false;
|
|
11060
|
+
line.distanceItem.unHighlight();
|
|
11061
|
+
this.group.remove(line.lightMesh);
|
|
11062
|
+
});
|
|
11063
|
+
this.highlightedLines = [];
|
|
11064
|
+
this.five.needsRender = true;
|
|
11065
|
+
}
|
|
11066
|
+
highlightLines(lines) {
|
|
11067
|
+
this.clearHighlightLines();
|
|
11068
|
+
this.highlightedLines = lines;
|
|
11069
|
+
lines.forEach((line) => this.highlightLine(line));
|
|
11070
|
+
}
|
|
11071
|
+
}
|
|
11072
|
+
|
|
10852
11073
|
const svg = `
|
|
10853
11074
|
<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">
|
|
10854
11075
|
<defs>
|
|
@@ -11053,50 +11274,6 @@ class DeleteDom {
|
|
|
11053
11274
|
}
|
|
11054
11275
|
}
|
|
11055
11276
|
|
|
11056
|
-
/**
|
|
11057
|
-
* 获取一点对于线段上最近的一点,
|
|
11058
|
-
* 如果可以是过直线垂线的垂足,不行的话取线段的两端
|
|
11059
|
-
* @param point
|
|
11060
|
-
* @param linePoints
|
|
11061
|
-
* @return
|
|
11062
|
-
*/
|
|
11063
|
-
function closestPointOnLine(point, linePoints) {
|
|
11064
|
-
const tA = point.x - linePoints[0].x;
|
|
11065
|
-
const tB = point.y - linePoints[0].y;
|
|
11066
|
-
const tC = linePoints[1].x - linePoints[0].x;
|
|
11067
|
-
const tD = linePoints[1].y - linePoints[0].y;
|
|
11068
|
-
// 设线段为 AB 线段,线段外一点为 P
|
|
11069
|
-
// tDot = AP 向量与 AB 向量乘积,tLenSq 为 |AB|平方。
|
|
11070
|
-
// tParam 是 AP 向量在 AB 向量投影向量 AC 与 AB 向量的比。
|
|
11071
|
-
const tDot = tA * tC + tB * tD;
|
|
11072
|
-
const tLenSq = tC * tC + tD * tD;
|
|
11073
|
-
const tParam = tDot / tLenSq;
|
|
11074
|
-
let tXx, tYy;
|
|
11075
|
-
if (tParam < 0 || samePointAt(linePoints[0], linePoints[1])) {
|
|
11076
|
-
tXx = linePoints[0].x;
|
|
11077
|
-
tYy = linePoints[0].y;
|
|
11078
|
-
}
|
|
11079
|
-
else if (tParam > 1) {
|
|
11080
|
-
tXx = linePoints[1].x;
|
|
11081
|
-
tYy = linePoints[1].y;
|
|
11082
|
-
}
|
|
11083
|
-
else {
|
|
11084
|
-
tXx = linePoints[0].x + tParam * tC;
|
|
11085
|
-
tYy = linePoints[0].y + tParam * tD;
|
|
11086
|
-
}
|
|
11087
|
-
return new Vector2$1(tXx, tYy);
|
|
11088
|
-
}
|
|
11089
|
-
/**
|
|
11090
|
-
* 检查两个点是否位置相同
|
|
11091
|
-
* point: { x: number, y: number }
|
|
11092
|
-
* @param point1
|
|
11093
|
-
* @param point2
|
|
11094
|
-
* @return
|
|
11095
|
-
*/
|
|
11096
|
-
function samePointAt(point1, point2) {
|
|
11097
|
-
return point1.x === point2.x && point1.y === point2.y;
|
|
11098
|
-
}
|
|
11099
|
-
|
|
11100
11277
|
function ndc2Screen(ndcPosition, containerSize) {
|
|
11101
11278
|
const left = ((ndcPosition.x + 1) / 2) * containerSize.width;
|
|
11102
11279
|
const top = (-(ndcPosition.y - 1) / 2) * containerSize.height;
|
|
@@ -11129,28 +11306,6 @@ function findClosestPoint(five, points, tapPoint, maxDistance) {
|
|
|
11129
11306
|
return ndcPoints[0];
|
|
11130
11307
|
}
|
|
11131
11308
|
|
|
11132
|
-
function findAssociatedLines(line) {
|
|
11133
|
-
// 找跟这个线段相邻的线
|
|
11134
|
-
const mergeNextLine = (point, nextIndex, target) => {
|
|
11135
|
-
const nextLine = point.lines.find((line) => {
|
|
11136
|
-
const pointIndex = line.points.findIndex(({ id }) => id === point.id);
|
|
11137
|
-
if (pointIndex === nextIndex)
|
|
11138
|
-
return false;
|
|
11139
|
-
return true;
|
|
11140
|
-
});
|
|
11141
|
-
if (!nextLine)
|
|
11142
|
-
return target;
|
|
11143
|
-
const nextPoint = nextLine.points[nextIndex];
|
|
11144
|
-
if (!nextPoint)
|
|
11145
|
-
return target;
|
|
11146
|
-
return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
|
|
11147
|
-
};
|
|
11148
|
-
const rightLines = mergeNextLine(line.points[0], 1, []);
|
|
11149
|
-
const leftLines = mergeNextLine(line.points[0], 0, []);
|
|
11150
|
-
const lines = rightLines.concat(leftLines);
|
|
11151
|
-
return lines;
|
|
11152
|
-
}
|
|
11153
|
-
|
|
11154
11309
|
class WatchController extends BaseController {
|
|
11155
11310
|
constructor(params) {
|
|
11156
11311
|
super(params);
|
|
@@ -11424,6 +11579,7 @@ class WatchController extends BaseController {
|
|
|
11424
11579
|
super.dispose();
|
|
11425
11580
|
this.deleteDom.dispose();
|
|
11426
11581
|
this.model.hook.off('lineRemoved', this.lineRemoved);
|
|
11582
|
+
this.model.lines.forEach((line) => line.hook.off('selected', this.chooseLine));
|
|
11427
11583
|
this.five.off('cameraUpdate', this.onCameraUpdate);
|
|
11428
11584
|
this.five.off('wantsPanGesture', this.wantsPanGesture);
|
|
11429
11585
|
this.five.off('wantsTapGesture', this.wantsTapGesture);
|
|
@@ -13182,6 +13338,7 @@ class MeasureController {
|
|
|
13182
13338
|
return new Error('不支持切换的Mode');
|
|
13183
13339
|
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
13184
13340
|
const controllerMap = {
|
|
13341
|
+
View: ViewController,
|
|
13185
13342
|
Watch: WatchController,
|
|
13186
13343
|
Edit: EditController,
|
|
13187
13344
|
};
|
|
@@ -15577,7 +15734,7 @@ function get_each_context(ctx, list, i) {
|
|
|
15577
15734
|
return child_ctx;
|
|
15578
15735
|
}
|
|
15579
15736
|
|
|
15580
|
-
// (
|
|
15737
|
+
// (234:2) {#if itemLabelItem.visible}
|
|
15581
15738
|
function create_if_block(ctx) {
|
|
15582
15739
|
let itemlabelitem;
|
|
15583
15740
|
let current;
|
|
@@ -15621,7 +15778,7 @@ function create_if_block(ctx) {
|
|
|
15621
15778
|
};
|
|
15622
15779
|
}
|
|
15623
15780
|
|
|
15624
|
-
// (
|
|
15781
|
+
// (233:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
|
|
15625
15782
|
function create_each_block(key_1, ctx) {
|
|
15626
15783
|
let first;
|
|
15627
15784
|
let if_block_anchor;
|
|
@@ -15844,8 +16001,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
15844
16001
|
};
|
|
15845
16002
|
|
|
15846
16003
|
const getFormatedItemLabels = (five, labels) => {
|
|
15847
|
-
console.log(labels);
|
|
15848
|
-
|
|
15849
16004
|
// 计算位置 & 可见性
|
|
15850
16005
|
const newLabels = labels.map(label => {
|
|
15851
16006
|
// 不在绑定点位则直接不可见
|