@realsee/dnalogel 2.0.0-alpha.12 → 2.0.0-alpha.13

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 (101) hide show
  1. package/dist/CSS3DRenderPlugin/index.js +17 -14
  2. package/dist/CameraMovementPlugin/index.js +40 -15
  3. package/dist/ModelChassisCompassPlugin/index.js +32 -6
  4. package/dist/ModelEntryDoorGuidePlugin/index.js +48 -18
  5. package/dist/ModelItemLabelPlugin/index.js +18 -17
  6. package/dist/ModelRoomLabelPlugin/index.js +67 -26
  7. package/dist/PanoCompassPlugin/index.js +311 -164
  8. package/dist/PanoCursorRaycasterPlugin/index.js +5 -3
  9. package/dist/PanoMeasurePlugin/index.js +1337 -583
  10. package/dist/PanoRulerPlugin/index.js +32 -5
  11. package/dist/PanoSpatialTagPlugin/index.js +64 -29
  12. package/dist/floorplan/ModelFloorplanPlugin/index.js +586 -362
  13. package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +164 -72
  14. package/dist/floorplan/TopviewFloorplanPlugin/index.js +311 -153
  15. package/dist/index.es.js +2663 -1341
  16. package/dist/index.js +2667 -1345
  17. package/dist/index.umd.js +2667 -1345
  18. package/docs/assets/main.js +1 -1
  19. package/docs/classes/ModelRoomLabelController.html +6 -6
  20. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  21. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  22. package/docs/interfaces/LineJson.html +1 -1
  23. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  24. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  25. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  26. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  27. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  28. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  29. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  30. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  31. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  32. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  33. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  34. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  35. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  36. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  37. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  38. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  39. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  40. package/docs/interfaces/PointJson.html +1 -1
  41. package/docs/interfaces/RoomLabel.html +7 -7
  42. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -1
  43. package/docs/modules.html +12 -12
  44. package/libs/CSS3DRenderPlugin/index.js +16 -13
  45. package/libs/CameraMovementPlugin/index.js +24 -15
  46. package/libs/ModelChassisCompassPlugin/index.js +14 -5
  47. package/libs/ModelEntryDoorGuidePlugin/index.js +24 -12
  48. package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +12 -10
  49. package/libs/ModelItemLabelPlugin/index.js +5 -3
  50. package/libs/ModelItemLabelPlugin/utils/parseData.js +1 -4
  51. package/libs/ModelRoomLabelPlugin/Controller.js +64 -23
  52. package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +3 -3
  53. package/libs/PanoCompassPlugin/index.js +225 -128
  54. package/libs/PanoCursorRaycasterPlugin/index.js +5 -3
  55. package/libs/PanoMeasurePlugin/Controller/BaseController.js +68 -13
  56. package/libs/PanoMeasurePlugin/Controller/EditController.js +267 -154
  57. package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.js +40 -20
  58. package/libs/PanoMeasurePlugin/Controller/WatchController.js +234 -152
  59. package/libs/PanoMeasurePlugin/Controller/index.js +131 -47
  60. package/libs/PanoMeasurePlugin/Model/index.js +30 -5
  61. package/libs/PanoMeasurePlugin/Model/line.js +60 -10
  62. package/libs/PanoMeasurePlugin/Model/point.js +24 -4
  63. package/libs/PanoMeasurePlugin/Model/polyline.js +20 -3
  64. package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.js +59 -14
  65. package/libs/PanoMeasurePlugin/Modules/FiveHelper.js +23 -8
  66. package/libs/PanoMeasurePlugin/Modules/GuideController.js +61 -26
  67. package/libs/PanoMeasurePlugin/Modules/Magnifier.js +60 -10
  68. package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +83 -37
  69. package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +52 -17
  70. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +61 -30
  71. package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -2
  72. package/libs/PanoMeasurePlugin/utils/line.js +8 -7
  73. package/libs/PanoRulerPlugin/index.js +16 -5
  74. package/libs/PanoSpatialTagPlugin/index.js +11 -9
  75. package/libs/floorplan/Components/BaseImage.js +10 -5
  76. package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +3 -1
  77. package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +5 -6
  78. package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +7 -2
  79. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +3 -1
  80. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +456 -273
  81. package/libs/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +33 -22
  82. package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.js +3 -1
  83. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +97 -36
  84. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +231 -108
  85. package/libs/floorplan/utils/formatData.js +43 -28
  86. package/libs/floorplan/utils/formatPosition.js +1 -1
  87. package/libs/shared-utils/Subscribe.js +8 -1
  88. package/libs/shared-utils/animationFrame/BetterTween.js +47 -18
  89. package/libs/shared-utils/createCanvasTextTexture.js +6 -5
  90. package/libs/shared-utils/five/changeMode.js +23 -12
  91. package/libs/shared-utils/getPxmm.js +1 -1
  92. package/libs/shared-utils/math/evenNumber.js +1 -1
  93. package/libs/shared-utils/three/loadFbxObj.js +20 -9
  94. package/libs/shared-utils/three/loadTexture.js +17 -6
  95. package/libs/shared-utils/three/transfromToMeshBasicMaterial.js +2 -1
  96. package/libs/shared-utils/tinyEJSrender.js +36 -6
  97. package/libs/shared-utils/to.js +21 -10
  98. package/libs/shared-utils/useDebounce.js +1 -1
  99. package/libs/shared-utils/useThrottle.js +2 -1
  100. package/package.json +1 -1
  101. package/CHANGELOG.md +0 -41
