@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
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
@@ -1,4 +1,11 @@
1
- import type { FivePlugin } from '@realsee/five';
1
+ import type { PartialDeep } from 'type-fest';
2
+ import { FivePlugin } from '@realsee/five';
3
+ export interface Config {
4
+ lookAtCurrentCamera: boolean;
5
+ lockedPanoIndex: number | null;
6
+ lockedLatitude: number | null;
7
+ lockedLongitude: number | null;
8
+ }
2
9
  export interface ModelViewPluginExportType {
3
10
  appendTo: (element: HTMLElement, size?: {
4
11
  width?: number;
@@ -8,10 +15,14 @@ export interface ModelViewPluginExportType {
8
15
  width?: number;
9
16
  height?: number;
10
17
  }) => void;
18
+ changeConfigs: (config: Partial<Config>) => void;
19
+ }
20
+ export interface ModelViewPluginParameterType {
21
+ config: Config;
11
22
  }
12
23
  /**
13
24
  * Five 模型插件
14
25
  * @template ExportType 导出方法
15
26
  */
16
- export declare const ModelViewPlugin: FivePlugin<void, ModelViewPluginExportType>;
27
+ export declare const ModelViewPlugin: FivePlugin<PartialDeep<ModelViewPluginParameterType> | undefined, ModelViewPluginExportType>;
17
28
  export default ModelViewPlugin;
package/dist/index.es.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Camera as Camera$2, Subscribe, Five } from '@realsee/five';
1
2
  import * as THREE from 'three';
2
3
  import { Vector3 as Vector3$1, Scene, Group, Raycaster as Raycaster$1, MeshBasicMaterial, CanvasTexture, AnimationMixer, Color, TextureLoader, Vector2 as Vector2$1, PlaneGeometry, sRGBEncoding, Mesh, CurvePath, LineCurve3, TubeGeometry, ShaderMaterial, SphereGeometry, DoubleSide, RingGeometry, Quaternion, Euler } from 'three';
