@realsee/dnalogel 2.0.0-alpha.26 → 2.0.0-alpha.28

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 (162) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/CSS3DRenderPlugin/Plugin.d.ts +49 -0
  3. package/dist/CSS3DRenderPlugin/index.d.ts +3 -48
  4. package/dist/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
  5. package/dist/CameraMovementPlugin/index.d.ts +4 -6
  6. package/dist/CameraMovementPlugin/index.js +12 -12
  7. package/dist/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
  8. package/dist/ModelChassisCompassPlugin/index.d.ts +3 -18
  9. package/dist/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
  10. package/dist/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
  11. package/dist/ModelEntryDoorGuidePlugin/index.js +0 -5
  12. package/dist/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
  13. package/dist/ModelItemLabelPlugin/index.d.ts +8 -3
  14. package/dist/ModelItemLabelPlugin/index.js +13 -7
  15. package/dist/ModelTVVideoPlugin/Plugin.d.ts +4 -0
  16. package/dist/ModelTVVideoPlugin/index.d.ts +4 -3
  17. package/dist/ModelTVVideoPlugin/index.js +3 -3
  18. package/dist/ModelViewPlugin/Plugin.d.ts +17 -0
  19. package/dist/ModelViewPlugin/index.d.ts +3 -16
  20. package/dist/PanoCompassPlugin/Plugin.d.ts +47 -0
  21. package/dist/PanoCompassPlugin/index.d.ts +4 -47
  22. package/dist/PanoCompassPlugin/index.js +5 -4
  23. package/dist/PanoMeasurePlugin/index.d.ts +1 -1
  24. package/dist/PanoMeasurePlugin/index.js +4 -1
  25. package/dist/PanoRulerPlugin/Plugin.d.ts +31 -0
  26. package/dist/PanoRulerPlugin/index.d.ts +4 -30
  27. package/dist/PanoRulerPlugin/index.js +0 -5
  28. package/dist/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
  29. package/dist/PanoSpatialTagPlugin/index.d.ts +4 -32
  30. package/dist/PanoSpatialTagPlugin/index.js +23 -21
  31. package/dist/_index.d.ts +30 -0
  32. package/dist/floorplan/index.d.ts +6 -0
  33. package/dist/index.d.ts +15 -30
  34. package/dist/index.es.js +149 -22
  35. package/dist/index.js +177 -43
  36. package/dist/index.umd.js +180 -47
  37. package/docs/assets/search.js +1 -1
  38. package/docs/classes/ModelRoomLabelController.html +5 -8
  39. package/docs/classes/PanoFloorplanRadarPluginController.html +3 -0
  40. package/docs/enums/CameraMovementEffect.html +3 -0
  41. package/docs/enums/DIRECTION.html +1 -0
  42. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -0
  43. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  44. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  45. package/docs/enums/Rotation.html +3 -0
  46. package/docs/index.html +2 -2
  47. package/docs/interfaces/CSS3DRenderPluginExportType.html +4 -0
  48. package/docs/interfaces/CameraMovementPluginExportType.html +17 -0
  49. package/docs/interfaces/FloorplanBounding.html +10 -0
  50. package/docs/interfaces/FloorplanData.html +3 -0
  51. package/docs/interfaces/FloorplanEntrance.html +15 -0
  52. package/docs/interfaces/FloorplanExtraObject.html +7 -0
  53. package/docs/interfaces/FloorplanExtraObject3D.html +3 -0
  54. package/docs/interfaces/FloorplanFloorData.html +3 -0
  55. package/docs/interfaces/FloorplanImagePosition.html +3 -0
  56. package/docs/interfaces/FloorplanObserver.html +5 -0
  57. package/docs/interfaces/FloorplanOutlineItem.html +3 -0
  58. package/docs/interfaces/FloorplanPosition.html +3 -0
  59. package/docs/interfaces/FloorplanRoomItem.html +17 -0
  60. package/docs/interfaces/FloorplanRoomLabelItem.html +7 -0
  61. package/docs/interfaces/FloorplanServerBounding.html +10 -0
  62. package/docs/interfaces/FloorplanServerComputedData.html +1 -0
  63. package/docs/interfaces/FloorplanServerData.html +3 -0
  64. package/docs/interfaces/FloorplanServerEntrance.html +15 -0
  65. package/docs/interfaces/FloorplanServerFloorData.html +3 -0
  66. package/docs/interfaces/FloorplanServerImagePosition.html +3 -0
  67. package/docs/interfaces/FloorplanServerObserver.html +5 -0
  68. package/docs/interfaces/FloorplanServerOutlineItem.html +3 -0
  69. package/docs/interfaces/FloorplanServerPosition.html +3 -0
  70. package/docs/interfaces/FloorplanServerRoomItem.html +20 -0
  71. package/docs/interfaces/FloorplanServerRoomLabelItem.html +7 -0
  72. package/docs/interfaces/LineJson.html +1 -1
  73. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  74. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  75. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  76. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  77. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  78. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  79. package/docs/interfaces/ModelFloorplanViewEvent.html +3 -3
  80. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  81. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  82. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  83. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  84. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  85. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  86. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  87. package/docs/interfaces/ModelViewPluginExportType.html +1 -0
  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 -0
  92. package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -0
  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 -0
  97. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -0
  98. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  99. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -0
  100. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  101. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -0
  102. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  103. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -0
  104. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -0
  105. package/docs/interfaces/Point.html +1 -0
  106. package/docs/interfaces/PointJson.html +1 -1
  107. package/docs/interfaces/Room.html +1 -0
  108. package/docs/interfaces/RoomInfo.html +1 -0
  109. package/docs/interfaces/RoomLabel.html +7 -7
  110. package/docs/interfaces/RoomRules.html +1 -0
  111. package/docs/interfaces/Rooms.html +1 -0
  112. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +10 -10
  113. package/docs/modules.html +28 -12
  114. package/libs/CSS3DRenderPlugin/Plugin.d.ts +49 -0
  115. package/libs/CSS3DRenderPlugin/Plugin.js +182 -0
  116. package/libs/CSS3DRenderPlugin/index.d.ts +3 -48
  117. package/libs/CSS3DRenderPlugin/index.js +2 -181
  118. package/libs/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
  119. package/libs/CameraMovementPlugin/CameraMovementPlugin.js +159 -0
  120. package/libs/CameraMovementPlugin/index.d.ts +4 -6
  121. package/libs/CameraMovementPlugin/index.js +3 -158
  122. package/libs/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
  123. package/libs/ModelChassisCompassPlugin/Plugin.js +75 -0
  124. package/libs/ModelChassisCompassPlugin/index.d.ts +3 -18
  125. package/libs/ModelChassisCompassPlugin/index.js +2 -74
  126. package/libs/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
  127. package/libs/ModelEntryDoorGuidePlugin/Plugin.js +140 -0
  128. package/libs/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
  129. package/libs/ModelEntryDoorGuidePlugin/index.js +2 -139
  130. package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
  131. package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.js +120 -0
  132. package/libs/ModelItemLabelPlugin/index.d.ts +8 -3
  133. package/libs/ModelItemLabelPlugin/index.js +7 -119
  134. package/libs/ModelTVVideoPlugin/Plugin.d.ts +4 -0
  135. package/libs/ModelTVVideoPlugin/Plugin.js +254 -0
  136. package/libs/ModelTVVideoPlugin/index.d.ts +4 -3
  137. package/libs/ModelTVVideoPlugin/index.js +3 -253
  138. package/libs/ModelViewPlugin/Plugin.d.ts +17 -0
  139. package/libs/ModelViewPlugin/Plugin.js +160 -0
  140. package/libs/ModelViewPlugin/index.d.ts +3 -16
  141. package/libs/ModelViewPlugin/index.js +2 -159
  142. package/libs/PanoCompassPlugin/Plugin.d.ts +47 -0
  143. package/libs/PanoCompassPlugin/Plugin.js +249 -0
  144. package/libs/PanoCompassPlugin/index.d.ts +4 -47
  145. package/libs/PanoCompassPlugin/index.js +3 -249
  146. package/libs/PanoMeasurePlugin/index.d.ts +1 -1
  147. package/libs/PanoMeasurePlugin/index.js +1 -1
  148. package/libs/PanoRulerPlugin/Plugin.d.ts +31 -0
  149. package/libs/PanoRulerPlugin/Plugin.js +402 -0
  150. package/libs/PanoRulerPlugin/index.d.ts +4 -30
  151. package/libs/PanoRulerPlugin/index.js +2 -401
  152. package/libs/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
  153. package/libs/PanoSpatialTagPlugin/Plugin.js +415 -0
  154. package/libs/PanoSpatialTagPlugin/index.d.ts +4 -32
  155. package/libs/PanoSpatialTagPlugin/index.js +4 -412
  156. package/libs/_index.d.ts +30 -0
  157. package/libs/_index.js +18 -0
  158. package/libs/floorplan/index.d.ts +6 -0
  159. package/libs/floorplan/index.js +7 -0
  160. package/libs/index.d.ts +15 -30
  161. package/libs/index.js +25 -17
  162. package/package.json +5 -4
