@realsee/dnalogel 2.0.0-alpha.35 → 2.0.0-alpha.36

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 (211) hide show
  1. package/dist/ItemLabelPlugin/index.js +21 -41
  2. package/dist/ModelItemLabelPlugin/index.js +16 -36
  3. package/dist/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +1 -1
  4. package/dist/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +0 -4
  5. package/dist/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +0 -3
  6. package/dist/PanoMeasurePlugin/Modules/UIController/mobileHTML.d.ts +2 -0
  7. package/dist/PanoMeasurePlugin/Modules/UIController/{NewMainBtnController.d.ts → mobileMainBtnController.d.ts} +1 -1
  8. package/dist/PanoMeasurePlugin/Modules/UIController/style.d.ts +0 -3
  9. package/dist/PanoMeasurePlugin/Modules/rangePiece/html.d.ts +1 -1
  10. package/dist/PanoMeasurePlugin/Modules/rangePiece/index.d.ts +2 -0
  11. package/dist/PanoMeasurePlugin/index.js +298 -331
  12. package/dist/PanoMeasurePlugin/typings/data.d.ts +5 -0
  13. package/dist/PanoMeasurePlugin/utils/mouseGroup.d.ts +6 -1
  14. package/dist/base/BasePlugin.d.ts +100 -0
  15. package/dist/base/BasePluginWithData.d.ts +34 -0
  16. package/dist/floorplan/ModelFloorplanPlugin/Controller.d.ts +70 -78
  17. package/dist/floorplan/ModelFloorplanPlugin/index.d.ts +5 -7
  18. package/dist/floorplan/ModelFloorplanPlugin/index.js +1059 -569
  19. package/dist/floorplan/ModelFloorplanPlugin/typing.d.ts +107 -0
  20. package/dist/floorplan/PanoFloorplanRadarPlugin/Controller.d.ts +23 -14
  21. package/dist/floorplan/PanoFloorplanRadarPlugin/index.d.ts +5 -6
  22. package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +489 -129
  23. package/dist/floorplan/PanoFloorplanRadarPlugin/typing.d.ts +52 -0
  24. package/dist/floorplan/TopviewFloorplanPlugin/Controller.d.ts +50 -58
  25. package/dist/floorplan/TopviewFloorplanPlugin/index.d.ts +5 -3
  26. package/dist/floorplan/TopviewFloorplanPlugin/index.js +1031 -443
  27. package/dist/floorplan/TopviewFloorplanPlugin/typing.d.ts +86 -0
  28. package/{libs/floorplan/ModelFloorplanPlugin → dist/floorplan}/utils/constant.d.ts +10 -3
  29. package/{libs/floorplan/ModelFloorplanPlugin → dist/floorplan}/utils/correctFiveState.d.ts +2 -1
  30. package/dist/index.es.js +2184 -1411
  31. package/dist/index.js +2188 -1415
  32. package/dist/index.umd.js +2142 -1369
  33. package/dist/shared-utils/five/changeMode.d.ts +4 -1
  34. package/dist/shared-utils/getPxmm.d.ts +8 -0
  35. package/docs/assets/search.js +1 -1
  36. package/docs/classes/Magnifier.html +4 -4
  37. package/docs/classes/ModelRoomLabelController.html +4 -4
  38. package/docs/enums/CameraMovementEffect.html +2 -2
  39. package/docs/enums/DIRECTION.html +1 -1
  40. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  41. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  42. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  43. package/docs/enums/Rotation.html +2 -2
  44. package/docs/index.html +2 -2
  45. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  46. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  47. package/docs/interfaces/FloorplanBounding.html +4 -4
  48. package/docs/interfaces/FloorplanData.html +2 -2
  49. package/docs/interfaces/FloorplanEntrance.html +7 -7
  50. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  51. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  52. package/docs/interfaces/FloorplanFloorData.html +2 -2
  53. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  54. package/docs/interfaces/FloorplanObserver.html +2 -2
  55. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  56. package/docs/interfaces/FloorplanPosition.html +2 -2
  57. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  58. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  59. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  60. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  61. package/docs/interfaces/FloorplanServerData.html +2 -2
  62. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  63. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  64. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  65. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  66. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  67. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  68. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  69. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  70. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  71. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  72. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  73. package/docs/interfaces/LineJson.html +1 -1
  74. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  75. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  76. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  77. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  78. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  79. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  80. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  81. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  82. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  83. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  84. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  85. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  86. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  87. package/docs/interfaces/OpenParameter.html +2 -2
  88. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  89. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  90. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  91. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  92. package/docs/interfaces/PanoMeasureParameterType.html +1 -1
  93. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  94. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  95. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  96. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  97. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  98. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  99. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  100. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  101. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  102. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  103. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  104. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  105. package/docs/interfaces/Point.html +1 -1
  106. package/docs/interfaces/PointJson.html +1 -1
  107. package/docs/interfaces/Room.html +1 -1
  108. package/docs/interfaces/RoomInfo.html +1 -1
  109. package/docs/interfaces/RoomLabel.html +7 -7
  110. package/docs/interfaces/RoomRules.html +1 -1
  111. package/docs/interfaces/Rooms.html +1 -1
  112. package/docs/modules.html +17 -27
  113. package/libs/ItemLabelPlugin/ItemLabelComponent.js +21 -41
  114. package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +16 -36
  115. package/libs/PanoMeasurePlugin/Controller/index.js +4 -2
  116. package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +1 -1
  117. package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +1 -1
  118. package/libs/PanoMeasurePlugin/Modules/GuideController.js +2 -2
  119. package/libs/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +0 -4
  120. package/libs/PanoMeasurePlugin/Modules/UIController/HTML.js +66 -55
  121. package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +0 -3
  122. package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +51 -73
  123. package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +7 -4
  124. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +10 -12
  125. package/libs/PanoMeasurePlugin/Modules/UIController/mobileHTML.d.ts +2 -0
  126. package/libs/PanoMeasurePlugin/Modules/UIController/mobileHTML.js +2 -2
  127. package/libs/PanoMeasurePlugin/Modules/UIController/{NewMainBtnController.d.ts → mobileMainBtnController.d.ts} +1 -1
  128. package/libs/PanoMeasurePlugin/Modules/UIController/{NewMainBtnController.js → mobileMainBtnController.js} +4 -4
  129. package/libs/PanoMeasurePlugin/Modules/UIController/style.d.ts +0 -3
  130. package/libs/PanoMeasurePlugin/Modules/UIController/style.js +7 -24
  131. package/libs/PanoMeasurePlugin/Modules/rangePiece/html.d.ts +1 -1
  132. package/libs/PanoMeasurePlugin/Modules/rangePiece/html.js +1 -1
  133. package/libs/PanoMeasurePlugin/Modules/rangePiece/index.d.ts +2 -0
  134. package/libs/PanoMeasurePlugin/Modules/rangePiece/index.js +1 -2
  135. package/libs/PanoMeasurePlugin/typings/data.d.ts +5 -0
  136. package/libs/PanoMeasurePlugin/utils/mouseGroup.d.ts +6 -1
  137. package/libs/PanoMeasurePlugin/utils/mouseGroup.js +55 -7
  138. package/libs/base/BasePlugin.d.ts +100 -0
  139. package/libs/base/BasePlugin.js +31 -0
  140. package/libs/base/BasePluginWithData.d.ts +34 -0
  141. package/libs/base/BasePluginWithData.js +4 -0
  142. package/libs/floorplan/Components/Compass.js +11 -11
  143. package/libs/floorplan/Components/CurrentFloor.js +24 -11
  144. package/libs/floorplan/Components/Main.js +21 -15
  145. package/libs/floorplan/Components/RoomHighlight/Room.js +44 -5
  146. package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +29 -12
  147. package/libs/floorplan/Components/RoomLabels/RoomLabel.js +164 -15
  148. package/libs/floorplan/Components/RoomLabels/RoomLabels.js +68 -24
  149. package/libs/floorplan/Components/RoomMaterials/RoomMaterial_1.js +1 -0
  150. package/libs/floorplan/Components/RoomMaterials/RoomMaterial_2.js +11 -9
  151. package/libs/floorplan/Components/RuleLabels/RuleItem.js +2 -2
  152. package/libs/floorplan/ModelFloorplanPlugin/Controller.d.ts +70 -78
  153. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +434 -274
  154. package/libs/floorplan/ModelFloorplanPlugin/index.d.ts +5 -7
  155. package/libs/floorplan/ModelFloorplanPlugin/index.js +2 -2
  156. package/libs/floorplan/ModelFloorplanPlugin/typing.d.ts +107 -0
  157. package/libs/floorplan/ModelFloorplanPlugin/{typings/events.type.js → typing.js} +0 -0
  158. package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Camera.js +5 -5
  159. package/libs/floorplan/PanoFloorplanRadarPlugin/Components/Main.js +114 -53
  160. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.d.ts +23 -14
  161. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +162 -52
  162. package/libs/floorplan/PanoFloorplanRadarPlugin/index.d.ts +5 -6
  163. package/libs/floorplan/PanoFloorplanRadarPlugin/index.js +2 -2
  164. package/libs/floorplan/PanoFloorplanRadarPlugin/typing.d.ts +52 -0
  165. package/libs/floorplan/PanoFloorplanRadarPlugin/typing.js +1 -0
  166. package/libs/floorplan/TopviewFloorplanPlugin/Controller.d.ts +50 -58
  167. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +320 -174
  168. package/libs/floorplan/TopviewFloorplanPlugin/index.d.ts +5 -3
  169. package/libs/floorplan/TopviewFloorplanPlugin/index.js +2 -2
  170. package/libs/floorplan/TopviewFloorplanPlugin/style.js +1 -1
  171. package/libs/floorplan/TopviewFloorplanPlugin/typing.d.ts +86 -0
  172. package/libs/floorplan/TopviewFloorplanPlugin/typing.js +1 -0
  173. package/{dist/floorplan/ModelFloorplanPlugin → libs/floorplan}/utils/constant.d.ts +10 -3
  174. package/libs/floorplan/{ModelFloorplanPlugin/utils → utils}/constant.js +9 -2
  175. package/{dist/floorplan/ModelFloorplanPlugin → libs/floorplan}/utils/correctFiveState.d.ts +2 -1
  176. package/libs/floorplan/{ModelFloorplanPlugin/utils → utils}/correctFiveState.js +16 -16
  177. package/libs/shared-utils/five/changeMode.d.ts +4 -1
  178. package/libs/shared-utils/five/changeMode.js +34 -13
  179. package/libs/shared-utils/getPxmm.d.ts +8 -0
  180. package/libs/shared-utils/getPxmm.js +25 -20
  181. package/package.json +2 -2
  182. package/dist/floorplan/ModelFloorplanPlugin/typings/events.type.d.ts +0 -23
  183. package/docs/classes/PanoFloorplanRadarPluginController.html +0 -3
  184. package/docs/enums/ModelFloorplanErrorType.html +0 -1
  185. package/docs/interfaces/ModelFloorplanParameterType.html +0 -1
  186. package/docs/interfaces/ModelFloorplanViewEvent.html +0 -5
  187. package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +0 -1
  188. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +0 -19
  189. package/libs/ModelSimulationPlugin/index.d.ts +0 -33
  190. package/libs/ModelSimulationPlugin/index.js +0 -166
  191. package/libs/ModelSimulationPlugin/shaders/fragment.d.ts +0 -2
  192. package/libs/ModelSimulationPlugin/shaders/fragment.js +0 -96
  193. package/libs/ModelSimulationPlugin/shaders/vertex.d.ts +0 -2
  194. package/libs/ModelSimulationPlugin/shaders/vertex.js +0 -23
  195. package/libs/floorplan/ModelFloorplanPlugin/Assets/compass.d.ts +0 -1
  196. package/libs/floorplan/ModelFloorplanPlugin/Assets/compass.js +0 -1
  197. package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.js +0 -120
  198. package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +0 -106
  199. package/libs/floorplan/ModelFloorplanPlugin/Components/CurrentFloor/CurrentFloor.js +0 -463
  200. package/libs/floorplan/ModelFloorplanPlugin/Components/Main.js +0 -375
  201. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +0 -171
  202. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabels.js +0 -265
  203. package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleItem.js +0 -301
  204. package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleLabels.js +0 -219
  205. package/libs/floorplan/ModelFloorplanPlugin/typings/events.type.d.ts +0 -23
  206. package/libs/shared-utils/five/useFivePlugin.d.ts +0 -1
  207. package/libs/shared-utils/five/useFivePlugin.js +0 -8
  208. package/libs/shared-utils/useDebounce.d.ts +0 -8
  209. package/libs/shared-utils/useDebounce.js +0 -22
  210. package/libs/shared-utils/useThrottle.d.ts +0 -8
  211. package/libs/shared-utils/useThrottle.js +0 -25
@@ -6,6 +6,9 @@ var THREE = require('three');
6
6
  var internal = require('svelte/internal');
7
7
  var easing = require('svelte/easing');
8
8
  var transition = require('svelte/transition');
9
+ var store = require('svelte/store');
10
+ var svelte = require('svelte');
11
+ var five = require('@realsee/five');
9
12
 
