@realsee/dnalogel 2.0.2 → 2.0.3

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 (115) hide show
  1. package/dist/CSS3DRenderPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  2. package/dist/CameraMovementPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  3. package/dist/CruisePlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  4. package/dist/GuideLinePlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  5. package/dist/ItemLabelPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  6. package/dist/ModelChassisCompassPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  7. package/dist/ModelEntryDoorGuidePlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  8. package/dist/ModelItemLabelPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  9. package/dist/ModelRoomLabelPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  10. package/dist/ModelRoomLabelPlugin/index.js +19 -22
  11. package/dist/ModelTVVideoPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  12. package/dist/ModelViewPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  13. package/dist/ModelViewPlugin/Plugin.d.ts +13 -2
  14. package/dist/ModelViewPlugin/index.js +53 -28
  15. package/dist/PanoCompassPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  16. package/dist/PanoCursorRaycasterPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  17. package/dist/PanoDoorLabelPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  18. package/dist/PanoMeasurePlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  19. package/dist/PanoRulerPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  20. package/dist/PanoRulerProPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  21. package/dist/PanoSpatialTagPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  22. package/dist/floorplan/MapviewFloorplanPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  23. package/dist/floorplan/ModelFloorplanPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  24. package/dist/floorplan/PanoFloorplanRadarPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  25. package/dist/floorplan/TopviewFloorplanPlugin/ModelViewPlugin/Plugin.d.ts +13 -2
  26. package/dist/index.es.js +64 -43
  27. package/dist/index.js +72 -51
  28. package/dist/index.umd.js +75 -54
  29. package/docs/assets/search.js +1 -1
  30. package/docs/classes/CruisePluginController.html +14 -14
  31. package/docs/classes/Magnifier.html +4 -4
  32. package/docs/classes/ModelRoomLabelController.html +4 -4
  33. package/docs/enums/CameraMovementEffect.html +2 -2
  34. package/docs/enums/DIRECTION.html +1 -1
  35. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  36. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  37. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  38. package/docs/enums/Rotation.html +2 -2
  39. package/docs/index.html +1 -1
  40. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  41. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  42. package/docs/interfaces/FloorplanBounding.html +4 -4
  43. package/docs/interfaces/FloorplanData.html +2 -2
  44. package/docs/interfaces/FloorplanEntrance.html +7 -7
  45. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  46. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  47. package/docs/interfaces/FloorplanFloorData.html +2 -2
  48. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  49. package/docs/interfaces/FloorplanObserver.html +2 -2
  50. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  51. package/docs/interfaces/FloorplanPosition.html +2 -2
  52. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  53. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  54. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  55. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  56. package/docs/interfaces/FloorplanServerData.html +2 -2
  57. package/docs/interfaces/FloorplanServerDoorItem.html +1 -1
  58. package/docs/interfaces/FloorplanServerDoorPosition.html +1 -1
  59. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  60. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  61. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  62. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  63. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  64. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  65. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  66. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  67. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  68. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  69. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  70. package/docs/interfaces/LineJson.html +1 -1
  71. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  72. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  73. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  74. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  75. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  76. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  77. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  78. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  79. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  80. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  81. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  82. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  83. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  84. package/docs/interfaces/OpenParameter.html +2 -2
  85. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  86. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  87. package/docs/interfaces/PanoMeasureParameterType.html +2 -2
  88. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  89. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  90. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  91. package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
  92. package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
  93. package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
  94. package/docs/interfaces/PanoRulerProPluginState.html +1 -1
  95. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  96. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  97. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  98. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  99. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  100. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  101. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  102. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  103. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  104. package/docs/interfaces/Point.html +1 -1
  105. package/docs/interfaces/PointJson.html +1 -1
  106. package/docs/interfaces/Room.html +1 -1
  107. package/docs/interfaces/RoomInfo.html +1 -1
  108. package/docs/interfaces/RoomLabel.html +7 -7
  109. package/docs/interfaces/RoomRules.html +1 -1
  110. package/docs/interfaces/Rooms.html +1 -1
  111. package/docs/modules.html +18 -18
  112. package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +19 -22
  113. package/libs/ModelViewPlugin/Plugin.d.ts +13 -2
  114. package/libs/ModelViewPlugin/Plugin.js +45 -20
  115. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var five = require('@realsee/five');