@@ -0,0 +1,415 @@
1
+ import * as THREE from 'three';
2
+ import { Five, Subscribe } from '@realsee/five';
3
+ import CSS3DRenderPlugin from '../CSS3DRenderPlugin';
4
+ import Origins from './Components/origins';
5
+ import Tag from './Components/tag';
6
+ import { pluginStyle } from './style';
7
+ import render from '../shared-utils/tinyEJSrender';
8
+ const MESH_SIZE = 0.001;
9
+ const RAY_ORIGIN_Y = 1.4;
10
+ const RAY_TOLERANT_DISTANCE = 0.01;
11
+ const BLUR_IMAGE_URL = 'https://vrlab-image4.ljcdn.com/release/web/PanoSpatialTagPlugin__blur.png';
12
+ const MIN_DISTANCE = 1.2;
13
+ const MAX_DISTANCE = 3.5;
14
+ /**
15
+ * 空间游走标签插件
16
+ */
17
+ export const PanoSpatialTagPlugin = (five, params) => {
18
+ var _a, _b, _c, _d, _e, _f;
19
+ let wrapper = params === null || params === void 0 ? void 0 : params.container;
20
+ const wait = (_a = params === null || params === void 0 ? void 0 : params.wait) !== null && _a !== void 0 ? _a : 200;
21
+ const maxNumberOnScreen = (_b = params === null || params === void 0 ? void 0 : params.maxNumberOnScreen) !== null && _b !== void 0 ? _b : 3;
22
+ const minRad = (_c = params === null || params === void 0 ? void 0 : params.minRad) !== null && _c !== void 0 ? _c : Math.PI / 4;
23
+ const nearTolerance = (_d = params === null || params === void 0 ? void 0 : params.nearTolerance) !== null && _d !== void 0 ? _d : 100;
24
+ const upsideHeight = (_e = params === null || params === void 0 ? void 0 : params.upsideHeight) !== null && _e !== void 0 ? _e : 1.6;
25
+ // const foldPercent = params?.foldPercent ?? 20
26
+ const css3DRender = CSS3DRenderPlugin(five);
27
+ const container = document.createElement('div');
28
+ container.classList.add('PanoSpatialTagPlugin');
29
+ Object.assign(container.style, pluginStyle);
30
+ const hooks = new Subscribe();
31
+ let blurImage = new Image();
32
+ blurImage.src = BLUR_IMAGE_URL;
33
+ const state = {
34
+ points: [],
35
+ origins: [],
36
+ tags: [],
37
+ template: '',
38
+ events: {},
39
+ render,
40
+ folded: false,
41
+ enabled: true,
42
+ forbidden: true,
43
+ };
44
+ const origins = new Origins({
45
+ target: container,
46
+ props: { origins: state.origins },
47
+ });
48
+ const onCameraUpdate = (pose, userAction) => {
49
+ updateOrigins();
50
+ if (userAction) {
51
+ updateTags();
52
+ // state.tags.forEach(tag => {
53
+ // const mouse = tag.position.clone().project(five.camera)
54
+ // const top = ( - mouse.y + 1 ) / 2 * 100
55
+ // })
56
+ }
57
+ };
58
+ const onPanoArrived = () => {
59
+ if (state.forbidden) {
60
+ state.forbidden = false;
61
+ updateTags();
62
+ }
63
+ };
64
+ const onPanoWillArrive = (pano, pose) => {
65
+ if (state.tags.length === 0)
66
+ return;
67
+ const rotateRad = pose.longitude - five.state.longitude;
68
+ const camera = five.camera.clone();
69
+ camera.position.copy(pose.offset);
70
+ camera.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), rotateRad);
71
+ camera.updateProjectionMatrix();
72
+ camera.updateMatrixWorld(true);
73
+ const frustum = new THREE.Frustum();
74
+ const projScreenMatrix = new THREE.Matrix4();
75
+ projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
76
+ frustum.setFromProjectionMatrix(projScreenMatrix);
77
+ state.tags.forEach(tag => {
78
+ const distance = camera.position.clone().setY(RAY_ORIGIN_Y).distanceTo(tag.position);
79
+ if (distance < MIN_DISTANCE || distance > MAX_DISTANCE)
80
+ return tag.destroying = true;
81
+ if (!frustum.containsPoint(tag.position))
82
+ return tag.destroying = true;
83
+ const v = tag.position.clone().sub(camera.position).setY(0);
84
+ if (v.angleTo(tag.normal) > Math.PI / 2 - minRad &&
85
+ v.angleTo(tag.normal) < Math.PI / 2 + minRad)
86
+ return tag.destroying = true;
87
+ });
88
+ state.tags.forEach(tag => {
89
+ if (tag.destroying) {
90
+ tag.app.$set({
91
+ contentZoom: 0.1 + camera.position.distanceTo(tag.position) / MAX_DISTANCE,
92
+ lineWidthZoom: 0.38 * (0.01 + camera.position.distanceTo(tag.position) / MAX_DISTANCE),
93
+ destroying: tag.destroying,
94
+ });
95
+ }
96
+ else {
97
+ tag.app.$set({
98
+ lineWidthZoom: 0.38 * (0.01 + camera.position.distanceTo(tag.position) / MAX_DISTANCE),
99
+ lineHeightZoom: 0.4 + (camera.position.distanceTo(tag.position) - MIN_DISTANCE) / MAX_DISTANCE * 0.6,
100
+ contentZoom: 0.1 + camera.position.distanceTo(tag.position) / MAX_DISTANCE,
101
+ });
102
+ }
103
+ });
104
+ setTimeout(() => {
105
+ state.tags.forEach(tag => {
106
+ if (tag.destroying) {
107
+ tag.app.$destroy();
108
+ tag = null;
109
+ }
110
+ });
111
+ state.tags = state.tags.filter(tag => !tag.destroying);
112
+ updateOrigins();
113
+ }, 1900);
114
+ };
115
+ const onModeChange = (mode) => {
116
+ if (mode !== Five.Mode.Panorama && !state.forbidden) {
117
+ origins.$set({ origins: [] });
118
+ state.tags.forEach(tag => {
119
+ tag.app.$destroy();
120
+ tag = null;
121
+ });
122
+ state.origins = [];
123
+ state.tags = [];
124
+ state.forbidden = true;
125
+ }
126
+ };
127
+ const updateOrigins = () => {
128
+ if (state.forbidden || !state.enabled)
129
+ return;
130
+ const camera = five.camera;
131
+ const direction = camera.getWorldDirection(new THREE.Vector3());
132
+ state.origins = state.tags.map(tag => {
133
+ const mouse = tag.position.clone().project(camera);
134
+ const front = tag.position.clone().sub(camera.position).setY(0)
135
+ .angleTo(direction.setY(0)) < Math.PI / 2;
136
+ return {
137
+ id: tag.id,
138
+ front,
139
+ left: (mouse.x + 1) / 2 * 100,
140
+ top: (-mouse.y + 1) / 2 * 100,
141
+ destroying: tag.destroying,
142
+ };
143
+ });
144
+ origins.$set({ origins: state.origins });
145
+ };
146
+ const updateTags = () => {
147
+ if (state.forbidden || !state.enabled)
148
+ return;
149
+ if (state.timeoutId)
150
+ clearTimeout(state.timeoutId);
151
+ state.timeoutId = setTimeout(() => {
152
+ state.timeoutId = undefined;
153
+ const newTags = getNewTags();
154
+ if (newTags.length) {
155
+ state.tags = state.tags.concat(newTags);
156
+ updateOrigins();
157
+ }
158
+ }, wait);
159
+ };
160
+ const getNewTags = () => {
161
+ const { clientWidth, clientHeight } = five.getElement();
162
+ const newTags = [];
163
+ const camera = five.camera;
164
+ const frustum = new THREE.Frustum();
165
+ const projScreenMatrix = new THREE.Matrix4();
166
+ const direction = camera.getWorldDirection(new THREE.Vector3());
167
+ projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
168
+ frustum.setFromProjectionMatrix(projScreenMatrix);
169
+ const frontTagLength = state.tags.filter(tag => frustum.containsPoint(tag.position) && !tag.destroying).length;
170
+ const points = state.points.reduce((result, point) => {
171
+ if (state.tags.find(tag => point.id === tag.id && !tag.destroying))
172
+ return result;
173
+ const distance = camera.position.clone().setY(RAY_ORIGIN_Y).distanceTo(point.position);
174
+ if (distance < MIN_DISTANCE || distance > MAX_DISTANCE)
175
+ return result;
176
+ if (!frustum.containsPoint(point.position))
177
+ return result;
178
+ const v = point.position.clone().sub(camera.position).setY(0);
179
+ if (v.angleTo(point.normal) > Math.PI / 2 - minRad &&
180
+ v.angleTo(point.normal) < Math.PI / 2 + minRad)
181
+ return result;
182
+ const mouse = point.position.clone().project(camera);
183
+ if (!state.tags.every(tag => {
184
+ if (tag.position.clone().sub(camera.position).setY(0)
185
+ .angleTo(direction.setY(0)) > Math.PI / 2)
186
+ return true;
187
+ const _mouse = tag.position.clone().project(camera);
188
+ return Math.sqrt(Math.pow((mouse.x - _mouse.x) / 2 * clientWidth, 2) +
189
+ Math.pow((mouse.y - _mouse.y) / 2 * clientHeight, 2)) > nearTolerance;
190
+ }))
191
+ return result;
192
+ const newPoint = {
193
+ id: point.id,
194
+ position: point.position,
195
+ normal: point.normal,
196
+ replacement: point.replacement,
197
+ weight: point.weight,
198
+ distance,
199
+ };
200
+ let index;
201
+ for (let i = 0, l = result.length; i < l; i++) {
202
+ const anotherPoint = result[i];
203
+ if (newPoint.weight > anotherPoint.weight) {
204
+ index = i;
205
+ break;
206
+ }
207
+ if (newPoint.distance < anotherPoint.distance) {
208
+ index = i;
209
+ break;
210
+ }
211
+ }
212
+ if (index !== undefined)
213
+ result.splice(index, 0, newPoint);
214
+ else
215
+ result.push(newPoint);
216
+ return result;
217
+ }, []);
218
+ for (let i = 0, l = points.length; i < l; i++) {
219
+ if (frontTagLength + newTags.length >= maxNumberOnScreen)
220
+ break;
221
+ const point = points[i];
222
+ if (newTags.find(tag => point.id === tag.id))
223
+ continue;
224
+ const mouse = point.position.clone().project(camera);
225
+ if (!state.tags.concat(newTags).every(tag => {
226
+ if (tag.position.clone().sub(camera.position).setY(0)
227
+ .angleTo(direction.setY(0)) > Math.PI / 2)
228
+ return true;
229
+ const _mouse = tag.position.clone().project(camera);
230
+ return Math.sqrt(Math.pow((mouse.x - _mouse.x) / 2 * clientWidth, 2) +
231
+ Math.pow((mouse.y - _mouse.y) / 2 * clientHeight, 2)) > nearTolerance;
232
+ }))
233
+ continue;
234
+ const raycaster = new THREE.Raycaster(camera.position.clone().setY(RAY_ORIGIN_Y), point.position.clone().sub(camera.position.clone().setY(RAY_ORIGIN_Y)).normalize(), 0, point.distance + RAY_TOLERANT_DISTANCE);
235
+ const [intersect] = five.model.bvhs.loaded ?
236
+ five.model.intersectRaycaster(raycaster) :
237
+ raycaster.intersectObjects(five.model.children, true);
238
+ if (!intersect)
239
+ continue;
240
+ if (point.distance - intersect.distance < RAY_TOLERANT_DISTANCE) {
241
+ const { position, normal, id, replacement } = point;
242
+ const plane = new THREE.Plane().setFromNormalAndCoplanarPoint(normal, position);
243
+ const right = position.clone().sub(camera.position)
244
+ .cross(new THREE.Vector3(0, 1, 0)).setLength(MESH_SIZE);
245
+ const square = [
246
+ position.clone(),
247
+ position.clone().add(right),
248
+ position.clone().add(new THREE.Vector3(0, MESH_SIZE, 0)).add(right),
249
+ position.clone().add(new THREE.Vector3(0, MESH_SIZE, 0)),
250
+ ].map(v => plane.projectPoint(v, new THREE.Vector3()));
251
+ const { container, dispose } = css3DRender.create3DDomContainer(square) || {};
252
+ const app = new Tag({
253
+ target: container,
254
+ props: {
255
+ id,
256
+ content: state.render(state.template, replacement),
257
+ lineWidthZoom: 0.38 * (0.01 + camera.position.distanceTo(position) / MAX_DISTANCE),
258
+ lineHeightZoom: 0.4 + (camera.position.distanceTo(position) - MIN_DISTANCE) / MAX_DISTANCE * 0.6,
259
+ contentZoom: 0.1 + camera.position.distanceTo(position) / MAX_DISTANCE,
260
+ upsideDown: position.y > upsideHeight,
261
+ folded: state.folded,
262
+ events: state.events,
263
+ hooks,
264
+ dispose,
265
+ },
266
+ });
267
+ newTags.push({
268
+ position,
269
+ normal,
270
+ id,
271
+ app,
272
+ });
273
+ }
274
+ }
275
+ return newTags;
276
+ };
277
+ /** 标签数据加载
278
+ * @param data.points {Array} 标签数据
279
+ * @param data.enabled {Boolean} 插件是否启用
280
+ * @param data.folded {Boolean} 标签是否默认展开
281
+ */
282
+ const load = (data) => {
283
+ state.points = data.points.map(point => {
284
+ var _a, _b;
285
+ return {
286
+ id: point.id,
287
+ position: new THREE.Vector3().fromArray(point.position),
288
+ normal: new THREE.Vector3().fromArray(point.normal),
289
+ replacement: (_a = point.replacement) !== null && _a !== void 0 ? _a : {},
290
+ weight: (_b = point.weight) !== null && _b !== void 0 ? _b : -1,
291
+ };
292
+ });
293
+ if (data.render)
294
+ state.render = data.render;
295
+ if (data.template)
296
+ state.template = data.template;
297
+ if (data.events)
298
+ state.events = data.events;
299
+ if (data.enabled === false)
300
+ state.enabled = data.enabled;
301
+ if (data.folded === true)
302
+ state.folded = data.folded;
303
+ };
304
+ /** 标签启用
305
+ * 启用插件并重新计算展示标签
306
+ */
307
+ const enable = () => {
308
+ state.enabled = true;
309
+ updateTags();
310
+ };
311
+ /** 插件禁用
312
+ * 1. 禁用同时会清除已展示的标签
313
+ * 2. 再次启用时会重新计算展示标签
314
+ */
315
+ const disable = () => {
316
+ state.enabled = false;
317
+ origins.$set({ origins: [] });
318
+ state.tags.forEach(tag => {
319
+ tag.app.$destroy();
320
+ tag = null;
321
+ });
322
+ state.origins = [];
323
+ state.tags = [];
324
+ };
325
+ /** 展开所有标签
326
+ * 1. 展开所有收起的标签
327
+ * 2. 新标签会默认展开
328
+ */
329
+ const unfoldAll = () => {
330
+ state.folded = false;
331
+ state.tags.forEach(tag => {
332
+ tag.app.$set({ folded: state.folded });
333
+ });
334
+ };
335
+ /** 收起所有标签
336
+ * 1. 收起所有展开的标签
337
+ * 2. 新标签会默认收起
338
+ */
339
+ const foldAll = () => {
340
+ state.folded = true;
341
+ state.tags.forEach(tag => {
342
+ tag.app.$set({ folded: state.folded });
343
+ });
344
+ };
345
+ /** 展开单个标签
346
+ * @param id {Number | String} 标签ID
347
+ */
348
+ const unfold = (id) => {
349
+ state.tags.forEach(tag => {
350
+ if (tag.id === id)
351
+ tag.app.$set({ folded: false });
352
+ });
353
+ };
354
+ /** 收起单个标签
355
+ * @param id {Number | String} 标签ID
356
+ */
357
+ const fold = (id) => {
358
+ state.tags.forEach(tag => {
359
+ if (tag.id === id)
360
+ tag.app.$set({ folded: true });
361
+ });
362
+ };
363
+ const dispose = () => {
364
+ blurImage = null;
365
+ css3DRender.disposeAll();
366
+ origins.$destroy();
367
+ state.tags.forEach(tag => {
368
+ tag.app.$destroy();
369
+ tag = null;
370
+ });
371
+ state.origins = [];
372
+ state.tags = [];
373
+ five.off('panoWillArrive', onPanoWillArrive);
374
+ five.off('panoArrived', onPanoArrived);
375
+ five.off('modeChange', onModeChange);
376
+ five.off('cameraUpdate', onCameraUpdate);
377
+ };
378
+ if ((_f = five === null || five === void 0 ? void 0 : five.model) === null || _f === void 0 ? void 0 : _f.loaded) {
379
+ if (!wrapper)
380
+ wrapper = five.getElement().parentElement;
381
+ wrapper.appendChild(container);
382
+ state.forbidden = false;
383
+ updateTags();
384
+ five.on('panoWillArrive', onPanoWillArrive);
385
+ five.on('panoArrived', onPanoArrived);
386
+ five.on('modeChange', onModeChange);
387
+ five.on('cameraUpdate', onCameraUpdate);
388
+ }
389
+ else {
390
+ five.once('modelLoaded', () => {
391
+ if (!wrapper)
392
+ wrapper = five.getElement().parentElement;
393
+ wrapper.appendChild(container);
394
+ state.forbidden = false;
395
+ updateTags();
396
+ five.on('panoWillArrive', onPanoWillArrive);
397
+ five.on('panoArrived', onPanoArrived);
398
+ five.on('modeChange', onModeChange);
399
+ five.on('cameraUpdate', onCameraUpdate);
400
+ });
401
+ }
402
+ five.on('dispose', dispose);
403
+ return {
404
+ load,
405
+ unfoldAll,
406
+ foldAll,
407
+ unfold,
408
+ fold,
409
+ enable,
410
+ disable,
411
+ hooks,
412
+ dispose,
413
+ };
414
+ };
415
+ export default PanoSpatialTagPlugin;
@@ -1,33 +1,5 @@
1
- import type { FivePlugin } from '@realsee/five';
2
- import type { PanoSpatialTagPluginId, PanoSpatialTagPluginDataElement, PanoSpatialTagPluginContentReplacement, PanoSpatialTagPluginContentEvent } from './typings';
3
- export interface PanoSpatialTagPluginData {
4
- folded?: boolean;
5
- enabled?: boolean;
6
- points: Array<PanoSpatialTagPluginDataElement>;
7
- template: string;
8
- events?: PanoSpatialTagPluginContentEvent;
9
- render?: (template: string, replacement: PanoSpatialTagPluginContentReplacement) => string;
10
- }
11
- export interface PanoSpatialTagPluginParameterType {
12
- container?: Element;
13
- wait?: number;
14
- maxNumberOnScreen?: number;
15
- minRad?: number;
16
- nearTolerance?: number;
17
- upsideHeight?: number;
18
- }
19
- export interface PanoSpatialTagPluginExportType {
20
- load: (data: PanoSpatialTagPluginData) => void;
21
- unfoldAll: () => void;
22
- foldAll: () => void;
23
- unfold: (id: PanoSpatialTagPluginId) => void;
24
- fold: (id: PanoSpatialTagPluginId) => void;
25
- enable: () => void;
26
- disable: () => void;
27
- dispose: () => void;
28
- }
29
- /**
30
- * 空间游走标签插件
31
- */
32
- export declare const PanoSpatialTagPlugin: FivePlugin<PanoSpatialTagPluginParameterType, PanoSpatialTagPluginExportType>;
1
+ import PanoSpatialTagPlugin from './Plugin';
2
+ export { PanoSpatialTagPlugin };
33
3
  export default PanoSpatialTagPlugin;
4
+ export * from './typings';
5
+ export type { PanoSpatialTagPluginExportType, PanoSpatialTagPluginParameterType, PanoSpatialTagPluginData } from './Plugin';