10
13
  function _interopNamespace(e) {
11
14
  if (e && e.__esModule) return e;
@@ -27,184 +30,109 @@ function _interopNamespace(e) {
27
30
 
28
31
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
29
32
 
30
- const pluginStyle = {
31
- position: 'absolute',
32
- left: '50%',
33
- top: '50%',
34
- transform: 'translate(-50%, -50%)',
35
- zIndex: '10',
36
- pointerEvents: 'none'
37
- };
38
-
39
- function pathD(points, options = {}) {
40
- let d = '';
41
- const { needZ, needA } = options;
42
- const _points = needZ ? points.slice().concat(points[0]) : points.slice();
43
- _points.forEach((_point, index) => {
44
- const { x, y } = options.format ? options.format(_point) : _point;
45
- const point = x + ',' + y;
46
- if (index === 0) {
47
- d += 'M' + point;
48
- return d;
49
- }
50
- if (needA === null || needA === void 0 ? void 0 : needA[index]) {
51
- d += 'A' + needA[index] + ',' + point;
52
- return d;
53
- }
54
- d += 'L' + point;
55
- return d;
56
- });
57
- return d + (needZ ? 'Z' : '');
58
- }
59
- /** 把户型图上点点位转换到 SVG 上的点位 */
60
- function formatFloorplanPoint({ x, y }, bounding) {
61
- const { max, min } = bounding;
62
- return { x: x - min.x, y: max.y - y };
33
+ /**
34
+ * 检查一个值是否是狭义上的对象
35
+ * @param {any} value 要检查的值
36
+ *
37
+ * isTruelyObject({})
38
+ * // => true
39
+ *
40
+ * isObjectLike([1, 2, 3])
41
+ * // => false
42
+ *
43
+ * isObjectLike(Function)
44
+ * // => false
45
+ *
46
+ * isObjectLike(null)
47
+ * // => false
48
+ *
49
+ */
50
+ function isTruelyObject(value) {
51
+ return Object.prototype.toString.call(value) === '[object Object]';
63
52
  }
64
53
 
65
- async function formatOutlines(outlines) {
66
- const headers = new Headers({ 'Content-Type': 'text/plain' });
67
- const getOutlineItem = async function (item) {
68
- const outlineItem = {
69
- index: item.index,
70
- url: item.url,
71
- svgUrl: item.svg_url,
72
- };
73
- if (item.svg_url) {
74
- const svgContent = await fetch(item.svg_url, { headers }).then((res) => res.text());
75
- outlineItem.svgContent = svgContent;
76
- }
77
- return outlineItem;
78
- };
79
- const svgOutlineItems = await Promise.all(outlines.map(getOutlineItem));
80
- return svgOutlineItems;
81
- }
82
- function formatRoom(data) {
83
- const floorplanRoomItem = {
84
- id: data.id,
85
- size: data.size,
86
- name: data.name,
87
- path: data.path,
88
- roomType: data.room_type,
89
- floorType: data.floor_type,
90
- roomLabel: {
91
- position: data.room_label.position,
92
- positionInImage: data.room_label.position_in_image,
93
- },
94
- observerIndexs: data.observer_indexs,
95
- };
96
- return floorplanRoomItem;
54
+ /* eslint-disable @typescript-eslint/no-use-before-define */
55
+ function baseIsEqual(value, other) {
56
+ if (value === other)
57
+ return true;
58
+ if (typeof value !== typeof other)
59
+ return false;
60
+ if (Number.isNaN(value) && Number.isNaN(other))
61
+ return true;
62
+ return false;
97
63
  }
98
- function formatFloorData(_data) {
99
- return {
100
- floorName: _data.floor_name,
101
- floorIndex: _data.floor_index,
102
- rooms: _data.rooms.map(formatRoom),
103
- rules: _data.rules,
104
- };
64
+ function objEqualShallow(value, other) {
65
+ const valueProps = Object.getOwnPropertyNames(value);
66
+ const otherProps = Object.getOwnPropertyNames(other);
67
+ if (valueProps.length !== otherProps.length)
68
+ return false;
69
+ for (let i = 0, len = valueProps.length; i < len; i++) {
70
+ const propName = valueProps[i];
71
+ if (!baseIsEqual(value[propName], other[propName]))
72
+ return false;
73
+ }
74
+ return true;
105
75
  }
106
- function formateFloorplanObserver(data) {
107
- const floorplanObserver = {
108
- index: data.index,
109
- floorIndex: data.floor_index,
110
- position: data.position,
111
- positionInImage: data.position_in_image,
112
- };
113
- return floorplanObserver;
76
+ function arrayEqualShallow(value, other) {
77
+ if (value.length !== other.length)
78
+ return false;
79
+ for (let i = 0, len = value.length; i < len; i++) {
80
+ if (!baseIsEqual(value[i], other[i]))
81
+ return false;
82
+ }
83
+ return true;
114
84
  }
115
- function formatFloorplanEntrance(data) {
116
- const floorplanEntrance = {
117
- rad: data.rad,
118
- position: data.position,
119
- positionInImage: data.position_in_image,
120
- northRad: data.north_rad,
121
- roomId: data.room_id,
122
- floorIndex: data.floor_index,
123
- };
124
- return floorplanEntrance;
85
+ function isShallowEqual(value, other) {
86
+ if (baseIsEqual(value, other))
87
+ return true;
88
+ if (isTruelyObject(value) && isTruelyObject(other))
89
+ return objEqualShallow(value, other);
90
+ if (Array.isArray(value) && Array.isArray(other))
91
+ return arrayEqualShallow(value, other);
92
+ return false;
125
93
  }
126
- async function formatData(data) {
127
- const outlines = await formatOutlines(data.outlines);
128
- const bounding = data.computed_data.bounding;
129
- const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
130
- const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
131
- const floorplanData = {
132
- outlines,
133
- entrance,
134
- bounding,
135
- floorDatas,
136
- observers: data.computed_data.observers.map(formateFloorplanObserver),
137
- };
138
- return floorplanData;
94
+ function isDeepEqual(value, other) {
95
+ if (baseIsEqual(value, other))
96
+ return true;
97
+ if (isTruelyObject(value) && isTruelyObject(other))
98
+ return objEqualDeep(value, other);
99
+ if (Array.isArray(value) && Array.isArray(other))
100
+ return arrayEqualDeep(value, other);
101
+ return false;
139
102
  }
140
-
141
- var FLOOR_PLAN_ATTACHED_TO;
142
- (function (FLOOR_PLAN_ATTACHED_TO) {
143
- FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["FLOOR"] = 1] = "FLOOR";
144
- FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["CEILING"] = 2] = "CEILING";
145
- FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["BOUNDING_CENTER"] = 3] = "BOUNDING_CENTER";
146
- })(FLOOR_PLAN_ATTACHED_TO || (FLOOR_PLAN_ATTACHED_TO = {}));
147
-
148
- /**
149
- * 获取「在俯视图」状态下,模型 mm 与屏幕像素 px 的对应关系,即每 mm 对应多少 px
150
- * @param five five
151
- */
152
- function getPxmm(five, container, floorIndex, options) {
153
- const maxFloorIndex = Math.max(...five.work.observers.map((ob) => ob.floorIndex));
154
- function getFloorY(floorIndex) {
155
- return floorIndex > maxFloorIndex
156
- ? five.model.bounding.max.y
157
- : Math.max(...five.work.observers
158
- .filter((ob) => ob.floorIndex === floorIndex)
159
- .map((ob) => ob.standingPosition.y));
103
+ function arrayEqualDeep(value, other) {
104
+ if (value.length !== other.length)
105
+ return false;
106
+ for (let i = 0, len = value.length; i < len; i++) {
107
+ if (!isDeepEqual(value[i], other[i]))
108
+ return false;
160
109
  }
161
- function getY() {
162
- const currentFloorY = getFloorY(floorIndex);
163
- const nextFloorY = getFloorY(floorIndex + 1);
164
- const attachedTo = (options === null || options === void 0 ? void 0 : options.attachedTo) || FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER;
165
- if (attachedTo === FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER)
166
- return (five.model.bounding.max.y + five.model.bounding.min.y) / 2;
167
- else if (attachedTo === FLOOR_PLAN_ATTACHED_TO.CEILING)
168
- return nextFloorY;
169
- else
170
- return currentFloorY;
171
- }
172
- const y = getY();
173
- const originPosition = new THREE__namespace.Vector3(0, y, 0);
174
- const originPositionXUnit = new THREE__namespace.Vector3(1, y, 0);
175
- const mouse = originPosition.clone().project(five.camera);
176
- const xUnitMouse = originPositionXUnit.clone().project(five.camera);
177
- const pxmm = Math.abs((xUnitMouse.x - mouse.x) / 1000) * (container.getBoundingClientRect().width / 2);
178
- return pxmm;
110
+ return true;
179
111
  }
180
-
181
- /**
182
- * 把第一个参数传入第二个参数(函数)中并执行
183
- * 一般用于执行函数后返回变量。
184
- * @param {any} something
185
- * @param {function} callback
186
- * @return {any}
187
- */
188
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
- function tap(something, callback) {
190
- callback(something);
191
- return something;
112
+ function objEqualDeep(value, other) {
113
+ const valueProps = Object.getOwnPropertyNames(value);
114
+ const otherProps = Object.getOwnPropertyNames(other);
115
+ if (valueProps.length !== otherProps.length)
116
+ return false;
117
+ for (let i = 0, len = valueProps.length; i < len; i++) {
118
+ const propName = valueProps[i];
119
+ if (!isDeepEqual(value[propName], other[propName]))
120
+ return false;
121
+ }
122
+ return true;
192
123
  }
193
-
194
124
  /**
195
- * 过滤掉不需要的对象字段函数:实现从一个对象中排除某些指定属性后生成的新对象。
196
- * @param object
197
- * @param props 排除的属性
198
- * @return
125
+ * 对象比较
126
+ * @param {*} value 第一个比较的值
127
+ * @param {*} other 第二个比较的值
128
+ * @param {Object} options 可选参数,可选项包括:<br />
129
+ * deep {Boolean} 是否深比较<br />
130
+ * @returns {boolean} 是否相等
199
131
  */
200
- function omit(object, props) {
201
- return tap({}, (result) => {
202
- for (const name in object) {
203
- if (props.indexOf(name) !== -1)
204
- continue;
205
- result[name] = object[name];
206
- }
207
- });
132
+ function equal(value, other, opt = { deep: false }) {
133
+ if (!opt.deep)
134
+ return isShallowEqual(value, other);
135
+ return isDeepEqual(value, other);
208
136
  }
209
137
 
210
138
  const CAMERA_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAMAAAANf8AYAAAC2VBMVEUAAACCnP+Dn/+Enf+HqP+Gp/+Fof+Gpf+IrP+Lsf+Dof+Cmv+Lsv+Mtf+Eo/+Bmf+JrP+Hqf+Env+Krv+Fo/+Pu/+Ms/+Qvv+Hqf+RwP+KsP+Fpf+Mtv+Gov+Bnf+Qv/+Nt/+Krv+Ho/+Rwf+Ouv+Emv+Amv+SxP+Sw/+NuP+Mtf/G0f6huP+Ot/+JrP+Jqv+Dnv+crf6Uqv////+QvP+PvP+Ms//J0/3p9/+Ux/+Ouf+Krf+Iqf+Fpv+/zf6WsP+MpP+RqP+Uyf+Jy//V3P6Yuf+Qqf+Rqv/5/f+Sxf+Jy/////+Lx/+Ouf+Nw/+Owv+PwP+Jr/+Jq/+VvP+Vuv/c4v+Fnf+btP+InP+Blf/3+P6Txf+Jzf+Jyf+NxP+Qwf/t8/6Svv+Tvf/O1f7Czv3T2f6cu/+qvP7a4fvo7v77/v/o9//p9//0+v////+Vy//w9//k8/+B1f/v9/+D0/+UyP/u9v+D0v/i8f+F0v/g7/+G0P+KzP+Hz/////+Lx//s8/+Puf/h7P+Mxv/w9f7q8v/q8f2RwP/r8f6JrP/t8v6RvP/l6f7////j6P6VvP/f5/7q8P7a4P/U2f6au/+ZuP+ewf+auP+iu//n6f2Fn//j6P/h4fn9/v/4/P/3/P/o9v/l9P+F1P+B1f/i8v+UyP+J0f+E0f/h7//r8v6Izf/g7v/q8v6Pv//f7P7f7f/g7f+Lxf+MyP+Mw//k7v6Ow/+Ov//v8/2Pu//t8f+Tvv/p8P6Uu//q7v/i6P2Xvf+WuP/L1vypu//Azv7K0/zy8v/l8v/A4P/o9f/x+f+I0f/j8v+J0P/s9v/h8P+I0P/t9v/r9P6Lyv+Lyf/s9P/g7P+Myv/s8/7j7v+Jrv/q8P2Uwf+Epf+TuP/a3vzh5f3w8P/a4P20v//Nzfzx8f/Pz/Cg0P/f7//u9f/q8v7o8v7s8/7s8v3w9f+Sv/+TuP+Gp//s8fr///8/HFXHAAAA8nRSTlMANUQ/Z2JJXXaKTjCPmVMre3E6gFiylLxsxoVYnk5JwaOFU8utOjrV0KieQS2icWwzMC4Dt7aTQvjfrHprXD0zMyvpvUxGNjH+2sK9raeYkoiAcF5TUi0rKCYY2cy3pIJ/eGpEQDcxLx0S/Pv19PPu7Ovr5+Tk4eDe3NXU09DIsq2opKCViYN9e3V1cmZlXllVTk1GQDs2NTMwJw0K/vn28u/u5+Pj3tjNycjGw8DAua2pqJ6SjYyMf3BvaWNgWk5NSTc3MxT79PHw6efl2trY19PHurWysqWZe2xkXVlUPjo6OSskCO7Qzs6+vKCedmhdN1av0hoAAAV1SURBVEjHjZT3P9RxHMe1nCjcObo4cjpX5w53l7pUbnBGkr2TPZJKmiqVEQlJhGjvvfcm2nvvvXf5C3q/P98bkuR1D7+9n16v1/vzvtPrnAade/ty6anHJfFHOjkfXbe07PGxkuL4oqIjCzoDjHtxurzsRHmFStokjBDG/59JrwurOF2hkkUoIyKEQmFqatG3/xDnXlSGPZcKI5VKiVgsli+vrakpfNAx8UoVlpRWH6mUeMsVcm8vhah6WfXB3A6IlSlVKoE4KjxcgtNGRl1Ayzw9H+Z20DypMVkZZWKiUIi6oHj2PAbPs6Eh/+6/kBUpVUliIEQKGGcwGPbdiBpCQ/O//AMZJ218XW9igoHsGTwY7kopdMmSvTvbz/VGmiyhCARwWJ/Ss5CQ9pl3zVJZJCEwEszb6BtaGxrCn3XIyZP3trW3rybBWTCB1jy0sNGHeWM7+BgzrX4kJu752E57mWA5mIjsMRVxgGkrJpPpRvtJSywt3X2rPUSMuUgqIIzx37vRaLQeqNKEhN03/womg/bYhDJBBzdqvjsqYeHCHdfa1k9BF0QoEyuwoOadWc4sFutoXNzWGW2W3Axd8E3AxAZ6WNGeEoDl7EwPho/T0cDAtswb2Bi6kFx2VkwaDYgRI5zo9EUGRIGHD82e+ufrJ8uo+l31oQogYMJiOdFh2BQ03NTscEDAn8wKgQCeUsRTI8QEMhkYDDc1NTMLMuNwLAP8/a9Pbl0mJQlXhvVtrO2YNLce3Uew6IvAAsYtLS17gvwLCrKR0d3la0DsgdG3NiZVMBZacMh8L9CB2NjsS61eRiCtB4YH/Q21CMQKAgLnh1hYWAyJ3b9/40Qd09woppJhFytAnIPpBmBCCBjvjdrn59eKSU+SRWkZphu40IMBgRpAAMBmO7DZbL/786+s0TIpKqXOhgqGCKcnhOrd28HBlmj+2LFZWia9KjkqnHoa3BmsjG7wKIgDuSzQw9F29Gh+3jDunTseWas1zKtKYbiIsrEjZdAF2iPiYOvIz+Nyuebm5h6+HuvGa2xU0qhwBbkzayzjDO8y3IwgbAdHPp87zNx8sIvLYN/tvhc1TF1lWqSEwaMWgG3ABpIB4sC2HY2Ei0sf0O2YmLWr1CdQGRYp8SK3ic/ZnRWMLqQ+2xGRwUD069dvV8zcuRom+rlA6Y2MbgGmhAGEz4VYSPQF5cyZM6GFYl6eTlN6ixi6aE6PqDLQZRi4EKI/KOfGFjUzqCKsXu6l2RpuAKJxiI1tHhcQJAYOHDhgwOZZs4ZSTHR5lQQYPDW1DS4aELQxdyEIAANGjtk8c6aaqTslk8gVwIAN0w3rAEL2bMtHm12AIOHqenXaNDWztEwo9hKJGHjR6OO0yDSI1IGdoQ0iY0a6Tt+06fKUDRQzqKw8Qlxr1AXrwNqwDvGBA+BrGUDc3d3Xr5+SQZj0E2ERqXIjPAJYNUbD18FoWEeDbHLPzLyQ4ePjQ5i3x1RCubfmpqkjMMNo6KOJ5uqe+f58C9GoaD29XyVSYS1h4DftKeWDDN4AbACZMZAsExEKghWUNKXWhlPfA2P1qjmUT556a9jmQotWi/VOFael1lR7ep4JfRZy8nhpwtG4wMMB/gdi9/nNH+vhezsmJ+fG5quX12fomHl6J+KFy88uA2RJyJPE4wkL4wIPBfgXxO5HxGN7zNw5W2bNnLZhio+OmaR3LD6tplrLfKeYAwX7/O6Dje/2dpniwuKiwoMHH+bn7723Z8/uHTu2fpg9+3p29sYrWVnr1l1cO2HCUFCGT+tshUcWLPj6IDf37ued27Z9unXz2owZU6dOnnxp4sQ1q1ePH79KN6vbQWc1SrfrTit6lO5NO6/F8yZNmofBfgNTwRQLsPLsHQAAAABJRU5ErkJggg==';
@@ -321,10 +249,10 @@ const COMPASS_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArUAAAB7CAM
321
249
  /* src/floorplan/Components/Compass.svelte generated by Svelte v3.47.0 */
322
250
 
323
251
  function add_css$c(target) {
324
- internal.append_styles(target, "svelte-1q44ru9", ".floorplan-plugin__compass.svelte-1q44ru9{position:absolute;left:50%;top:-2.39583rem;width:12.03125rem;height:2.13542rem;will-change:opacity;transform-origin:center 9.58333rem}.floorplan-plugin__compass-image.svelte-1q44ru9{width:100%;height:100%;position:absolute;left:0;top:0;opacity:0.1;background-repeat:no-repeat;background-size:100% 100%}.floorplan-plugin__compass-text.svelte-1q44ru9{position:absolute;left:50%;top:0.78125rem;transform:translateX(-50%);opacity:0.2;font-weight:bold;font-size:0.52083rem;color:#fff}");
252
+ internal.append_styles(target, "svelte-z9kwkx", ".floorplan-plugin__compass.svelte-z9kwkx{position:absolute;left:50%;top:-2.39583rem;width:12.03125rem;height:2.13542rem;will-change:opacity;transform-origin:center 9.58333rem}.floorplan-plugin__compass-image.svelte-z9kwkx{width:100%;height:100%;position:absolute;left:0;top:0;opacity:0.1;background-repeat:no-repeat;background-size:100% 100%}.floorplan-plugin__compass-text.svelte-z9kwkx{position:absolute;left:50%;top:0.78125rem;transform:translateX(-50%);opacity:0.2;font-weight:bold;font-size:0.52083rem;color:#fff}");
325
253
  }
326
254
 
327
- // (14:0) {#if canShowCompass}
255
+ // (14:0) {#if canCompassShow}
328
256
  function create_if_block$6(ctx) {
329
257
  let div1;
330
258
  let div0;
@@ -339,11 +267,11 @@ function create_if_block$6(ctx) {
339
267
  t0 = internal.space();
340
268
  span = internal.element("span");
341
269
  t1 = internal.text(/*northDesc*/ ctx[0]);
342
- internal.attr(div0, "class", "floorplan-plugin__compass-image svelte-1q44ru9");
270
+ internal.attr(div0, "class", "floorplan-plugin__compass-image svelte-z9kwkx");
343
271
  internal.set_style(div0, "background-image", `url(${COMPASS_IMAGE})`);
344
- internal.attr(span, "class", "floorplan-plugin__compass-text svelte-1q44ru9");
345
- internal.attr(div1, "class", "floorplan-plugin__compass svelte-1q44ru9");
346
- internal.set_style(div1, "transform", /*compassTransformStyle*/ ctx[1], false);
272
+ internal.attr(span, "class", "floorplan-plugin__compass-text svelte-z9kwkx");
273
+ internal.attr(div1, "class", "floorplan-plugin__compass svelte-z9kwkx");
274
+ internal.set_style(div1, "transform", /*compassTransformStyle*/ ctx[2], false);
347
275
  },
348
276
  m(target, anchor) {
349
277
  internal.insert(target, div1, anchor);
@@ -363,7 +291,7 @@ function create_if_block$6(ctx) {
363
291
 
364
292
  function create_fragment$f(ctx) {
365
293
  let if_block_anchor;
366
- let if_block = /*canShowCompass*/ ctx[2] && create_if_block$6(ctx);
294
+ let if_block = /*canCompassShow*/ ctx[1] && create_if_block$6(ctx);
367
295
 
368
296
  return {
369
297
  c() {
@@ -375,7 +303,7 @@ function create_fragment$f(ctx) {
375
303
  internal.insert(target, if_block_anchor, anchor);
376
304
  },
377
305
  p(ctx, [dirty]) {
378
- if (/*canShowCompass*/ ctx[2]) if_block.p(ctx, dirty);
306
+ if (/*canCompassShow*/ ctx[1]) if_block.p(ctx, dirty);
379
307
  },
380
308
  i: internal.noop,
381
309
  o: internal.noop,
@@ -399,16 +327,16 @@ function instance$f($$self, $$props, $$invalidate) {
399
327
  ? void 0
400
328
  : _a.northRad;
401
329
 
402
- const rotate = typeof northRad !== 'number' ? 0 : rad2Deg(northRad);
330
+ const canCompassShow = typeof northRad === 'number';
331
+ const rotate = !northRad ? 0 : rad2Deg(northRad);
403
332
  const compassTransformStyle = `translateX(-50%) translateZ(10px) rotate(${-rotate + 90}deg)`;
404
- const canShowCompass = typeof northRad === 'number';
405
333
 
406
334
  $$self.$$set = $$props => {
407
335
  if ('floorplanData' in $$props) $$invalidate(3, floorplanData = $$props.floorplanData);
408
336
  if ('northDesc' in $$props) $$invalidate(0, northDesc = $$props.northDesc);
409
337
  };
410
338
 
411
- return [northDesc, compassTransformStyle, canShowCompass, floorplanData];
339
+ return [northDesc, canCompassShow, compassTransformStyle, floorplanData];
412
340
  }
413
341
 
414
342
  class Compass extends internal.SvelteComponent {
@@ -739,13 +667,13 @@ class BaseImage extends internal.SvelteComponent {
739
667
  /* src/floorplan/Components/RoomLabels/RoomLabel.svelte generated by Svelte v3.47.0 */
740
668
 
741
669
  function add_css$8(target) {
742
- internal.append_styles(target, "svelte-i2nwuk", ".floorplan-plugin__room-label-item.svelte-i2nwuk{position:absolute;display:flex;flex-flow:column;align-items:center;line-height:0.78125rem;color:#fff;transform:translate(-50%, -50%);white-space:nowrap}.floorplan-plugin__room-size.svelte-i2nwuk{opacity:0.45}");
670
+ internal.append_styles(target, "svelte-12pzct5", ".floorplan-plugin__room-label-item.svelte-12pzct5{position:absolute;display:flex;flex-flow:column;align-items:center;line-height:1;color:#fff;transform:translate(-50%, -50%);white-space:nowrap;will-change:opacity;transition:opacity 300ms}.floorplan-plugin__room-size.svelte-12pzct5{opacity:0.45}");
743
671
  }
744
672
 
745
- // (22:30)
673
+ // (95:30)
746
674
  function create_if_block_1$3(ctx) {
747
675
  let html_tag;
748
- let raw_value = /*userConfigElement*/ ctx[2].outerHTML + "";
676
+ let raw_value = /*userConfigElement*/ ctx[4].outerHTML + "";
749
677
  let html_anchor;
750
678
 
751
679
  return {
@@ -759,7 +687,7 @@ function create_if_block_1$3(ctx) {
759
687
  internal.insert(target, html_anchor, anchor);
760
688
  },
761
689
  p(ctx, dirty) {
762
- if (dirty & /*userConfigElement*/ 4 && raw_value !== (raw_value = /*userConfigElement*/ ctx[2].outerHTML + "")) html_tag.p(raw_value);
690
+ if (dirty & /*userConfigElement*/ 16 && raw_value !== (raw_value = /*userConfigElement*/ ctx[4].outerHTML + "")) html_tag.p(raw_value);
763
691
  },
764
692
  d(detaching) {
765
693
  if (detaching) internal.detach(html_anchor);
@@ -768,7 +696,7 @@ function create_if_block_1$3(ctx) {
768
696
  };
769
697
  }
770
698
 
771
- // (16:2) {#if getLabelElement === undefined}
699
+ // (89:2) {#if getLabelElement === undefined}
772
700
  function create_if_block$4(ctx) {
773
701
  let span0;
774
702
  let t0_value = /*room*/ ctx[0].name + "";
@@ -782,9 +710,9 @@ function create_if_block$4(ctx) {
782
710
  t0 = internal.text(t0_value);
783
711
  t1 = internal.space();
784
712
  span1 = internal.element("span");
785
- span1.textContent = `${/*roomSizeDes*/ ctx[3]}`;
713
+ span1.textContent = `${/*roomSizeDes*/ ctx[5]}`;
786
714
  internal.attr(span0, "class", "floorplan-plugin__room-name");
787
- internal.attr(span1, "class", "floorplan-plugin__room-size svelte-i2nwuk");
715
+ internal.attr(span1, "class", "floorplan-plugin__room-size svelte-12pzct5");
788
716
  },
789
717
  m(target, anchor) {
790
718
  internal.insert(target, span0, anchor);
@@ -808,7 +736,7 @@ function create_fragment$b(ctx) {
808
736
 
809
737
  function select_block_type(ctx, dirty) {
810
738
  if (/*getLabelElement*/ ctx[1] === undefined) return create_if_block$4;
811
- if (/*userConfigElement*/ ctx[2]) return create_if_block_1$3;
739
+ if (/*userConfigElement*/ ctx[4]) return create_if_block_1$3;
812
740
  }
813
741
 
814
742
  let current_block_type = select_block_type(ctx);
@@ -818,14 +746,16 @@ function create_fragment$b(ctx) {
818
746
  c() {
819
747
  div = internal.element("div");
820
748
  if (if_block) if_block.c();
821
- internal.attr(div, "class", "floorplan-plugin__room-label-item svelte-i2nwuk");
822
- internal.set_style(div, "left", /*left*/ ctx[4], false);
823
- internal.set_style(div, "top", /*top*/ ctx[5], false);
824
- internal.set_style(div, "font-size", /*fontSize*/ ctx[6], false);
749
+ internal.attr(div, "class", "floorplan-plugin__room-label-item svelte-12pzct5");
750
+ internal.set_style(div, "left", /*left*/ ctx[6], false);
751
+ internal.set_style(div, "top", /*top*/ ctx[7], false);
752
+ internal.set_style(div, "font-size", /*fontSize*/ ctx[8], false);
753
+ internal.set_style(div, "opacity", /*labelVisible*/ ctx[3] ? '1' : '0', false);
825
754
  },
826
755
  m(target, anchor) {
827
756
  internal.insert(target, div, anchor);
828
757
  if (if_block) if_block.m(div, null);
758
+ /*div_binding*/ ctx[15](div);
829
759
  },
830
760
  p(ctx, [dirty]) {
831
761
  if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
@@ -839,6 +769,10 @@ function create_fragment$b(ctx) {
839
769
  if_block.m(div, null);
840
770
  }
841
771
  }
772
+
773
+ if (dirty & /*labelVisible*/ 8) {
774
+ internal.set_style(div, "opacity", /*labelVisible*/ ctx[3] ? '1' : '0', false);
775
+ }
842
776
  },
843
777
  i: internal.noop,
844
778
  o: internal.noop,
@@ -848,45 +782,185 @@ function create_fragment$b(ctx) {
848
782
  if (if_block) {
849
783
  if_block.d();
850
784
  }
785
+
786
+ /*div_binding*/ ctx[15](null);
851
787
  }
852
788
  };
853
789
  }
854
790
 
791
+ function isPointInPolygon(point, polygon) {
792
+ const x = point[0];
793
+ const y = point[1];
794
+ let inside = false;
795
+
796
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
797
+ const xi = polygon[i][0];
798
+ const yi = polygon[i][1];
799
+ const xj = polygon[j][0];
800
+ const yj = polygon[j][1];
801
+ const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
802
+ if (intersect) inside = !inside;
803
+ }
804
+
805
+ return inside;
806
+ }
807
+
855
808
  function instance$b($$self, $$props, $$invalidate) {
809
+ let isLabelInRoom;
856
810
  let userConfigElement;
811
+ let labelVisible;
812
+ let { pxmm } = $$props;
857
813
  let { room } = $$props;
814
+ let { hoveredRoom } = $$props;
858
815
  let { getLabelElement } = $$props;
816
+ let { adaptiveRoomLabelVisibleEnable } = $$props;
817
+
818
+ function isLabelInRoomCurry(room, labelElementSize) {
819
+ if (labelElementSize.width === 0 || labelElementSize.height === 0) return () => false;
820
+ const polygon = room.path.map(({ x, y }) => [x, y]);
821
+ const labelPosition = room.roomLabel.position;
822
+ const { x, y } = labelPosition;
823
+ const { width, height } = labelElementSize;
824
+ const halfWidth = width / 2;
825
+ const halfHeight = height / 2;
826
+
827
+ return function isLabelInRoom(pxmm) {
828
+ const clientX = x * pxmm;
829
+ const clientY = y * pxmm;
830
+ const clientPolygon = polygon.map(([x, y]) => [x * pxmm, y * pxmm]);
831
+
832
+ // const
833
+ /** 围成 labelRect 的四个点
834
+ * 1----0
835
+ * | |
836
+ * 2----3
837
+ */
838
+ const labelRectClientPoints = [
839
+ [clientX + halfWidth, clientY - halfHeight],
840
+ [clientX - halfWidth, clientY - halfHeight],
841
+ [clientX - halfWidth, clientY + halfHeight],
842
+ [clientX + halfWidth, clientY + halfHeight]
843
+ ];
844
+
845
+ return labelRectClientPoints.every(point => isPointInPolygon(point, clientPolygon));
846
+ };
847
+ }
859
848
 
849
+ // ========== 获取设备宽高像素 ==========
860
850
  // TODO: 统一这里的判断条件,目前写了多处
861
851
  const bodyWidth = document.body.clientWidth;
862
852
 
863
853
  const bodyHeight = document.body.clientHeight;
864
854
  const roomSizeDes = room.size ? (room.size / 1000000).toFixed(1) + '㎡' : '';
855
+
856
+ // ====================================
865
857
  const roomLabel = room.roomLabel;
858
+
866
859
  const left = roomLabel.positionInImage.x * 100 + '%';
867
860
  const top = roomLabel.positionInImage.y * 100 + '%';
861
+
862
+ // 屏幕宽或高小于 500px 时,用 10px 字体,否则用 14px
868
863
  const fontSize = (bodyWidth < 500 || bodyHeight < 500 ? 10 : 14) / 16 + 'rem';
869
864
 
865
+ let isHoverd = false;
866
+ let labelElement;
867
+ let labelElementSize;
868
+
869
+ hoveredRoom.subscribe(function onHoverdRoomUpdate(_room) {
870
+ $$invalidate(12, isHoverd = !!_room && _room.id === room.id);
871
+ });
872
+
873
+ svelte.onMount(() => {
874
+ // Label 能不能展示只跟房间大小有关
875
+ // 计算 LabelElement 宽高
876
+ const labelDomRect = labelElement === null || labelElement === void 0
877
+ ? void 0
878
+ : labelElement.getClientRects()[0];
879
+
880
+ $$invalidate(13, labelElementSize = {
881
+ width: labelDomRect.width,
882
+ height: labelDomRect.height
883
+ });
884
+ });
885
+
886
+ function div_binding($$value) {
887
+ internal.binding_callbacks[$$value ? 'unshift' : 'push'](() => {
888
+ labelElement = $$value;
889
+ $$invalidate(2, labelElement);
890
+ });
891
+ }
892
+
870
893
  $$self.$$set = $$props => {
894
+ if ('pxmm' in $$props) $$invalidate(9, pxmm = $$props.pxmm);
871
895
  if ('room' in $$props) $$invalidate(0, room = $$props.room);
896
+ if ('hoveredRoom' in $$props) $$invalidate(10, hoveredRoom = $$props.hoveredRoom);
872
897
  if ('getLabelElement' in $$props) $$invalidate(1, getLabelElement = $$props.getLabelElement);
898
+ if ('adaptiveRoomLabelVisibleEnable' in $$props) $$invalidate(11, adaptiveRoomLabelVisibleEnable = $$props.adaptiveRoomLabelVisibleEnable);
873
899
  };
874
900
 
875
901
  $$self.$$.update = () => {
902
+ if ($$self.$$.dirty & /*labelElementSize, room*/ 8193) {
903
+ $$invalidate(14, isLabelInRoom = labelElementSize
904
+ ? isLabelInRoomCurry(room, labelElementSize)
905
+ : undefined);
906
+ }
907
+
876
908
  if ($$self.$$.dirty & /*getLabelElement, room*/ 3) {
877
- $$invalidate(2, userConfigElement = getLabelElement === null || getLabelElement === void 0
909
+ $$invalidate(4, userConfigElement = getLabelElement === null || getLabelElement === void 0
878
910
  ? void 0
879
911
  : getLabelElement(room));
880
912
  }
913
+
914
+ if ($$self.$$.dirty & /*adaptiveRoomLabelVisibleEnable, isHoverd, isLabelInRoom, pxmm*/ 23040) {
915
+ $$invalidate(3, labelVisible = adaptiveRoomLabelVisibleEnable
916
+ ? isHoverd
917
+ ? true
918
+ : !!(isLabelInRoom === null || isLabelInRoom === void 0
919
+ ? void 0
920
+ : isLabelInRoom(pxmm))
921
+ : true);
922
+ }
881
923
  };
882
924
 
883
- return [room, getLabelElement, userConfigElement, roomSizeDes, left, top, fontSize];
925
+ return [
926
+ room,
927
+ getLabelElement,
928
+ labelElement,
929
+ labelVisible,
930
+ userConfigElement,
931
+ roomSizeDes,
932
+ left,
933
+ top,
934
+ fontSize,
935
+ pxmm,
936
+ hoveredRoom,
937
+ adaptiveRoomLabelVisibleEnable,
938
+ isHoverd,
939
+ labelElementSize,
940
+ isLabelInRoom,
941
+ div_binding
942
+ ];
884
943
  }
885
944
 
886
945
  class RoomLabel extends internal.SvelteComponent {
887
946
  constructor(options) {
888
947
  super();
889
- internal.init(this, options, instance$b, create_fragment$b, internal.safe_not_equal, { room: 0, getLabelElement: 1 }, add_css$8);
948
+
949
+ internal.init(
950
+ this,
951
+ options,
952
+ instance$b,
953
+ create_fragment$b,
954
+ internal.safe_not_equal,
955
+ {
956
+ pxmm: 9,
957
+ room: 0,
958
+ hoveredRoom: 10,
959
+ getLabelElement: 1,
960
+ adaptiveRoomLabelVisibleEnable: 11
961
+ },
962
+ add_css$8
963
+ );
890
964
  }
891
965
  }
892
966
 
@@ -898,18 +972,19 @@ function add_css$7(target) {
898
972
 
899
973
  function get_each_context$5(ctx, list, i) {
900
974
  const child_ctx = ctx.slice();
901
- child_ctx[4] = list[i];
975
+ child_ctx[9] = list[i];
902
976
  return child_ctx;
903
977
  }
904
978
 
905
- // (8:0) {#if rooms}
979
+ // (17:0) {#if rooms}
906
980
  function create_if_block$3(ctx) {
907
981
  let div;
908
982
  let each_blocks = [];
909
983
  let each_1_lookup = new Map();
984
+ let div_resize_listener;
910
985
  let current;
911
- let each_value = /*rooms*/ ctx[1];
912
- const get_key = ctx => /*room*/ ctx[4].id;
986
+ let each_value = /*rooms*/ ctx[5];
987
+ const get_key = ctx => /*room*/ ctx[9].id;
913
988
 
914
989
  for (let i = 0; i < each_value.length; i += 1) {
915
990
  let child_ctx = get_each_context$5(ctx, each_value, i);
@@ -926,6 +1001,7 @@ function create_if_block$3(ctx) {
926
1001
  }
927
1002
 
928
1003
  internal.attr(div, "class", "floorplan-plugin__room-labels svelte-13xux0b");
1004
+ internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[8].call(div));
929
1005
  },
930
1006
  m(target, anchor) {
931
1007
  internal.insert(target, div, anchor);
@@ -934,11 +1010,12 @@ function create_if_block$3(ctx) {
934
1010
  each_blocks[i].m(div, null);
935
1011
  }
936
1012
 
1013
+ div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[8].bind(div));
937
1014
  current = true;
938
1015
  },
939
1016
  p(ctx, dirty) {
940
- if (dirty & /*rooms, getLabelElement*/ 3) {
941
- each_value = /*rooms*/ ctx[1];
1017
+ if (dirty & /*pxmm, rooms, getLabelElement, hoveredRoom, adaptiveRoomLabelVisibleEnable*/ 55) {
1018
+ each_value = /*rooms*/ ctx[5];
942
1019
  internal.group_outros();
943
1020
  each_blocks = internal.update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div, internal.outro_and_destroy_block, create_each_block$5, null, get_each_context$5);
944
1021
  internal.check_outros();
@@ -966,11 +1043,13 @@ function create_if_block$3(ctx) {
966
1043
  for (let i = 0; i < each_blocks.length; i += 1) {
967
1044
  each_blocks[i].d();
968
1045
  }
1046
+
1047
+ div_resize_listener();
969
1048
  }
970
1049
  };
971
1050
  }
972
1051
 
973
- // (10:4) {#each rooms as room (room.id)}
1052
+ // (19:4) {#each rooms as room (room.id)}
974
1053
  function create_each_block$5(key_1, ctx) {
975
1054
  let first;
976
1055
  let roomlabel;
@@ -978,8 +1057,11 @@ function create_each_block$5(key_1, ctx) {
978
1057
 
979
1058
  const roomlabel_spread_levels = [
980
1059
  {
981
- room: /*room*/ ctx[4],
982
- getLabelElement: /*getLabelElement*/ ctx[0]
1060
+ pxmm: /*pxmm*/ ctx[4],
1061
+ room: /*room*/ ctx[9],
1062
+ getLabelElement: /*getLabelElement*/ ctx[1],
1063
+ hoveredRoom: /*hoveredRoom*/ ctx[0],
1064
+ adaptiveRoomLabelVisibleEnable: /*adaptiveRoomLabelVisibleEnable*/ ctx[2]
983
1065
  }
984
1066
  ];
985
1067
 
@@ -1007,11 +1089,14 @@ function create_each_block$5(key_1, ctx) {
1007
1089
  p(new_ctx, dirty) {
1008
1090
  ctx = new_ctx;
1009
1091
 
1010
- const roomlabel_changes = (dirty & /*rooms, getLabelElement*/ 3)
1092
+ const roomlabel_changes = (dirty & /*pxmm, rooms, getLabelElement, hoveredRoom, adaptiveRoomLabelVisibleEnable*/ 55)
1011
1093
  ? internal.get_spread_update(roomlabel_spread_levels, [
1012
1094
  {
1013
- room: /*room*/ ctx[4],
1014
- getLabelElement: /*getLabelElement*/ ctx[0]
1095
+ pxmm: /*pxmm*/ ctx[4],
1096
+ room: /*room*/ ctx[9],
1097
+ getLabelElement: /*getLabelElement*/ ctx[1],
1098
+ hoveredRoom: /*hoveredRoom*/ ctx[0],
1099
+ adaptiveRoomLabelVisibleEnable: /*adaptiveRoomLabelVisibleEnable*/ ctx[2]
1015
1100
  }
1016
1101
  ])
1017
1102
  : {};
@@ -1037,7 +1122,7 @@ function create_each_block$5(key_1, ctx) {
1037
1122
  function create_fragment$a(ctx) {
1038
1123
  let if_block_anchor;
1039
1124
  let current;
1040
- let if_block = /*rooms*/ ctx[1] && create_if_block$3(ctx);
1125
+ let if_block = /*rooms*/ ctx[5] && create_if_block$3(ctx);
1041
1126
 
1042
1127
  return {
1043
1128
  c() {
@@ -1050,11 +1135,11 @@ function create_fragment$a(ctx) {
1050
1135
  current = true;
1051
1136
  },
1052
1137
  p(ctx, [dirty]) {
1053
- if (/*rooms*/ ctx[1]) {
1138
+ if (/*rooms*/ ctx[5]) {
1054
1139
  if (if_block) {
1055
1140
  if_block.p(ctx, dirty);
1056
1141
 
1057
- if (dirty & /*rooms*/ 2) {
1142
+ if (dirty & /*rooms*/ 32) {
1058
1143
  internal.transition_in(if_block, 1);
1059
1144
  }
1060
1145
  } else {
@@ -1093,21 +1178,50 @@ function instance$a($$self, $$props, $$invalidate) {
1093
1178
  let rooms;
1094
1179
  let { floorIndex } = $$props;
1095
1180
  let { floorplanData } = $$props;
1181
+ let { hoveredRoom } = $$props;
1096
1182
  let { getLabelElement } = $$props;
1183
+ let { adaptiveRoomLabelVisibleEnable } = $$props;
1184
+ let clientWidth = 0;
1185
+ let pxmm = 0;
1186
+
1187
+ function div_elementresize_handler() {
1188
+ clientWidth = this.clientWidth;
1189
+ $$invalidate(3, clientWidth);
1190
+ }
1097
1191
 
1098
1192
  $$self.$$set = $$props => {
1099
- if ('floorIndex' in $$props) $$invalidate(2, floorIndex = $$props.floorIndex);
1100
- if ('floorplanData' in $$props) $$invalidate(3, floorplanData = $$props.floorplanData);
1101
- if ('getLabelElement' in $$props) $$invalidate(0, getLabelElement = $$props.getLabelElement);
1193
+ if ('floorIndex' in $$props) $$invalidate(6, floorIndex = $$props.floorIndex);
1194
+ if ('floorplanData' in $$props) $$invalidate(7, floorplanData = $$props.floorplanData);
1195
+ if ('hoveredRoom' in $$props) $$invalidate(0, hoveredRoom = $$props.hoveredRoom);
1196
+ if ('getLabelElement' in $$props) $$invalidate(1, getLabelElement = $$props.getLabelElement);
1197
+ if ('adaptiveRoomLabelVisibleEnable' in $$props) $$invalidate(2, adaptiveRoomLabelVisibleEnable = $$props.adaptiveRoomLabelVisibleEnable);
1102
1198
  };
1103
1199
 
1104
1200
  $$self.$$.update = () => {
1105
- if ($$self.$$.dirty & /*floorplanData, floorIndex*/ 12) {
1106
- $$invalidate(1, rooms = floorplanData.floorDatas[floorIndex].rooms);
1201
+ if ($$self.$$.dirty & /*floorplanData, floorIndex*/ 192) {
1202
+ $$invalidate(5, rooms = floorplanData.floorDatas[floorIndex].rooms);
1203
+ }
1204
+
1205
+ if ($$self.$$.dirty & /*floorplanData, clientWidth*/ 136) {
1206
+ {
1207
+ const { max, min } = floorplanData.bounding;
1208
+ const boundingWidth = max.x - min.x;
1209
+ $$invalidate(4, pxmm = clientWidth / boundingWidth);
1210
+ }
1107
1211
  }
1108
1212
  };
1109
1213
 
1110
- return [getLabelElement, rooms, floorIndex, floorplanData];
1214
+ return [
1215
+ hoveredRoom,
1216
+ getLabelElement,
1217
+ adaptiveRoomLabelVisibleEnable,
1218
+ clientWidth,
1219
+ pxmm,
1220
+ rooms,
1221
+ floorIndex,
1222
+ floorplanData,
1223
+ div_elementresize_handler
1224
+ ];
1111
1225
  }
1112
1226
 
1113
1227
  class RoomLabels extends internal.SvelteComponent {
@@ -1121,9 +1235,11 @@ class RoomLabels extends internal.SvelteComponent {
1121
1235
  create_fragment$a,
1122
1236
  internal.safe_not_equal,
1123
1237
  {
1124
- floorIndex: 2,
1125
- floorplanData: 3,
1126
- getLabelElement: 0
1238
+ floorIndex: 6,
1239
+ floorplanData: 7,
1240
+ hoveredRoom: 0,
1241
+ getLabelElement: 1,
1242
+ adaptiveRoomLabelVisibleEnable: 2
1127
1243
  },
1128
1244
  add_css$7
1129
1245
  );
@@ -1149,7 +1265,7 @@ function get_each_context_1(ctx, list, i) {
1149
1265
  return child_ctx;
1150
1266
  }
1151
1267
 
1152
- // (53:4) {#each rulerLabels as rulerLabel}
1268
+ // (47:4) {#each rulerLabels as rulerLabel}
1153
1269
  function create_each_block_1(ctx) {
1154
1270
  let div;
1155
1271
 
@@ -1170,7 +1286,7 @@ function create_each_block_1(ctx) {
1170
1286
  };
1171
1287
  }
1172
1288
 
1173
- // (62:4) {#each rulerTexts as textItem, textItemIndex (textItemIndex)}
1289
+ // (56:4) {#each rulerTexts as textItem, textItemIndex (textItemIndex)}
1174
1290
  function create_each_block$4(key_1, ctx) {
1175
1291
  let div1;
1176
1292
  let div0;
@@ -1637,6 +1753,32 @@ class RuleLabels extends internal.SvelteComponent {
1637
1753
  }
1638
1754
  }
1639
1755
 
1756
+ function pathD(points, options = {}) {
1757
+ let d = '';
1758
+ const { needZ, needA } = options;
1759
+ const _points = needZ ? points.slice().concat(points[0]) : points.slice();
1760
+ _points.forEach((_point, index) => {
1761
+ const { x, y } = options.format ? options.format(_point) : _point;
1762
+ const point = x + ',' + y;
1763
+ if (index === 0) {
1764
+ d += 'M' + point;
1765
+ return d;
1766
+ }
1767
+ if (needA === null || needA === void 0 ? void 0 : needA[index]) {
1768
+ d += 'A' + needA[index] + ',' + point;
1769
+ return d;
1770
+ }
1771
+ d += 'L' + point;
1772
+ return d;
1773
+ });
1774
+ return d + (needZ ? 'Z' : '');
1775
+ }
1776
+ /** 把户型图上点点位转换到 SVG 上的点位 */
1777
+ function formatFloorplanPoint({ x, y }, bounding) {
1778
+ const { max, min } = bounding;
1779
+ return { x: x - min.x, y: max.y - y };
1780
+ }
1781
+
1640
1782
  /* src/floorplan/Components/RoomMaterials/RoomMaterial_0.svelte generated by Svelte v3.47.0 */
1641
1783
 
1642
1784
  function create_fragment$7(ctx) {
@@ -1722,6 +1864,7 @@ function create_fragment$6(ctx) {
1722
1864
  internal.attr(pattern, "width", /*width*/ ctx[1]);
1723
1865
  internal.attr(pattern, "height", /*width*/ ctx[1]);
1724
1866
  internal.attr(pattern, "patternUnits", "userSpaceOnUse");
1867
+ internal.attr(pattern, "patternTransform", "scale(50 50)");
1725
1868
  internal.attr(path1, "d", /*d*/ ctx[0]);
1726
1869
  internal.attr(path1, "fill", "url(#fpm-room-pattern-0)");
1727
1870
  },
@@ -1804,8 +1947,8 @@ function create_fragment$5(ctx) {
1804
1947
  path1 = internal.svg_element("path");
1805
1948
  t2 = internal.space();
1806
1949
  path2 = internal.svg_element("path");
1807
- internal.attr(rect0, "x", "0.5");
1808
- internal.attr(rect0, "y", "0.5");
1950
+ internal.attr(rect0, "x", "0");
1951
+ internal.attr(rect0, "y", "0");
1809
1952
  internal.attr(rect0, "width", "6");
1810
1953
  internal.attr(rect0, "height", "50");
1811
1954
  internal.attr(rect0, "fill", "none");
@@ -1814,22 +1957,24 @@ function create_fragment$5(ctx) {
1814
1957
  internal.attr(pattern0, "id", "room-material-pattern-1");
1815
1958
  internal.attr(pattern0, "x", "0");
1816
1959
  internal.attr(pattern0, "y", "0");
1817
- internal.attr(pattern0, "width", "13");
1818
- internal.attr(pattern0, "height", "51");
1960
+ internal.attr(pattern0, "width", "12");
1961
+ internal.attr(pattern0, "height", "50");
1819
1962
  internal.attr(pattern0, "patternUnits", "userSpaceOnUse");
1820
- internal.attr(rect1, "x", "0.5");
1821
- internal.attr(rect1, "y", "0.5");
1963
+ internal.attr(pattern0, "patternTransform", "scale(50 50)");
1964
+ internal.attr(rect1, "x", "0");
1965
+ internal.attr(rect1, "y", "0");
1822
1966
  internal.attr(rect1, "width", "6");
1823
1967
  internal.attr(rect1, "height", "50");
1824
1968
  internal.attr(rect1, "fill", "none");
1825
1969
  internal.attr(rect1, "stroke", "#4B4B57");
1826
1970
  internal.attr(rect1, "stroke-width", "0.5");
1827
1971
  internal.attr(pattern1, "id", "room-material-pattern-2");
1828
- internal.attr(pattern1, "x", "7");
1972
+ internal.attr(pattern1, "x", "6");
1829
1973
  internal.attr(pattern1, "y", "25");
1830
- internal.attr(pattern1, "width", "13");
1831
- internal.attr(pattern1, "height", "51");
1974
+ internal.attr(pattern1, "width", "12");
1975
+ internal.attr(pattern1, "height", "50");
1832
1976
  internal.attr(pattern1, "patternUnits", "userSpaceOnUse");
1977
+ internal.attr(pattern1, "patternTransform", "scale(50 50)");
1833
1978
  internal.attr(path0, "d", /*d*/ ctx[0]);
1834
1979
  internal.attr(path0, "fill", "#43434D");
1835
1980
  internal.attr(path1, "d", /*d*/ ctx[0]);
@@ -2215,22 +2360,35 @@ function add_css$3(target) {
2215
2360
 
2216
2361
  function create_fragment$3(ctx) {
2217
2362
  let path;
2363
+ let mounted;
2364
+ let dispose;
2218
2365
 
2219
2366
  return {
2220
2367
  c() {
2221
2368
  path = internal.svg_element("path");
2222
- internal.attr(path, "d", /*_pathD*/ ctx[0]);
2369
+ internal.attr(path, "d", /*_pathD*/ ctx[2]);
2223
2370
  internal.attr(path, "fill", `#fff`);
2224
2371
  internal.attr(path, "class", "svelte-19uvvss");
2225
2372
  },
2226
2373
  m(target, anchor) {
2227
2374
  internal.insert(target, path, anchor);
2375
+
2376
+ if (!mounted) {
2377
+ dispose = [
2378
+ internal.listen(path, "mouseenter", /*onMouseEnter*/ ctx[0]),
2379
+ internal.listen(path, "mouseleave", /*onMouseLeave*/ ctx[1])
2380
+ ];
2381
+
2382
+ mounted = true;
2383
+ }
2228
2384
  },
2229
2385
  p: internal.noop,
2230
2386
  i: internal.noop,
2231
2387
  o: internal.noop,
2232
2388
  d(detaching) {
2233
2389
  if (detaching) internal.detach(path);
2390
+ mounted = false;
2391
+ internal.run_all(dispose);
2234
2392
  }
2235
2393
  };
2236
2394
  }
@@ -2238,6 +2396,16 @@ function create_fragment$3(ctx) {
2238
2396
  function instance$3($$self, $$props, $$invalidate) {
2239
2397
  let { room } = $$props;
2240
2398
  let { floorplanData } = $$props;
2399
+ let { hoveredRoom } = $$props;
2400
+
2401
+ function onMouseEnter() {
2402
+ hoveredRoom.set(room);
2403
+ }
2404
+
2405
+ function onMouseLeave() {
2406
+ hoveredRoom.set(undefined);
2407
+ }
2408
+
2241
2409
  const { bounding } = floorplanData;
2242
2410
 
2243
2411
  const _pathD = pathD(room.path, {
@@ -2246,17 +2414,31 @@ function instance$3($$self, $$props, $$invalidate) {
2246
2414
  });
2247
2415
 
2248
2416
  $$self.$$set = $$props => {
2249
- if ('room' in $$props) $$invalidate(1, room = $$props.room);
2250
- if ('floorplanData' in $$props) $$invalidate(2, floorplanData = $$props.floorplanData);
2417
+ if ('room' in $$props) $$invalidate(3, room = $$props.room);
2418
+ if ('floorplanData' in $$props) $$invalidate(4, floorplanData = $$props.floorplanData);
2419
+ if ('hoveredRoom' in $$props) $$invalidate(5, hoveredRoom = $$props.hoveredRoom);
2251
2420
  };
2252
2421
 
2253
- return [_pathD, room, floorplanData];
2422
+ return [onMouseEnter, onMouseLeave, _pathD, room, floorplanData, hoveredRoom];
2254
2423
  }
2255
2424
 
2256
2425
  class Room extends internal.SvelteComponent {
2257
2426
  constructor(options) {
2258
2427
  super();
2259
- internal.init(this, options, instance$3, create_fragment$3, internal.safe_not_equal, { room: 1, floorplanData: 2 }, add_css$3);
2428
+
2429
+ internal.init(
2430
+ this,
2431
+ options,
2432
+ instance$3,
2433
+ create_fragment$3,
2434
+ internal.safe_not_equal,
2435
+ {
2436
+ room: 3,
2437
+ floorplanData: 4,
2438
+ hoveredRoom: 5
2439
+ },
2440
+ add_css$3
2441
+ );
2260
2442
  }
2261
2443
  }
2262
2444
 
@@ -2268,11 +2450,11 @@ function add_css$2(target) {
2268
2450
 
2269
2451
  function get_each_context$1(ctx, list, i) {
2270
2452
  const child_ctx = ctx.slice();
2271
- child_ctx[4] = list[i];
2453
+ child_ctx[5] = list[i];
2272
2454
  return child_ctx;
2273
2455
  }
2274
2456
 
2275
- // (10:4) {#each floorplanData.floorDatas[floorIndex].rooms as room (room.id)}
2457
+ // (11:4) {#each floorplanData.floorDatas[floorIndex].rooms as room (room.id)}
2276
2458
  function create_each_block$1(key_1, ctx) {
2277
2459
  let first;
2278
2460
  let room;
@@ -2280,8 +2462,9 @@ function create_each_block$1(key_1, ctx) {
2280
2462
 
2281
2463
  const room_spread_levels = [
2282
2464
  {
2283
- room: /*room*/ ctx[4],
2284
- floorplanData: /*floorplanData*/ ctx[1]
2465
+ room: /*room*/ ctx[5],
2466
+ floorplanData: /*floorplanData*/ ctx[1],
2467
+ hoveredRoom: /*hoveredRoom*/ ctx[2]
2285
2468
  }
2286
2469
  ];
2287
2470
 
@@ -2309,11 +2492,12 @@ function create_each_block$1(key_1, ctx) {
2309
2492
  p(new_ctx, dirty) {
2310
2493
  ctx = new_ctx;
2311
2494
 
2312
- const room_changes = (dirty & /*floorplanData, floorIndex*/ 3)
2495
+ const room_changes = (dirty & /*floorplanData, floorIndex, hoveredRoom*/ 7)
2313
2496
  ? internal.get_spread_update(room_spread_levels, [
2314
2497
  {
2315
- room: /*room*/ ctx[4],
2316
- floorplanData: /*floorplanData*/ ctx[1]
2498
+ room: /*room*/ ctx[5],
2499
+ floorplanData: /*floorplanData*/ ctx[1],
2500
+ hoveredRoom: /*hoveredRoom*/ ctx[2]
2317
2501
  }
2318
2502
  ])
2319
2503
  : {};
@@ -2343,7 +2527,7 @@ function create_fragment$2(ctx) {
2343
2527
  let each_1_lookup = new Map();
2344
2528
  let current;
2345
2529
  let each_value = /*floorplanData*/ ctx[1].floorDatas[/*floorIndex*/ ctx[0]].rooms;
2346
- const get_key = ctx => /*room*/ ctx[4].id;
2530
+ const get_key = ctx => /*room*/ ctx[5].id;
2347
2531
 
2348
2532
  for (let i = 0; i < each_value.length; i += 1) {
2349
2533
  let child_ctx = get_each_context$1(ctx, each_value, i);
@@ -2362,7 +2546,7 @@ function create_fragment$2(ctx) {
2362
2546
 
2363
2547
  internal.attr(svg, "width", "100%");
2364
2548
  internal.attr(svg, "height", "100%");
2365
- internal.attr(svg, "viewBox", `0 0 ${/*boundingWidth*/ ctx[2]} ${/*boundingHeight*/ ctx[3]}`);
2549
+ internal.attr(svg, "viewBox", `0 0 ${/*boundingWidth*/ ctx[3]} ${/*boundingHeight*/ ctx[4]}`);
2366
2550
  internal.attr(svg, "class", "svelte-1kqo6e4");
2367
2551
  internal.attr(div, "class", "floorplan-plugin__room-highlight svelte-1kqo6e4");
2368
2552
  },
@@ -2377,7 +2561,7 @@ function create_fragment$2(ctx) {
2377
2561
  current = true;
2378
2562
  },
2379
2563
  p(ctx, [dirty]) {
2380
- if (dirty & /*floorplanData, floorIndex*/ 3) {
2564
+ if (dirty & /*floorplanData, floorIndex, hoveredRoom*/ 7) {
2381
2565
  each_value = /*floorplanData*/ ctx[1].floorDatas[/*floorIndex*/ ctx[0]].rooms;
2382
2566
  internal.group_outros();
2383
2567
  each_blocks = internal.update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, svg, internal.outro_and_destroy_block, create_each_block$1, null, get_each_context$1);
@@ -2413,21 +2597,36 @@ function create_fragment$2(ctx) {
2413
2597
  function instance$2($$self, $$props, $$invalidate) {
2414
2598
  let { floorIndex } = $$props;
2415
2599
  let { floorplanData } = $$props;
2600
+ let { hoveredRoom } = $$props;
2416
2601
  const boundingWidth = floorplanData.bounding.max.x - floorplanData.bounding.min.x;
2417
2602
  const boundingHeight = floorplanData.bounding.max.y - floorplanData.bounding.min.y;
2418
2603
 
2419
2604
  $$self.$$set = $$props => {
2420
2605
  if ('floorIndex' in $$props) $$invalidate(0, floorIndex = $$props.floorIndex);
2421
2606
  if ('floorplanData' in $$props) $$invalidate(1, floorplanData = $$props.floorplanData);
2607
+ if ('hoveredRoom' in $$props) $$invalidate(2, hoveredRoom = $$props.hoveredRoom);
2422
2608
  };
2423
2609
 
2424
- return [floorIndex, floorplanData, boundingWidth, boundingHeight];
2610
+ return [floorIndex, floorplanData, hoveredRoom, boundingWidth, boundingHeight];
2425
2611
  }
2426
2612
 
2427
2613
  class RoomHighlight extends internal.SvelteComponent {
2428
2614
  constructor(options) {
2429
2615
  super();
2430
- internal.init(this, options, instance$2, create_fragment$2, internal.safe_not_equal, { floorIndex: 0, floorplanData: 1 }, add_css$2);
2616
+
2617
+ internal.init(
2618
+ this,
2619
+ options,
2620
+ instance$2,
2621
+ create_fragment$2,
2622
+ internal.safe_not_equal,
2623
+ {
2624
+ floorIndex: 0,
2625
+ floorplanData: 1,
2626
+ hoveredRoom: 2
2627
+ },
2628
+ add_css$2
2629
+ );
2431
2630
  }
2432
2631
  }
2433
2632
 
@@ -2437,7 +2636,7 @@ function add_css$1(target) {
2437
2636
  internal.append_styles(target, "svelte-bl8zrz", ".floorplan-plugin__floor.svelte-bl8zrz{position:absolute;left:0;top:0;width:100%;height:100%;opacity:0;pointer-events:none}.floorplan-plugin__floor--is-current.svelte-bl8zrz{opacity:1;pointer-events:auto}");
2438
2637
  }
2439
2638
 
2440
- // (17:2) {#if hoverEnable}
2639
+ // (20:2) {#if hoverEnable}
2441
2640
  function create_if_block_2(ctx) {
2442
2641
  let roomhighlight;
2443
2642
  let current;
@@ -2445,7 +2644,8 @@ function create_if_block_2(ctx) {
2445
2644
  const roomhighlight_spread_levels = [
2446
2645
  {
2447
2646
  floorIndex: /*floorIndex*/ ctx[1],
2448
- floorplanData: /*floorplanData*/ ctx[5]
2647
+ floorplanData: /*floorplanData*/ ctx[5],
2648
+ hoveredRoom: /*hoveredRoom*/ ctx[8]
2449
2649
  }
2450
2650
  ];
2451
2651
 
@@ -2466,11 +2666,12 @@ function create_if_block_2(ctx) {
2466
2666
  current = true;
2467
2667
  },
2468
2668
  p(ctx, dirty) {
2469
- const roomhighlight_changes = (dirty & /*floorIndex, floorplanData*/ 34)
2669
+ const roomhighlight_changes = (dirty & /*floorIndex, floorplanData, hoveredRoom*/ 290)
2470
2670
  ? internal.get_spread_update(roomhighlight_spread_levels, [
2471
2671
  {
2472
2672
  floorIndex: /*floorIndex*/ ctx[1],
2473
- floorplanData: /*floorplanData*/ ctx[5]
2673
+ floorplanData: /*floorplanData*/ ctx[5],
2674
+ hoveredRoom: /*hoveredRoom*/ ctx[8]
2474
2675
  }
2475
2676
  ])
2476
2677
  : {};
@@ -2492,7 +2693,7 @@ function create_if_block_2(ctx) {
2492
2693
  };
2493
2694
  }
2494
2695
 
2495
- // (21:2) {#if roomLabelsEnable}
2696
+ // (24:2) {#if roomLabelsEnable}
2496
2697
  function create_if_block_1$1(ctx) {
2497
2698
  let roomlabels;
2498
2699
  let current;
@@ -2501,7 +2702,9 @@ function create_if_block_1$1(ctx) {
2501
2702
  {
2502
2703
  floorplanData: /*floorplanData*/ ctx[5],
2503
2704
  floorIndex: /*floorIndex*/ ctx[1],
2504
- getLabelElement: /*getLabelElement*/ ctx[6]
2705
+ getLabelElement: /*getLabelElement*/ ctx[6],
2706
+ hoveredRoom: /*hoveredRoom*/ ctx[8],
2707
+ adaptiveRoomLabelVisibleEnable: /*adaptiveRoomLabelVisibleEnable*/ ctx[7]
2505
2708
  }
2506
2709
  ];
2507
2710
 
@@ -2522,12 +2725,14 @@ function create_if_block_1$1(ctx) {
2522
2725
  current = true;
2523
2726
  },
2524
2727
  p(ctx, dirty) {
2525
- const roomlabels_changes = (dirty & /*floorplanData, floorIndex, getLabelElement*/ 98)
2728
+ const roomlabels_changes = (dirty & /*floorplanData, floorIndex, getLabelElement, hoveredRoom, adaptiveRoomLabelVisibleEnable*/ 482)
2526
2729
  ? internal.get_spread_update(roomlabels_spread_levels, [
2527
2730
  {
2528
2731
  floorplanData: /*floorplanData*/ ctx[5],
2529
2732
  floorIndex: /*floorIndex*/ ctx[1],
2530
- getLabelElement: /*getLabelElement*/ ctx[6]
2733
+ getLabelElement: /*getLabelElement*/ ctx[6],
2734
+ hoveredRoom: /*hoveredRoom*/ ctx[8],
2735
+ adaptiveRoomLabelVisibleEnable: /*adaptiveRoomLabelVisibleEnable*/ ctx[7]
2531
2736
  }
2532
2737
  ])
2533
2738
  : {};
@@ -2549,7 +2754,7 @@ function create_if_block_1$1(ctx) {
2549
2754
  };
2550
2755
  }
2551
2756
 
2552
- // (24:2) {#if ruleLabelsEnable}
2757
+ // (27:2) {#if ruleLabelsEnable}
2553
2758
  function create_if_block$1(ctx) {
2554
2759
  let rulelabels;
2555
2760
  let current;
@@ -2812,6 +3017,8 @@ function instance$1($$self, $$props, $$invalidate) {
2812
3017
  let { ruleLabelsEnable } = $$props;
2813
3018
  let { floorplanData } = $$props;
2814
3019
  let { getLabelElement } = $$props;
3020
+ let { adaptiveRoomLabelVisibleEnable } = $$props;
3021
+ const hoveredRoom = store.writable(undefined);
2815
3022
 
2816
3023
  $$self.$$set = $$props => {
2817
3024
  if ('isCurrent' in $$props) $$invalidate(0, isCurrent = $$props.isCurrent);
@@ -2821,6 +3028,7 @@ function instance$1($$self, $$props, $$invalidate) {
2821
3028
  if ('ruleLabelsEnable' in $$props) $$invalidate(4, ruleLabelsEnable = $$props.ruleLabelsEnable);
2822
3029
  if ('floorplanData' in $$props) $$invalidate(5, floorplanData = $$props.floorplanData);
2823
3030
  if ('getLabelElement' in $$props) $$invalidate(6, getLabelElement = $$props.getLabelElement);
3031
+ if ('adaptiveRoomLabelVisibleEnable' in $$props) $$invalidate(7, adaptiveRoomLabelVisibleEnable = $$props.adaptiveRoomLabelVisibleEnable);
2824
3032
  };
2825
3033
 
2826
3034
  return [
@@ -2830,7 +3038,9 @@ function instance$1($$self, $$props, $$invalidate) {
2830
3038
  roomLabelsEnable,
2831
3039
  ruleLabelsEnable,
2832
3040
  floorplanData,
2833
- getLabelElement
3041
+ getLabelElement,
3042
+ adaptiveRoomLabelVisibleEnable,
3043
+ hoveredRoom
2834
3044
  ];
2835
3045
  }
2836
3046
 
@@ -2851,7 +3061,8 @@ class CurrentFloor extends internal.SvelteComponent {
2851
3061
  roomLabelsEnable: 3,
2852
3062
  ruleLabelsEnable: 4,
2853
3063
  floorplanData: 5,
2854
- getLabelElement: 6
3064
+ getLabelElement: 6,
3065
+ adaptiveRoomLabelVisibleEnable: 7
2855
3066
  },
2856
3067
  add_css$1
2857
3068
  );
@@ -2866,11 +3077,11 @@ function add_css(target) {
2866
3077
 
2867
3078
  function get_each_context(ctx, list, i) {
2868
3079
  const child_ctx = ctx.slice();
2869
- child_ctx[13] = list[i];
3080
+ child_ctx[14] = list[i];
2870
3081
  return child_ctx;
2871
3082
  }
2872
3083
 
2873
- // (21:0) {#if visible}
3084
+ // (22:0) {#if visible}
2874
3085
  function create_if_block(ctx) {
2875
3086
  let div;
2876
3087
  let t0;
@@ -2937,7 +3148,7 @@ function create_if_block(ctx) {
2937
3148
  p(new_ctx, dirty) {
2938
3149
  ctx = new_ctx;
2939
3150
 
2940
- if (dirty & /*hoverEnable, floorplanData, getLabelElement, roomLabelsEnable, ruleLabelsEnable, floorIndex*/ 5040) {
3151
+ if (dirty & /*hoverEnable, floorplanData, getLabelElement, roomLabelsEnable, ruleLabelsEnable, adaptiveRoomLabelVisibleEnable, floorIndex*/ 13232) {
2941
3152
  each_value = /*floorplanData*/ ctx[9].floorDatas;
2942
3153
  let i;
2943
3154
 
@@ -3043,7 +3254,7 @@ function create_if_block(ctx) {
3043
3254
  };
3044
3255
  }
3045
3256
 
3046
- // (23:4) {#each floorplanData.floorDatas as floorData}
3257
+ // (24:4) {#each floorplanData.floorDatas as floorData}
3047
3258
  function create_each_block(ctx) {
3048
3259
  let currentfloor;
3049
3260
  let current;
@@ -3054,13 +3265,14 @@ function create_each_block(ctx) {
3054
3265
  floorplanData: /*floorplanData*/ ctx[9],
3055
3266
  getLabelElement: /*getLabelElement*/ ctx[12],
3056
3267
  roomLabelsEnable: /*roomLabelsEnable*/ ctx[7],
3057
- ruleLabelsEnable: /*ruleLabelsEnable*/ ctx[8]
3268
+ ruleLabelsEnable: /*ruleLabelsEnable*/ ctx[8],
3269
+ adaptiveRoomLabelVisibleEnable: /*adaptiveRoomLabelVisibleEnable*/ ctx[13]
3058
3270
  },
3059
3271
  {
3060
- floorIndex: /*floorData*/ ctx[13].floorIndex
3272
+ floorIndex: /*floorData*/ ctx[14].floorIndex
3061
3273
  },
3062
3274
  {
3063
- isCurrent: /*floorData*/ ctx[13].floorIndex === /*floorIndex*/ ctx[4]
3275
+ isCurrent: /*floorData*/ ctx[14].floorIndex === /*floorIndex*/ ctx[4]
3064
3276
  }
3065
3277
  ];
3066
3278
 
@@ -3081,20 +3293,21 @@ function create_each_block(ctx) {
3081
3293
  current = true;
3082
3294
  },
3083
3295
  p(ctx, dirty) {
3084
- const currentfloor_changes = (dirty & /*hoverEnable, floorplanData, getLabelElement, roomLabelsEnable, ruleLabelsEnable, floorIndex*/ 5040)
3296
+ const currentfloor_changes = (dirty & /*hoverEnable, floorplanData, getLabelElement, roomLabelsEnable, ruleLabelsEnable, adaptiveRoomLabelVisibleEnable, floorIndex*/ 13232)
3085
3297
  ? internal.get_spread_update(currentfloor_spread_levels, [
3086
- dirty & /*hoverEnable, floorplanData, getLabelElement, roomLabelsEnable, ruleLabelsEnable*/ 5024 && {
3298
+ dirty & /*hoverEnable, floorplanData, getLabelElement, roomLabelsEnable, ruleLabelsEnable, adaptiveRoomLabelVisibleEnable*/ 13216 && {
3087
3299
  hoverEnable: /*hoverEnable*/ ctx[5],
3088
3300
  floorplanData: /*floorplanData*/ ctx[9],
3089
3301
  getLabelElement: /*getLabelElement*/ ctx[12],
3090
3302
  roomLabelsEnable: /*roomLabelsEnable*/ ctx[7],
3091
- ruleLabelsEnable: /*ruleLabelsEnable*/ ctx[8]
3303
+ ruleLabelsEnable: /*ruleLabelsEnable*/ ctx[8],
3304
+ adaptiveRoomLabelVisibleEnable: /*adaptiveRoomLabelVisibleEnable*/ ctx[13]
3092
3305
  },
3093
3306
  dirty & /*floorplanData*/ 512 && {
3094
- floorIndex: /*floorData*/ ctx[13].floorIndex
3307
+ floorIndex: /*floorData*/ ctx[14].floorIndex
3095
3308
  },
3096
3309
  dirty & /*floorplanData, floorIndex*/ 528 && {
3097
- isCurrent: /*floorData*/ ctx[13].floorIndex === /*floorIndex*/ ctx[4]
3310
+ isCurrent: /*floorData*/ ctx[14].floorIndex === /*floorIndex*/ ctx[4]
3098
3311
  }
3099
3312
  ])
3100
3313
  : {};
@@ -3116,7 +3329,7 @@ function create_each_block(ctx) {
3116
3329
  };
3117
3330
  }
3118
3331
 
3119
- // (37:4) {#if compassEnable}
3332
+ // (39:4) {#if compassEnable}
3120
3333
  function create_if_block_1(ctx) {
3121
3334
  let compass;
3122
3335
  let current;
@@ -3226,6 +3439,7 @@ function instance($$self, $$props, $$invalidate) {
3226
3439
  let { lastPanoramaLongitude } = $$props;
3227
3440
  let { cameraImageUrl } = $$props;
3228
3441
  let { getLabelElement } = $$props;
3442
+ let { adaptiveRoomLabelVisibleEnable } = $$props;
3229
3443
 
3230
3444
  $$self.$$set = $$props => {
3231
3445
  if ('duration' in $$props) $$invalidate(0, duration = $$props.duration);
@@ -3241,6 +3455,7 @@ function instance($$self, $$props, $$invalidate) {
3241
3455
  if ('lastPanoramaLongitude' in $$props) $$invalidate(10, lastPanoramaLongitude = $$props.lastPanoramaLongitude);
3242
3456
  if ('cameraImageUrl' in $$props) $$invalidate(11, cameraImageUrl = $$props.cameraImageUrl);
3243
3457
  if ('getLabelElement' in $$props) $$invalidate(12, getLabelElement = $$props.getLabelElement);
3458
+ if ('adaptiveRoomLabelVisibleEnable' in $$props) $$invalidate(13, adaptiveRoomLabelVisibleEnable = $$props.adaptiveRoomLabelVisibleEnable);
3244
3459
  };
3245
3460
 
3246
3461
  return [
@@ -3256,7 +3471,8 @@ function instance($$self, $$props, $$invalidate) {
3256
3471
  floorplanData,
3257
3472
  lastPanoramaLongitude,
3258
3473
  cameraImageUrl,
3259
- getLabelElement
3474
+ getLabelElement,
3475
+ adaptiveRoomLabelVisibleEnable
3260
3476
  ];
3261
3477
  }
3262
3478
 
@@ -3283,14 +3499,244 @@ class Main extends internal.SvelteComponent {
3283
3499
  floorplanData: 9,
3284
3500
  lastPanoramaLongitude: 10,
3285
3501
  cameraImageUrl: 11,
3286
- getLabelElement: 12
3502
+ getLabelElement: 12,
3503
+ adaptiveRoomLabelVisibleEnable: 13
3287
3504
  },
3288
3505
  add_css
3289
3506
  );
3290
3507
  }
3291
3508
  }
3292
3509
 
3293
- function changeModelCanvasOpacity(five, opacity, duration = 300) {
3510
+ async function formatOutlines(outlines) {
3511
+ const headers = new Headers({ 'Content-Type': 'text/plain' });
3512
+ const getOutlineItem = async function (item) {
3513
+ const outlineItem = {
3514
+ index: item.index,
3515
+ url: item.url,
3516
+ svgUrl: item.svg_url,
3517
+ };
3518
+ if (item.svg_url) {
3519
+ const svgContent = await fetch(item.svg_url, { headers }).then((res) => res.text());
3520
+ outlineItem.svgContent = svgContent;
3521
+ }
3522
+ return outlineItem;
3523
+ };
3524
+ const svgOutlineItems = await Promise.all(outlines.map(getOutlineItem));
3525
+ return svgOutlineItems;
3526
+ }
3527
+ function formatRoom(data) {
3528
+ const floorplanRoomItem = {
3529
+ id: data.id,
3530
+ size: data.size,
3531
+ name: data.name,
3532
+ path: data.path,
3533
+ roomType: data.room_type,
3534
+ floorType: data.floor_type,
3535
+ roomLabel: {
3536
+ position: data.room_label.position,
3537
+ positionInImage: data.room_label.position_in_image,
3538
+ },
3539
+ observerIndexs: data.observer_indexs,
3540
+ };
3541
+ return floorplanRoomItem;
3542
+ }
3543
+ function formatFloorData(_data) {
3544
+ return {
3545
+ floorName: _data.floor_name,
3546
+ floorIndex: _data.floor_index,
3547
+ rooms: _data.rooms.map(formatRoom),
3548
+ rules: _data.rules,
3549
+ };
3550
+ }
3551
+ function formateFloorplanObserver(data) {
3552
+ const floorplanObserver = {
3553
+ index: data.index,
3554
+ floorIndex: data.floor_index,
3555
+ position: data.position,
3556
+ positionInImage: data.position_in_image,
3557
+ };
3558
+ return floorplanObserver;
3559
+ }
3560
+ function formatFloorplanEntrance(data) {
3561
+ const floorplanEntrance = {
3562
+ rad: data.rad,
3563
+ position: data.position,
3564
+ positionInImage: data.position_in_image,
3565
+ northRad: data.north_rad,
3566
+ roomId: data.room_id,
3567
+ floorIndex: data.floor_index,
3568
+ };
3569
+ return floorplanEntrance;
3570
+ }
3571
+ async function formatData(data) {
3572
+ const outlines = await formatOutlines(data.outlines);
3573
+ const bounding = data.computed_data.bounding;
3574
+ const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
3575
+ const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
3576
+ const floorplanData = {
3577
+ outlines,
3578
+ entrance,
3579
+ bounding,
3580
+ floorDatas,
3581
+ observers: data.computed_data.observers.map(formateFloorplanObserver),
3582
+ };
3583
+ return floorplanData;
3584
+ }
3585
+
3586
+ /**
3587
+ * 把第一个参数传入第二个参数(函数)中并执行
3588
+ * 一般用于执行函数后返回变量。
3589
+ * @param {any} something
3590
+ * @param {function} callback
3591
+ * @return {any}
3592
+ */
3593
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3594
+ function tap(something, callback) {
3595
+ callback(something);
3596
+ return something;
3597
+ }
3598
+
3599
+ /**
3600
+ * 过滤掉不需要的对象字段函数:实现从一个对象中排除某些指定属性后生成的新对象。
3601
+ * @param object
3602
+ * @param props 排除的属性
3603
+ * @return
3604
+ */
3605
+ function omit(object, props) {
3606
+ return tap({}, (result) => {
3607
+ for (const name in object) {
3608
+ if (props.indexOf(name) !== -1)
3609
+ continue;
3610
+ result[name] = object[name];
3611
+ }
3612
+ });
3613
+ }
3614
+
3615
+ var FLOOR_PLAN_ATTACHED_TO;
3616
+ (function (FLOOR_PLAN_ATTACHED_TO) {
3617
+ FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["FLOOR"] = 1] = "FLOOR";
3618
+ FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["CEILING"] = 2] = "CEILING";
3619
+ FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["BOUNDING_CENTER"] = 3] = "BOUNDING_CENTER";
3620
+ })(FLOOR_PLAN_ATTACHED_TO || (FLOOR_PLAN_ATTACHED_TO = {}));
3621
+
3622
+ /**
3623
+ * plugin 的基本控制器
3624
+ */
3625
+ class Controller$2 {
3626
+ constructor(five$1) {
3627
+ Object.defineProperty(this, "five", {
3628
+ enumerable: true,
3629
+ configurable: true,
3630
+ writable: true,
3631
+ value: void 0
3632
+ });
3633
+ /**
3634
+ * 插件事件钩子
3635
+ */
3636
+ Object.defineProperty(this, "hooks", {
3637
+ enumerable: true,
3638
+ configurable: true,
3639
+ writable: true,
3640
+ value: new five.Subscribe()
3641
+ });
3642
+ this.five = five$1;
3643
+ }
3644
+ /**
3645
+ * 获取当前的插件状态,如果当初插件内存在需要通过动画变更的 state 值,则通过此方法可以得到中间状态
3646
+ */
3647
+ getCurrentState() {
3648
+ return this.state;
3649
+ }
3650
+ }
3651
+
3652
+ class Controller$1 extends Controller$2 {
3653
+ }
3654
+
3655
+ /**
3656
+ * 比较两个数字近似相等
3657
+ * @param num1 数字1
3658
+ * @param num2 数字2
3659
+ * @param accuracy 精度:精确到小数点后几位,默认精确到 小数点后四位
3660
+ */
3661
+ function nearlyEqual(num1, num2, accuracy = 4) {
3662
+ return Math.floor(num1 * Math.pow(10, accuracy)) === Math.floor(num2 * Math.pow(10, accuracy));
3663
+ }
3664
+
3665
+ /** 等待 five changeMode 结束
3666
+ * @description Promise 的状态只代表 mode 与预期是否一致,不保证参数的一致性
3667
+ */
3668
+ async function changeMode(five, changeModeParams) {
3669
+ await new Promise((resolve, reject) => {
3670
+ // 虽然 changeMode 是异步函数,但不代表异步流程结束代表切换 Mode 动画结束
3671
+ five.changeMode(...changeModeParams).catch((error) => reject(error));
3672
+ five.once('initAnimationEnded', () => {
3673
+ const fiveCurrentState = five.getCurrentState();
3674
+ const correctMode = changeModeParams[0];
3675
+ if (fiveCurrentState.mode !== correctMode)
3676
+ reject(new Error('mode 与预期不符'));
3677
+ /** 检测当前的 current pose 和传入的 pose 是否一致 */
3678
+ const checkPose = () => {
3679
+ const correctPose = changeModeParams[1];
3680
+ if (!correctPose)
3681
+ return true;
3682
+ return Object.keys(correctPose).every((key) => {
3683
+ const fivePoseItem = fiveCurrentState[key];
3684
+ if (fivePoseItem === undefined)
3685
+ return true;
3686
+ const correctPoseItem = correctPose[key];
3687
+ if (typeof fivePoseItem === 'number' && typeof correctPoseItem === 'number') {
3688
+ return nearlyEqual(fivePoseItem, correctPoseItem, 2);
3689
+ }
3690
+ return fivePoseItem === correctPoseItem;
3691
+ });
3692
+ };
3693
+ const checkPoseResult = checkPose();
3694
+ if (!checkPoseResult)
3695
+ reject(new Error('five pose 与预期不符'));
3696
+ resolve();
3697
+ });
3698
+ });
3699
+ }
3700
+
3701
+ /** 获取当前楼层地面的 Y 值 */
3702
+ function getFloorY(five, floorIndex) {
3703
+ const maxFloorIndex = Math.max(...five.work.observers.map((ob) => ob.floorIndex));
3704
+ return floorIndex > maxFloorIndex
3705
+ ? five.model.bounding.max.y
3706
+ : Math.max(...five.work.observers
3707
+ .filter((ob) => ob.floorIndex === floorIndex)
3708
+ .map((ob) => ob.standingPosition.y));
3709
+ }
3710
+ /** 获取当前吸附类型的 Y 值
3711
+ * * FLOOR_PLAN_ATTACHED_TO.FLOOR:当前楼层地板的 Y
3712
+ * * FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER:当前模型中心的 Y
3713
+ * * FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER:当前楼层天花板的 Y
3714
+ */
3715
+ function getAttachedY(five, floorIndex, attachedTo = FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER) {
3716
+ const currentFloorY = getFloorY(five, floorIndex);
3717
+ const nextFloorY = getFloorY(five, floorIndex + 1);
3718
+ if (attachedTo === FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER)
3719
+ return (five.model.bounding.max.y + five.model.bounding.min.y) / 2;
3720
+ else if (attachedTo === FLOOR_PLAN_ATTACHED_TO.CEILING)
3721
+ return nextFloorY;
3722
+ else
3723
+ return currentFloorY;
3724
+ }
3725
+ /**
3726
+ * 获取「在俯视图」状态下,模型 mm 与屏幕像素 px 的对应关系,即每 mm 对应多少 px
3727
+ * @param five five
3728
+ */
3729
+ function getPxmm(five, container, floorIndex, options) {
3730
+ const y = getAttachedY(five, floorIndex, options === null || options === void 0 ? void 0 : options.attachedTo);
3731
+ const originPosition = new THREE__namespace.Vector3(0, y, 0);
3732
+ const originPositionXUnit = new THREE__namespace.Vector3(1, y, 0);
3733
+ const mouse = originPosition.clone().project(five.camera);
3734
+ const xUnitMouse = originPositionXUnit.clone().project(five.camera);
3735
+ const pxmm = Math.abs((xUnitMouse.x - mouse.x) / 1000) * (container.getBoundingClientRect().width / 2);
3736
+ return pxmm;
3737
+ }
3738
+
3739
+ function changeModelCanvasOpacity(five, opacity, duration = 300) {
3294
3740
  const fiveEle = five.getElement();
3295
3741
  if (!fiveEle)
3296
3742
  return;
@@ -3306,33 +3752,36 @@ function changeModelCanvasOpacity(five, opacity, duration = 300) {
3306
3752
  });
3307
3753
  }
3308
3754
 
3309
- class TopviewFloorplanPluginController {
3755
+ class Controller extends Controller$1 {
3310
3756
  constructor(five, params) {
3311
- Object.defineProperty(this, "size", {
3757
+ super(five);
3758
+ // =============== public properties =================
3759
+ Object.defineProperty(this, "name", {
3312
3760
  enumerable: true,
3313
3761
  configurable: true,
3314
3762
  writable: true,
3315
- value: { width: 0, height: 0 }
3763
+ value: 'topviewFloorplanPlugin'
3316
3764
  });
3317
- Object.defineProperty(this, "visible", {
3765
+ Object.defineProperty(this, "state", {
3318
3766
  enumerable: true,
3319
3767
  configurable: true,
3320
3768
  writable: true,
3321
- value: false
3769
+ value: void 0
3322
3770
  });
3323
- Object.defineProperty(this, "pxmm", {
3771
+ // =============== private properties =================
3772
+ Object.defineProperty(this, "data", {
3324
3773
  enumerable: true,
3325
3774
  configurable: true,
3326
3775
  writable: true,
3327
- value: 0
3776
+ value: void 0
3328
3777
  });
3329
3778
  Object.defineProperty(this, "app", {
3330
3779
  enumerable: true,
3331
3780
  configurable: true,
3332
3781
  writable: true,
3333
- value: void 0
3782
+ value: undefined
3334
3783
  });
3335
- Object.defineProperty(this, "five", {
3784
+ Object.defineProperty(this, "selector", {
3336
3785
  enumerable: true,
3337
3786
  configurable: true,
3338
3787
  writable: true,
@@ -3350,98 +3799,136 @@ class TopviewFloorplanPluginController {
3350
3799
  writable: true,
3351
3800
  value: 0
3352
3801
  });
3353
- Object.defineProperty(this, "configs", {
3802
+ /** 户型图父容器 */
3803
+ Object.defineProperty(this, "wrapper", {
3804
+ enumerable: true,
3805
+ configurable: true,
3806
+ writable: true,
3807
+ value: void 0
3808
+ });
3809
+ /** 户型图主容器 */
3810
+ Object.defineProperty(this, "container", {
3354
3811
  enumerable: true,
3355
3812
  configurable: true,
3356
3813
  writable: true,
3357
- value: {}
3814
+ value: document.createElement('div')
3358
3815
  });
3816
+ /** 展示户型图图前,Five 的 Panorama Longitude */
3359
3817
  Object.defineProperty(this, "lastPanoramaLongitude", {
3360
3818
  enumerable: true,
3361
3819
  configurable: true,
3362
3820
  writable: true,
3363
3821
  value: 0
3364
3822
  });
3365
- Object.defineProperty(this, "selector", {
3823
+ /** 户型图大小 */
3824
+ Object.defineProperty(this, "size", {
3366
3825
  enumerable: true,
3367
3826
  configurable: true,
3368
3827
  writable: true,
3369
- value: void 0
3828
+ value: { width: 0, height: 0 }
3370
3829
  });
3371
- Object.defineProperty(this, "floorplanData", {
3830
+ /** 是否已经执行过事件监听 */
3831
+ Object.defineProperty(this, "hasAddedEventListener", {
3372
3832
  enumerable: true,
3373
3833
  configurable: true,
3374
3834
  writable: true,
3375
- value: void 0
3835
+ value: false
3376
3836
  });
3377
- Object.defineProperty(this, "wrapper", {
3837
+ /** 上一次隐藏是否是用户调用了 hide 导致的 */
3838
+ Object.defineProperty(this, "isHiddenByHideFunc", {
3378
3839
  enumerable: true,
3379
3840
  configurable: true,
3380
3841
  writable: true,
3381
- value: void 0
3842
+ value: false
3382
3843
  });
3383
- Object.defineProperty(this, "container", {
3844
+ /** 更新户型图大小 */
3845
+ Object.defineProperty(this, "updateSize", {
3384
3846
  enumerable: true,
3385
3847
  configurable: true,
3386
3848
  writable: true,
3387
- value: document.createElement('div')
3849
+ value: () => {
3850
+ if (!this.data)
3851
+ return;
3852
+ if (!this.container || !this.wrapper)
3853
+ return;
3854
+ if (this.five.getCurrentState().mode !== 'Topview')
3855
+ return;
3856
+ // 计算户型图展示大小
3857
+ const { min, max } = this.data.bounding;
3858
+ const width = max.x - min.x;
3859
+ const height = max.y - min.y;
3860
+ // 每毫米对应的 px 值
3861
+ const options = this.state.config.attachedTo ? { attachedTo: this.state.config.attachedTo } : undefined;
3862
+ const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
3863
+ const _width = Math.ceil(width * pxmm);
3864
+ const _height = Math.ceil(height * pxmm);
3865
+ if (this.size.width === _width && this.size.height === _height)
3866
+ return;
3867
+ this.container.style.width = _width + 'px';
3868
+ this.container.style.height = _height + 'px';
3869
+ this.size = { width: _width, height: _height };
3870
+ }
3388
3871
  });
3872
+ /** 销毁插件 */
3389
3873
  Object.defineProperty(this, "dispose", {
3390
3874
  enumerable: true,
3391
3875
  configurable: true,
3392
3876
  writable: true,
3393
3877
  value: () => {
3394
3878
  var _a, _b;
3395
- this.hide();
3879
+ this.removeEventListener();
3396
3880
  (_a = this.app) === null || _a === void 0 ? void 0 : _a.$destroy();
3881
+ this.app = undefined;
3397
3882
  (_b = this.container) === null || _b === void 0 ? void 0 : _b.remove();
3398
- this.five.off('modeChange', this.onFiveModeChange);
3399
- this.five.off('panGesture', this.onFivePanGesture);
3400
- this.five.off('panoArrived', this.onFivePanoArrived);
3401
- this.five.off('modelLoaded', this.onFiveModelLoaded);
3402
- this.five.off('pinchGesture', this.onFivePinchGesture);
3403
- this.five.off('wantsGesture', this.onFiveWantsGesture);
3404
- this.five.off('wantsMoveToPano', this.onFiveWantsMoveToPano);
3405
- this.five.off('initAnimationEnded', this.onFiveInitAnimationEnded);
3406
- this.five.off('modelShownFloorChange', this.onModelShownFloorChange);
3883
+ this.data = undefined;
3884
+ this.wrapper = undefined;
3885
+ this.selector = undefined;
3886
+ this.hooks.emit('dispose');
3407
3887
  }
3408
3888
  });
3409
- Object.defineProperty(this, "onFiveWantsMoveToPano", {
3889
+ Object.defineProperty(this, "_disable", {
3410
3890
  enumerable: true,
3411
3891
  configurable: true,
3412
3892
  writable: true,
3413
- value: () => {
3414
- if (this.visible && this.configs.preventRoomClick)
3415
- return false;
3893
+ value: (options) => {
3894
+ var _a, _b;
3895
+ const { userAction } = options;
3896
+ (_a = this.app) === null || _a === void 0 ? void 0 : _a.$destroy();
3897
+ this.app = undefined;
3898
+ (_b = this.container) === null || _b === void 0 ? void 0 : _b.remove();
3899
+ this.removeEventListener();
3900
+ this.hooks.emit('disable', { userAction });
3416
3901
  }
3417
3902
  });
3418
- Object.defineProperty(this, "onFiveWantsGesture", {
3903
+ /** modelLoaded 之后自动执行 append container 操作 */
3904
+ Object.defineProperty(this, "onFiveModelLoaded", {
3419
3905
  enumerable: true,
3420
3906
  configurable: true,
3421
3907
  writable: true,
3422
- value: (type) => {
3423
- if (type !== 'pan' && type !== 'pinch' && type !== 'mouseWheel')
3908
+ value: () => {
3909
+ if (this.state.enabled === false)
3424
3910
  return;
3425
- if (this.visible && !this.configs.gestureEnable)
3426
- return false;
3911
+ if (this.wrapper)
3912
+ return;
3913
+ if (!this.selector)
3914
+ return;
3915
+ const wrapper = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
3916
+ if (!wrapper)
3917
+ throw new Error('不正确的父容器选择器');
3918
+ this.wrapper = wrapper;
3919
+ wrapper.append(this.container);
3427
3920
  }
3428
3921
  });
3429
- Object.defineProperty(this, "onModelShownFloorChange", {
3922
+ /** Topview 态隐藏户型图 */
3923
+ Object.defineProperty(this, "onFiveModeChange", {
3430
3924
  enumerable: true,
3431
3925
  configurable: true,
3432
3926
  writable: true,
3433
- value: (shownFloor) => {
3434
- if (this.floorIndex === shownFloor)
3435
- return;
3436
- if (shownFloor === null) {
3437
- const panoIndex = this.five.getCurrentState().panoIndex;
3438
- this.floorIndex = this.five.work.observers[panoIndex].floorIndex;
3439
- return;
3927
+ value: (...[mode, , , , userAction]) => {
3928
+ if (mode !== 'Topview' && this.state.visible) {
3929
+ this.updateState({ visible: false }, userAction);
3930
+ this._hide({ userAction });
3440
3931
  }
3441
- // 模型楼层高亮改变时,自动进行楼层切换
3442
- this.floorIndex = shownFloor;
3443
- this.updateSize();
3444
- this.render();
3445
3932
  }
3446
3933
  });
3447
3934
  Object.defineProperty(this, "onFivePanoArrived", {
@@ -3456,51 +3943,35 @@ class TopviewFloorplanPluginController {
3456
3943
  this.floorIndex = this.five.work.observers[index].floorIndex;
3457
3944
  }
3458
3945
  });
3459
- Object.defineProperty(this, "onFivePanGesture", {
3946
+ Object.defineProperty(this, "onFiveCameraUpdate", {
3460
3947
  enumerable: true,
3461
3948
  configurable: true,
3462
3949
  writable: true,
3463
- value: () => {
3464
- if (!this.visible)
3465
- return;
3466
- this.updatePosition();
3467
- }
3468
- });
3469
- Object.defineProperty(this, "onFivePinchGesture", {
3470
- enumerable: true,
3471
- configurable: true,
3472
- writable: true,
3473
- value: () => {
3474
- if (!this.visible)
3950
+ value: (_, userAction) => {
3951
+ if (!this.state.visible)
3475
3952
  return;
3476
3953
  this.updatePosition();
3477
3954
  this.updateSize();
3478
3955
  }
3479
3956
  });
3480
- Object.defineProperty(this, "onFiveModelLoaded", {
3957
+ Object.defineProperty(this, "onFiveWantsGesture", {
3481
3958
  enumerable: true,
3482
3959
  configurable: true,
3483
3960
  writable: true,
3484
- value: () => {
3485
- if (this.wrapper)
3486
- return;
3487
- if (!this.selector)
3961
+ value: (type) => {
3962
+ if (type !== 'pan' && type !== 'pinch' && type !== 'mouseWheel')
3488
3963
  return;
3489
- const wrapper = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
3490
- if (!wrapper)
3491
- throw new Error('不正确的父容器选择器');
3492
- this.wrapper = wrapper;
3493
- wrapper.append(this.container);
3964
+ if (this.state.visible && !this.state.config.gestureEnable)
3965
+ return false;
3494
3966
  }
3495
3967
  });
3496
- /** Topview 态隐藏户型图 */
3497
- Object.defineProperty(this, "onFiveModeChange", {
3968
+ Object.defineProperty(this, "onFiveWantsMoveToPano", {
3498
3969
  enumerable: true,
3499
3970
  configurable: true,
3500
3971
  writable: true,
3501
- value: (mode) => {
3502
- if (mode !== 'Topview')
3503
- return this.hide();
3972
+ value: () => {
3973
+ if (this.state.visible && this.state.config.preventRoomClick)
3974
+ return false;
3504
3975
  }
3505
3976
  });
3506
3977
  /** 动画结束后是 Topview 态就展示户型图 */
@@ -3508,140 +3979,257 @@ class TopviewFloorplanPluginController {
3508
3979
  enumerable: true,
3509
3980
  configurable: true,
3510
3981
  writable: true,
3511
- value: () => {
3982
+ value: (...[, , userAction]) => {
3512
3983
  const { mode } = this.five.getCurrentState();
3513
- if (mode === 'Topview')
3514
- this.show();
3984
+ if (mode === 'Topview' && !this.isHiddenByHideFunc && !this.state.visible && this.state.config.autoShowEnable) {
3985
+ this.updateState({ visible: true }, userAction);
3986
+ this._show({ userAction });
3987
+ }
3515
3988
  }
3516
3989
  });
3517
- /** 更新户型图大小 */
3518
- Object.defineProperty(this, "updateSize", {
3990
+ Object.defineProperty(this, "onModelShownFloorChange", {
3519
3991
  enumerable: true,
3520
3992
  configurable: true,
3521
3993
  writable: true,
3522
- value: () => {
3523
- if (!this.floorplanData)
3524
- return;
3525
- if (!this.container || !this.wrapper)
3994
+ value: (shownFloor) => {
3995
+ if (this.floorIndex === shownFloor)
3526
3996
  return;
3527
- if (this.five.getCurrentState().mode !== 'Topview')
3997
+ if (shownFloor === null) {
3998
+ const panoIndex = this.five.getCurrentState().panoIndex;
3999
+ this.floorIndex = this.five.work.observers[panoIndex].floorIndex;
3528
4000
  return;
3529
- // 计算户型图展示大小
3530
- const { min, max } = this.floorplanData.bounding;
3531
- const width = max.x - min.x;
3532
- const height = max.y - min.y;
3533
- // 每毫米对应的 px 值
3534
- const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : undefined;
3535
- const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
3536
- const _width = Math.ceil(width * pxmm);
3537
- const _height = Math.ceil(height * pxmm);
3538
- this.pxmm = pxmm;
3539
- this.size = { width: _width, height: _height };
3540
- this.container.style.width = _width + 'px';
3541
- this.container.style.height = _height + 'px';
4001
+ }
4002
+ // 模型楼层高亮改变时,自动进行楼层切换
4003
+ this.floorIndex = shownFloor;
4004
+ this.updateSize();
4005
+ this.render();
3542
4006
  }
3543
4007
  });
3544
- this.five = five;
3545
- this.selector = params.selector;
3546
- this.configs = omit(params, ['selector']);
3547
- this.five.addExtraElement(this.container);
3548
- // 设置 container 样式
3549
- this.container.classList.add('floorplan-plugin');
3550
- Object.assign(this.container.style, pluginStyle);
4008
+ if (params === null || params === void 0 ? void 0 : params.selector) {
4009
+ this.selector = params.selector;
4010
+ console.warn('不推荐继续使用 params.selector 配置父容器,请使用 appendTo 方法');
4011
+ }
4012
+ // =============== init State ===============
4013
+ const baseConfig = {
4014
+ northDesc: '北',
4015
+ modelOpacity: 1,
4016
+ hoverEnable: true,
4017
+ compassEnable: true,
4018
+ gestureEnable: false,
4019
+ autoShowEnable: true,
4020
+ ruleLabelsEnable: true,
4021
+ roomLabelsEnable: true,
4022
+ cameraImageUrl: CAMERA_IMAGE,
4023
+ attachedTo: FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER,
4024
+ getLabelElement: undefined,
4025
+ adaptiveRoomLabelVisibleEnable: true,
4026
+ };
4027
+ const paramsConfig = params ? omit(params, ['selector', 'scale']) : {};
4028
+ const config = Object.assign(Object.assign({}, baseConfig), paramsConfig);
4029
+ this.state = {
4030
+ enabled: true,
4031
+ visible: false,
4032
+ config,
4033
+ };
4034
+ // =============== init Container ===============
4035
+ this.initContainer();
4036
+ // =============== init Listener ===============
4037
+ // 注意插件声明周期内只监听一次的事件不放在 addEventListener 里面
3551
4038
  // 如果初始化的时候模型已经加载完毕了,就不用再等 modelLoaded
3552
- this.five.model.loaded
3553
- ? this.onFiveModelLoaded()
3554
- : five.once('modelLoaded', this.onFiveModelLoaded);
3555
- this.five.once('dispose', this.dispose);
3556
- this.five.on('modeChange', this.onFiveModeChange);
3557
- this.five.on('panGesture', this.onFivePanGesture);
3558
- this.five.on('mouseWheel', this.onFivePinchGesture);
3559
- this.five.on('panoArrived', this.onFivePanoArrived);
3560
- this.five.on('pinchGesture', this.onFivePinchGesture);
3561
- this.five.on('wantsGesture', this.onFiveWantsGesture);
3562
- this.five.on('wantsMoveToPano', this.onFiveWantsMoveToPano);
3563
- this.five.on('initAnimationEnded', this.onFiveInitAnimationEnded);
3564
- this.five.on('modelShownFloorChange', this.onModelShownFloorChange);
4039
+ five.model.loaded ? this.onFiveModelLoaded() : five.once('modelLoaded', this.onFiveModelLoaded);
4040
+ five.once('dispose', this.dispose);
4041
+ this.addEventListener();
3565
4042
  }
3566
- /** 加载户型图数据 */
3567
- async load(data) {
3568
- const copyData = JSON.parse(JSON.stringify(data));
3569
- this.floorplanData = await formatData(copyData);
4043
+ async load(serverData, state, userAction = true) {
4044
+ function isPluginServerData(serverData) {
4045
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
4046
+ }
4047
+ const _data = serverData;
4048
+ if (_data && !_data.version)
4049
+ console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
4050
+ const copyData = JSON.parse(JSON.stringify(serverData));
4051
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
4052
+ const prevData = this.data;
4053
+ this.data = await formatData(_serverData);
4054
+ this.hooks.emit('dataLoaded', this.data);
4055
+ this.hooks.emit('dataChange', this.data, prevData);
4056
+ if (state)
4057
+ this.updateState(state, userAction);
3570
4058
  this.render();
3571
4059
  }
4060
+ /** 更新户型图位置 */
4061
+ updatePosition() {
4062
+ var _a;
4063
+ const y = getAttachedY(this.five, this.floorIndex, this.state.config.attachedTo);
4064
+ const modelPosition = (_a = this.five.model) === null || _a === void 0 ? void 0 : _a.bounding.getCenter(new THREE__namespace.Vector3()).setY(y);
4065
+ if (!modelPosition)
4066
+ return;
4067
+ const ndcPosition = modelPosition.clone().project(this.five.camera);
4068
+ const left = (ndcPosition.x + 1) / 2;
4069
+ const top = -(ndcPosition.y - 1) / 2;
4070
+ this.container.style.left = left * 100 + '%';
4071
+ this.container.style.top = top * 100 + '%';
4072
+ }
3572
4073
  /** 把插件的渲染DOM插入到对应的容器中去 */
3573
4074
  appendTo(wrapper) {
3574
4075
  this.wrapper = wrapper;
4076
+ // 插件 disabled 时,只是不执行副作用,但是 wrapper 还是要赋值的,不然 enable 的时候找不到父容器
4077
+ if (!this.state.enabled)
4078
+ return;
3575
4079
  wrapper.appendChild(this.container);
4080
+ this.render();
3576
4081
  return this;
3577
4082
  }
3578
- show() {
3579
- this.visible = true;
4083
+ async show(options = {}) {
4084
+ // 已经展示完成了,不做任何操作
4085
+ if (this.state.visible)
4086
+ return;
4087
+ const userAction = options.userAction !== undefined ? options.userAction : true;
4088
+ this.updateState({ visible: true }, userAction);
4089
+ this._show({ userAction });
4090
+ }
4091
+ async hide(options = {}) {
4092
+ this.isHiddenByHideFunc = true;
4093
+ if (!this.state.visible)
4094
+ return;
4095
+ const userAction = options.userAction !== undefined ? options.userAction : true;
4096
+ this.updateState({ visible: false }, userAction);
4097
+ this._hide({ userAction });
4098
+ }
4099
+ enable(options = {}) {
4100
+ if (this.state.enabled)
4101
+ return;
4102
+ const userAction = options.userAction !== undefined ? options.userAction : true;
4103
+ this.updateState({ enabled: true }, options.userAction || userAction);
4104
+ this._enable({ userAction });
4105
+ }
4106
+ disable(options = {}) {
4107
+ if (!this.state.enabled)
4108
+ return;
4109
+ const userAction = options.userAction !== undefined ? options.userAction : true;
4110
+ this.updateState({ enabled: false }, options.userAction || userAction);
4111
+ this._disable({ userAction });
4112
+ }
4113
+ /** 更改插件 State */
4114
+ setState(state, options = {}) {
4115
+ const prevState = this.state;
4116
+ const userAction = options.userAction !== undefined ? options.userAction : true;
4117
+ this.updateState(state, userAction);
4118
+ if (state.enabled !== undefined && prevState.enabled !== state.enabled) {
4119
+ const options = { userAction };
4120
+ state.enabled ? this._enable(options) : this._disable(options);
4121
+ }
4122
+ if (state.visible !== undefined && prevState.visible !== state.visible) {
4123
+ const options = { userAction };
4124
+ state.visible ? this._show(options) : this._hide(options);
4125
+ }
4126
+ }
4127
+ async formatData(serverData) {
4128
+ return await formatData(serverData.data);
4129
+ }
4130
+ async _show(options) {
4131
+ if (!this.state.enabled)
4132
+ return;
4133
+ this.isHiddenByHideFunc = false;
4134
+ const { userAction } = options;
4135
+ this.hooks.emit('show', { userAction });
4136
+ if (this.five.getCurrentState().mode !== 'Topview') {
4137
+ await changeMode(this.five, ['Topview', undefined, undefined, userAction]);
4138
+ }
3580
4139
  this.five.model.show(this.floorIndex);
3581
4140
  this.updatePosition();
3582
4141
  this.updateSize();
3583
4142
  const renderDuration = 500;
3584
- const modelOpacity = this.configs.modelOpacity;
3585
- if (typeof modelOpacity === 'number') {
3586
- changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
3587
- }
3588
- this.render(renderDuration);
4143
+ const modelOpacity = this.state.config.modelOpacity;
4144
+ changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
4145
+ this.hooks.emit('showAnimationEnded', { userAction });
4146
+ this.render();
3589
4147
  }
3590
- hide() {
4148
+ async _hide(options) {
4149
+ if (!this.state.enabled)
4150
+ return;
4151
+ const { userAction } = options;
4152
+ this.hooks.emit('hide', { userAction });
3591
4153
  const modelOpacity = 1;
3592
4154
  const renderDuration = 0;
3593
- this.visible = false;
3594
4155
  changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
3595
4156
  this.render();
3596
4157
  }
3597
- /** 更新户型图位置 */
3598
- updatePosition() {
3599
- var _a;
3600
- const modelCenter = (_a = this.five.model) === null || _a === void 0 ? void 0 : _a.bounding.getCenter(new THREE__namespace.Vector3());
3601
- if (!modelCenter)
4158
+ _enable(options) {
4159
+ const { userAction } = options;
4160
+ this.addEventListener();
4161
+ if (this.wrapper)
4162
+ this.wrapper.append(this.container);
4163
+ this.hooks.emit('enable', { userAction });
4164
+ if (this.state.visible)
4165
+ this._show({ userAction });
4166
+ }
4167
+ updateState(state, userAction) {
4168
+ const prevState = this.state;
4169
+ this.state = Object.assign(Object.assign({}, this.state), state);
4170
+ if (equal(this.state, prevState, { deep: true }))
3602
4171
  return;
3603
- const ndcModelCenter = modelCenter.clone().project(this.five.camera);
3604
- const left = (ndcModelCenter.x + 1) / 2;
3605
- const top = -(ndcModelCenter.y - 1) / 2;
3606
- this.container.style.left = left * 100 + '%';
3607
- this.container.style.top = top * 100 + '%';
4172
+ this.hooks.emit('stateChange', { state: this.state, prevState, userAction });
4173
+ }
4174
+ addEventListener() {
4175
+ if (!this.state.enabled)
4176
+ return;
4177
+ if (this.hasAddedEventListener)
4178
+ return;
4179
+ const five = this.five;
4180
+ five.on('modeChange', this.onFiveModeChange);
4181
+ five.on('panoArrived', this.onFivePanoArrived);
4182
+ five.on('cameraUpdate', this.onFiveCameraUpdate);
4183
+ five.on('wantsGesture', this.onFiveWantsGesture);
4184
+ five.on('wantsMoveToPano', this.onFiveWantsMoveToPano);
4185
+ five.on('initAnimationEnded', this.onFiveInitAnimationEnded);
4186
+ five.on('modelShownFloorChange', this.onModelShownFloorChange);
4187
+ }
4188
+ removeEventListener() {
4189
+ const five = this.five;
4190
+ this.hasAddedEventListener = false;
4191
+ // 注意这里并没有消除 dispose 的监听
4192
+ five.off('modeChange', this.onFiveModeChange);
4193
+ five.off('panoArrived', this.onFivePanoArrived);
4194
+ five.off('cameraUpdate', this.onFiveCameraUpdate);
4195
+ five.off('wantsGesture', this.onFiveWantsGesture);
4196
+ five.off('wantsMoveToPano', this.onFiveWantsMoveToPano);
4197
+ five.off('initAnimationEnded', this.onFiveInitAnimationEnded);
4198
+ five.off('modelShownFloorChange', this.onModelShownFloorChange);
4199
+ }
4200
+ /** 如果用户是通过 selector 设置父容器,需要在 modelLoaded 之后把 container 自动放到父容器里
4201
+ *
4202
+ * - TODO: 等 selector 功能下掉之后删除这个逻辑
4203
+ */
4204
+ initContainer() {
4205
+ this.container.classList.add('floorplan-plugin');
4206
+ Object.assign(this.container.style, {
4207
+ position: 'absolute',
4208
+ left: '50%',
4209
+ top: '50%',
4210
+ transform: 'translate3d(-50%, -50%, 10px)',
4211
+ zIndex: 10,
4212
+ pointerEvents: 'none',
4213
+ 'will-change': 'width, height',
4214
+ });
4215
+ this.five.addExtraElement(this.container);
3608
4216
  }
3609
4217
  render(duration) {
3610
- if (!this.container || !this.floorplanData)
4218
+ if (!this.state.enabled)
4219
+ return;
4220
+ if (!this.container || !this.data)
3611
4221
  return;
3612
4222
  if (this.size.width === 0)
3613
4223
  return;
3614
- const { northDesc, getLabelElement, cameraImageUrl, hoverEnable, compassEnable, roomLabelsEnable, ruleLabelsEnable, } = this.configs;
3615
- const props = {
3616
- getLabelElement,
3617
- northDesc: northDesc !== null && northDesc !== void 0 ? northDesc : '北',
3618
- cameraImageUrl,
3619
- visible: this.visible,
3620
- duration: duration !== null && duration !== void 0 ? duration : 0,
3621
- panoIndex: this.panoIndex,
3622
- floorIndex: this.floorIndex,
3623
- floorplanData: this.floorplanData,
3624
- hoverEnable: hoverEnable !== null && hoverEnable !== void 0 ? hoverEnable : false,
3625
- compassEnable: compassEnable !== null && compassEnable !== void 0 ? compassEnable : true,
3626
- ruleLabelsEnable: ruleLabelsEnable !== null && ruleLabelsEnable !== void 0 ? ruleLabelsEnable : true,
3627
- roomLabelsEnable: roomLabelsEnable !== null && roomLabelsEnable !== void 0 ? roomLabelsEnable : true,
3628
- lastPanoramaLongitude: this.lastPanoramaLongitude,
3629
- };
3630
- if (!this.app) {
3631
- this.app = new Main({
3632
- target: this.container,
3633
- intro: true,
3634
- props,
3635
- });
3636
- }
3637
- else {
3638
- this.app.$set(props);
3639
- }
4224
+ const props = Object.assign(Object.assign({}, this.state.config), { visible: this.state.visible, duration: duration !== null && duration !== void 0 ? duration : 0, panoIndex: this.panoIndex, floorIndex: this.floorIndex, floorplanData: this.data, lastPanoramaLongitude: this.lastPanoramaLongitude });
4225
+ if (this.app)
4226
+ return this.app.$set(props);
4227
+ this.app = new Main({ target: this.container, intro: true, props });
3640
4228
  }
3641
4229
  }
3642
4230
 
3643
4231
  const TopviewFloorplanPlugin = (five, params) => {
3644
- return new TopviewFloorplanPluginController(five, params);
4232
+ return new Controller(five, params);
3645
4233
  };
3646
4234
 
3647
4235
  exports.TopviewFloorplanPlugin = TopviewFloorplanPlugin;