@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.
Files changed (104) hide show
  1. package/dist/ItemLabelPlugin/index.js +2 -4
  2. package/dist/PanoMeasurePlugin/Controller/ViewController.d.ts +16 -0
  3. package/dist/PanoMeasurePlugin/Controller/index.d.ts +1 -1
  4. package/dist/PanoMeasurePlugin/index.js +232 -75
  5. package/dist/PanoMeasurePlugin/utils/constants.d.ts +4 -4
  6. package/dist/PanoMeasurePlugin/utils/distanceDom.d.ts +2 -2
  7. package/dist/PanoMeasurePlugin/utils/line.d.ts +3 -3
  8. package/dist/index.es.js +236 -81
  9. package/dist/index.js +236 -81
  10. package/dist/index.umd.js +236 -81
  11. package/docs/classes/Magnifier.html +4 -4
  12. package/docs/classes/ModelRoomLabelController.html +4 -4
  13. package/docs/enums/CameraMovementEffect.html +2 -2
  14. package/docs/enums/DIRECTION.html +1 -1
  15. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  16. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  17. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  18. package/docs/enums/Rotation.html +2 -2
  19. package/docs/index.html +1 -1
  20. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  21. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  22. package/docs/interfaces/FloorplanBounding.html +4 -4
  23. package/docs/interfaces/FloorplanData.html +2 -2
  24. package/docs/interfaces/FloorplanEntrance.html +7 -7
  25. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  26. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  27. package/docs/interfaces/FloorplanFloorData.html +2 -2
  28. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  29. package/docs/interfaces/FloorplanObserver.html +2 -2
  30. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  31. package/docs/interfaces/FloorplanPosition.html +2 -2
  32. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  33. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  34. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  35. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  36. package/docs/interfaces/FloorplanServerData.html +2 -2
  37. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  38. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  39. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  40. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  41. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  42. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  43. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  44. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  45. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  46. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  47. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  48. package/docs/interfaces/LineJson.html +1 -1
  49. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  50. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  51. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  52. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  53. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  54. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  55. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  56. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  57. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  58. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  59. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  60. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  61. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  62. package/docs/interfaces/OpenParameter.html +2 -2
  63. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  64. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  65. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  66. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  67. package/docs/interfaces/PanoMeasureParameterType.html +1 -1
  68. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  69. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  70. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  71. package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
  72. package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
  73. package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
  74. package/docs/interfaces/PanoRulerProPluginState.html +1 -1
  75. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  76. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  77. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  78. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  79. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  80. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  81. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  82. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  83. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  84. package/docs/interfaces/Point.html +1 -1
  85. package/docs/interfaces/PointJson.html +1 -1
  86. package/docs/interfaces/Room.html +1 -1
  87. package/docs/interfaces/RoomInfo.html +1 -1
  88. package/docs/interfaces/RoomLabel.html +7 -7
  89. package/docs/interfaces/RoomRules.html +1 -1
  90. package/docs/interfaces/Rooms.html +1 -1
  91. package/docs/modules.html +18 -18
  92. package/libs/ItemLabelPlugin/ItemLabelComponent.js +2 -4
  93. package/libs/PanoMeasurePlugin/Controller/ViewController.d.ts +16 -0
  94. package/libs/PanoMeasurePlugin/Controller/ViewController.js +160 -0
  95. package/libs/PanoMeasurePlugin/Controller/WatchController.js +1 -0
  96. package/libs/PanoMeasurePlugin/Controller/index.d.ts +1 -1
  97. package/libs/PanoMeasurePlugin/Controller/index.js +2 -0
  98. package/libs/PanoMeasurePlugin/Model/line.js +5 -5
  99. package/libs/PanoMeasurePlugin/utils/constants.d.ts +4 -4
  100. package/libs/PanoMeasurePlugin/utils/distanceDom.d.ts +2 -2
  101. package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -3
  102. package/libs/PanoMeasurePlugin/utils/line.d.ts +3 -3
  103. package/libs/PanoMeasurePlugin/utils/line.js +3 -3
  104. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -405,7 +405,7 @@ const CSS3DRenderPlugin = (five) => {
405
405
  };
406
406
  };
407
407
 
