@realsee/dnalogel 2.0.0-alpha.3 → 2.0.0-alpha.6

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 (64) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/TERMS.txt +56 -0
  3. package/dist/dnalogel.cjs.js +2 -2
  4. package/dist/dnalogel.es.js +697 -62
  5. package/dist/dnalogel.umd.js +2 -2
  6. package/dist/style.css +1 -1
  7. package/docs/.nojekyll +1 -0
  8. package/docs/assets/highlight.css +29 -0
  9. package/docs/assets/icons.css +1043 -0
  10. package/docs/assets/icons.png +0 -0
  11. package/docs/assets/icons@2x.png +0 -0
  12. package/docs/assets/main.js +52 -0
  13. package/docs/assets/search.js +1 -0
  14. package/docs/assets/style.css +1413 -0
  15. package/docs/assets/widgets.png +0 -0
  16. package/docs/assets/widgets@2x.png +0 -0
  17. package/docs/classes/ModelRoomLabelController.html +20 -0
  18. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -0
  19. package/docs/enums/ModelFloorplanErrorType.html +1 -0
  20. package/docs/index.html +10 -0
  21. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -0
  22. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -0
  23. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -0
  24. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -0
  25. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -0
  26. package/docs/interfaces/ModelFloorplanParameterType.html +1 -0
  27. package/docs/interfaces/ModelFloorplanViewEvent.html +5 -0
  28. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -0
  29. package/docs/interfaces/PanoCompassPluginData.html +1 -0
  30. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -0
  31. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +11 -0
  32. package/docs/interfaces/PanoRulerPluginExportType.html +1 -0
  33. package/docs/interfaces/PanoRulerPluginOptions.html +1 -0
  34. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -0
  35. package/docs/interfaces/RoomLabel.html +13 -0
  36. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -0
  37. package/docs/modules.html +26 -0
  38. package/libs/CSS3DRenderPlugin/index.js +1 -1
  39. package/libs/PanoCompassPlugin/Assets/roomInfoIcon.d.ts +1 -0
  40. package/libs/PanoCompassPlugin/Assets/roomInfoIcon.js +1 -0
  41. package/libs/PanoCompassPlugin/getRoomInfoInstance.d.ts +8 -0
  42. package/libs/PanoCompassPlugin/getRoomInfoInstance.js +48 -0
  43. package/libs/PanoCompassPlugin/index.d.ts +29 -3
  44. package/libs/PanoCompassPlugin/index.js +106 -36
  45. package/libs/PanoRulerPlugin/index.d.ts +31 -0
  46. package/libs/PanoRulerPlugin/index.js +398 -0
  47. package/libs/PanoRulerPlugin/style.d.ts +2 -0
  48. package/libs/PanoRulerPlugin/style.js +88 -0
  49. package/libs/PanoRulerPlugin/typings.d.ts +21 -0
  50. package/libs/PanoRulerPlugin/typings.js +1 -0
  51. package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.svelte +3 -3
  52. package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.svelte.map +1 -1
  53. package/libs/floorplan/ModelFloorplanPlugin/Controller.d.ts +2 -0
  54. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +3 -1
  55. package/libs/floorplan/TopviewFloorplanPlugin/Controller.d.ts +2 -0
  56. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +4 -3
  57. package/libs/floorplan/constant.d.ts +5 -0
  58. package/libs/floorplan/constant.js +6 -0
  59. package/libs/floorplan/typings/floorplanServerData.d.ts +4 -0
  60. package/libs/index.d.ts +4 -1
  61. package/libs/index.js +4 -1
  62. package/libs/shared-utils/getPxmm.d.ts +6 -1
  63. package/libs/shared-utils/getPxmm.js +26 -12
  64. package/package.json +4 -2
@@ -317,7 +317,7 @@ const CSS3DRenderPlugin = (five) => {
317
317
  const rotateXAngle = new Vector3$1(0, 1, 0).angleTo(new Vector3$1(0, vector12.y, vector12.z));
318
318
  const rotateYAngle = new Vector3$1(1, 0, 0).angleTo(new Vector3$1(vector01.x, 0, vector01.z));
319
319
  const rotateZAngle = vector01.angleTo(new Vector3$1(vector01.x, 0, vector01.z));
320
- const rotateX = (vector12.z > 0 ? 1 : -1) * rotateXAngle;
320
+ const rotateX = (vector12.z > 0 ? -1 : 1) * rotateXAngle;
321
321
  const rotateY = (vector01.z < 0 ? 1 : -1) * rotateYAngle;
322
322
  const rotateZ = (vector01.x > 0 && vector01.y < 0 || vector01.x < 0 && vector01.y > 0 ? -1 : 1) * rotateZAngle;
323
323
  css3DObject.rotateOnWorldAxis(new Vector3$1(1, 0, 0), rotateX);
@@ -1476,6 +1476,12 @@ class ModelRoomLabelController {
1476
1476
  const ModelRoomLabelPlugin = (five) => {
1477
1477
  return new ModelRoomLabelController(five);
1478
1478
  };
1479
+ var FLOOR_PLAN_ATTACHED_TO = /* @__PURE__ */ ((FLOOR_PLAN_ATTACHED_TO2) => {
1480
+ FLOOR_PLAN_ATTACHED_TO2[FLOOR_PLAN_ATTACHED_TO2["FLOOR"] = 1] = "FLOOR";
1481
+ FLOOR_PLAN_ATTACHED_TO2[FLOOR_PLAN_ATTACHED_TO2["CEILING"] = 2] = "CEILING";
1482
+ FLOOR_PLAN_ATTACHED_TO2[FLOOR_PLAN_ATTACHED_TO2["BOUNDING_CENTER"] = 3] = "BOUNDING_CENTER";
1483
+ return FLOOR_PLAN_ATTACHED_TO2;
1484
+ })(FLOOR_PLAN_ATTACHED_TO || {});
1479
1485
  const pluginStyle = {
1480
1486
  position: "absolute",
1481
1487
  left: "50%",
@@ -1634,16 +1640,27 @@ function omit(object, props) {
1634
1640
  }
1635
1641
  });
1636
1642
  }