3
4
  import { CSS3DRenderer, CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer';
@@ -7,7 +8,6 @@ import { onDestroy, onMount, afterUpdate, beforeUpdate } from 'svelte';
7
8
  import { linear } from 'svelte/easing';
8
9
  import { fade } from 'svelte/transition';
9
10
  import { writable } from 'svelte/store';
10
- import { Subscribe, Five } from '@realsee/five';
11
11
  import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
12
12
  import * as TWEEN from '@tweenjs/tween.js';
13
13
  import TWEEN__default from '@tweenjs/tween.js';
@@ -18,12 +18,21 @@ import classNames from 'classnames';
18
18
  * Five 模型插件
19
19
  * @template ExportType 导出方法
20
20
  */
21
- const ModelViewPlugin = (five) => {
21
+ const ModelViewPlugin = (five, params) => {
22
22
  let needsRender = true;
23
23
  let renderer = null;
24
+ const defaultConfig = {
25
+ lookAtCurrentCamera: false,
26
+ lockedPanoIndex: null,
27
+ lockedLatitude: null,
28
+ lockedLongitude: null,
29
+ };
30
+ const config = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
24
31
  const scene = new THREE.Scene();
25
- const camera = new THREE.PerspectiveCamera(60, 1, 0.1, 1000);
32
+ const camera = new Camera$2(60);
26
33
  let model = new THREE.Object3D();
34
+ let distance;
35
+ let offset;
27
36
  {
28
37
  const light = new THREE.DirectionalLight(0xffffff, 0.5);
29
38
  light.position.copy(new THREE.Vector3(1, 1, 1));
@@ -63,6 +72,8 @@ const ModelViewPlugin = (five) => {
63
72
  update();
64
73
  };
65
74
  const handleModelLoaded = () => {
75
+ distance = getDistanceFromModel(five.model, camera.fov, camera.aspect);
76
+ offset = five.model.bounding.getCenter(new THREE.Vector3());
66
77
  function cloneMaterial(_material) {
67
78
  const material = _material.clone();
68
79
  material.uniforms.modelAlpha.value = 1;
@@ -122,29 +133,36 @@ const ModelViewPlugin = (five) => {
122
133
  }
123
134
  update();
124
135
  };
125
- const cameraDistance = () => {
126
- const bounding = five.model.bounding;
127
- const { fov, aspect } = camera;
128
- const radius = Math.sqrt(Math.pow(bounding.max.x - bounding.min.x + 2, 2) +
129
- Math.pow(bounding.max.y - bounding.min.y + 2, 2) +
130
- Math.pow(bounding.max.z - bounding.min.z + 2, 2));
136
+ function getDistanceFromModel(model, fov, aspect) {
137
+ const bounding = model.bounding;
138
+ const radius = Math.pow(Math.pow(bounding.max.x - bounding.min.x + 1, 2) +
139
+ Math.pow(bounding.max.y - bounding.min.y + 1, 2) +
140
+ Math.pow(bounding.max.z - bounding.min.z + 1, 2), 1 / 2);
131
141
  // fit screen
132
142
  let distance = radius / 2 / Math.tan((Math.PI * fov) / 360);
133
143
  if (aspect < 1)
134
144
  distance = distance / aspect;
135
145
  return isNaN(distance) ? radius : distance;
136
- };
146
+ }
147
+ function getOffsetFromPanoIndex(panoIndex) {
148
+ return five.work.observers[panoIndex].standingPosition.clone();
149
+ }
137
150
  const update = () => {
138
- const { longitude, latitude } = five.getPose();
139
- const distance = cameraDistance();
140
- const lookAt = five.model.bounding.getCenter(new THREE.Vector3());
141
- const longitudeDistance = distance * Math.cos(latitude);
142
- const cameraPosition = new THREE.Vector3();
143
- cameraPosition.x = Math.sin(longitude) * longitudeDistance + lookAt.x;
144
- cameraPosition.z = Math.cos(longitude) * longitudeDistance + lookAt.z;
145
- cameraPosition.y = Math.sin(latitude) * distance + lookAt.y;
146
- camera.position.copy(cameraPosition);
147
- camera.lookAt(lookAt);
151
+ if (!distance || !offset)
152
+ return;
153
+ const pose = five.getPose();
154
+ pose.fov = camera.fov;
155
+ pose.offset = offset;
156
+ pose.distance = distance;
157
+ if (typeof config.lockedLatitude === 'number')
158
+ pose.latitude = config.lockedLatitude;
159
+ if (typeof config.lockedLongitude === 'number')
160
+ pose.longitude = config.lockedLongitude;
161
+ if (typeof config.lockedPanoIndex === 'number')
162
+ pose.offset = getOffsetFromPanoIndex(config.lockedPanoIndex);
163
+ if (config.lookAtCurrentCamera)
164
+ pose.offset = five.camera.position.clone().setY(five.camera.position.y + 1);
165
+ camera.setFromPose(pose);
148
166
  needsRender = true;
149
167
  };
150
168
  const render = () => {
@@ -165,12 +183,18 @@ const ModelViewPlugin = (five) => {
165
183
  renderer.dispose();
166
184
  renderer = null;
167
185
  };
186
+ const changeConfigs = (userConfig) => {
187
+ Object.assign(config, userConfig);
188
+ update();
189
+ };
190
+ Object.assign(window, { camera });
168
191
  five.on('modelLoaded', handleModelLoaded);
169
192
  five.on('modelWillLoad', handleModelWillLoad);
170
193
  five.on('cameraDirectionUpdate', update);
171
194
  five.on('dispose', dispose);
172
195
  five.on('renderFrame', render);
173
- return { appendTo, refresh };
196
+ five.on('cameraPositionUpdate', update);
197
+ return { appendTo, refresh, changeConfigs };
174
198
  };
175
199
 
176
200
  function evenNumber(num, config) {
@@ -571,11 +595,11 @@ function add_css$p(target) {
571
595
 
572
596
  function get_each_context$c(ctx, list, i) {
573
597
  const child_ctx = ctx.slice();
574
- child_ctx[12] = list[i];
598
+ child_ctx[13] = list[i];
575
599
  return child_ctx;
576
600
  }
577
601
 
578
- // (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
602
+ // (79:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
579
603
  function create_each_block$c(key_1, ctx) {
580
604
  let first;
581
605
  let roomlabelitem;
@@ -583,7 +607,7 @@ function create_each_block$c(key_1, ctx) {
583
607
 
584
608
  roomlabelitem = new RoomLabelItem({
585
609
  props: {
586
- roomLabel: /*roomLableItem*/ ctx[12],
610
+ roomLabel: /*roomLableItem*/ ctx[13],
587
611
  five: /*five*/ ctx[1]
588
612
  }
589
613
  });
@@ -604,7 +628,7 @@ function create_each_block$c(key_1, ctx) {
604
628
  p(new_ctx, dirty) {
605
629
  ctx = new_ctx;
606
630
  const roomlabelitem_changes = {};
607
- if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
631
+ if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[13];
608
632
  if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
609
633
  roomlabelitem.$set(roomlabelitem_changes);
610
634
  },
@@ -631,7 +655,7 @@ function create_fragment$u(ctx) {
631
655
  let div_resize_listener;
632
656
  let current;
633
657
  let each_value = /*roomLabels*/ ctx[0];
634
- const get_key = ctx => /*roomLableItem*/ ctx[12].id;
658
+ const get_key = ctx => /*roomLableItem*/ ctx[13].id;
635
659
 
636
660
  for (let i = 0; i < each_value.length; i += 1) {
637
661
  let child_ctx = get_each_context$c(ctx, each_value, i);
@@ -698,13 +722,19 @@ function create_fragment$u(ctx) {
698
722
 
699
723
  function instance$u($$self, $$props, $$invalidate) {
700
724
  let rendererSize;
725
+ var _a;
701
726
  let { five } = $$props;
702
727
  let { roomLabels } = $$props;
703
728
  let containerWidth;
704
729
  let containerHeight;
705
- let shownFloor = null;
730
+
731
+ let shownFloor = (_a = five.model.shownFloor) !== null && _a !== void 0
732
+ ? _a
733
+ : null;
706
734
 
707
735
  function getLabelVisible(item) {
736
+ const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
737
+ if (!isLabelInFloor) return false;
708
738
  const raycaster = new Raycaster$1();
709
739
  const cameraPosition = five.camera.position.clone();
710
740
  const position = new Vector3$1(item.position.x, item.position.y, item.position.z);
@@ -723,7 +753,9 @@ function instance$u($$self, $$props, $$invalidate) {
723
753
  return `translate(${xOffset}px, ${yOffset}px)`;
724
754
  }
725
755
 
726
- function getFormatedRoomLabels(rendererSize) {
756
+ function getFormatedRoomLabels(params) {
757
+ const { rendererSize, shownFloor } = params;
758
+
727
759
  // 因为 item distance 需要重复计算,所以缓存一下
728
760
  const distanceMap = new Map();
729
761
 
@@ -756,7 +788,7 @@ function instance$u($$self, $$props, $$invalidate) {
756
788
  }
757
789
 
758
790
  function onFiveCameraUpdate() {
759
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
791
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
760
792
  }
761
793
 
762
794
  function onFiveModelShownFloorChange(floorIndex) {
@@ -788,21 +820,10 @@ function instance$u($$self, $$props, $$invalidate) {
788
820
  $$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
789
821
  }
790
822
 
791
- if ($$self.$$.dirty & /*rendererSize*/ 32) {
792
- {
793
- // rendererSize 变化时,触发 reRender
794
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
795
- }
796
- }
797
-
798
- if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
823
+ if ($$self.$$.dirty & /*rendererSize, shownFloor*/ 48) {
799
824
  {
800
- // shownFloor 变化时,更新 item visible
801
- $$invalidate(0, roomLabels = roomLabels.map(item => {
802
- const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
803
- const visible = isLabelInFloor ? item.visible : false;
804
- return Object.assign(Object.assign({}, item), { visible });
805
- }));
825
+ // rendererSize 和 shownFloor 变化时,触发 reRender
826
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
806
827
  }
807
828
  }
808
829
  };