@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
@@ -34,11 +34,11 @@ function add_css(target) {
34
34
 
35
35
  function get_each_context(ctx, list, i) {
36
36
  const child_ctx = ctx.slice();
37
- child_ctx[12] = list[i];
37
+ child_ctx[13] = list[i];
38
38
  return child_ctx;
39
39
  }
40
40
 
41
- // (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
41
+ // (79:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
42
42
  function create_each_block(key_1, ctx) {
43
43
  let first;
44
44
  let roomlabelitem;
@@ -46,7 +46,7 @@ function create_each_block(key_1, ctx) {
46
46
 
47
47
  roomlabelitem = new RoomLabelItem({
48
48
  props: {
49
- roomLabel: /*roomLableItem*/ ctx[12],
49
+ roomLabel: /*roomLableItem*/ ctx[13],
50
50
  five: /*five*/ ctx[1]
51
51
  }
52
52
  });
@@ -67,7 +67,7 @@ function create_each_block(key_1, ctx) {
67
67
  p(new_ctx, dirty) {
68
68
  ctx = new_ctx;
69
69
  const roomlabelitem_changes = {};
70
- if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
70
+ if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[13];
71
71
  if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
72
72
  roomlabelitem.$set(roomlabelitem_changes);
73
73
  },
@@ -94,7 +94,7 @@ function create_fragment(ctx) {
94
94
  let div_resize_listener;
95
95
  let current;
96
96
  let each_value = /*roomLabels*/ ctx[0];
97
- const get_key = ctx => /*roomLableItem*/ ctx[12].id;
97
+ const get_key = ctx => /*roomLableItem*/ ctx[13].id;
98
98
 
99
99
  for (let i = 0; i < each_value.length; i += 1) {
100
100
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -161,13 +161,19 @@ function create_fragment(ctx) {
161
161
 
162
162
  function instance($$self, $$props, $$invalidate) {
163
163
  let rendererSize;
164
+ var _a;
164
165
  let { five } = $$props;
165
166
  let { roomLabels } = $$props;
166
167
  let containerWidth;
167
168
  let containerHeight;
168
- let shownFloor = null;
169
+
170
+ let shownFloor = (_a = five.model.shownFloor) !== null && _a !== void 0
171
+ ? _a
172
+ : null;
169
173
 
170
174
  function getLabelVisible(item) {
175
+ const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
176
+ if (!isLabelInFloor) return false;
171
177
  const raycaster = new Raycaster();
172
178
  const cameraPosition = five.camera.position.clone();
173
179
  const position = new Vector3(item.position.x, item.position.y, item.position.z);
@@ -186,7 +192,9 @@ function instance($$self, $$props, $$invalidate) {
186
192
  return `translate(${xOffset}px, ${yOffset}px)`;
187
193
  }
188
194
 
189
- function getFormatedRoomLabels(rendererSize) {
195
+ function getFormatedRoomLabels(params) {
196
+ const { rendererSize, shownFloor } = params;
197
+
190
198
  // 因为 item distance 需要重复计算,所以缓存一下
191
199
  const distanceMap = new Map();
192
200
 
@@ -219,7 +227,7 @@ function instance($$self, $$props, $$invalidate) {
219
227
  }
220
228
 
221
229
  function onFiveCameraUpdate() {
222
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
230
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
223
231
  }
224
232
 
225
233
  function onFiveModelShownFloorChange(floorIndex) {
@@ -251,21 +259,10 @@ function instance($$self, $$props, $$invalidate) {
251
259
  $: $$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
252
260
  }
253
261
 
254
- if ($$self.$$.dirty & /*rendererSize*/ 32) {
255
- $: {
256
- // rendererSize 变化时,触发 reRender
257
- $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
258
- }
259
- }
260
-
261
- if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
262
+ if ($$self.$$.dirty & /*rendererSize, shownFloor*/ 48) {
262
263
  $: {
263
- // shownFloor 变化时,更新 item visible
264
- $$invalidate(0, roomLabels = roomLabels.map(item => {
265
- const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
266
- const visible = isLabelInFloor ? item.visible : false;
267
- return Object.assign(Object.assign({}, item), { visible });
268
- }));
264
+ // rendererSize 和 shownFloor 变化时,触发 reRender
265
+ $$invalidate(0, roomLabels = getFormatedRoomLabels({ rendererSize, shownFloor }));
269
266
  }
270
267
  }
271
268
  };
@@ -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,14 +1,24 @@
1
+ import { Camera } from '@realsee/five';
1
2
  import * as THREE from 'three';
2
3
  /**
3
4
  * Five 模型插件
4
5
  * @template ExportType 导出方法
5
6
  */
6
- export const ModelViewPlugin = (five) => {
7
+ export const ModelViewPlugin = (five, params) => {
7
8
  let needsRender = true;
8
9
  let renderer = null;
10
+ const defaultConfig = {
11
+ lookAtCurrentCamera: false,
12
+ lockedPanoIndex: null,
13
+ lockedLatitude: null,
14
+ lockedLongitude: null,
15
+ };
16
+ const config = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
9
17
  const scene = new THREE.Scene();
10
- const camera = new THREE.PerspectiveCamera(60, 1, 0.1, 1000);
18
+ const camera = new Camera(60);
11
19
  let model = new THREE.Object3D();
20
+ let distance;
21
+ let offset;
12
22
  {
13
23
  const light = new THREE.DirectionalLight(0xffffff, 0.5);
14
24
  light.position.copy(new THREE.Vector3(1, 1, 1));
@@ -48,6 +58,8 @@ export const ModelViewPlugin = (five) => {
48
58
  update();
49
59
  };
50
60
  const handleModelLoaded = () => {
61
+ distance = getDistanceFromModel(five.model, camera.fov, camera.aspect);
62
+ offset = five.model.bounding.getCenter(new THREE.Vector3());
51
63
  function cloneMaterial(_material) {
52
64
  const material = _material.clone();
53
65
  material.uniforms.modelAlpha.value = 1;
@@ -107,29 +119,36 @@ export const ModelViewPlugin = (five) => {
107
119
  }
108
120
  update();
109
121
  };
110
- const cameraDistance = () => {
111
- const bounding = five.model.bounding;
112
- const { fov, aspect } = camera;
113
- const radius = Math.sqrt(Math.pow(bounding.max.x - bounding.min.x + 2, 2) +
114
- Math.pow(bounding.max.y - bounding.min.y + 2, 2) +
115
- Math.pow(bounding.max.z - bounding.min.z + 2, 2));
122
+ function getDistanceFromModel(model, fov, aspect) {
123
+ const bounding = model.bounding;
124
+ const radius = Math.pow(Math.pow(bounding.max.x - bounding.min.x + 1, 2) +
125
+ Math.pow(bounding.max.y - bounding.min.y + 1, 2) +
126
+ Math.pow(bounding.max.z - bounding.min.z + 1, 2), 1 / 2);
116
127
  // fit screen
117
128
  let distance = radius / 2 / Math.tan((Math.PI * fov) / 360);
118
129
  if (aspect < 1)
119
130
  distance = distance / aspect;
120
131
  return isNaN(distance) ? radius : distance;
121
- };
132
+ }
133
+ function getOffsetFromPanoIndex(panoIndex) {
134
+ return five.work.observers[panoIndex].standingPosition.clone();
135
+ }
122
136
  const update = () => {
123
- const { longitude, latitude } = five.getPose();
124
- const distance = cameraDistance();
125
- const lookAt = five.model.bounding.getCenter(new THREE.Vector3());
126
- const longitudeDistance = distance * Math.cos(latitude);
127
- const cameraPosition = new THREE.Vector3();
128
- cameraPosition.x = Math.sin(longitude) * longitudeDistance + lookAt.x;
129
- cameraPosition.z = Math.cos(longitude) * longitudeDistance + lookAt.z;
130
- cameraPosition.y = Math.sin(latitude) * distance + lookAt.y;
131
- camera.position.copy(cameraPosition);
132
- camera.lookAt(lookAt);
137
+ if (!distance || !offset)
138
+ return;
139
+ const pose = five.getPose();
140
+ pose.fov = camera.fov;
141
+ pose.offset = offset;
142
+ pose.distance = distance;
143
+ if (typeof config.lockedLatitude === 'number')
144
+ pose.latitude = config.lockedLatitude;
145
+ if (typeof config.lockedLongitude === 'number')
146
+ pose.longitude = config.lockedLongitude;
147
+ if (typeof config.lockedPanoIndex === 'number')
148
+ pose.offset = getOffsetFromPanoIndex(config.lockedPanoIndex);
149
+ if (config.lookAtCurrentCamera)
150
+ pose.offset = five.camera.position.clone().setY(five.camera.position.y + 1);
151
+ camera.setFromPose(pose);
133
152
  needsRender = true;
134
153
  };
135
154
  const render = () => {
@@ -150,11 +169,17 @@ export const ModelViewPlugin = (five) => {
150
169
  renderer.dispose();
151
170
  renderer = null;
152
171
  };
172
+ const changeConfigs = (userConfig) => {
173
+ Object.assign(config, userConfig);
174
+ update();
175
+ };
176
+ Object.assign(window, { camera });
153
177
  five.on('modelLoaded', handleModelLoaded);
154
178
  five.on('modelWillLoad', handleModelWillLoad);
155
179
  five.on('cameraDirectionUpdate', update);
156
180
  five.on('dispose', dispose);
157
181
  five.on('renderFrame', render);
158
- return { appendTo, refresh };
182
+ five.on('cameraPositionUpdate', update);
183
+ return { appendTo, refresh, changeConfigs };
159
184
  };
160
185
  export default ModelViewPlugin;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "repository": "https://github.com/realsee-developer/dnalogel.git",
9
9
  "description": "如视 VR 看房插件合集",
10
10
  "private": false,
11
- "version": "2.0.2",
11
+ "version": "2.0.3",
12
12
  "license": "SEE LICENSE IN TERMS.txt",
13
13
  "scripts": {
14
14
  "build": "yarn run tsb && yarn run build:rollup && yarn run build:components && yarn build:docs",
@@ -46,8 +46,8 @@
46
46
  "eslint": "^8.9.0",
47
47
  "eslint-config-alloy": "^4.5.1",
48
48
  "glob": "^8.0.1",
49
- "postcss": "^8.4.6",
50
49
  "polyline-normals": "^2.0.2",
50
+ "postcss": "^8.4.6",
51
51
  "postcss-plugin-px2rem": "^0.8.1",
52
52
  "replace": "^1.2.1",
53
53
  "rollup-plugin-multi-input": "^1.3.1",
@@ -59,7 +59,7 @@
59
59
  "svelte-strip": "^1.0.1",
60
60
  "three": "0.117.1",
61
61
  "tslib": "^2.3.1",
62
- "type-fest": "^2.19.0",
62
+ "type-fest": "^3.0.0",
63
63
  "typedoc": "^0.22.11",
64
64
  "typescript": "^4.5.5",
65
65
  "vite": "^2.8.0"