1637
- function getPxmm(five, container) {
1638
- const boundingCenter = new THREE.Vector3(0, 0, 0);
1639
- five.model.bounding.getCenter(boundingCenter);
1640
- const { y: boundingCenterY } = boundingCenter;
1641
- const { longitude } = five.getCurrentState();
1642
- const X2 = 1 / Math.abs(Math.cos(longitude));
1643
- const originPosition = new THREE.Vector3(0, boundingCenterY, 0);
1644
- const originPositionXUnit = new THREE.Vector3(X2, boundingCenterY, 0);
1645
- const mouse = originPosition.project(five.camera);
1646
- const xUnitMouse = originPositionXUnit.project(five.camera);
1643
+ function getPxmm(five, container, floorIndex, options) {
1644
+ const maxFloorIndex = Math.max(...five.work.observers.map((ob) => ob.floorIndex));
1645
+ function getFloorY(floorIndex2) {
1646
+ return floorIndex2 > maxFloorIndex ? five.model.bounding.max.y : Math.max(...five.work.observers.filter((ob) => ob.floorIndex === floorIndex2).map((ob) => ob.standingPosition.y));
1647
+ }
1648
+ function getY() {
1649
+ const currentFloorY = getFloorY(floorIndex);
1650
+ const nextFloorY = getFloorY(floorIndex + 1);
1651
+ const attachedTo = (options == null ? void 0 : options.attachedTo) || FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER;
1652
+ if (attachedTo === FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER)
1653
+ return (five.model.bounding.max.y + five.model.bounding.min.y) / 2;
1654
+ else if (attachedTo === FLOOR_PLAN_ATTACHED_TO.CEILING)
1655
+ return nextFloorY;
1656
+ else
1657
+ return currentFloorY;
1658
+ }
1659
+ const y2 = getY();
1660
+ const originPosition = new THREE.Vector3(0, y2, 0);
1661
+ const originPositionXUnit = new THREE.Vector3(1, y2, 0);
1662
+ const mouse = originPosition.clone().project(five.camera);
1663
+ const xUnitMouse = originPositionXUnit.clone().project(five.camera);
1647
1664
  const pxmm = Math.abs((xUnitMouse.x - mouse.x) / 1e3) * (container.getBoundingClientRect().width / 2);
1648
1665
  return pxmm;
1649
1666
  }
@@ -1659,12 +1676,15 @@ function create_fragment$k(ctx) {
1659
1676
  c() {
1660
1677
  div1 = element("div");
1661
1678
  div0 = element("div");
1662
- attr(div0, "class", "floorplan__camera-rotate svelte-1kosz2p");
1679
+ attr(div0, "class", "floorplan__camera-rotate svelte-e8a2kn");
1663
1680
  set_style(div0, "background-image", `url(${ctx[0] || CAMERA_IMAGE})`);
1664
1681
  set_style(div0, "width", ctx[4], false);
1665
1682
  set_style(div0, "height", ctx[4], false);
1683
+ set_style(div0, "left", "-" + ctx[4], false);
1684
+ set_style(div0, "top", "-" + ctx[4], false);
1666
1685
  set_style(div0, "transform", `rotate(${ctx[3]}deg)`, false);
1667
- attr(div1, "class", "floorplan__camera-position svelte-1kosz2p");
1686
+ set_style(div0, "transform-origin", `${ctx[4]} ${ctx[4]}`, false);
1687
+ attr(div1, "class", "floorplan__camera-position svelte-e8a2kn");
1668
1688
  set_style(div1, "left", ctx[1], false);
1669
1689
  set_style(div1, "top", ctx[2], false);
1670
1690
  },
@@ -4384,6 +4404,7 @@ class TopviewFloorplanPluginController {
4384
4404
  if (shownFloor === null)
4385
4405
  return;
4386
4406
  this.floorIndex = shownFloor;
4407
+ this.updateSize();
4387
4408
  this.render();
4388
4409
  });
4389
4410
  __publicField(this, "handlePanoArrived", (index) => {
@@ -4435,7 +4456,8 @@ class TopviewFloorplanPluginController {
4435
4456
  const { min, max } = this.floorplanData.bounding;
4436
4457
  const width = max.x - min.x;
4437
4458
  const height = max.y - min.y;
4438
- const pxmm = getPxmm(this.five, this.wrapper);
4459
+ const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : void 0;
4460
+ const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
4439
4461
  const _width = Math.ceil(width * pxmm);
4440
4462
  const _height = Math.ceil(height * pxmm);
4441
4463
  this.pxmm = pxmm;
@@ -4467,8 +4489,8 @@ class TopviewFloorplanPluginController {
4467
4489
  }
4468
4490
  show() {
4469
4491
  this.visible = true;
4470
- this.updateSize();
4471
4492
  this.five.model.show(this.floorIndex);
4493
+ this.updateSize();
4472
4494
  const renderDuration = 500;
4473
4495
  const modelOpacity = this.configs.modelOpacity;
4474
4496
  if (typeof modelOpacity === "number") {
@@ -4502,7 +4524,6 @@ class TopviewFloorplanPluginController {
4502
4524
  ruleLabelsEnable
4503
4525
  } = this.configs;
4504
4526
  const handleClick = preventRoomClick ? () => false : void 0;
4505
- console.log("\u{1F680} ~ TopviewFloorplanPluginController ~ handleClick", handleClick);
4506
4527
  const props = {
4507
4528
  five: this.five,
4508
4529
  pxmm: this.pxmm,
@@ -5482,7 +5503,8 @@ class ModelFloorplanPluginController {
5482
5503
  const { min, max } = this.floorplanData.bounding;
5483
5504
  const width = max.x - min.x;
5484
5505
  const height = max.y - min.y;
5485
- const pxmm = getPxmm(this.five, this.wrapper);
5506
+ const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : void 0;
5507
+ const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
5486
5508
  const _width = Math.ceil(width * pxmm);
5487
5509
  const _height = Math.ceil(height * pxmm);
5488
5510
  if (this.size.width === _width && this.size.height === _height)
@@ -5574,6 +5596,7 @@ class ModelFloorplanPluginController {
5574
5596
  if (shownFloor === null)
5575
5597
  return;
5576
5598
  this.floorIndex = shownFloor;
5599
+ this.updateSize();
5577
5600
  this.render();
5578
5601
  });
5579
5602
  __publicField(this, "handleModelLoaded", () => {
@@ -36959,11 +36982,11 @@ var exports = {
36959
36982
  };
36960
36983
  const _requestAnimationFrame = window.requestAnimationFrame || ((fn) => setTimeout(fn, 16));
36961
36984
  const _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
36962
- function nextFrame(fn, delay = 0) {
36985
+ function nextFrame$1(fn, delay = 0) {
36963
36986
  if (delay <= 0)
36964
36987
  _requestAnimationFrame(fn);
36965
36988
  else
36966
- _requestAnimationFrame(() => nextFrame(fn, delay - 1));
36989
+ _requestAnimationFrame(() => nextFrame$1(fn, delay - 1));
36967
36990
  }
36968
36991
  function requestAnimationFrameInterval(callback, frame = 60) {
36969
36992
  let index = -1;
@@ -36987,7 +37010,7 @@ function requestAnimationFrameInterval(callback, frame = 60) {
36987
37010
  const Easing = Easing$1;
36988
37011
  function tween(from, to2, duration, easing = Easing.Linear.None) {
36989
37012
  const tween2 = new Tween(from).to(to2, duration).easing(easing);
36990
- nextFrame(() => tween2.start(0));
37013
+ nextFrame$1(() => tween2.start(0));
36991
37014
  const cancelAnimationFrame2 = requestAnimationFrameInterval((time) => {
36992
37015
  if (tween2.update(time) === false)
36993
37016
  cancelAnimationFrame2();
@@ -37159,6 +37182,561 @@ const CameraMovementPlugin = (five) => {
37159
37182
  rotate
37160
37183
  };
37161
37184
  };
37185
+ function samePointAt(point1, point2) {
37186
+ return point1.x === point2.x && point1.y === point2.y;
37187
+ }
37188
+ function sameK(k1, k2) {
37189
+ if (Math.abs(k1) === Infinity && Math.abs(k2) === Infinity)
37190
+ return true;
37191
+ return Math.abs(k1 - k2) < 1e-3;
37192
+ }
37193
+ function getK(point1, point2) {
37194
+ return (point2.y - point1.y) / (point2.x - point1.x);
37195
+ }
37196
+ function intersectionOfLine(linePoints1, linePoints2, needIntersectionInLine) {
37197
+ const k1 = getK(linePoints1[1], linePoints1[0]);
37198
+ const k2 = getK(linePoints2[1], linePoints2[0]);
37199
+ if (isNaN(k1) || isNaN(k2))
37200
+ return false;
37201
+ if (sameK(k1, k2))
37202
+ return false;
37203
+ if (pointOnLine(linePoints1[0], linePoints2))
37204
+ return linePoints1[0];
37205
+ if (pointOnLine(linePoints1[1], linePoints2))
37206
+ return linePoints1[1];
37207
+ if (pointOnLine(linePoints2[0], linePoints1))
37208
+ return linePoints2[0];
37209
+ if (pointOnLine(linePoints2[1], linePoints1))
37210
+ return linePoints2[1];
37211
+ if (needIntersectionInLine && !isIntersect(linePoints1, linePoints2))
37212
+ return false;
37213
+ const p1 = linePoints1[0];
37214
+ const p2 = linePoints2[0];
37215
+ if (Math.abs(k1) === Infinity) {
37216
+ return { x: p1.x, y: linePoints2[1].y - (linePoints2[1].x - p1.x) * k2 };
37217
+ }
37218
+ if (Math.abs(k2) === Infinity) {
37219
+ return { x: p2.x, y: linePoints1[1].y - (linePoints1[1].x - p2.x) * k1 };
37220
+ }
37221
+ const x = (p2.y - p1.y + k1 * p1.x - k2 * p2.x) / (k1 - k2);
37222
+ const y2 = k1 * x - k1 * p1.x + p1.y;
37223
+ return { x, y: y2 };
37224
+ }
37225
+ function pointOnLine(point, linePoints) {
37226
+ if (samePointAt(point, linePoints[0]))
37227
+ return true;
37228
+ if (samePointAt(point, linePoints[1]))
37229
+ return true;
37230
+ return (linePoints[0].x - point.x) * (point.x - linePoints[1].x) >= 0 && (linePoints[0].y - point.y) * (point.y - linePoints[1].y) >= 0 && sameK(getK(linePoints[0], point), getK(point, linePoints[1]));
37231
+ }
37232
+ function multi(p1, p2, p0) {
37233
+ return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
37234
+ }
37235
+ function isIntersect(linePoints1, linePoints2) {
37236
+ if (Math.max(linePoints1[0].x, linePoints1[1].x) >= Math.min(linePoints2[0].x, linePoints2[1].x) && Math.max(linePoints2[0].x, linePoints2[1].x) >= Math.min(linePoints1[0].x, linePoints1[1].x) && Math.max(linePoints1[0].y, linePoints1[1].y) >= Math.min(linePoints2[0].y, linePoints2[1].y) && multi(linePoints2[0], linePoints1[1], linePoints1[0]) * multi(linePoints1[1], linePoints2[1], linePoints1[0]) > 0 && multi(linePoints1[0], linePoints2[1], linePoints2[0]) * multi(linePoints2[1], linePoints1[1], linePoints2[0]) > 0)
37237
+ return 1;
37238
+ return 0;
37239
+ }
37240
+ function nextFrame(fn, delay = 0) {
37241
+ if (delay <= 0)
37242
+ requestAnimationFrame(fn);
37243
+ else
37244
+ requestAnimationFrame(() => nextFrame(fn, delay - 1));
37245
+ }
37246
+ const PanoRulerStyle = `<style type="text/css">
37247
+ .PanoRulerPlugin-rule-line {
37248
+ position: absolute;
37249
+ transform-origin: left center;
37250
+ width: 0;
37251
+ height: 0.0625rem;
37252
+ }
37253
+
37254
+ .PanoRulerPlugin-rule-line::after {
37255
+ content: '';
37256
+ position: absolute;
37257
+ left: -0.125rem;
37258
+ top: -0.1rem;
37259
+ width: 0.25rem;
37260
+ height: 0.25rem;
37261
+ border-radius: 50%;
37262
+ background: #FFFFFF;
37263
+ z-index: 1;
37264
+ animation: viewport-rule-point 0.1s 1s;
37265
+ animation-fill-mode: both;
37266
+ }
37267
+
37268
+ .PanoRulerPlugin-rule-line::before {
37269
+ content: '';
37270
+ position: absolute;
37271
+ right: -0.125rem;
37272
+ top: -0.1rem;
37273
+ width: 0.25rem;
37274
+ height: 0.25rem;
37275
+ border-radius: 50%;
37276
+ background: #FFFFFF;
37277
+ animation: viewport-rule-point 0.1s 1.5s;
37278
+ animation-fill-mode: both;
37279
+ }
37280
+
37281
+ .PanoRulerPlugin-rule-line em {
37282
+ background: #fff;
37283
+ display: block;
37284
+ height: 100%;
37285
+ animation: viewport-rule-line 0.5s ease 1s;
37286
+ animation-fill-mode: both;
37287
+ box-shadow: 0 0 0.25rem rgb(0 0 0 / 40%);
37288
+ }
37289
+
37290
+ .PanoRulerPlugin-rule-label {
37291
+ position: absolute;
37292
+ width: 0;
37293
+ height: 0;
37294
+ top: 0.0625rem;
37295
+ }
37296
+
37297
+ .PanoRulerPlugin-rule-label-name {
37298
+ position: absolute;
37299
+ padding: 0.1875rem 0.375rem;
37300
+ background: rgba(195,195,195,0.30);
37301
+ backdrop-filter: blur(0.25rem);
37302
+ -webkit-backdrop-filter: blur(0.25rem);
37303
+ border-radius: 6.25rem;
37304
+ border: 0.0625rem solid rgba(255,255,255,0.6);
37305
+ white-space: nowrap;
37306
+ overflow: hidden;
37307
+ color: #FFFFFF;
37308
+ font-weight: 500;
37309
+ font-size: 0.75rem;
37310
+ line-height: 1;
37311
+ -webkit-animation: viewport-rule-label 0.25s ease 1s;
37312
+ animation: viewport-rule-label 0.25s ease 1s;
37313
+ animation-fill-mode: both;
37314
+ box-shadow: inset 0 0 0.625rem 0 rgba(255,255,255,0.30);
37315
+ }
37316
+
37317
+ @keyframes viewport-rule-line {
37318
+ 0% { width: 0% }
37319
+ 100% { width: 100% }
37320
+ }
37321
+
37322
+ @keyframes viewport-rule-label {
37323
+ 0% { opacity: 0; transform: scaleX(0); }
37324
+ 100% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
37325
+ }
37326
+
37327
+ @keyframes viewport-rule-point {
37328
+ 0% { transform: scaleX(0); }
37329
+ 100% { transform: scaleX(1); }
37330
+ }
37331
+ </style>
37332
+ `;
37333
+ const getDistance = (p1, p2) => {
37334
+ return Math.sqrt(Math.pow(p1.z - p2.z, 2) + Math.pow(p1.x - p2.x, 2));
37335
+ };
37336
+ const getRoomHeightInfo = (roomInfo, five) => {
37337
+ const roomHeightInfo = {};
37338
+ const raycaster = new Raycaster$1();
37339
+ const work = five.work;
37340
+ if (!work)
37341
+ return roomHeightInfo;
37342
+ const observers = roomInfo.observers;
37343
+ work.observers.forEach((observer, index) => {
37344
+ const { standingPosition: position } = observer;
37345
+ const point = new Vector3$1(position.x, position.y, position.z);
37346
+ raycaster.set(point, new Vector3$1(0, 1, 0));
37347
+ const [intersection] = five.model.intersectRaycaster(raycaster);
37348
+ const verticalY = intersection ? intersection.point.y : 2.7;
37349
+ const id = observers[index];
37350
+ if (!id)
37351
+ return roomHeightInfo;
37352
+ const observerRoomName = roomInfo.rooms[id].name;
37353
+ if (roomHeightInfo[observerRoomName] === void 0) {
37354
+ roomHeightInfo[observerRoomName] = {
37355
+ __roof: [verticalY],
37356
+ __floor: [point.y]
37357
+ };
37358
+ } else {
37359
+ roomHeightInfo[observerRoomName].__roof.push(verticalY);
37360
+ roomHeightInfo[observerRoomName].__floor.push(point.y);
37361
+ }
37362
+ });
37363
+ for (const roomName in roomHeightInfo) {
37364
+ const room = roomHeightInfo[roomName];
37365
+ room.__roof.sort();
37366
+ room.__floor.sort();
37367
+ room.floor = room.__floor[~~(room.__floor.length / 2)];
37368
+ room.roof = room.__roof[room.__roof.length - 1];
37369
+ }
37370
+ return roomHeightInfo;
37371
+ };
37372
+ const PanoRulerPlugin = (five, params) => {
37373
+ const state = {
37374
+ enable: false,
37375
+ loaded: false,
37376
+ options: params.options || {
37377
+ distanceText: (distance) => `${distance.toFixed(1)}m`
37378
+ }
37379
+ };
37380
+ const tpl = (name, distance) => {
37381
+ const domStr = `
37382
+ <div class="PanoRulerPlugin-rule-line">
37383
+ <em></em>
37384
+ <div class="PanoRulerPlugin-rule-label">
37385
+ <div class="PanoRulerPlugin-rule-label-name">${state.options.distanceText(distance)}</div>
37386
+ </div>
37387
+ </div>
37388
+ `;
37389
+ const res = document.createElement("div");
37390
+ res.setAttribute("class", "PanoRulerPlugin-rule");
37391
+ res.setAttribute("data-name", name);
37392
+ res.setAttribute("style", "display: none");
37393
+ res.innerHTML = domStr;
37394
+ return res;
37395
+ };
37396
+ const $rule = document.createElement("div");
37397
+ $rule.setAttribute("style", `position: absolute;pointer-events: none;width: 100%;height: 100%;left: 0;top: 0;overflow: hidden;`);
37398
+ const style = document.createElement("div");
37399
+ style.innerHTML = PanoRulerStyle;
37400
+ $rule.appendChild(style);
37401
+ const __rule = {};
37402
+ const _load = (roomInfo, roomRules) => {
37403
+ if (state.loaded) {
37404
+ throw new Error("\u6807\u5C3A\u88AB\u91CD\u590D\u521D\u59CB\u5316\uFF01");
37405
+ }
37406
+ const roomHeightInfo = getRoomHeightInfo(roomInfo, five);
37407
+ const work = five.work;
37408
+ if (!work)
37409
+ return false;
37410
+ for (const obKey in roomRules) {
37411
+ const points = roomRules[obKey];
37412
+ const { standingPosition: defaultPosition } = work.observers[0];
37413
+ const roomPoints = points.map(({ x, z, observers }) => {
37414
+ const pointRoomName = observers.length > 0 ? roomInfo.rooms[roomInfo.observers[observers[0]]].name : "";
37415
+ const medianFloorHeight = roomHeightInfo[pointRoomName] ? roomHeightInfo[pointRoomName].floor : null;
37416
+ let minDistance = Infinity;
37417
+ let nearestPoint = {
37418
+ index: 0,
37419
+ x: defaultPosition.x,
37420
+ y: defaultPosition.y,
37421
+ z: defaultPosition.z
37422
+ };
37423
+ observers.forEach((index) => {
37424
+ if (!work.observers[index])
37425
+ return;
37426
+ const { standingPosition: position } = work.observers[index];
37427
+ const observerPoint = {
37428
+ index,
37429
+ x: position.x,
37430
+ y: position.y,
37431
+ z: position.z
37432
+ };
37433
+ const distance = getDistance({ x, z }, observerPoint);
37434
+ if (medianFloorHeight) {
37435
+ if (distance < minDistance && Math.abs(observerPoint.y - medianFloorHeight) < 0.3) {
37436
+ minDistance = distance;
37437
+ nearestPoint = observerPoint;
37438
+ }
37439
+ } else {
37440
+ if (distance < minDistance) {
37441
+ minDistance = distance;
37442
+ nearestPoint = observerPoint;
37443
+ }
37444
+ }
37445
+ });
37446
+ const _origin = new Vector3$1(x, nearestPoint.y, z);
37447
+ Object.assign(_origin, { observers });
37448
+ const verticalY = roomHeightInfo[pointRoomName] ? roomHeightInfo[pointRoomName].roof : null;
37449
+ const _vertical = !verticalY ? null : new Vector3$1(x, verticalY, z);
37450
+ if (_vertical)
37451
+ Object.assign(_vertical, { observers });
37452
+ const origin = _origin;
37453
+ const vertical = _vertical;
37454
+ return { origin, vertical };
37455
+ });
37456
+ __rule[obKey] = {
37457
+ origins: roomPoints.map((roomPoint) => roomPoint.origin),
37458
+ rules: []
37459
+ };
37460
+ for (const { origin, vertical } of roomPoints) {
37461
+ if (!vertical)
37462
+ continue;
37463
+ const $element = tpl(obKey, origin.distanceTo(vertical));
37464
+ $rule.append($element);
37465
+ __rule[obKey].rules.push({ vertical: true, rule: [origin, vertical], $element });
37466
+ }
37467
+ for (let index = 0; index < roomPoints.length; index++) {
37468
+ let nextIndex = index + 1;
37469
+ if (nextIndex >= roomPoints.length)
37470
+ nextIndex = 0;
37471
+ const { origin } = roomPoints[index];
37472
+ const { origin: next } = roomPoints[nextIndex];
37473
+ const $element = tpl(obKey, origin.distanceTo(next));
37474
+ $rule.append($element);
37475
+ __rule[obKey].rules.push({ vertical: false, rule: [origin, next], $element });
37476
+ }
37477
+ }
37478
+ state.loaded = true;
37479
+ return true;
37480
+ };
37481
+ const load = async (_roomInfo, _roomRules, options) => {
37482
+ const roomInfo = _roomInfo || params.roomInfo;
37483
+ const roomRules = _roomRules || params.roomRules;
37484
+ if (!roomInfo || !roomRules) {
37485
+ throw new Error("\u6807\u5C3A\u6570\u636E\u4F9D\u8D56\u4E0D\u9F50\u5168\uFF01");
37486
+ }
37487
+ state.options = Object.assign({}, state.options, options || {});
37488
+ if (five.model.loaded) {
37489
+ return _load(roomInfo, roomRules);
37490
+ } else {
37491
+ return await new Promise((resolve) => five.once("modelLoaded", () => resolve(_load(roomInfo, roomRules))));
37492
+ }
37493
+ };
37494
+ if (params.roomInfo && params.roomRules) {
37495
+ load(params.roomInfo, params.roomRules);
37496
+ }
37497
+ const getRuleScreenIntr = (startPoint, endPoint, canvasWidth, canvasHeight) => {
37498
+ const screenLines = [
37499
+ [
37500
+ { x: 0, y: 0 },
37501
+ { x: canvasWidth, y: 0 }
37502
+ ],
37503
+ [
37504
+ { x: 0, y: 0 },
37505
+ { x: 0, y: canvasHeight }
37506
+ ],
37507
+ [
37508
+ { x: canvasWidth, y: 0 },
37509
+ { x: canvasWidth, y: canvasHeight }
37510
+ ],
37511
+ [
37512
+ { x: 0, y: canvasHeight },
37513
+ { x: canvasWidth, y: canvasHeight }
37514
+ ]
37515
+ ];
37516
+ const intr = [];
37517
+ for (let i = 0; i < screenLines.length; i++) {
37518
+ const result = intersectionOfLine([startPoint, endPoint], [screenLines[i][0], screenLines[i][1]], true);
37519
+ if (result)
37520
+ intr.push(result);
37521
+ }
37522
+ if (intr.length === 0)
37523
+ return false;
37524
+ else {
37525
+ return intr;
37526
+ }
37527
+ };
37528
+ const freshRule = () => {
37529
+ var _a;
37530
+ const element2 = (_a = five.getElement()) == null ? void 0 : _a.parentElement;
37531
+ if (!element2)
37532
+ return;
37533
+ if (!state.loaded)
37534
+ return;
37535
+ if (Object.keys(__rule).length <= 0)
37536
+ return;
37537
+ const { panoIndex, camera, currentMode } = five;
37538
+ if (panoIndex === void 0)
37539
+ return;
37540
+ let name;
37541
+ for (const _name in __rule) {
37542
+ if (_name.split(",").indexOf(panoIndex.toString()) >= 0)
37543
+ name = _name;
37544
+ }
37545
+ if (!name)
37546
+ return;
37547
+ const cameraPosition = camera.position;
37548
+ const cameraDirection = camera.getWorldDirection(new Vector3$1());
37549
+ const width = element2.clientWidth;
37550
+ const height = element2.clientHeight;
37551
+ if (currentMode !== Five.Mode.Panorama) {
37552
+ for (const _name in __rule) {
37553
+ for (const { $element } of __rule[_name].rules) {
37554
+ $element.style.display = "none";
37555
+ }
37556
+ }
37557
+ return;
37558
+ }
37559
+ for (const _name in __rule) {
37560
+ for (const { $element } of __rule[_name].rules) {
37561
+ $element.style.display = _name === name ? "block" : "none";
37562
+ }
37563
+ }
37564
+ const [visibleOrigin] = __rule[name].origins.slice().filter((point) => point.observers.indexOf(panoIndex) >= 0).sort((pointA, pointB) => {
37565
+ const angleA = pointA.clone().setY(0).sub(cameraPosition).normalize().angleTo(cameraDirection.clone().setY(0));
37566
+ const angleB = pointB.clone().setY(0).sub(cameraPosition).normalize().angleTo(cameraDirection.clone().setY(0));
37567
+ return angleA - angleB;
37568
+ });
37569
+ for (const { rule, vertical, $element } of __rule[name].rules) {
37570
+ const [start, end] = rule;
37571
+ const $line = $element.querySelector(".PanoRulerPlugin-rule-line");
37572
+ if (!$line)
37573
+ return;
37574
+ if (!visibleOrigin) {
37575
+ $element.style.display = "none";
37576
+ continue;
37577
+ }
37578
+ if (start !== visibleOrigin && end !== visibleOrigin) {
37579
+ $element.style.display = "none";
37580
+ continue;
37581
+ }
37582
+ if (start.distanceTo(end) < 0.5) {
37583
+ $element.style.display = "none";
37584
+ continue;
37585
+ }
37586
+ if (start.observers.indexOf(panoIndex) === -1 || end.observers.indexOf(panoIndex) === -1) {
37587
+ $element.style.display = "none";
37588
+ continue;
37589
+ }
37590
+ const startAngle = start.clone().sub(cameraPosition).normalize().angleTo(cameraDirection);
37591
+ if (startAngle > Math.PI / 2) {
37592
+ $element.style.display = "none";
37593
+ continue;
37594
+ }
37595
+ const endAngle = end.clone().sub(cameraPosition).normalize().angleTo(cameraDirection);
37596
+ if (endAngle > Math.PI / 2) {
37597
+ $element.style.display = "none";
37598
+ continue;
37599
+ }
37600
+ const ruleLength = start.distanceTo(end);
37601
+ const midPoint = end.clone().sub(end.clone().sub(start).divide(new Vector3$1(2, 2, 2)));
37602
+ const disFromCameraToMid = midPoint.distanceTo(cameraPosition);
37603
+ if (disFromCameraToMid / ruleLength > 8) {
37604
+ $element.style.display = "none";
37605
+ continue;
37606
+ }
37607
+ const mouseStart = start.clone().project(camera);
37608
+ const startLeft = (mouseStart.x + 1) / 2 * width;
37609
+ const startTop = (-mouseStart.y + 1) / 2 * height;
37610
+ const mouseEnd = end.clone().project(camera);
37611
+ const endLeft = (mouseEnd.x + 1) / 2 * width;
37612
+ const endTop = (-mouseEnd.y + 1) / 2 * height;
37613
+ const distance = Math.sqrt(Math.pow(endLeft - startLeft, 2) + Math.pow(endTop - startTop, 2));
37614
+ let visibleLength = distance;
37615
+ let labelOffset = 50;
37616
+ const intr = getRuleScreenIntr({ x: ~~startLeft, y: ~~startTop }, {
37617
+ x: ~~endLeft,
37618
+ y: ~~endTop
37619
+ }, width, height);
37620
+ if (intr && intr.length === 1) {
37621
+ if (visibleOrigin === start) {
37622
+ visibleLength = Math.sqrt(Math.pow(intr[0].x - startLeft, 2) + Math.pow(intr[0].y - startTop, 2));
37623
+ labelOffset = visibleLength / distance * 50;
37624
+ } else if (visibleOrigin === end) {
37625
+ visibleLength = Math.sqrt(Math.pow(intr[0].x - endLeft, 2) + Math.pow(intr[0].y - endTop, 2));
37626
+ labelOffset = 100 - visibleLength / distance * 50;
37627
+ }
37628
+ }
37629
+ if (intr && intr.length === 2) {
37630
+ const middlePoint = {
37631
+ x: (intr[0].x + intr[1].x) / 2,
37632
+ y: (intr[0].y + intr[1].y) / 2
37633
+ };
37634
+ const distanceFromStart = Math.sqrt(Math.pow(middlePoint.x - startLeft, 2) + Math.pow(middlePoint.y - startTop, 2));
37635
+ labelOffset = distanceFromStart / distance * 100;
37636
+ }
37637
+ const rad = Math.PI / 2 - Math.atan2(endLeft - startLeft, startTop - endTop);
37638
+ const deg = rad / Math.PI * 180;
37639
+ const $label = $line.querySelector(".PanoRulerPlugin-rule-label");
37640
+ const labelWidth = $label.children[0].clientWidth;
37641
+ if (labelWidth >= distance || labelWidth / 2 >= labelOffset / 100 * distance || labelWidth / 2 >= (1 - labelOffset / 100) * distance) {
37642
+ $line.style.display = "none";
37643
+ } else {
37644
+ $line.style.display = "block";
37645
+ $line.style.width = distance + "px";
37646
+ $line.style.left = startLeft + "px";
37647
+ $line.style.top = startTop + "px";
37648
+ $line.style.transform = `rotate(${-deg}deg)`;
37649
+ $label.style.left = `${labelOffset}%`;
37650
+ }
37651
+ }
37652
+ };
37653
+ const nextFrameFreshRule = () => nextFrame(freshRule);
37654
+ const throttleFreshRule = throttle(freshRule, 80);
37655
+ const enable = () => {
37656
+ var _a, _b;
37657
+ if (!state.loaded)
37658
+ return false;
37659
+ if (state.enable)
37660
+ return true;
37661
+ $rule.setAttribute("class", "PanoRulerPlugin" + (state.options.className ? " " + state.options.className : ""));
37662
+ (_b = (_a = five.getElement()) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.append($rule);
37663
+ freshRule();
37664
+ five.on("panoArrived", freshRule);
37665
+ five.on("modeChange", freshRule);
37666
+ five.on("cameraDirectionUpdate", nextFrameFreshRule);
37667
+ five.on("movingToPano", nextFrameFreshRule);
37668
+ five.on("mouseWheel", throttleFreshRule);
37669
+ five.on("pinchGesture", throttleFreshRule);
37670
+ state.enable = true;
37671
+ return true;
37672
+ };
37673
+ const disable = () => {
37674
+ if (!state.enable)
37675
+ return true;
37676
+ five.off("panoArrived", freshRule);
37677
+ five.off("modeChange", freshRule);
37678
+ five.off("cameraDirectionUpdate", nextFrameFreshRule);
37679
+ five.off("movingToPano", nextFrameFreshRule);
37680
+ five.off("mouseWheel", throttleFreshRule);
37681
+ five.off("pinchGesture", throttleFreshRule);
37682
+ if ($rule) {
37683
+ $rule.remove();
37684
+ }
37685
+ state.enable = false;
37686
+ return true;
37687
+ };
37688
+ return {
37689
+ enable,
37690
+ disable,
37691
+ load,
37692
+ state
37693
+ };
37694
+ };
37695
+ const roomInfoIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZIAAABCCAYAAAB9y1BhAAAAAXNSR0IArs4c6QAADh5JREFUeAHtnVuPLDcVhedwC/dACKAICDxEIBQpygNI/Ab+MX8B8YCQEAjxgBAQLsm5Jjkn58r6Sl4jT52qnu4zXd121dqSx67q7ip7eXsv721XzcVFJAgEgSAQBIJAEAgCQeC4CLx48eKbSu+RH/fKuVoQWB8Cn1tfk9KiIHAUBH6tq/xKiTwSBILADgRCJDvAyUebRuAbpfXxSDatBmn8Pgh8YZ8v5TtBYIMIvFCbSZEgEASuQSBEcg1A+XizCDzfbMvT8CBwIAIhkgMBy9c3g0CIZDNdnYbeFIEQyU0RzO/XikCIZK09m3YdHYEQydEhzQVXgkCIZCUdmWYsj0CIZHmMc4c+EchCe5/9llqfAYEQyRlAzy27QCAeSRfdlEq2gECIpIVeSB1aRAAiudVixVKnINAaAiGS1nok9WkFAUJb8Upa6Y3Uo2kEQiRNd08qd0YEQiJnBD+37guBEElf/ZXang6BEMnpsM6dOkcgRNJ5B66x+nrjLmsTX1J6bSJHZ7+o9HklynWaOse1eKcc+XVlvxYFEnlfaThWfb7mcsn5nPRM6WmVU55KfO+J0mdKj8f5rVu3skNMoET6RSBE0m/fdVNzGWII4StKXy65y18t58aEAVGcUjDkGHsLhIOYfCC1xUT4QDJjgnmkc58qkT8saSiLeCCkSBBoBoEQSTNd0V9FZADRH8iAGfvXS06Zc5CFCePQt0y3EFaq61CX1ayjC56U8br24sKd+kAuJhkI55OSPi75pyIcvKNIEFgcgRDJ4hD3ewMZLDwDXqfOq9RNFCYOCAMPYx851BDjIXiWzky9Tpyvw0kOL/nc+Jh7DyGqko+P+cznVLwMf31Uypz7jZLJ0GEy8jqURnl8zPjyObDEsxknztsDUnFvMfF8e+4X6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KdYHunnkthwo7tfXQqQjmYSNQImBACIU2xIuGreB8CIdIvAtJzNogMosHI4mYkCDSHgPTUXspU2ItoEIvzEArlxWRvIlGFWTSnsnWF+b1dKAhk8QrrHpEgsDgC0ndi0oNoEBIuiASBZhGQvnqCz/KCJ/jYZtto7DPRoUU2N11LJIXxqNyUC0VFqeCTpRlP94gEgZMhIL0nbDCIdJswQSQINI9AIRRsNRP+KfvOkgNrKEddr5660YUqw3k8EAhkbvsuCztPVSF7JDqMBIF1IKAxcOl5S8eZLEWCQDcIFBtO2Kv2UOr645lAKkex4VeIpLo5jHbls1KD4eYaWIu4R+UeyYLA2RHQWGAADiJ9P9u2StcheRB4VQSkyzgD2PQppwBH4MaEMpBFRSDcqCYQx9ggDphr0QUb3SMSBJpAQGPiciei9P6oYYAmGphKbA4B6TRrJ+j1HKHYzh8cZbpVBowXZ8bgQhzPNJAOvvD4QjkOAj0hUAbdUOVMoHrqudT1OgSk2zgLkAl2n/LYvh9s900kutYV4UIvQiBXMMlBEAgCQWA1CBRCgUjmHAkI5vk+PACR1BcZmGmfH64GzTQkCASBILBhBAqhgEC9rDFGJI7FGJEcB4EgEASCQBAIAkEgCASBIBAEgkAQCAJBIAgEgSAQBIJAEAgCm0fg/x4jQQWGalpFAAAAAElFTkSuQmCC";
37696
+ function getRoomInfoInstance() {
37697
+ const infoDom = document.createElement("div");
37698
+ const iconDom = document.createElement("i");
37699
+ const textDom = document.createElement("span");
37700
+ infoDom.appendChild(iconDom);
37701
+ infoDom.appendChild(textDom);
37702
+ infoDom.style.position = "relative";
37703
+ infoDom.style.width = "100%";
37704
+ infoDom.style.display = "flex";
37705
+ infoDom.style.flexDirection = "column";
37706
+ infoDom.style.alignItems = "center";
37707
+ infoDom.style.marginTop = `${150 / 16}rem`;
37708
+ infoDom.style.opacity = "0";
37709
+ infoDom.style.transition = "opacity 1000ms linear";
37710
+ iconDom.style.display = "block";
37711
+ iconDom.style.width = `${134 / 16}rem`;
37712
+ iconDom.style.height = `${22 / 16}rem`;
37713
+ iconDom.style.backgroundSize = "100%";
37714
+ iconDom.style.backgroundRepeat = "no-repeat";
37715
+ iconDom.style.backgroundImage = `url(${roomInfoIcon})`;
37716
+ textDom.style.marginTop = `${10 / 16}rem`;
37717
+ textDom.style.fontSize = `${16 / 16}rem`;
37718
+ textDom.style.color = "#fff";
37719
+ textDom.style.opacity = "0.7";
37720
+ textDom.style.textShadow = "0 2px 16px rgb(22 34 83 / 24%)";
37721
+ textDom.style.fontWeight = "bold";
37722
+ return {
37723
+ appendTo(element2) {
37724
+ element2.appendChild(infoDom);
37725
+ },
37726
+ dispose() {
37727
+ infoDom.remove();
37728
+ },
37729
+ setRoom(room) {
37730
+ textDom.innerHTML = room.name + " " + Math.floor(room.size / 1e6) + "\u33A1";
37731
+ },
37732
+ show() {
37733
+ infoDom.style.opacity = "1";
37734
+ },
37735
+ hide() {
37736
+ infoDom.style.opacity = "0";
37737
+ }
37738
+ };
37739
+ }
37162
37740
  const textureLoader = new THREE.TextureLoader();
37163
37741
  async function loadTexture(url) {
37164
37742
  return new Promise((resolve, reject) => {
@@ -37208,33 +37786,26 @@ class PanoCompassController {
37208
37786
  __publicField(this, "five");
37209
37787
  __publicField(this, "data");
37210
37788
  __publicField(this, "config");
37789
+ __publicField(this, "group", new THREE.Group());
37790
+ __publicField(this, "modelLoaded", false);
37791
+ __publicField(this, "roomInfoInstance");
37792
+ __publicField(this, "roomInfoWrapperInstance");
37211
37793
  __publicField(this, "compassMeshTween");
37212
37794
  __publicField(this, "compassMesh");
37795
+ __publicField(this, "entryDoorMesh");
37213
37796
  __publicField(this, "dispose", () => {
37797
+ var _a, _b, _c, _d;
37798
+ this.five.scene.remove(this.group);
37799
+ this.group.remove(...this.group.children);
37800
+ (_b = (_a = this.compassMesh) == null ? void 0 : _a.material.map) == null ? void 0 : _b.dispose();
37801
+ (_d = (_c = this.entryDoorMesh) == null ? void 0 : _c.material.map) == null ? void 0 : _d.dispose();
37214
37802
  this.five.off("panoArrived", this.onFivePanoArrived);
37215
37803
  this.five.off("panoWillArrive", this.onFivePanoWillArrive);
37216
- this.five.off();
37217
37804
  });
37218
- __publicField(this, "loadCompassMesh", async () => {
37219
- var _a;
37220
- const compassImageUrl = ((_a = this.config) == null ? void 0 : _a.compassImageUrl) || "//vrlab-image4.ljcdn.com/release/web/v3/north-point-circle.96498e69.png";
37221
- const texture = await loadTexture(compassImageUrl);
37222
- const compassGeometry = new THREE.CircleGeometry(0.7, 32);
37223
- const compassMaterial = new THREE.MeshBasicMaterial({
37224
- map: texture,
37225
- transparent: true,
37226
- opacity: 1,
37227
- depthTest: false
37228
- });
37229
- const compassMesh = new THREE.Mesh(compassGeometry, compassMaterial);
37230
- compassMesh.rotateX(-Math.PI / 2);
37231
- compassMesh.name = "pano-compass-mesh";
37232
- this.compassMesh = compassMesh;
37233
- this.fixPosition(this.five.panoIndex || 0);
37234
- if (!this.data)
37235
- return;
37236
- this.fixRotation(this.data.north_rad);
37237
- this.five.scene.add(compassMesh);
37805
+ __publicField(this, "onFiveFistPanoLoaded", () => {
37806
+ this.modelLoaded = true;
37807
+ if (this.data)
37808
+ this.init();
37238
37809
  });
37239
37810
  __publicField(this, "onFivePanoWillArrive", (panoIndex) => {
37240
37811
  var _a, _b;
@@ -37244,45 +37815,109 @@ class PanoCompassController {
37244
37815
  (_b = this.compassMesh) == null ? void 0 : _b.material.setValues({ opacity: 0 });
37245
37816
  });
37246
37817
  __publicField(this, "onFivePanoArrived", (panoIndex) => {
37247
- var _a, _b;
37248
- if (((_a = this.compassMesh) == null ? void 0 : _a.material.opacity) !== 0)
37818
+ var _a, _b, _c, _d;
37819
+ if (!this.compassMesh || !this.entryDoorMesh || !this.roomInfoInstance || !this.roomInfoWrapperInstance)
37820
+ return;
37821
+ if (!this.data)
37822
+ return;
37823
+ const standingPosition = this.five.work.observers[panoIndex].standingPosition;
37824
+ this.compassMesh.position.copy(standingPosition.clone().setY(standingPosition.y + 0.01));
37825
+ const entryDoorPosition = new THREE.Vector3(this.data.entrance.position.x, this.data.entrance.position.y, this.data.entrance.position.z);
37826
+ const panoToEntryDoorVector = entryDoorPosition.clone().setY(standingPosition.y).sub(standingPosition).normalize();
37827
+ const compassEntryDoorPosition = standingPosition.clone().add(panoToEntryDoorVector.clone().multiplyScalar(0.7)).setY(standingPosition.y + 0.01);
37828
+ this.entryDoorMesh.rotation.z = new THREE.Vector3(0, 0, -1).angleTo(panoToEntryDoorVector);
37829
+ this.entryDoorMesh.position.copy(compassEntryDoorPosition);
37830
+ this.roomInfoWrapperInstance.css3DObject.position.copy(standingPosition.clone().setY(standingPosition.y + 0.01));
37831
+ this.roomInfoInstance.setRoom(this.data.room_observers[panoIndex].room);
37832
+ ((_a = this.data) == null ? void 0 : _a.room_observers[panoIndex].room.type) === 1 ? (_b = this.entryDoorMesh) == null ? void 0 : _b.material.setValues({ opacity: 1 }) : (_c = this.entryDoorMesh) == null ? void 0 : _c.material.setValues({ opacity: 0 });
37833
+ this.five.needsRender = true;
37834
+ if (this.compassMesh.material.opacity !== 0)
37249
37835
  return;
37250
- this.fixPosition(panoIndex);
37251
- (_b = this.compassMeshTween) == null ? void 0 : _b.dispose();
37836
+ (_d = this.compassMeshTween) == null ? void 0 : _d.dispose();
37252
37837
  this.compassMeshTween = tweenProgress(1e3).onUpdate(({ progress }) => {
37253
37838
  var _a2;
37254
37839
  (_a2 = this.compassMesh) == null ? void 0 : _a2.material.setValues({ opacity: progress });
37255
37840
  this.five.needsRender = true;
37256
37841
  }).play();
37257
37842
  });
37843
+ __publicField(this, "onFiveCameraDirectionUpdate", ({ longitude, latitude }) => {
37844
+ var _a, _b;
37845
+ if (!this.roomInfoWrapperInstance)
37846
+ return;
37847
+ this.roomInfoWrapperInstance.css3DObject.rotation.z = longitude;
37848
+ latitude > 0.66 && this.five.getCurrentState().mode === "Panorama" ? (_a = this.roomInfoInstance) == null ? void 0 : _a.show() : (_b = this.roomInfoInstance) == null ? void 0 : _b.hide();
37849
+ });
37258
37850
  this.five = five;
37259
37851
  this.config = config;
37260
- five.once("panoLoaded", this.loadCompassMesh);
37852
+ this.five.scene.add(this.group);
37261
37853
  five.once("dispose", this.dispose);
37854
+ five.once("modelLoaded", this.onFiveFistPanoLoaded);
37262
37855
  this.five.on("panoArrived", this.onFivePanoArrived);
37263
37856
  this.five.on("panoWillArrive", this.onFivePanoWillArrive);
37857
+ this.five.on("cameraDirectionUpdate", this.onFiveCameraDirectionUpdate);
37264
37858
  }
37265
37859
  load(data) {
37266
37860
  this.data = data;
37267
- if (this.compassMesh && !this.five.scene.children.includes(this.compassMesh)) {
37268
- this.fixRotation(data.north_rad);
37269
- this.fixPosition(this.five.panoIndex || 0);
37270
- this.five.scene.add(this.compassMesh);
37271
- }
37861
+ if (this.modelLoaded)
37862
+ this.init();
37272
37863
  }
37273
- fixPosition(panoIndex) {
37274
- if (!this.compassMesh)
37275
- return;
37276
- const standingPosition = this.five.work.observers[panoIndex].standingPosition;
37277
- const compassPosition = standingPosition.clone().add(new THREE.Vector3(0, 0.01, 0));
37278
- this.compassMesh.position.copy(compassPosition);
37279
- this.five.needsRender = true;
37280
- }
37281
- fixRotation(northRad) {
37282
- if (!this.compassMesh)
37864
+ async init() {
37865
+ if (!this.data || !this.modelLoaded)
37283
37866
  return;
37867
+ this.compassMesh = await this.loadCompassMesh();
37868
+ this.entryDoorMesh = await this.loadEntryDoorMesh();
37869
+ this.roomInfoWrapperInstance = this.loadRoomInfo();
37870
+ this.roomInfoInstance = getRoomInfoInstance();
37871
+ this.compassMesh.rotateX(-Math.PI / 2);
37872
+ this.entryDoorMesh.rotateX(-Math.PI / 2);
37873
+ const northRad = this.data.entrance.north_rad;
37284
37874
  this.compassMesh.rotateZ(northRad - Math.PI / 2);
37875
+ this.onFivePanoArrived(this.five.panoIndex || 0);
37876
+ this.group.add(this.compassMesh);
37877
+ this.group.add(this.entryDoorMesh);
37878
+ if (this.roomInfoWrapperInstance)
37879
+ this.roomInfoInstance.appendTo(this.roomInfoWrapperInstance.container);
37285
37880
  this.five.needsRender = true;
37286
37881
  }
37882
+ async loadCompassMesh() {
37883
+ var _a;
37884
+ const compassImageUrl = ((_a = this.config) == null ? void 0 : _a.compassImageUrl) || "//vrlab-image4.ljcdn.com/release/web/v3/north-point-circle.96498e69.png";
37885
+ const compassTexture = await loadTexture(compassImageUrl);
37886
+ const compassGeometry = new THREE.CircleGeometry(0.7, 32);
37887
+ const compassMaterial = new THREE.MeshBasicMaterial({
37888
+ map: compassTexture,
37889
+ transparent: true,
37890
+ opacity: 0,
37891
+ depthTest: false
37892
+ });
37893
+ const compassMesh = new THREE.Mesh(compassGeometry, compassMaterial);
37894
+ compassMesh.name = "pano-compass-mesh";
37895
+ return compassMesh;
37896
+ }
37897
+ async loadEntryDoorMesh() {
37898
+ var _a;
37899
+ const entryDoorImageUrl = ((_a = this.config) == null ? void 0 : _a.entryDoorImageUrl) || "//vrlab-image4.ljcdn.com/release/web/enterDoor.831b8208.png";
37900
+ const entryDoorTexture = await loadTexture(entryDoorImageUrl);
37901
+ const entryDoorGeometry = new THREE.PlaneGeometry(0.2, 0.16);
37902
+ const entryDoorMaterial = new THREE.MeshBasicMaterial({
37903
+ map: entryDoorTexture,
37904
+ transparent: true,
37905
+ opacity: 0.8,
37906
+ depthTest: false
37907
+ });
37908
+ const entryDoorMesh = new THREE.Mesh(entryDoorGeometry, entryDoorMaterial);
37909
+ entryDoorMesh.name = "pano-compass-entry-door";
37910
+ return entryDoorMesh;
37911
+ }
37912
+ loadRoomInfo() {
37913
+ const points = [
37914
+ new THREE.Vector3(-0.7, 0, -0.7),
37915
+ new THREE.Vector3(0.7, 0, -0.7),
37916
+ new THREE.Vector3(0.7, 0, 0.7),
37917
+ new THREE.Vector3(-0.7, 0, 0.7)
37918
+ ];
37919
+ const roomInfo = CSS3DRenderPlugin(this.five).create3DDomContainer(points);
37920
+ return roomInfo;
37921
+ }
37287
37922
  }
37288
- export { CSS3DRenderPlugin, CameraMovementPlugin, ModelChassisCompassPlugin, ModelEntryDoorGuidePlugin, ModelFloorplanPlugin, ModelRoomLabelPlugin, ModelViewPlugin, PanoCompassPlugin as PanoCompassPluginPlugin, PanoCursorRaycasterPlugin, PanoFloorplanRadarPlugin, TopviewFloorplanPlugin };
37923
+ export { CSS3DRenderPlugin, CameraMovementPlugin, FLOOR_PLAN_ATTACHED_TO, ModelChassisCompassPlugin, ModelEntryDoorGuidePlugin, ModelFloorplanPlugin, ModelRoomLabelPlugin, ModelViewPlugin, PanoCompassPlugin, PanoCursorRaycasterPlugin, PanoFloorplanRadarPlugin, PanoRulerPlugin, TopviewFloorplanPlugin };