@@ -27,7 +27,7 @@ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
27
27
 
28
28
  function evenNumber(num, config) {
29
29
  const roundNum = Math.round(num);
30
- return roundNum % 2 === 0 ? roundNum : roundNum + Number(config?.smaller ? -1 : 1);
30
+ return roundNum % 2 === 0 ? roundNum : roundNum + Number((config === null || config === void 0 ? void 0 : config.smaller) ? -1 : 1);
31
31
  }
32
32
 
33
33
  function centerPoint(point1, point2) {
@@ -64,24 +64,25 @@ function createResizeObserver(func, element) {
64
64
  const CSS3DRenderPlugin = (five) => {
65
65
  const state = { disposeCallbacks: [] };
66
66
  const create3DDomContainer = (...params) => {
67
+ var _a, _b, _c;
67
68
  const points = params[0].map((point) => (point instanceof THREE.Vector3 ? point : transformPositionToVector3(point)));
68
69
  const config = params[1];
69
- if (points?.length < 4)
70
+ if ((points === null || points === void 0 ? void 0 : points.length) < 4)
70
71
  return console.error('points must be equal or greater than than 4');
71
- if (!five?.model?.loaded)
72
- return console.error('five.model.loaded is: ', five?.model?.loaded);
72
+ if (!((_a = five === null || five === void 0 ? void 0 : five.model) === null || _a === void 0 ? void 0 : _a.loaded))
73
+ return console.error('five.model.loaded is: ', (_b = five === null || five === void 0 ? void 0 : five.model) === null || _b === void 0 ? void 0 : _b.loaded);
73
74
  const fiveElement = five.getElement();
74
75
  if (!fiveElement)
75
76
  return console.error('five.getElement() is ' + fiveElement);
76
77
  const disposers = [];
77
- const ratio = config?.ratio || 0.00216;
78
+ const ratio = (config === null || config === void 0 ? void 0 : config.ratio) || 0.00216;
78
79
  if (ratio <= 0.00215)
79
80
  console.warn('if you need click css3DElement on safari, ratio must be greater than 0.00215');
80
- const dpr = config?.dpr || 1;
81
- const mode = config?.mode || 'front';
82
- const autoRender = config?.autoRender ?? true;
83
- const behindFiveContainer = config?.behindFiveContainer || fiveElement.parentElement || document.body;
84
- const container = config?.container || document.createElement('div');
81
+ const dpr = (config === null || config === void 0 ? void 0 : config.dpr) || 1;
82
+ const mode = (config === null || config === void 0 ? void 0 : config.mode) || 'front';
83
+ const autoRender = (_c = config === null || config === void 0 ? void 0 : config.autoRender) !== null && _c !== void 0 ? _c : true;
84
+ const behindFiveContainer = (config === null || config === void 0 ? void 0 : config.behindFiveContainer) || fiveElement.parentElement || document.body;
85
+ const container = (config === null || config === void 0 ? void 0 : config.container) || document.createElement('div');
85
86
  container.classList.add('__Dnalogel-plugin--CSS3DRenderPlugin');
86
87
  // 获取css3DObject, 如果mode为behind的话,一起获取mesh
87
88
  const { css3DObject, mesh } = createObject(points, { ratio, dpr, container, mode });
@@ -119,8 +120,9 @@ const CSS3DRenderPlugin = (five) => {
119
120
  css3DRenderer.render(scene, five.camera);
120
121
  };
121
122
  return () => {
123
+ var _a;
122
124
  scene.add(css3DObject);
123
- resizeObserver?.observe?.();
125
+ (_a = resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe) === null || _a === void 0 ? void 0 : _a.call(resizeObserver);
124
126
  renderEveryFrame();
125
127
  if (mode === 'behind' && mesh) {
126
128
  five.scene.add(mesh);
@@ -144,7 +146,8 @@ const CSS3DRenderPlugin = (five) => {
144
146
  }
145
147
  // ======= INIT END =======
146
148
  const dispose = () => {
147
- disposers.forEach((d) => d?.());
149
+ var _a;
150
+ disposers.forEach((d) => d === null || d === void 0 ? void 0 : d());
148
151
  scene.remove(css3DObject);
149
152
  if (scene.children.length === 0) {
150
153
  if (typeof stateMode.requestAnimationFrameId === 'number') {
@@ -156,7 +159,7 @@ const CSS3DRenderPlugin = (five) => {
156
159
  if (mode === 'behind')
157
160
  state.behindMode = undefined;
158
161
  if (!state.behindMode && !state.frontMode) {
159
- resizeObserver?.unobserve?.();
162
+ (_a = resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve) === null || _a === void 0 ? void 0 : _a.call(resizeObserver);
160
163
  }
161
164
  }
162
165
  return true;
@@ -221,7 +224,7 @@ const CSS3DRenderPlugin = (five) => {
221
224
  return {
222
225
  create3DDomContainer,
223
226
  disposeAll: () => {
224
- state.disposeCallbacks.forEach((d) => d?.());
227
+ state.disposeCallbacks.forEach((d) => d === null || d === void 0 ? void 0 : d());
225
228
  state.disposeCallbacks = [];
226
229
  },
227
230
  };
@@ -25,6 +25,31 @@ function _interopNamespace(e) {
25
25
 
26
26
  var TWEEN__namespace = /*#__PURE__*/_interopNamespace(TWEEN);
27
27
 
28
+ /*! *****************************************************************************
29
+ Copyright (c) Microsoft Corporation.
30
+
31
+ Permission to use, copy, modify, and/or distribute this software for any
32
+ purpose with or without fee is hereby granted.
33
+
34
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
35
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
37
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
+ PERFORMANCE OF THIS SOFTWARE.
41
+ ***************************************************************************** */
42
+
43
+ function __awaiter(thisArg, _arguments, P, generator) {
44
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
45
+ return new (P || (P = Promise))(function (resolve, reject) {
46
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
47
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
48
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
49
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
50
+ });
51
+ }
52
+
28
53
  const _requestAnimationFrame = window.requestAnimationFrame || ((fn) => setTimeout(fn, 16));
29
54
  const _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
30
55
  function nextFrame(fn, delay = 0) {
@@ -170,21 +195,21 @@ const getLongitudeParams = (from, to, rotation) => {
170
195
  */
171
196
  const CameraMovementPlugin = (five$1) => {
172
197
  const state = {};
173
- const move = async (args, duration, opts = { preload: true }) => {
198
+ const move = (args, duration, opts = { preload: true }) => __awaiter(void 0, void 0, void 0, function* () {
174
199
  if (state.interruptCallback) {
175
200
  state.interruptCallback(false);
176
201
  }
177
202
  if (opts.asyncStartCallback) {
178
- await opts.asyncStartCallback();
203
+ yield opts.asyncStartCallback();
179
204
  }
180
205
  if (args.mode && args.mode !== five$1.currentMode) {
181
- await five$1.changeMode(args.mode);
206
+ yield five$1.changeMode(args.mode);
182
207
  }
183
208
  if (opts.preload && args.panoIndex !== undefined && args.panoIndex !== five$1.panoIndex) {
184
- await five$1.preloadPano(args.panoIndex);
209
+ yield five$1.preloadPano(args.panoIndex);
185
210
  }
186
211
  if (opts.asyncEndCallback) {
187
- await opts.asyncEndCallback();
212
+ yield opts.asyncEndCallback();
188
213
  }
189
214
  if (args.panoIndex === undefined &&
190
215
  args.fov === undefined &&
@@ -192,7 +217,7 @@ const CameraMovementPlugin = (five$1) => {
192
217
  args.longitude === undefined) {
193
218
  return true;
194
219
  }
195
- return await new Promise((resolve, reject) => {
220
+ return yield new Promise((resolve, reject) => {
196
221
  const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five$1.panoIndex;
197
222
  if (panoIndex !== undefined) {
198
223
  five$1.moveToPano(panoIndex, Object.assign({
@@ -205,7 +230,7 @@ const CameraMovementPlugin = (five$1) => {
205
230
  reject(false);
206
231
  }
207
232
  });
208
- };
233
+ });
209
234
  const getAnimeParams = (args) => {
210
235
  const currentFiveState = five$1.state;
211
236
  // latitude
@@ -221,20 +246,20 @@ const CameraMovementPlugin = (five$1) => {
221
246
  to: { latitude: toLatitude, longitude: toLongitude, fov: toFov },
222
247
  };
223
248
  };
224
- const rotate = async (args, duration, opts = {}) => {
249
+ const rotate = (args, duration, opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
225
250
  if (state.interruptCallback) {
226
251
  state.interruptCallback(false);
227
252
  }
228
253
  if (opts.asyncStartCallback) {
229
- await opts.asyncStartCallback();
254
+ yield opts.asyncStartCallback();
230
255
  }
231
256
  if (five$1.currentMode !== five.Five.Mode.Panorama) {
232
- await five$1.changeMode(five.Five.Mode.Panorama);
257
+ yield five$1.changeMode(five.Five.Mode.Panorama);
233
258
  }
234
259
  if (args.panoIndex !== undefined && args.panoIndex !== five$1.panoIndex) {
235
260
  if (opts.preload)
236
- await five$1.preloadPano(args.panoIndex);
237
- await new Promise((resolve, reject) => {
261
+ yield five$1.preloadPano(args.panoIndex);
262
+ yield new Promise((resolve, reject) => {
238
263
  if (!args.panoIndex) {
239
264
  resolve(true);
240
265
  return;
@@ -246,10 +271,10 @@ const CameraMovementPlugin = (five$1) => {
246
271
  });
247
272
  }
248
273
  if (opts.asyncEndCallback) {
249
- await opts.asyncEndCallback();
274
+ yield opts.asyncEndCallback();
250
275
  }
251
276
  const { from, to } = getAnimeParams(args);
252
- return await new Promise((resolve) => {
277
+ return yield new Promise((resolve) => {
253
278
  const onUpdate = ({ progress }) => {
254
279
  const state = {};
255
280
  state.longitude = progressNumber(from.longitude, to.longitude, progress);
@@ -291,7 +316,7 @@ const CameraMovementPlugin = (five$1) => {
291
316
  state.interruptCallback(true);
292
317
  }, duration);
293
318
  });
294
- };
319
+ });
295
320
  return {
296
321
  move,
297
322
  rotate,
@@ -25,6 +25,31 @@ function _interopNamespace(e) {
25
25
 
26
26
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
27
27
 
28
+ /*! *****************************************************************************
29
+ Copyright (c) Microsoft Corporation.
30
+
31
+ Permission to use, copy, modify, and/or distribute this software for any
32
+ purpose with or without fee is hereby granted.
33
+
34
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
35
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
37
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
+ PERFORMANCE OF THIS SOFTWARE.
41
+ ***************************************************************************** */
42
+
43
+ function __awaiter(thisArg, _arguments, P, generator) {
44
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
45
+ return new (P || (P = Promise))(function (resolve, reject) {
46
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
47
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
48
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
49
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
50
+ });
51
+ }
52
+
28
53
  const genRotationMatrix = (x, y, z) => {
29
54
  const matrix = new THREE__namespace.Matrix4();
30
55
  const euler = new THREE__namespace.Euler(x, y, z, 'YXZ');
@@ -55,12 +80,13 @@ const bject3d2LocalMatrix = (mesh, { scale, rotation, position, }) => {
55
80
 
56
81
  function transfromToMeshBasicMaterial(object, options) {
57
82
  object.traverse((ele) => {
83
+ var _a;
58
84
  if (ele.type === 'Mesh') {
59
85
  const mesh = ele;
60
86
  const materialConf = Object.assign({ map: mesh.material.map || {} }, options);
61
87
  mesh.material = new THREE.MeshBasicMaterial(materialConf);
62
88
  mesh.renderOrder = 1;
63
- if (ele.parent?.type === 'Mesh') {
89
+ if (((_a = ele.parent) === null || _a === void 0 ? void 0 : _a.type) === 'Mesh') {
64
90
  ele.renderOrder = ele.parent.renderOrder + 1;
65
91
  }
66
92
  }
@@ -75,9 +101,9 @@ const ModelChassisCompassPlugin = (five, params) => {
75
101
  const defaultNorthRad = params.north_rad || undefined;
76
102
  // 局部状态
77
103
  const state = {};
78
- const load = async (data) => {
79
- const fbxUrl = data?.fbx_url || defaultFbxUrl;
80
- const northRad = data?.north_rad || defaultNorthRad;
104
+ const load = (data) => __awaiter(void 0, void 0, void 0, function* () {
105
+ const fbxUrl = (data === null || data === void 0 ? void 0 : data.fbx_url) || defaultFbxUrl;
106
+ const northRad = (data === null || data === void 0 ? void 0 : data.north_rad) || defaultNorthRad;
81
107
  if (!northRad) {
82
108
  throw new Error('"northRad"配置参数缺失:未配置指南针指向!');
83
109
  }
@@ -86,7 +112,7 @@ const ModelChassisCompassPlugin = (five, params) => {
86
112
  const zOffset = bounding.max.z - bounding.min.z;
87
113
  const maxOffset = Math.max(xOffset, zOffset);
88
114
  const fbxLoader = new FBXLoader.FBXLoader();
89
- const object = await fbxLoader.loadAsync(fbxUrl);
115
+ const object = yield fbxLoader.loadAsync(fbxUrl);
90
116
  transfromToMeshBasicMaterial(object, {
91
117
  transparent: true,
92
118
  side: THREE__namespace.DoubleSide,
@@ -100,7 +126,7 @@ const ModelChassisCompassPlugin = (five, params) => {
100
126
  bject3d2LocalMatrix(object, { position, rotation, scale });
101
127
  state.object = object;
102
128
  return true;
103
- };
129
+ });
104
130
  const onCameraUpdate = ({ latitude }) => {
105
131
  if (!state.object)
106
132
  return;
@@ -25,12 +25,38 @@ function _interopNamespace(e) {
25
25
 
26
26
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
27
27
 
28
+ /*! *****************************************************************************
29
+ Copyright (c) Microsoft Corporation.
30
+
31
+ Permission to use, copy, modify, and/or distribute this software for any
32
+ purpose with or without fee is hereby granted.
33
+
34
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
35
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
37
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
+ PERFORMANCE OF THIS SOFTWARE.
41
+ ***************************************************************************** */
42
+
43
+ function __awaiter(thisArg, _arguments, P, generator) {
44
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
45
+ return new (P || (P = Promise))(function (resolve, reject) {
46
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
47
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
48
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
49
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
50
+ });
51
+ }
52
+
28
53
  function createCanvasTextTexture(text, config) {
29
- const size = config?.size ?? 512;
30
- const fontSize = config?.fontSize ?? size * (35 / 256) * 1.2;
31
- const backgroundColor = config?.backgroundColor ?? 'rgba(0,0,0,0)';
32
- const fontColor = config?.fontColor ?? '#fff';
33
- const textAlign = config?.textAlign ?? 'center';
54
+ var _a, _b, _c, _d, _e;
55
+ const size = (_a = config === null || config === void 0 ? void 0 : config.size) !== null && _a !== void 0 ? _a : 512;
56
+ const fontSize = (_b = config === null || config === void 0 ? void 0 : config.fontSize) !== null && _b !== void 0 ? _b : size * (35 / 256) * 1.2;
57
+ const backgroundColor = (_c = config === null || config === void 0 ? void 0 : config.backgroundColor) !== null && _c !== void 0 ? _c : 'rgba(0,0,0,0)';
58
+ const fontColor = (_d = config === null || config === void 0 ? void 0 : config.fontColor) !== null && _d !== void 0 ? _d : '#fff';
59
+ const textAlign = (_e = config === null || config === void 0 ? void 0 : config.textAlign) !== null && _e !== void 0 ? _e : 'center';
34
60
  const canvas = document.createElement('canvas');
35
61
  canvas.setAttribute('width', size + '');
36
62
  canvas.setAttribute('height', size + '');
@@ -48,12 +74,13 @@ const transformPositionToVector3 = ({ x, y, z }) => new THREE.Vector3(x, y, z);
48
74
 
49
75
  function transfromToMeshBasicMaterial(object, options) {
50
76
  object.traverse((ele) => {
77
+ var _a;
51
78
  if (ele.type === 'Mesh') {
52
79
  const mesh = ele;
53
80
  const materialConf = Object.assign({ map: mesh.material.map || {} }, options);
54
81
  mesh.material = new THREE.MeshBasicMaterial(materialConf);
55
82
  mesh.renderOrder = 1;
56
- if (ele.parent?.type === 'Mesh') {
83
+ if (((_a = ele.parent) === null || _a === void 0 ? void 0 : _a.type) === 'Mesh') {
57
84
  ele.renderOrder = ele.parent.renderOrder + 1;
58
85
  }
59
86
  }
@@ -64,31 +91,33 @@ function transfromToMeshBasicMaterial(object, options) {
64
91
  * 模型入户门引导插件
65
92
  */
66
93
  const ModelEntryDoorGuidePlugin = (five, params) => {
94
+ var _a, _b, _c;
67
95
  // 局部状态
68
96
  const state = {};
69
- const defaultAnimationEnable = params.animationEnabled ?? true;
70
- const defaultModelPosition = params.position ?? undefined;
71
- const defaultRad = params.rad ?? undefined;
97
+ const defaultAnimationEnable = (_a = params.animationEnabled) !== null && _a !== void 0 ? _a : true;
98
+ const defaultModelPosition = (_b = params.position) !== null && _b !== void 0 ? _b : undefined;
99
+ const defaultRad = (_c = params.rad) !== null && _c !== void 0 ? _c : undefined;
72
100
  const defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
73
101
  const mixers = [];
74
- const load = async (data) => {
75
- const position = data?.position ?? defaultModelPosition;
102
+ const load = (data) => __awaiter(void 0, void 0, void 0, function* () {
103
+ var _d, _e, _f, _g, _h, _j, _k;
104
+ const position = (_d = data === null || data === void 0 ? void 0 : data.position) !== null && _d !== void 0 ? _d : defaultModelPosition;
76
105
  if (!position)
77
106
  return Promise.reject(`ModelEntryDoorGuidePlugin.load(): position is undefined`);
78
107
  const modelPosition = transformPositionToVector3(position);
79
- const rad = data?.rad ?? defaultRad;
80
- const fbxUrl = data?.fbx_url ?? defaultFbxUrl;
108
+ const rad = (_e = data === null || data === void 0 ? void 0 : data.rad) !== null && _e !== void 0 ? _e : defaultRad;
109
+ const fbxUrl = (_f = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _f !== void 0 ? _f : defaultFbxUrl;
81
110
  state.rad = rad;
82
111
  if (rad === undefined)
83
112
  return Promise.reject(`ModelEntryDoorGuidePlugin.load(): rad is ${rad}`);
84
113
  // 加载模型
85
- const object = await new FBXLoader.FBXLoader().loadAsync(fbxUrl);
114
+ const object = yield new FBXLoader.FBXLoader().loadAsync(fbxUrl);
86
115
  // 设置位置
87
116
  object.position.copy(modelPosition);
88
117
  object.rotation.z = rad;
89
118
  object.scale.set(0.8, 0.8, 0.8);
90
119
  transfromToMeshBasicMaterial(object, { transparent: true, side: THREE__namespace.DoubleSide });
91
- const textMesh = object.children?.[0]?.children?.[3]?.clone();
120
+ const textMesh = (_k = (_j = (_h = (_g = object.children) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.children) === null || _j === void 0 ? void 0 : _j[3]) === null || _k === void 0 ? void 0 : _k.clone();
92
121
  if (!textMesh)
93
122
  return Promise.reject(`ModelEntryDoorGuidePlugin.load(): textMesh is ${textMesh}`);
94
123
  textMesh.material = new THREE.MeshBasicMaterial({ transparent: true, map: createCanvasTextTexture('入户门') });
@@ -96,7 +125,7 @@ const ModelEntryDoorGuidePlugin = (five, params) => {
96
125
  object.children[0].add(textMesh);
97
126
  state.object = object;
98
127
  return true;
99
- };
128
+ });
100
129
  const initAnimation = () => {
101
130
  if (state.animation)
102
131
  return;
@@ -140,16 +169,17 @@ const ModelEntryDoorGuidePlugin = (five, params) => {
140
169
  };
141
170
  const stop = () => {
142
171
  action.stop();
143
- stopAnimation?.();
172
+ stopAnimation === null || stopAnimation === void 0 ? void 0 : stopAnimation();
144
173
  stopAnimation = undefined;
145
174
  };
146
175
  const animation = { play, stop };
147
176
  state.animation = animation;
148
177
  };
149
178
  const show = (config) => {
179
+ var _a;
150
180
  if (!state.object)
151
181
  return console.error('ModelEntryDoorGuidePlugin.enable(): object is ', state.object);
152
- const animationEnable = config?.animationEnable ?? defaultAnimationEnable;
182
+ const animationEnable = (_a = config === null || config === void 0 ? void 0 : config.animationEnable) !== null && _a !== void 0 ? _a : defaultAnimationEnable;
153
183
  if (animationEnable) {
154
184
  if (!state.animation)
155
185
  initAnimation();
@@ -321,8 +321,15 @@ function instance($$self, $$props, $$invalidate) {
321
321
  const getLabelCssOffset = (five, itemLabel) => {
322
322
  const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
323
323
  const cssPosition = five.project2d(modelPosition);
324
- const xOffset = cssPosition?.x;
325
- const yOffset = cssPosition?.y;
324
+
325
+ const xOffset = cssPosition === null || cssPosition === void 0
326
+ ? void 0
327
+ : cssPosition.x;
328
+
329
+ const yOffset = cssPosition === null || cssPosition === void 0
330
+ ? void 0
331
+ : cssPosition.y;
332
+
326
333
  return [xOffset, yOffset];
327
334
  };
328
335
 
@@ -364,18 +371,13 @@ function instance($$self, $$props, $$invalidate) {
364
371
  : true;
365
372
 
366
373
  const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth);
367
- if (!visible) return { ...label, visible };
374
+ if (!visible) return Object.assign(Object.assign({}, label), { visible });
368
375
  cssOffsetLists.push(cssOffset);
369
376
 
370
377
  // position
371
378
  const transform = getLabelTransform(cssOffset);
372
379
 
373
- return {
374
- ...label,
375
- visible,
376
- transform,
377
- strokeLength
378
- };
380
+ return Object.assign(Object.assign({}, label), { visible, transform, strokeLength });
379
381
  });
380
382
 
381
383
  const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
@@ -385,7 +387,7 @@ function instance($$self, $$props, $$invalidate) {
385
387
 
386
388
  return newLabels.map(label => {
387
389
  const sortIndex = sortedItemLabelItems.findIndex(item => item.itemLabelItem.id === label.id);
388
- if (sortIndex !== undefined) return { ...label, zIndex: sortIndex * 10 };
390
+ if (sortIndex !== undefined) return Object.assign(Object.assign({}, label), { zIndex: sortIndex * 10 });
389
391
  return label;
390
392
  });
391
393
  };
@@ -502,13 +504,11 @@ class ItemLabelComponent extends internal.SvelteComponent {
502
504
 
503
505
  /** @description 转成内部所需数据 */
504
506
  function parseModelItemLabelPluginData(data) {
505
- return data.model_item_labels.map(label => ({
506
- modelPosition: [label.position[0], label.position[1] + label.size[1], label.position[2]],
507
- ...label
508
- }));
507
+ return data.model_item_labels.map(label => (Object.assign({ modelPosition: [label.position[0], label.position[1] + label.size[1], label.position[2]] }, label)));
509
508
  }
510
509
 
511
510
  const ModelItemLabelPlugin = (five$1, params) => {
511
+ var _a, _b;
512
512
  const pluginState = {
513
513
  container: document.createElement('div'),
514
514
  data: null,
@@ -518,8 +518,8 @@ const ModelItemLabelPlugin = (five$1, params) => {
518
518
  wrapper: null,
519
519
  app: undefined,
520
520
  hooks: new five.Subscribe(),
521
- modelOcclusionEnable: params?.modelOcclusionEnable ?? true,
522
- displayStrategyType: params?.displayStrategyType ?? DISPLAY_STRATEGY_TYPE.SMALL
521
+ modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
522
+ displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : DISPLAY_STRATEGY_TYPE.SMALL
523
523
  };
524
524
  pluginState.container.setAttribute('class', 'model-item-label-plugin-container');
525
525
  pluginState.container.style.cssText = `
@@ -594,11 +594,12 @@ const ModelItemLabelPlugin = (five$1, params) => {
594
594
  render();
595
595
  };
596
596
  const render = () => {
597
+ var _a;
597
598
  if (!pluginState.wrapper)
598
599
  return;
599
600
  // 只要不可展示,销毁容器
600
601
  if (!pluginState.enabled || !pluginState.fiveModeEnabled) {
601
- pluginState.app?.$destroy();
602
+ (_a = pluginState.app) === null || _a === void 0 ? void 0 : _a.$destroy();
602
603
  pluginState.app = undefined;
603
604
  return;
604
605
  }
@@ -278,12 +278,12 @@ function instance($$self, $$props, $$invalidate) {
278
278
  // 计算是否可见,如果不可见,不会更新位置
279
279
  const visible = getLabelVisible(five, roomLabelItem);
280
280
 
281
- if (!visible) return { ...roomLabelItem, visible };
281
+ if (!visible) return Object.assign(Object.assign({}, roomLabelItem), { visible });
282
282
 
283
283
  // 更新位置
284
284
  const transform = getLabelTransform(five, roomLabelItem);
285
285
 
286
- return { ...roomLabelItem, visible, transform };
286
+ return Object.assign(Object.assign({}, roomLabelItem), { visible, transform });
287
287
  });
288
288
 
289
289
  const sortedRoomLabelItems = newLabels.filter(({ visible }) => visible).map(roomLabelItem => ({
@@ -293,7 +293,7 @@ function instance($$self, $$props, $$invalidate) {
293
293
 
294
294
  return newLabels.map(roomLabelItem => {
295
295
  const sortIndex = sortedRoomLabelItems.findIndex(item => item.roomLabelItem.id === roomLabelItem.id);
296
- if (sortIndex !== undefined) return { ...roomLabelItem, zIndex: sortIndex * 10 };
296
+ if (sortIndex !== undefined) return Object.assign(Object.assign({}, roomLabelItem), { zIndex: sortIndex * 10 });
297
297
  return roomLabelItem;
298
298
  });
299
299
  }
@@ -352,14 +352,69 @@ function parseModelRoomLabelPluginData(data) {
352
352
  }
353
353
 
354
354
  class ModelRoomLabelController {
355
- five;
356
- enabled = true;
357
- fiveModeEnabled;
358
- app = undefined;
359
- wrapper;
360
- roomLabels = [];
361
- container = document.createElement('div');
362
355
  constructor(five) {
356
+ Object.defineProperty(this, "five", {
357
+ enumerable: true,
358
+ configurable: true,
359
+ writable: true,
360
+ value: void 0
361
+ });
362
+ Object.defineProperty(this, "enabled", {
363
+ enumerable: true,
364
+ configurable: true,
365
+ writable: true,
366
+ value: true
367
+ });
368
+ Object.defineProperty(this, "fiveModeEnabled", {
369
+ enumerable: true,
370
+ configurable: true,
371
+ writable: true,
372
+ value: void 0
373
+ });
374
+ Object.defineProperty(this, "app", {
375
+ enumerable: true,
376
+ configurable: true,
377
+ writable: true,
378
+ value: undefined
379
+ });
380
+ Object.defineProperty(this, "wrapper", {
381
+ enumerable: true,
382
+ configurable: true,
383
+ writable: true,
384
+ value: void 0
385
+ });
386
+ Object.defineProperty(this, "roomLabels", {
387
+ enumerable: true,
388
+ configurable: true,
389
+ writable: true,
390
+ value: []
391
+ });
392
+ Object.defineProperty(this, "container", {
393
+ enumerable: true,
394
+ configurable: true,
395
+ writable: true,
396
+ value: document.createElement('div')
397
+ });
398
+ /** 监听 Five Mode 变化
399
+ * @description
400
+ * Mode 不符合要求时,立刻消失,满足要求时,需要等待动画结束再展示
401
+ */
402
+ Object.defineProperty(this, "onFiveModeChange", {
403
+ enumerable: true,
404
+ configurable: true,
405
+ writable: true,
406
+ value: (mode) => {
407
+ if (mode !== 'Floorplan') {
408
+ this.fiveModeEnabled = false;
409
+ this.render();
410
+ return;
411
+ }
412
+ this.five.once('initAnimationEnded', () => {
413
+ this.fiveModeEnabled = this.five.currentMode === 'Floorplan';
414
+ this.render();
415
+ });
416
+ }
417
+ });
363
418
  this.five = five;
364
419
  this.fiveModeEnabled = this.five.currentMode === 'Floorplan';
365
420
  // init container style
@@ -412,26 +467,12 @@ class ModelRoomLabelController {
412
467
  this.render();
413
468
  return this;
414
469
  }
415
- /** 监听 Five Mode 变化
416
- * @description
417
- * Mode 不符合要求时,立刻消失,满足要求时,需要等待动画结束再展示
418
- */
419
- onFiveModeChange = (mode) => {
420
- if (mode !== 'Floorplan') {
421
- this.fiveModeEnabled = false;
422
- this.render();
423
- return;
424
- }
425
- this.five.once('initAnimationEnded', () => {
426
- this.fiveModeEnabled = this.five.currentMode === 'Floorplan';
427
- this.render();
428
- });
429
- };
430
470
  render() {
471
+ var _a;
431
472
  if (!this.wrapper)
432
473
  return;
433
474
  if (!this.enabled || !this.fiveModeEnabled) {
434
- this.app?.$destroy();
475
+ (_a = this.app) === null || _a === void 0 ? void 0 : _a.$destroy();
435
476
  this.app = undefined;
436
477
  return;
437
478
  }