408
- function createLine(point1, point2, color = new THREE.Vector3(1, 1, 1), dashed = false) {
408
+ function createLine$1(point1, point2, color = new THREE.Vector3(1, 1, 1), dashed = false) {
409
409
  const line$1 = new line.Line(point1, point2);
410
410
  line$1.setMaterial({ dashed, color, linewidth: 1 });
411
411
  line$1.remove(line$1.points);
@@ -441,7 +441,7 @@ const PanoCursorRaycasterPlugin = (five) => {
441
441
  const helperCenterPoint = movePointTowardsCamera(point, fixDistance);
442
442
  const p = helperCenterPoint;
443
443
  const pointAxesHelperMesh = new THREE.Group();
444
- pointAxesHelperMesh.add(createLine(new THREE.Vector3(p.x + halfLength, p.y, p.z), new THREE.Vector3(p.x - halfLength, p.y, p.z), new THREE.Vector3(1, 0, 0)), createLine(new THREE.Vector3(p.x, p.y + halfLength, p.z), new THREE.Vector3(p.x, p.y - halfLength, p.z), new THREE.Vector3(0, 1, 0)), createLine(new THREE.Vector3(p.x, p.y, p.z + halfLength), new THREE.Vector3(p.x, p.y, p.z - halfLength), new THREE.Vector3(0, 0, 1)));
444
+ pointAxesHelperMesh.add(createLine$1(new THREE.Vector3(p.x + halfLength, p.y, p.z), new THREE.Vector3(p.x - halfLength, p.y, p.z), new THREE.Vector3(1, 0, 0)), createLine$1(new THREE.Vector3(p.x, p.y + halfLength, p.z), new THREE.Vector3(p.x, p.y - halfLength, p.z), new THREE.Vector3(0, 1, 0)), createLine$1(new THREE.Vector3(p.x, p.y, p.z + halfLength), new THREE.Vector3(p.x, p.y, p.z - halfLength), new THREE.Vector3(0, 0, 1)));
445
445
  five.scene.add(pointAxesHelperMesh);
446
446
  five.needsRender = true;
447
447
  // 清理函数
@@ -9937,7 +9937,7 @@ const lightLineOpts = {
9937
9937
  pointsRenderOrder: 10,
9938
9938
  };
9939
9939
 
9940
- function creatLine(start, end, opts) {
9940
+ function createLine(start, end, opts) {
9941
9941
  var _a, _b, _c, _d, _e;
9942
9942
  const lineWidth = (_a = opts === null || opts === void 0 ? void 0 : opts.lineWidth) !== null && _a !== void 0 ? _a : 2;
9943
9943
  const lineColor = (_b = opts === null || opts === void 0 ? void 0 : opts.lineColor) !== null && _b !== void 0 ? _b : new THREE.Color(0xffffff);
@@ -9960,10 +9960,10 @@ function creatLine(start, end, opts) {
9960
9960
  pointMaterial.map = opts.pointTexture;
9961
9961
  return line$1;
9962
9962
  }
9963
- function creatLineMesh(line, type) {
9963
+ function createLineMesh(line, type) {
9964
9964
  const [point, anotherPoint] = line.points;
9965
9965
  const opts = type === 'light' ? lightLineOpts : normalLineOpts;
9966
- const fiveLine = creatLine(point.position, anotherPoint.position, opts);
9966
+ const fiveLine = createLine(point.position, anotherPoint.position, opts);
9967
9967
  fiveLine.name = 'normalLine_' + line.id;
9968
9968
  return fiveLine;
9969
9969
  }
@@ -9975,7 +9975,7 @@ function isNDCPointInScreen(ndcPoint) {
9975
9975
  return true;
9976
9976
  }
9977
9977
 
9978
- function creatContentDom() {
9978
+ function createContentDom() {
9979
9979
  const contentDom = document.createElement('div');
9980
9980
  contentDom.setAttribute('style', `backdrop-filter: blur(4px);-webkit-backdrop-filter: blur(4px);`);
9981
9981
  contentDom.style.padding = '3px 6px';
@@ -10003,7 +10003,7 @@ function createContainerDom(line) {
10003
10003
  containerDom.style.transformOrigin = 'left top';
10004
10004
  return containerDom;
10005
10005
  }
10006
- function creatDistanceItem(props) {
10006
+ function createDistanceItem(props) {
10007
10007
  function handleClick() {
10008
10008
  var _a;
10009
10009
  // 线被选中时才高亮,外部手动触发高亮
@@ -10077,7 +10077,7 @@ function creatDistanceItem(props) {
10077
10077
  }
10078
10078
  const { line } = props;
10079
10079
  const lineID = line.id;
10080
- const contentDom = creatContentDom();
10080
+ const contentDom = createContentDom();
10081
10081
  const containerDom = createContainerDom(line);
10082
10082
  const userDistanceItem = props.userDistanceItem;
10083
10083
  const ndcPosition = new THREE.Vector3(0, 0, 0);
@@ -10162,9 +10162,9 @@ class Line {
10162
10162
  throw new Error('无效的线段, 一个点无法构成线段');
10163
10163
  this.hook = new five.Subscribe();
10164
10164
  this.points = [point, anotherPoint];
10165
- this.mesh = creatLineMesh(this, 'normal');
10166
- this.lightMesh = creatLineMesh(this, 'light');
10167
- this.distanceItem = creatDistanceItem({
10165
+ this.mesh = createLineMesh(this, 'normal');
10166
+ this.lightMesh = createLineMesh(this, 'light');
10167
+ this.distanceItem = createDistanceItem({
10168
10168
  line: this,
10169
10169
  clickCallback: () => this.hook.emit('selected', this),
10170
10170
  userDistanceItem: this.model.params.userDistanceItemCreator
@@ -10877,6 +10877,227 @@ class EditController extends BaseController {
10877
10877
  }
10878
10878
  }
10879
10879
 
10880
+ /**
10881
+ * 获取一点对于线段上最近的一点,
10882
+ * 如果可以是过直线垂线的垂足,不行的话取线段的两端
10883
+ * @param point
10884
+ * @param linePoints
10885
+ * @return
10886
+ */
10887
+ function closestPointOnLine(point, linePoints) {
10888
+ const tA = point.x - linePoints[0].x;
10889
+ const tB = point.y - linePoints[0].y;
10890
+ const tC = linePoints[1].x - linePoints[0].x;
10891
+ const tD = linePoints[1].y - linePoints[0].y;
10892
+ // 设线段为 AB 线段,线段外一点为 P
10893
+ // tDot = AP 向量与 AB 向量乘积,tLenSq 为 |AB|平方。
10894
+ // tParam 是 AP 向量在 AB 向量投影向量 AC 与 AB 向量的比。
10895
+ const tDot = tA * tC + tB * tD;
10896
+ const tLenSq = tC * tC + tD * tD;
10897
+ const tParam = tDot / tLenSq;
10898
+ let tXx, tYy;
10899
+ if (tParam < 0 || samePointAt(linePoints[0], linePoints[1])) {
10900
+ tXx = linePoints[0].x;
10901
+ tYy = linePoints[0].y;
10902
+ }
10903
+ else if (tParam > 1) {
10904
+ tXx = linePoints[1].x;
10905
+ tYy = linePoints[1].y;
10906
+ }
10907
+ else {
10908
+ tXx = linePoints[0].x + tParam * tC;
10909
+ tYy = linePoints[0].y + tParam * tD;
10910
+ }
10911
+ return new THREE.Vector2(tXx, tYy);
10912
+ }
10913
+ /**
10914
+ * 检查两个点是否位置相同
10915
+ * point: { x: number, y: number }
10916
+ * @param point1
10917
+ * @param point2
10918
+ * @return
10919
+ */
10920
+ function samePointAt(point1, point2) {
10921
+ return point1.x === point2.x && point1.y === point2.y;
10922
+ }
10923
+
10924
+ function findAssociatedLines(line) {
10925
+ // 找跟这个线段相邻的线
10926
+ const mergeNextLine = (point, nextIndex, target) => {
10927
+ const nextLine = point.lines.find((line) => {
10928
+ const pointIndex = line.points.findIndex(({ id }) => id === point.id);
10929
+ if (pointIndex === nextIndex)
10930
+ return false;
10931
+ return true;
10932
+ });
10933
+ if (!nextLine)
10934
+ return target;
10935
+ const nextPoint = nextLine.points[nextIndex];
10936
+ if (!nextPoint)
10937
+ return target;
10938
+ return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
10939
+ };
10940
+ const rightLines = mergeNextLine(line.points[0], 1, []);
10941
+ const leftLines = mergeNextLine(line.points[0], 0, []);
10942
+ const lines = rightLines.concat(leftLines);
10943
+ return lines;
10944
+ }
10945
+
10946
+ class ViewController extends BaseController {
10947
+ constructor(params) {
10948
+ super(params);
10949
+ Object.defineProperty(this, "type", {
10950
+ enumerable: true,
10951
+ configurable: true,
10952
+ writable: true,
10953
+ value: 'view'
10954
+ });
10955
+ Object.defineProperty(this, "highlightedLines", {
10956
+ enumerable: true,
10957
+ configurable: true,
10958
+ writable: true,
10959
+ value: []
10960
+ });
10961
+ Object.defineProperty(this, "hammer", {
10962
+ enumerable: true,
10963
+ configurable: true,
10964
+ writable: true,
10965
+ value: void 0
10966
+ });
10967
+ Object.defineProperty(this, "wantsTapGesture", {
10968
+ enumerable: true,
10969
+ configurable: true,
10970
+ writable: true,
10971
+ value: (raycaster) => {
10972
+ // 不存在线
10973
+ if (this.model.lines.length === 0)
10974
+ return;
10975
+ const [target] = this.five.model.intersectRaycaster(raycaster);
10976
+ // 点击射线与模型没有交点
10977
+ if (!target)
10978
+ return;
10979
+ const camera = this.five.camera;
10980
+ const ndcTarget = target.point.clone().project(camera);
10981
+ const screenWidth = this.container.clientWidth;
10982
+ const screenHeight = this.container.clientHeight;
10983
+ const targetScreenPosition = new THREE.Vector2(ndcTarget.x * screenWidth, ndcTarget.y * screenHeight);
10984
+ // 把线的端点全部映射到屏幕上,过滤掉不在视野内的线,同时乘以屏幕宽 & 高
10985
+ const screenLines = this.model.lines
10986
+ .map((line) => {
10987
+ const [startPoint, endPoint] = line.points;
10988
+ const ndcStartPoint = startPoint.position.clone().project(camera);
10989
+ const ndcEndPoint = endPoint.position.clone().project(camera);
10990
+ if (!isNDCPointInScreen(ndcStartPoint) && !isNDCPointInScreen(ndcEndPoint))
10991
+ return null;
10992
+ const startScreenPosition = new THREE.Vector2(ndcStartPoint.x * screenWidth, ndcStartPoint.y * screenHeight);
10993
+ const endScreenPosition = new THREE.Vector2(ndcEndPoint.x * screenWidth, ndcEndPoint.y * screenHeight);
10994
+ return { id: line.id, points: [startScreenPosition, endScreenPosition] };
10995
+ })
10996
+ .filter((line) => !!line);
10997
+ if (screenLines.length === 0)
10998
+ return;
10999
+ // 找这些线距离鼠标点击位置最近的线
11000
+ const distanceLines = screenLines
11001
+ .map((line) => {
11002
+ const closestPoint = closestPointOnLine(targetScreenPosition, line.points);
11003
+ return { id: line.id, distance: closestPoint.distanceTo(targetScreenPosition) };
11004
+ })
11005
+ .sort((a, b) => a.distance - b.distance);
11006
+ const closestScreenLine = distanceLines[0];
11007
+ const closestLine = closestScreenLine.distance > 20
11008
+ ? undefined
11009
+ : this.model.lines.find(({ id }) => id === closestScreenLine.id);
11010
+ if (this.highlightedLines.length > 0 && !closestLine) {
11011
+ this.clearHighlightLines();
11012
+ return false;
11013
+ }
11014
+ if (closestLine) {
11015
+ this.chooseLine(closestLine);
11016
+ return false;
11017
+ }
11018
+ }
11019
+ });
11020
+ Object.defineProperty(this, "chooseLine", {
11021
+ enumerable: true,
11022
+ configurable: true,
11023
+ writable: true,
11024
+ value: (line) => {
11025
+ const highlightLines = findAssociatedLines(line);
11026
+ this.highlightLines(highlightLines);
11027
+ this.five.needsRender = true;
11028
+ this.hook.emit('selectedChange', highlightLines.map((line) => line.toCompletelyJson()));
11029
+ }
11030
+ });
11031
+ Object.defineProperty(this, "lineRemoved", {
11032
+ enumerable: true,
11033
+ configurable: true,
11034
+ writable: true,
11035
+ value: (line) => {
11036
+ this.removeLine(line);
11037
+ // TODO: 这个逻辑不太好,改进一下
11038
+ this.hook.emit('selectedChange', this.model.lines.filter((line) => line.selected).map((line) => line.toCompletelyJson()));
11039
+ }
11040
+ });
11041
+ Object.defineProperty(this, "onCameraUpdate", {
11042
+ enumerable: true,
11043
+ configurable: true,
11044
+ writable: true,
11045
+ value: () => {
11046
+ this.updateDistanceUI();
11047
+ }
11048
+ });
11049
+ this.model.lines.forEach((line) => {
11050
+ line.distanceItem.appendTo(this.container);
11051
+ line.distanceItem.update(this.five);
11052
+ line.hook.on('selected', this.chooseLine);
11053
+ this.group.add(line.mesh);
11054
+ });
11055
+ const fiveElement = this.five.getElement();
11056
+ if (fiveElement) {
11057
+ const hammer = new Hammer__default["default"](fiveElement);
11058
+ this.hammer = hammer;
11059
+ }
11060
+ this.model.hook.on('lineRemoved', this.lineRemoved);
11061
+ this.five.on('cameraUpdate', this.onCameraUpdate);
11062
+ this.five.on('wantsTapGesture', this.wantsTapGesture);
11063
+ this.five.needsRender = true;
11064
+ }
11065
+ dispose() {
11066
+ var _a;
11067
+ super.dispose();
11068
+ this.model.hook.off('lineRemoved', this.lineRemoved);
11069
+ this.five.off('cameraUpdate', this.onCameraUpdate);
11070
+ this.five.off('wantsTapGesture', this.wantsTapGesture);
11071
+ this.five.needsRender = true;
11072
+ this.hook.emit('selectedChange', []);
11073
+ (_a = this.hammer) === null || _a === void 0 ? void 0 : _a.destroy();
11074
+ }
11075
+ highlightLine(line) {
11076
+ if (line.selected)
11077
+ return;
11078
+ line.selected = true;
11079
+ this.group.add(line.lightMesh);
11080
+ line.distanceItem.highlight();
11081
+ this.five.needsRender = true;
11082
+ }
11083
+ clearHighlightLines() {
11084
+ if (this.group.children.length === 0)
11085
+ return;
11086
+ this.model.lines.forEach((line) => {
11087
+ line.selected = false;
11088
+ line.distanceItem.unHighlight();
11089
+ this.group.remove(line.lightMesh);
11090
+ });
11091
+ this.highlightedLines = [];
11092
+ this.five.needsRender = true;
11093
+ }
11094
+ highlightLines(lines) {
11095
+ this.clearHighlightLines();
11096
+ this.highlightedLines = lines;
11097
+ lines.forEach((line) => this.highlightLine(line));
11098
+ }
11099
+ }
11100
+
10880
11101
  const svg = `
10881
11102
  <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">
10882
11103
  <defs>
@@ -11081,50 +11302,6 @@ class DeleteDom {
11081
11302
  }
11082
11303
  }
11083
11304
 
11084
- /**
11085
- * 获取一点对于线段上最近的一点,
11086
- * 如果可以是过直线垂线的垂足,不行的话取线段的两端
11087
- * @param point
11088
- * @param linePoints
11089
- * @return
11090
- */
11091
- function closestPointOnLine(point, linePoints) {
11092
- const tA = point.x - linePoints[0].x;
11093
- const tB = point.y - linePoints[0].y;
11094
- const tC = linePoints[1].x - linePoints[0].x;
11095
- const tD = linePoints[1].y - linePoints[0].y;
11096
- // 设线段为 AB 线段,线段外一点为 P
11097
- // tDot = AP 向量与 AB 向量乘积,tLenSq 为 |AB|平方。
11098
- // tParam 是 AP 向量在 AB 向量投影向量 AC 与 AB 向量的比。
11099
- const tDot = tA * tC + tB * tD;
11100
- const tLenSq = tC * tC + tD * tD;
11101
- const tParam = tDot / tLenSq;
11102
- let tXx, tYy;
11103
- if (tParam < 0 || samePointAt(linePoints[0], linePoints[1])) {
11104
- tXx = linePoints[0].x;
11105
- tYy = linePoints[0].y;
11106
- }
11107
- else if (tParam > 1) {
11108
- tXx = linePoints[1].x;
11109
- tYy = linePoints[1].y;
11110
- }
11111
- else {
11112
- tXx = linePoints[0].x + tParam * tC;
11113
- tYy = linePoints[0].y + tParam * tD;
11114
- }
11115
- return new THREE.Vector2(tXx, tYy);
11116
- }
11117
- /**
11118
- * 检查两个点是否位置相同
11119
- * point: { x: number, y: number }
11120
- * @param point1
11121
- * @param point2
11122
- * @return
11123
- */
11124
- function samePointAt(point1, point2) {
11125
- return point1.x === point2.x && point1.y === point2.y;
11126
- }
11127
-
11128
11305
  function ndc2Screen(ndcPosition, containerSize) {
11129
11306
  const left = ((ndcPosition.x + 1) / 2) * containerSize.width;
11130
11307
  const top = (-(ndcPosition.y - 1) / 2) * containerSize.height;
@@ -11157,28 +11334,6 @@ function findClosestPoint(five, points, tapPoint, maxDistance) {
11157
11334
  return ndcPoints[0];
11158
11335
  }
11159
11336
 
11160
- function findAssociatedLines(line) {
11161
- // 找跟这个线段相邻的线
11162
- const mergeNextLine = (point, nextIndex, target) => {
11163
- const nextLine = point.lines.find((line) => {
11164
- const pointIndex = line.points.findIndex(({ id }) => id === point.id);
11165
- if (pointIndex === nextIndex)
11166
- return false;
11167
- return true;
11168
- });
11169
- if (!nextLine)
11170
- return target;
11171
- const nextPoint = nextLine.points[nextIndex];
11172
- if (!nextPoint)
11173
- return target;
11174
- return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
11175
- };
11176
- const rightLines = mergeNextLine(line.points[0], 1, []);
11177
- const leftLines = mergeNextLine(line.points[0], 0, []);
11178
- const lines = rightLines.concat(leftLines);
11179
- return lines;
11180
- }
11181
-
11182
11337
  class WatchController extends BaseController {
11183
11338
  constructor(params) {
11184
11339
  super(params);
@@ -11452,6 +11607,7 @@ class WatchController extends BaseController {
11452
11607
  super.dispose();
11453
11608
  this.deleteDom.dispose();
11454
11609
  this.model.hook.off('lineRemoved', this.lineRemoved);
11610
+ this.model.lines.forEach((line) => line.hook.off('selected', this.chooseLine));
11455
11611
  this.five.off('cameraUpdate', this.onCameraUpdate);
11456
11612
  this.five.off('wantsPanGesture', this.wantsPanGesture);
11457
11613
  this.five.off('wantsTapGesture', this.wantsTapGesture);
@@ -13210,6 +13366,7 @@ class MeasureController {
13210
13366
  return new Error('不支持切换的Mode');
13211
13367
  (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
13212
13368
  const controllerMap = {
13369
+ View: ViewController,
13213
13370
  Watch: WatchController,
13214
13371
  Edit: EditController,
13215
13372
  };
@@ -15605,7 +15762,7 @@ function get_each_context(ctx, list, i) {
15605
15762
  return child_ctx;
15606
15763
  }
15607
15764
 
15608
- // (235:2) {#if itemLabelItem.visible}
15765
+ // (234:2) {#if itemLabelItem.visible}
15609
15766
  function create_if_block(ctx) {
15610
15767
  let itemlabelitem;
15611
15768
  let current;
@@ -15649,7 +15806,7 @@ function create_if_block(ctx) {
15649
15806
  };
15650
15807
  }
15651
15808
 
15652
- // (234:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
15809
+ // (233:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
15653
15810
  function create_each_block(key_1, ctx) {
15654
15811
  let first;
15655
15812
  let if_block_anchor;
@@ -15872,8 +16029,6 @@ function instance($$self, $$props, $$invalidate) {
15872
16029
  };
15873
16030
 
15874
16031
  const getFormatedItemLabels = (five$1, labels) => {
15875
- console.log(labels);
15876
-
15877
16032
  // 计算位置 & 可见性
15878
16033
  const newLabels = labels.map(label => {
15879
16034
  // 不在绑定点位则直接不可见