5
6
  var THREE = require('three');
6
7
  var CSS3DRenderer = require('three/examples/jsm/renderers/CSS3DRenderer');
7
8
  var line = require('@realsee/five/line');
@@ -10,7 +11,6 @@ var svelte = require('svelte');
10
11
  var easing = require('svelte/easing');
11
12
  var transition = require('svelte/transition');
12
13
  var store = require('svelte/store');
13
- var five = require('@realsee/five');
14
14
  var FBXLoader = require('three/examples/jsm/loaders/FBXLoader');
15
15
  var TWEEN = require('@tweenjs/tween.js');
16
16
  var Hammer = require('hammerjs');
@@ -46,12 +46,21 @@ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
46
46
  * Five 模型插件
47
47
  * @template ExportType 导出方法
48
48
  */
49
- const ModelViewPlugin = (five) => {
49
+ const ModelViewPlugin = (five$1, params) => {
50
50
  let needsRender = true;
51
51
  let renderer = null;
52
+ const defaultConfig = {
53
+ lookAtCurrentCamera: false,
54
+ lockedPanoIndex: null,
55
+ lockedLatitude: null,
56
+ lockedLongitude: null,
57
+ };
58
+ const config = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
52
59
  const scene = new THREE__namespace.Scene();
53
- const camera = new THREE__namespace.PerspectiveCamera(60, 1, 0.1, 1000);
60
+ const camera = new five.Camera(60);
54
61
  let model = new THREE__namespace.Object3D();
62
+ let distance;
63
+ let offset;
55
64
  {
56
65
  const light = new THREE__namespace.DirectionalLight(0xffffff, 0.5);
57
66
  light.position.copy(new THREE__namespace.Vector3(1, 1, 1));
@@ -67,11 +76,11 @@ const ModelViewPlugin = (five) => {
67
76
  }
68
77
  scene.add(model);
69
78
  const initRendererIfNeeds = () => {
70
- if (!five.renderer)
79
+ if (!five$1.renderer)
71
80
  return;
72
81
  if (!renderer) {
73
82
  renderer = new THREE__namespace.WebGLRenderer({ antialias: false, alpha: true });
74
- renderer.setPixelRatio(five.renderer.getPixelRatio());
83
+ renderer.setPixelRatio(five$1.renderer.getPixelRatio());
75
84
  renderer.outputEncoding = THREE__namespace.sRGBEncoding;
76
85
  renderer.setClearColor(0x181a1c, 0);
77
86
  renderer.autoClear = true;
@@ -91,6 +100,8 @@ const ModelViewPlugin = (five) => {
91
100
  update();
92
101
  };
93
102
  const handleModelLoaded = () => {
103
+ distance = getDistanceFromModel(five$1.model, camera.fov, camera.aspect);
104
+ offset = five$1.model.bounding.getCenter(new THREE__namespace.Vector3());
94
105
  function cloneMaterial(_material) {
95
106
  const material = _material.clone();
96
107
  material.uniforms.modelAlpha.value = 1;
@@ -119,7 +130,7 @@ const ModelViewPlugin = (five) => {
119
130
  }
120
131
  }
121
132
  scene.remove(model);
122
- model = cloneModel(five.model);
133
+ model = cloneModel(five$1.model);
123
134
  scene.add(model);
124
135
  update();
125
136
  };
@@ -150,29 +161,36 @@ const ModelViewPlugin = (five) => {
150
161
  }
151
162
  update();
152
163
  };
153
- const cameraDistance = () => {
154
- const bounding = five.model.bounding;
155
- const { fov, aspect } = camera;
156
- const radius = Math.sqrt(Math.pow(bounding.max.x - bounding.min.x + 2, 2) +
157
- Math.pow(bounding.max.y - bounding.min.y + 2, 2) +
158
- Math.pow(bounding.max.z - bounding.min.z + 2, 2));
164
+ function getDistanceFromModel(model, fov, aspect) {
165
+ const bounding = model.bounding;
166
+ const radius = Math.pow(Math.pow(bounding.max.x - bounding.min.x + 1, 2) +
167
+ Math.pow(bounding.max.y - bounding.min.y + 1, 2) +
168
+ Math.pow(bounding.max.z - bounding.min.z + 1, 2), 1 / 2);
159
169
  // fit screen
160
170
  let distance = radius / 2 / Math.tan((Math.PI * fov) / 360);
161
171
  if (aspect < 1)
162
172
  distance = distance / aspect;
163
173
  return isNaN(distance) ? radius : distance;
164
- };
174
+ }
175
+ function getOffsetFromPanoIndex(panoIndex) {
176
+ return five$1.work.observers[panoIndex].standingPosition.clone();
177
+ }
165
178
  const update = () => {
166
- const { longitude, latitude } = five.getPose();
167
- const distance = cameraDistance();
168
- const lookAt = five.model.bounding.getCenter(new THREE__namespace.Vector3());
169
- const longitudeDistance = distance * Math.cos(latitude);
170
- const cameraPosition = new THREE__namespace.Vector3();
171
- cameraPosition.x = Math.sin(longitude) * longitudeDistance + lookAt.x;
172
- cameraPosition.z = Math.cos(longitude) * longitudeDistance + lookAt.z;
173
- cameraPosition.y = Math.sin(latitude) * distance + lookAt.y;
174
- camera.position.copy(cameraPosition);
175
- camera.lookAt(lookAt);
179
+ if (!distance || !offset)
180
+ return;
181
+ const pose = five$1.getPose();
182
+ pose.fov = camera.fov;
183
+ pose.offset = offset;
184
+ pose.distance = distance;
185
+ if (typeof config.lockedLatitude === 'number')
186
+ pose.latitude = config.lockedLatitude;
187
+ if (typeof config.lockedLongitude === 'number')
188
+ pose.longitude = config.lockedLongitude;
189
+ if (typeof config.lockedPanoIndex === 'number')
190
+ pose.offset = getOffsetFromPanoIndex(config.lockedPanoIndex);
191
+ if (config.lookAtCurrentCamera)
192
+ pose.offset = five$1.camera.position.clone().setY(five$1.camera.position.y + 1);
193
+ camera.setFromPose(pose);
176
194
  needsRender = true;
177
195
  };
178
196
  const render = () => {
@@ -193,12 +211,18 @@ const ModelViewPlugin = (five) => {
193
211
  renderer.dispose();
194
212
  renderer = null;
195
213
  };
196
- five.on('modelLoaded', handleModelLoaded);
197
- five.on('modelWillLoad', handleModelWillLoad);
198
- five.on('cameraDirectionUpdate', update);
199
- five.on('dispose', dispose);
200
- five.on('renderFrame', render);
201
- return { appendTo, refresh };
214
+ const changeConfigs = (userConfig) => {
215
+ Object.assign(config, userConfig);
216
+ update();
217
+ };
218
+ Object.assign(window, { camera });
219
+ five$1.on('modelLoaded', handleModelLoaded);
220
+ five$1.on('modelWillLoad', handleModelWillLoad);
221
+ five$1.on('cameraDirectionUpdate', update);
222
+ five$1.on('dispose', dispose);
223
+ five$1.on('renderFrame', render);
224
+ five$1.on('cameraPositionUpdate', update);
225
+ return { appendTo, refresh, changeConfigs };
202
226
  };
203
227
 
204
228
  function evenNumber(num, config) {
@@ -599,11 +623,11 @@ function add_css$p(target) {
599
623
 
600
624
  function get_each_context$c(ctx, list, i) {
601
625
  const child_ctx = ctx.slice();
602
- child_ctx[12] = list[i];
626
+ child_ctx[13] = list[i];
603
627
  return child_ctx;
604
628
  }
605
629
 
606
- // (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
630
+ // (79:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
607
631
  function create_each_block$c(key_1, ctx) {
608
632
  let first;
609
633
  let roomlabelitem;
@@ -611,7 +635,7 @@ function create_each_block$c(key_1, ctx) {
611
635
 
612
636
  roomlabelitem = new RoomLabelItem({
613
637
  props: {
614
- roomLabel: /*roomLableItem*/ ctx[12],
638
+ roomLabel: /*roomLableItem*/ ctx[13],
615
639
  five: /*five*/ ctx[1]
616
640
  }
617
641
  });
@@ -632,7 +656,7 @@ function create_each_block$c(key_1, ctx) {
632
656
  p(new_ctx, dirty) {
633
657
  ctx = new_ctx;
634
658
  const roomlabelitem_changes = {};
635
- if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
659
+ if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[13];
636
660
  if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
637
661
  roomlabelitem.$set(roomlabelitem_changes);
638
662
  },
@@ -659,7 +683,7 @@ function create_fragment$u(ctx) {
659
683
  let div_resize_listener;
660
684
  let current;
661
685
  let each_value = /*roomLabels*/ ctx[0];
662
- const get_key = ctx => /*roomLableItem*/ ctx[12].id;
686
+ const get_key = ctx => /*roomLableItem*/ ctx[13].id;
663
687
 
664
688
  for (let i = 0; i < each_value.length; i += 1) {
665
689
  let child_ctx = get_each_context$c(ctx, each_value, i);
@@ -726,13 +750,19 @@ function create_fragment$u(ctx) {
726
750
 
727
751
  function instance$u($$self, $$props, $$invalidate) {
728
752
  let rendererSize;
753
+ var _a;
729
754
  let { five } = $$props;
730
755
  let { roomLabels } = $$props;
731
756
  let containerWidth;
732
757
  let containerHeight;
733
- let shownFloor = null;
758
+
759
+ let shownFloor = (_a = five.model.shownFloor) !== null && _a !== void 0
760
+ ? _a
761
+ : null;
734
762
 
735
763
  function getLabelVisible(item) {
764
+ const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
765
+ if (!isLabelInFloor) return false;
736
766
  const raycaster = new THREE.Raycaster();
737
767
  const cameraPosition = five.camera.position.clone();
738
768
  const position = new THREE.Vector3(item.position.x, item.position.y, item.position.z);
@@ -751,7 +781,9 @@ function instance$u($$self, $$props, $$invalidate) {
751
781
  return `translate(${xOffset}px, ${yOffset}px)`;
752
782
  }
753
783
 
754
- function getFormatedRoomLabels(rendererSize) {
784
+ function getFormatedRoomLabels(params) {
785
+ const { rendererSize, shownFloor } = params;
786
+
755
787
  // 因为 item distance 需要重复计算,所以缓存一下
756
788
  const distanceMap = new Map();
757
789
 
@@ -784,7 +816,7 @@ function instance$u($$self, $$props, $$invalidate) {
784
816
  }
785
817
 
786
818
  function onFiveCameraUpdate() {
787
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
819
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
788
820
  }
789
821
 
790
822
  function onFiveModelShownFloorChange(floorIndex) {
@@ -816,21 +848,10 @@ function instance$u($$self, $$props, $$invalidate) {
816
848
  $$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
817
849
  }
818
850
 
819
- if ($$self.$$.dirty & /*rendererSize*/ 32) {
851
+ if ($$self.$$.dirty & /*rendererSize, shownFloor*/ 48) {
820
852
  {
821
- // rendererSize 变化时,触发 reRender
822
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
823
- }
824
- }
825
-
826
- if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
827
- {
828
- // shownFloor 变化时,更新 item visible
829
- $$invalidate(0, roomLabels = roomLabels.map(item => {
830
- const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
831
- const visible = isLabelInFloor ? item.visible : false;
832
- return Object.assign(Object.assign({}, item), { visible });
833
- }));
853
+ // rendererSize 和 shownFloor 变化时,触发 reRender
854
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
834
855
  }
835
856
  }
836
857
  };
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('three/examples/jsm/renderers/CSS3DRenderer'), require('@realsee/five/line'), require('svelte/internal'), require('svelte'), require('svelte/easing'), require('svelte/transition'), require('svelte/store'), require('@realsee/five'), require('three/examples/jsm/loaders/FBXLoader'), require('@tweenjs/tween.js'), require('hammerjs'), require('classnames')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'three', 'three/examples/jsm/renderers/CSS3DRenderer', '@realsee/five/line', 'svelte/internal', 'svelte', 'svelte/easing', 'svelte/transition', 'svelte/store', '@realsee/five', 'three/examples/jsm/loaders/FBXLoader', '@tweenjs/tween.js', 'hammerjs', 'classnames'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.dnalogel = {}, global.THREE, global.CSS3DRenderer, global.FiveSDK_Line, global.internal, global.svelte, global.easing, global.transition, global.store, global.five, global.FBXLoader, global.TWEEN, global.Hammer, global.classNames));
5
- })(this, (function (exports, THREE, CSS3DRenderer, line, internal, svelte, easing, transition, store, five, FBXLoader, TWEEN, Hammer, classNames) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@realsee/five'), require('three'), require('three/examples/jsm/renderers/CSS3DRenderer'), require('@realsee/five/line'), require('svelte/internal'), require('svelte'), require('svelte/easing'), require('svelte/transition'), require('svelte/store'), require('three/examples/jsm/loaders/FBXLoader'), require('@tweenjs/tween.js'), require('hammerjs'), require('classnames')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@realsee/five', 'three', 'three/examples/jsm/renderers/CSS3DRenderer', '@realsee/five/line', 'svelte/internal', 'svelte', 'svelte/easing', 'svelte/transition', 'svelte/store', 'three/examples/jsm/loaders/FBXLoader', '@tweenjs/tween.js', 'hammerjs', 'classnames'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.dnalogel = {}, global.five, global.THREE, global.CSS3DRenderer, global.FiveSDK_Line, global.internal, global.svelte, global.easing, global.transition, global.store, global.FBXLoader, global.TWEEN, global.Hammer, global.classNames));
5
+ })(this, (function (exports, five, THREE, CSS3DRenderer, line, internal, svelte, easing, transition, store, FBXLoader, TWEEN, Hammer, classNames) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -34,12 +34,21 @@
34
34
  * Five 模型插件
35
35
  * @template ExportType 导出方法
36
36
  */
37
- const ModelViewPlugin = (five) => {
37
+ const ModelViewPlugin = (five$1, params) => {
38
38
  let needsRender = true;
39
39
  let renderer = null;
40
+ const defaultConfig = {
41
+ lookAtCurrentCamera: false,
42
+ lockedPanoIndex: null,
43
+ lockedLatitude: null,
44
+ lockedLongitude: null,
45
+ };
46
+ const config = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
40
47
  const scene = new THREE__namespace.Scene();
41
- const camera = new THREE__namespace.PerspectiveCamera(60, 1, 0.1, 1000);
48
+ const camera = new five.Camera(60);
42
49
  let model = new THREE__namespace.Object3D();
50
+ let distance;
51
+ let offset;
43
52
  {
44
53
  const light = new THREE__namespace.DirectionalLight(0xffffff, 0.5);
45
54
  light.position.copy(new THREE__namespace.Vector3(1, 1, 1));
@@ -55,11 +64,11 @@
55
64
  }
56
65
  scene.add(model);
57
66
  const initRendererIfNeeds = () => {
58
- if (!five.renderer)
67
+ if (!five$1.renderer)
59
68
  return;
60
69
  if (!renderer) {
61
70
  renderer = new THREE__namespace.WebGLRenderer({ antialias: false, alpha: true });
62
- renderer.setPixelRatio(five.renderer.getPixelRatio());
71
+ renderer.setPixelRatio(five$1.renderer.getPixelRatio());
63
72
  renderer.outputEncoding = THREE__namespace.sRGBEncoding;
64
73
  renderer.setClearColor(0x181a1c, 0);
65
74
  renderer.autoClear = true;
@@ -79,6 +88,8 @@
79
88
  update();
80
89
  };
81
90
  const handleModelLoaded = () => {
91
+ distance = getDistanceFromModel(five$1.model, camera.fov, camera.aspect);
92
+ offset = five$1.model.bounding.getCenter(new THREE__namespace.Vector3());
82
93
  function cloneMaterial(_material) {
83
94
  const material = _material.clone();
84
95
  material.uniforms.modelAlpha.value = 1;
@@ -107,7 +118,7 @@
107
118
  }
108
119
  }
109
120
  scene.remove(model);
110
- model = cloneModel(five.model);
121
+ model = cloneModel(five$1.model);
111
122
  scene.add(model);
112
123
  update();
113
124
  };
@@ -138,29 +149,36 @@
138
149
  }
139
150
  update();
140
151
  };
141
- const cameraDistance = () => {
142
- const bounding = five.model.bounding;
143
- const { fov, aspect } = camera;
144
- const radius = Math.sqrt(Math.pow(bounding.max.x - bounding.min.x + 2, 2) +
145
- Math.pow(bounding.max.y - bounding.min.y + 2, 2) +
146
- Math.pow(bounding.max.z - bounding.min.z + 2, 2));
152
+ function getDistanceFromModel(model, fov, aspect) {
153
+ const bounding = model.bounding;
154
+ const radius = Math.pow(Math.pow(bounding.max.x - bounding.min.x + 1, 2) +
155
+ Math.pow(bounding.max.y - bounding.min.y + 1, 2) +
156
+ Math.pow(bounding.max.z - bounding.min.z + 1, 2), 1 / 2);
147
157
  // fit screen
148
158
  let distance = radius / 2 / Math.tan((Math.PI * fov) / 360);
149
159
  if (aspect < 1)
150
160
  distance = distance / aspect;
151
161
  return isNaN(distance) ? radius : distance;
152
- };
162
+ }
163
+ function getOffsetFromPanoIndex(panoIndex) {
164
+ return five$1.work.observers[panoIndex].standingPosition.clone();
165
+ }
153
166
  const update = () => {
154
- const { longitude, latitude } = five.getPose();
155
- const distance = cameraDistance();
156
- const lookAt = five.model.bounding.getCenter(new THREE__namespace.Vector3());
157
- const longitudeDistance = distance * Math.cos(latitude);
158
- const cameraPosition = new THREE__namespace.Vector3();
159
- cameraPosition.x = Math.sin(longitude) * longitudeDistance + lookAt.x;
160
- cameraPosition.z = Math.cos(longitude) * longitudeDistance + lookAt.z;
161
- cameraPosition.y = Math.sin(latitude) * distance + lookAt.y;
162
- camera.position.copy(cameraPosition);
163
- camera.lookAt(lookAt);
167
+ if (!distance || !offset)
168
+ return;
169
+ const pose = five$1.getPose();
170
+ pose.fov = camera.fov;
171
+ pose.offset = offset;
172
+ pose.distance = distance;
173
+ if (typeof config.lockedLatitude === 'number')
174
+ pose.latitude = config.lockedLatitude;
175
+ if (typeof config.lockedLongitude === 'number')
176
+ pose.longitude = config.lockedLongitude;
177
+ if (typeof config.lockedPanoIndex === 'number')
178
+ pose.offset = getOffsetFromPanoIndex(config.lockedPanoIndex);
179
+ if (config.lookAtCurrentCamera)
180
+ pose.offset = five$1.camera.position.clone().setY(five$1.camera.position.y + 1);
181
+ camera.setFromPose(pose);
164
182
  needsRender = true;
165
183
  };
166
184
  const render = () => {
@@ -181,12 +199,18 @@
181
199
  renderer.dispose();
182
200
  renderer = null;
183
201
  };
184
- five.on('modelLoaded', handleModelLoaded);
185
- five.on('modelWillLoad', handleModelWillLoad);
186
- five.on('cameraDirectionUpdate', update);
187
- five.on('dispose', dispose);
188
- five.on('renderFrame', render);
189
- return { appendTo, refresh };
202
+ const changeConfigs = (userConfig) => {
203
+ Object.assign(config, userConfig);
204
+ update();
205
+ };
206
+ Object.assign(window, { camera });
207
+ five$1.on('modelLoaded', handleModelLoaded);
208
+ five$1.on('modelWillLoad', handleModelWillLoad);
209
+ five$1.on('cameraDirectionUpdate', update);
210
+ five$1.on('dispose', dispose);
211
+ five$1.on('renderFrame', render);
212
+ five$1.on('cameraPositionUpdate', update);
213
+ return { appendTo, refresh, changeConfigs };
190
214
  };
191
215
 
192
216
  function evenNumber(num, config) {
@@ -587,11 +611,11 @@
587
611
 
588
612
  function get_each_context$c(ctx, list, i) {
589
613
  const child_ctx = ctx.slice();
590
- child_ctx[12] = list[i];
614
+ child_ctx[13] = list[i];
591
615
  return child_ctx;
592
616
  }
593
617
 
594
- // (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
618
+ // (79:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
595
619
  function create_each_block$c(key_1, ctx) {
596
620
  let first;
597
621
  let roomlabelitem;
@@ -599,7 +623,7 @@
599
623
 
600
624
  roomlabelitem = new RoomLabelItem({
601
625
  props: {
602
- roomLabel: /*roomLableItem*/ ctx[12],
626
+ roomLabel: /*roomLableItem*/ ctx[13],
603
627
  five: /*five*/ ctx[1]
604
628
  }
605
629
  });
@@ -620,7 +644,7 @@
620
644
  p(new_ctx, dirty) {
621
645
  ctx = new_ctx;
622
646
  const roomlabelitem_changes = {};
623
- if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
647
+ if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[13];
624
648
  if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
625
649
  roomlabelitem.$set(roomlabelitem_changes);
626
650
  },
@@ -647,7 +671,7 @@
647
671
  let div_resize_listener;
648
672
  let current;
649
673
  let each_value = /*roomLabels*/ ctx[0];
650
- const get_key = ctx => /*roomLableItem*/ ctx[12].id;
674
+ const get_key = ctx => /*roomLableItem*/ ctx[13].id;
651
675
 
652
676
  for (let i = 0; i < each_value.length; i += 1) {
653
677
  let child_ctx = get_each_context$c(ctx, each_value, i);
@@ -714,13 +738,19 @@
714
738
 
715
739
  function instance$u($$self, $$props, $$invalidate) {
716
740
  let rendererSize;
741
+ var _a;
717
742
  let { five } = $$props;
718
743
  let { roomLabels } = $$props;
719
744
  let containerWidth;
720
745
  let containerHeight;
721
- let shownFloor = null;
746
+
747
+ let shownFloor = (_a = five.model.shownFloor) !== null && _a !== void 0
748
+ ? _a
749
+ : null;
722
750
 
723
751
  function getLabelVisible(item) {
752
+ const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
753
+ if (!isLabelInFloor) return false;
724
754
  const raycaster = new THREE.Raycaster();
725
755
  const cameraPosition = five.camera.position.clone();
726
756
  const position = new THREE.Vector3(item.position.x, item.position.y, item.position.z);
@@ -739,7 +769,9 @@
739
769
  return `translate(${xOffset}px, ${yOffset}px)`;
740
770
  }
741
771
 
742
- function getFormatedRoomLabels(rendererSize) {
772
+ function getFormatedRoomLabels(params) {
773
+ const { rendererSize, shownFloor } = params;
774
+
743
775
  // 因为 item distance 需要重复计算,所以缓存一下
744
776
  const distanceMap = new Map();
745
777
 
@@ -772,7 +804,7 @@
772
804
  }
773
805
 
774
806
  function onFiveCameraUpdate() {
775
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
807
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
776
808
  }
777
809
 
778
810
  function onFiveModelShownFloorChange(floorIndex) {
@@ -804,21 +836,10 @@
804
836
  $$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
805
837
  }
806
838
 
807
- if ($$self.$$.dirty & /*rendererSize*/ 32) {
839
+ if ($$self.$$.dirty & /*rendererSize, shownFloor*/ 48) {
808
840
  {
809
- // rendererSize 变化时,触发 reRender
810
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
811
- }
812
- }
813
-
814
- if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
815
- {
816
- // shownFloor 变化时,更新 item visible
817
- $$invalidate(0, roomLabels = roomLabels.map(item => {
818
- const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
819
- const visible = isLabelInFloor ? item.visible : false;
820
- return Object.assign(Object.assign({}, item), { visible });
821
- }));
841
+ // rendererSize 和 shownFloor 变化时,触发 reRender
842
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
822
843
  }
823
844
  }
824
845
  };