@realsee/dnalogel 2.0.0-alpha.26-beta → 2.0.0-alpha.28-beta

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 (139) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/CSS3DRenderPlugin/Plugin.d.ts +49 -0
  3. package/dist/CSS3DRenderPlugin/index.d.ts +3 -48
  4. package/dist/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
  5. package/dist/CameraMovementPlugin/index.d.ts +4 -6
  6. package/dist/CameraMovementPlugin/index.js +12 -12
  7. package/dist/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
  8. package/dist/ModelChassisCompassPlugin/index.d.ts +3 -18
  9. package/dist/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
  10. package/dist/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
  11. package/dist/ModelEntryDoorGuidePlugin/index.js +0 -5
  12. package/dist/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
  13. package/dist/ModelItemLabelPlugin/index.d.ts +8 -3
  14. package/dist/ModelItemLabelPlugin/index.js +14 -8
  15. package/dist/ModelRoomLabelPlugin/index.js +82 -46
  16. package/dist/ModelTVVideoPlugin/Plugin.d.ts +4 -0
  17. package/dist/ModelTVVideoPlugin/index.d.ts +4 -3
  18. package/dist/ModelTVVideoPlugin/index.js +3 -3
  19. package/dist/ModelViewPlugin/Plugin.d.ts +17 -0
  20. package/dist/ModelViewPlugin/index.d.ts +3 -16
  21. package/dist/PanoCompassPlugin/Plugin.d.ts +47 -0
  22. package/dist/PanoCompassPlugin/index.d.ts +4 -47
  23. package/dist/PanoCompassPlugin/index.js +5 -4
  24. package/dist/PanoMeasurePlugin/index.d.ts +1 -1
  25. package/dist/PanoMeasurePlugin/index.js +4 -1
  26. package/dist/PanoRulerPlugin/Plugin.d.ts +31 -0
  27. package/dist/PanoRulerPlugin/index.d.ts +4 -30
  28. package/dist/PanoRulerPlugin/index.js +0 -5
  29. package/dist/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
  30. package/dist/PanoSpatialTagPlugin/index.d.ts +4 -32
  31. package/dist/PanoSpatialTagPlugin/index.js +23 -21
  32. package/dist/_index.d.ts +30 -0
  33. package/dist/index.d.ts +16 -29
  34. package/dist/index.es.js +122 -70
  35. package/dist/index.js +145 -90
  36. package/dist/index.umd.js +145 -90
  37. package/docs/assets/search.js +1 -1
  38. package/docs/classes/ModelRoomLabelController.html +6 -6
  39. package/docs/classes/PanoFloorplanRadarPluginController.html +3 -0
  40. package/docs/enums/CameraMovementEffect.html +3 -0
  41. package/docs/enums/DIRECTION.html +1 -0
  42. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -0
  43. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  44. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  45. package/docs/enums/Rotation.html +3 -0
  46. package/docs/index.html +1 -1
  47. package/docs/interfaces/CSS3DRenderPluginExportType.html +4 -0
  48. package/docs/interfaces/CameraMovementPluginExportType.html +17 -0
  49. package/docs/interfaces/LineJson.html +1 -1
  50. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  51. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  52. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  53. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  54. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  55. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  56. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  57. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  58. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  59. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  60. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  61. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  62. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  63. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  64. package/docs/interfaces/ModelViewPluginExportType.html +1 -0
  65. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  66. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  67. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  68. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -0
  69. package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -0
  70. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  71. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  72. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  73. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -0
  74. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -0
  75. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  76. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -0
  77. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  78. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -0
  79. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  80. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -0
  81. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -0
  82. package/docs/interfaces/Point.html +1 -0
  83. package/docs/interfaces/PointJson.html +1 -1
  84. package/docs/interfaces/Room.html +1 -0
  85. package/docs/interfaces/RoomInfo.html +1 -0
  86. package/docs/interfaces/RoomLabel.html +7 -7
  87. package/docs/interfaces/RoomRules.html +1 -0
  88. package/docs/interfaces/Rooms.html +1 -0
  89. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +8 -8
  90. package/docs/modules.html +20 -12
  91. package/libs/CSS3DRenderPlugin/Plugin.d.ts +49 -0
  92. package/libs/CSS3DRenderPlugin/Plugin.js +182 -0
  93. package/libs/CSS3DRenderPlugin/index.d.ts +3 -48
  94. package/libs/CSS3DRenderPlugin/index.js +2 -181
  95. package/libs/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
  96. package/libs/CameraMovementPlugin/CameraMovementPlugin.js +159 -0
  97. package/libs/CameraMovementPlugin/index.d.ts +4 -6
  98. package/libs/CameraMovementPlugin/index.js +3 -158
  99. package/libs/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
  100. package/libs/ModelChassisCompassPlugin/Plugin.js +75 -0
  101. package/libs/ModelChassisCompassPlugin/index.d.ts +3 -18
  102. package/libs/ModelChassisCompassPlugin/index.js +2 -74
  103. package/libs/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
  104. package/libs/ModelEntryDoorGuidePlugin/Plugin.js +140 -0
  105. package/libs/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
  106. package/libs/ModelEntryDoorGuidePlugin/index.js +2 -139
  107. package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +1 -1
  108. package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
  109. package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.js +120 -0
  110. package/libs/ModelItemLabelPlugin/index.d.ts +8 -3
  111. package/libs/ModelItemLabelPlugin/index.js +7 -119
  112. package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +83 -47
  113. package/libs/ModelTVVideoPlugin/Plugin.d.ts +4 -0
  114. package/libs/ModelTVVideoPlugin/Plugin.js +254 -0
  115. package/libs/ModelTVVideoPlugin/index.d.ts +4 -3
  116. package/libs/ModelTVVideoPlugin/index.js +3 -253
  117. package/libs/ModelViewPlugin/Plugin.d.ts +17 -0
  118. package/libs/ModelViewPlugin/Plugin.js +160 -0
  119. package/libs/ModelViewPlugin/index.d.ts +3 -16
  120. package/libs/ModelViewPlugin/index.js +2 -159
  121. package/libs/PanoCompassPlugin/Plugin.d.ts +47 -0
  122. package/libs/PanoCompassPlugin/Plugin.js +249 -0
  123. package/libs/PanoCompassPlugin/index.d.ts +4 -47
  124. package/libs/PanoCompassPlugin/index.js +3 -249
  125. package/libs/PanoMeasurePlugin/index.d.ts +1 -1
  126. package/libs/PanoMeasurePlugin/index.js +1 -1
  127. package/libs/PanoRulerPlugin/Plugin.d.ts +31 -0
  128. package/libs/PanoRulerPlugin/Plugin.js +402 -0
  129. package/libs/PanoRulerPlugin/index.d.ts +4 -30
  130. package/libs/PanoRulerPlugin/index.js +2 -401
  131. package/libs/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
  132. package/libs/PanoSpatialTagPlugin/Plugin.js +415 -0
  133. package/libs/PanoSpatialTagPlugin/index.d.ts +4 -32
  134. package/libs/PanoSpatialTagPlugin/index.js +4 -412
  135. package/libs/_index.d.ts +30 -0
  136. package/libs/_index.js +18 -0
  137. package/libs/index.d.ts +16 -29
  138. package/libs/index.js +25 -16
  139. package/package.json +6 -5
@@ -1,140 +1,3 @@
1
- import { AnimationMixer, MeshBasicMaterial } from 'three';
2
- import * as THREE from 'three';
3
- import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
4
- import createCanvasTextTexture from '../shared-utils/createCanvasTextTexture';
5
- import transformPositionToVector3 from '../shared-utils/three/transformPositionToVector3';
6
- import transfromToMeshBasicMaterial from '../shared-utils/three/transfromToMeshBasicMaterial';
7
- /**
8
- * 模型入户门引导插件
9
- */
10
- export const ModelEntryDoorGuidePlugin = (five, params) => {
11
- var _a, _b, _c;
12
- // 局部状态
13
- const state = {};
14
- const defaultAnimationEnable = (_a = params.animationEnabled) !== null && _a !== void 0 ? _a : true;
15
- const defaultModelPosition = (_b = params.position) !== null && _b !== void 0 ? _b : undefined;
16
- const defaultRad = (_c = params.rad) !== null && _c !== void 0 ? _c : undefined;
17
- const defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
18
- const mixers = [];
19
- const load = async (data) => {
20
- var _a, _b, _c, _d, _e, _f, _g;
21
- const position = (_a = data === null || data === void 0 ? void 0 : data.position) !== null && _a !== void 0 ? _a : defaultModelPosition;
22
- if (!position)
23
- return Promise.reject(`ModelEntryDoorGuidePlugin.load(): position is undefined`);
24
- const modelPosition = transformPositionToVector3(position);
25
- const rad = (_b = data === null || data === void 0 ? void 0 : data.rad) !== null && _b !== void 0 ? _b : defaultRad;
26
- const fbxUrl = (_c = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _c !== void 0 ? _c : defaultFbxUrl;
27
- state.rad = rad;
28
- if (rad === undefined)
29
- return Promise.reject(`ModelEntryDoorGuidePlugin.load(): rad is ${rad}`);
30
- // 加载模型
31
- const object = await new FBXLoader().loadAsync(fbxUrl);
32
- // 设置位置
33
- object.position.copy(modelPosition);
34
- object.rotation.z = rad;
35
- object.scale.set(0.8, 0.8, 0.8);
36
- transfromToMeshBasicMaterial(object, { transparent: true, side: THREE.DoubleSide });
37
- const textMesh = (_g = (_f = (_e = (_d = object.children) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.children) === null || _f === void 0 ? void 0 : _f[3]) === null || _g === void 0 ? void 0 : _g.clone();
38
- if (!textMesh)
39
- return Promise.reject(`ModelEntryDoorGuidePlugin.load(): textMesh is ${textMesh}`);
40
- textMesh.material = new MeshBasicMaterial({ transparent: true, map: createCanvasTextTexture('入户门') });
41
- textMesh.renderOrder = 3;
42
- object.children[0].add(textMesh);
43
- state.object = object;
44
- return true;
45
- };
46
- const initAnimation = () => {
47
- if (state.animation)
48
- return;
49
- if (!state.object)
50
- return console.error('ModelEntryDoorGuidePlugin.initAnimation(): state.object is ', state.object);
51
- // action
52
- const animationSpeed = 1;
53
- const mixer = new AnimationMixer(state.object);
54
- mixers.push(mixer);
55
- const action = mixer.clipAction(state.object.animations[0]);
56
- action.timeScale = animationSpeed;
57
- let stopAnimation;
58
- const requestAnimationFrameLoop = () => {
59
- let index = 0;
60
- let oldTime = 0;
61
- const minDeltaTime = 1000 / 30;
62
- const animation = (time) => {
63
- index = requestAnimationFrame(animation);
64
- const deltaTime = time - oldTime;
65
- if (deltaTime < minDeltaTime)
66
- return;
67
- oldTime = time;
68
- mixers.forEach((mixer) => mixer.update(deltaTime / 1000));
69
- five.needsRender = true;
70
- };
71
- index = requestAnimationFrame(animation);
72
- return () => {
73
- cancelAnimationFrame(index);
74
- };
75
- };
76
- const play = () => {
77
- if (stopAnimation)
78
- return;
79
- action.play();
80
- stopAnimation = requestAnimationFrameLoop();
81
- // 开始播动画时,rotation可能会还原
82
- requestAnimationFrame(() => {
83
- if (state.object && state.object.rotation.z !== state.rad)
84
- state.object.rotation.z = state.rad;
85
- });
86
- };
87
- const stop = () => {
88
- action.stop();
89
- stopAnimation === null || stopAnimation === void 0 ? void 0 : stopAnimation();
90
- stopAnimation = undefined;
91
- };
92
- const animation = { play, stop };
93
- state.animation = animation;
94
- };
95
- const show = (config) => {
96
- var _a;
97
- if (!state.object)
98
- return console.error('ModelEntryDoorGuidePlugin.enable(): object is ', state.object);
99
- const animationEnable = (_a = config === null || config === void 0 ? void 0 : config.animationEnable) !== null && _a !== void 0 ? _a : defaultAnimationEnable;
100
- if (animationEnable) {
101
- if (!state.animation)
102
- initAnimation();
103
- state.animation.play();
104
- }
105
- five.scene.add(state.object);
106
- five.needsRender = true;
107
- };
108
- const hide = () => {
109
- if (!state.object)
110
- return;
111
- if (state.animation)
112
- state.animation.stop();
113
- five.scene.remove(state.object);
114
- five.needsRender = true;
115
- };
116
- const modeChangeHandler = (mode) => (mode === 'Floorplan' ? show() : hide());
117
- const enable = (config) => {
118
- if (state.enabled)
119
- return true;
120
- state.enabled = true;
121
- modeChangeHandler(five.currentMode);
122
- five.on('modeChange', modeChangeHandler);
123
- show(config);
124
- return true;
125
- };
126
- const disable = () => {
127
- if (!state.enabled)
128
- return true;
129
- state.enabled = false;
130
- hide();
131
- five.off('modeChange', modeChangeHandler);
132
- return true;
133
- };
134
- return { load, enable, disable };
135
- };
136
- export const modelEntryDoorGuidePluginServerParams = {
137
- name: 'ModelEntryDoorGuidePlugin',
138
- version: 0,
139
- };
1
+ import ModelEntryDoorGuidePlugin from './Plugin';
2
+ export { ModelEntryDoorGuidePlugin };
140
3
  export default ModelEntryDoorGuidePlugin;
@@ -40,7 +40,7 @@ function get_each_context(ctx, list, i) {
40
40
  return child_ctx;
41
41
  }
42
42
 
43
- // (162:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
43
+ // (163:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
44
44
  function create_each_block(key_1, ctx) {
45
45
  let first;
46
46
  let itemlabelitem;
@@ -0,0 +1,4 @@
1
+ import type { FivePlugin } from "@realsee/five";
2
+ import { ModelItemLabelPluginExportReturnsType, ModelItemLabelPluginParametersType } from "./typings";
3
+ export declare const ModelItemLabelPlugin: FivePlugin<ModelItemLabelPluginParametersType, ModelItemLabelPluginExportReturnsType>;
4
+ export default ModelItemLabelPlugin;
@@ -0,0 +1,120 @@
1
+ import { Five, Subscribe } from "@realsee/five";
2
+ import ItemLabelComponent from './ItemLabelComponent';
3
+ import { DISPLAY_STRATEGY_TYPE } from "./typings";
4
+ import { parseModelItemLabelPluginData } from "./utils/parseData";
5
+ export const ModelItemLabelPlugin = (five, params) => {
6
+ var _a, _b;
7
+ const pluginState = {
8
+ container: document.createElement('div'),
9
+ data: null,
10
+ enabled: true,
11
+ fiveModeEnabled: undefined,
12
+ itemLabels: [],
13
+ wrapper: null,
14
+ app: undefined,
15
+ hooks: new Subscribe(),
16
+ modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
17
+ displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : DISPLAY_STRATEGY_TYPE.SMALL,
18
+ };
19
+ pluginState.container.setAttribute('class', 'model-item-label-plugin-container');
20
+ pluginState.container.style.cssText = `
21
+ position: absolute;
22
+ left: 0;
23
+ top: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ z-index: 5;
27
+ `;
28
+ pluginState.container.style.pointerEvents = 'none'; // 写到 cssText 里不生效
29
+ const appendTo = (wrapper) => {
30
+ pluginState.wrapper = wrapper;
31
+ wrapper.appendChild(pluginState.container);
32
+ render();
33
+ return true;
34
+ };
35
+ const load = (data) => {
36
+ pluginState.itemLabels = parseModelItemLabelPluginData(data);
37
+ render();
38
+ };
39
+ const enable = () => {
40
+ if (pluginState.enabled)
41
+ return true;
42
+ pluginState.enabled = true;
43
+ render();
44
+ return true;
45
+ };
46
+ const disable = () => {
47
+ if (!pluginState.enabled)
48
+ return true;
49
+ pluginState.enabled = false;
50
+ render();
51
+ return true;
52
+ };
53
+ const dispose = () => {
54
+ removeListener4Five();
55
+ pluginState.container.remove();
56
+ };
57
+ const render = () => {
58
+ var _a;
59
+ if (!pluginState.wrapper)
60
+ return;
61
+ // 只要不可展示,销毁容器
62
+ if (!pluginState.enabled || !pluginState.fiveModeEnabled) {
63
+ (_a = pluginState.app) === null || _a === void 0 ? void 0 : _a.$destroy();
64
+ pluginState.app = undefined;
65
+ return;
66
+ }
67
+ // 正常显示时,分为 app 存在和不存在两种情况,如果存在,传值,不存在则初始化并传值
68
+ if (!pluginState.app) {
69
+ pluginState.app = new ItemLabelComponent({
70
+ target: pluginState.container,
71
+ props: {
72
+ five: five,
73
+ modelOcclusionEnable: pluginState.modelOcclusionEnable,
74
+ itemLabels: pluginState.itemLabels,
75
+ wrapper: pluginState.wrapper,
76
+ hooks: pluginState.hooks,
77
+ displayStrategyType: pluginState.displayStrategyType
78
+ }
79
+ });
80
+ }
81
+ else {
82
+ pluginState.app.$set({
83
+ five: five,
84
+ itemLabels: pluginState.itemLabels
85
+ });
86
+ }
87
+ };
88
+ // 添加 five 监听
89
+ const addListener4Five = () => {
90
+ five.on('modeChange', onFiveModeChange);
91
+ five.once('dispose', dispose);
92
+ };
93
+ // 取消 five 监听
94
+ const removeListener4Five = () => {
95
+ five.off('modeChange', onFiveModeChange);
96
+ };
97
+ const onFiveModeChange = (mode) => {
98
+ if (!pluginState.enabled)
99
+ return;
100
+ if (mode !== Five.Mode.Floorplan) {
101
+ pluginState.fiveModeEnabled = false;
102
+ render();
103
+ return;
104
+ }
105
+ five.once('initAnimationEnded', () => {
106
+ pluginState.fiveModeEnabled = five.currentMode === Five.Mode.Floorplan;
107
+ render();
108
+ });
109
+ };
110
+ addListener4Five();
111
+ return {
112
+ appendTo,
113
+ load,
114
+ enable,
115
+ disable,
116
+ dispose,
117
+ hooks: pluginState.hooks
118
+ };
119
+ };
120
+ export default ModelItemLabelPlugin;
@@ -1,4 +1,9 @@
1
- import type { FivePlugin } from "@realsee/five";
2
- import { ModelItemLabelPluginExportReturnsType, ModelItemLabelPluginParametersType } from "./typings";
3
- export declare const ModelItemLabelPlugin: FivePlugin<ModelItemLabelPluginParametersType, ModelItemLabelPluginExportReturnsType>;
1
+ import ModelItemLabelPlugin from './ModelItemLabelPlugin';
2
+ export { ModelItemLabelPlugin };
4
3
  export default ModelItemLabelPlugin;
4
+ export declare const modelItemLabelPluginServerParams: {
5
+ name: string;
6
+ version: number;
7
+ };
8
+ export type { ModelItemLabelPluginParametersType, ModelItemLabelPluginData, ModelItemLabelPluginExportReturnsType } from './typings';
9
+ export { DISPLAY_STRATEGY_TYPE } from './typings';
@@ -1,120 +1,8 @@
1
- import { Five, Subscribe } from "@realsee/five";
2
- import ItemLabelComponent from './ItemLabelComponent';
3
- import { DISPLAY_STRATEGY_TYPE } from "./typings";
4
- import { parseModelItemLabelPluginData } from "./utils/parseData";
5
- export const ModelItemLabelPlugin = (five, params) => {
6
- var _a, _b;
7
- const pluginState = {
8
- container: document.createElement('div'),
9
- data: null,
10
- enabled: true,
11
- fiveModeEnabled: undefined,
12
- itemLabels: [],
13
- wrapper: null,
14
- app: undefined,
15
- hooks: new Subscribe(),
16
- modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
17
- displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : DISPLAY_STRATEGY_TYPE.SMALL,
18
- };
19
- pluginState.container.setAttribute('class', 'model-item-label-plugin-container');
20
- pluginState.container.style.cssText = `
21
- position: absolute;
22
- left: 0;
23
- top: 0;
24
- width: 100%;
25
- height: 100%;
26
- z-index: 5;
27
- `;
28
- pluginState.container.style.pointerEvents = 'none'; // 写到 cssText 里不生效
29
- const appendTo = (wrapper) => {
30
- pluginState.wrapper = wrapper;
31
- wrapper.appendChild(pluginState.container);
32
- render();
33
- return true;
34
- };
35
- const load = (data) => {
36
- pluginState.itemLabels = parseModelItemLabelPluginData(data);
37
- render();
38
- };
39
- const enable = () => {
40
- if (pluginState.enabled)
41
- return true;
42
- pluginState.enabled = true;
43
- render();
44
- return true;
45
- };
46
- const disable = () => {
47
- if (!pluginState.enabled)
48
- return true;
49
- pluginState.enabled = false;
50
- render();
51
- return true;
52
- };
53
- const dispose = () => {
54
- removeListener4Five();
55
- pluginState.container.remove();
56
- };
57
- const render = () => {
58
- var _a;
59
- if (!pluginState.wrapper)
60
- return;
61
- // 只要不可展示,销毁容器
62
- if (!pluginState.enabled || !pluginState.fiveModeEnabled) {
63
- (_a = pluginState.app) === null || _a === void 0 ? void 0 : _a.$destroy();
64
- pluginState.app = undefined;
65
- return;
66
- }
67
- // 正常显示时,分为 app 存在和不存在两种情况,如果存在,传值,不存在则初始化并传值
68
- if (!pluginState.app) {
69
- pluginState.app = new ItemLabelComponent({
70
- target: pluginState.container,
71
- props: {
72
- five: five,
73
- modelOcclusionEnable: pluginState.modelOcclusionEnable,
74
- itemLabels: pluginState.itemLabels,
75
- wrapper: pluginState.wrapper,
76
- hooks: pluginState.hooks,
77
- displayStrategyType: pluginState.displayStrategyType
78
- }
79
- });
80
- }
81
- else {
82
- pluginState.app.$set({
83
- five: five,
84
- itemLabels: pluginState.itemLabels
85
- });
86
- }
87
- };
88
- // 添加 five 监听
89
- const addListener4Five = () => {
90
- five.on('modeChange', onFiveModeChange);
91
- five.once('dispose', dispose);
92
- };
93
- // 取消 five 监听
94
- const removeListener4Five = () => {
95
- five.off('modeChange', onFiveModeChange);
96
- };
97
- const onFiveModeChange = (mode) => {
98
- if (!pluginState.enabled)
99
- return;
100
- if (mode !== Five.Mode.Floorplan) {
101
- pluginState.fiveModeEnabled = false;
102
- render();
103
- return;
104
- }
105
- five.once('initAnimationEnded', () => {
106
- pluginState.fiveModeEnabled = five.currentMode === Five.Mode.Floorplan;
107
- render();
108
- });
109
- };
110
- addListener4Five();
111
- return {
112
- appendTo,
113
- load,
114
- enable,
115
- disable,
116
- dispose,
117
- hooks: pluginState.hooks
118
- };
119
- };
1
+ import ModelItemLabelPlugin from './ModelItemLabelPlugin';
2
+ export { ModelItemLabelPlugin };
120
3
  export default ModelItemLabelPlugin;
4
+ export const modelItemLabelPluginServerParams = {
5
+ name: 'ModelItemLabelPlugin',
6
+ version: 0,
7
+ };
8
+ export { DISPLAY_STRATEGY_TYPE } from './typings';
@@ -11,6 +11,7 @@ import {
11
11
  detach,
12
12
  element,
13
13
  empty,
14
+ globals,
14
15
  group_outros,
15
16
  init,
16
17
  insert,
@@ -22,7 +23,8 @@ import {
22
23
  update_keyed_each
23
24
  } from "svelte/internal";
24
25
 
25
- import { onDestroy, onMount } from 'svelte';
26
+ const { Map: Map_1 } = globals;
27
+ import { onDestroy } from 'svelte';
26
28
  import { Raycaster, Vector3 } from 'three';
27
29
  import RoomLabelItem from './RoomLabelItem';
28
30
 
@@ -32,11 +34,11 @@ function add_css(target) {
32
34
 
33
35
  function get_each_context(ctx, list, i) {
34
36
  const child_ctx = ctx.slice();
35
- child_ctx[9] = list[i];
37
+ child_ctx[12] = list[i];
36
38
  return child_ctx;
37
39
  }
38
40
 
39
- // (70:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
41
+ // (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
40
42
  function create_each_block(key_1, ctx) {
41
43
  let first;
42
44
  let roomlabelitem;
@@ -44,7 +46,7 @@ function create_each_block(key_1, ctx) {
44
46
 
45
47
  roomlabelitem = new RoomLabelItem({
46
48
  props: {
47
- roomLabel: /*roomLableItem*/ ctx[9],
49
+ roomLabel: /*roomLableItem*/ ctx[12],
48
50
  five: /*five*/ ctx[1]
49
51
  }
50
52
  });
@@ -65,7 +67,7 @@ function create_each_block(key_1, ctx) {
65
67
  p(new_ctx, dirty) {
66
68
  ctx = new_ctx;
67
69
  const roomlabelitem_changes = {};
68
- if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[9];
70
+ if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
69
71
  if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
70
72
  roomlabelitem.$set(roomlabelitem_changes);
71
73
  },
@@ -88,11 +90,11 @@ function create_each_block(key_1, ctx) {
88
90
  function create_fragment(ctx) {
89
91
  let div;
90
92
  let each_blocks = [];
91
- let each_1_lookup = new Map();
93
+ let each_1_lookup = new Map_1();
92
94
  let div_resize_listener;
93
95
  let current;
94
96
  let each_value = /*roomLabels*/ ctx[0];
95
- const get_key = ctx => /*roomLableItem*/ ctx[9].id;
97
+ const get_key = ctx => /*roomLableItem*/ ctx[12].id;
96
98
 
97
99
  for (let i = 0; i < each_value.length; i += 1) {
98
100
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -109,7 +111,7 @@ function create_fragment(ctx) {
109
111
  }
110
112
 
111
113
  attr(div, "class", "room-labels-container svelte-185yvaa");
112
- add_render_callback(() => /*div_elementresize_handler*/ ctx[4].call(div));
114
+ add_render_callback(() => /*div_elementresize_handler*/ ctx[6].call(div));
113
115
  },
114
116
  m(target, anchor) {
115
117
  insert(target, div, anchor);
@@ -118,7 +120,7 @@ function create_fragment(ctx) {
118
120
  each_blocks[i].m(div, null);
119
121
  }
120
122
 
121
- div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[4].bind(div));
123
+ div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[6].bind(div));
122
124
  current = true;
123
125
  },
124
126
  p(ctx, [dirty]) {
@@ -158,22 +160,17 @@ function create_fragment(ctx) {
158
160
  }
159
161
 
160
162
  function instance($$self, $$props, $$invalidate) {
163
+ let rendererSize;
161
164
  let { five } = $$props;
162
165
  let { roomLabels } = $$props;
163
166
  let containerWidth;
164
167
  let containerHeight;
168
+ let shownFloor = null;
165
169
 
166
- function getLabelVisible(five, roomLabelItem) {
167
- // 先看是不是在当前展示的楼层上
168
- const isLabelInFloor = five.model.shownFloor === null || roomLabelItem.floorIndex === five.model.shownFloor;
169
-
170
- if (!isLabelInFloor) return false;
171
-
172
- // 再看是不是被模型遮挡
170
+ function getLabelVisible(item) {
173
171
  const raycaster = new Raycaster();
174
-
175
172
  const cameraPosition = five.camera.position.clone();
176
- const position = new Vector3(roomLabelItem.position.x, roomLabelItem.position.y, roomLabelItem.position.z);
173
+ const position = new Vector3(item.position.x, item.position.y, item.position.z);
177
174
  const vectorDistance = position.distanceTo(cameraPosition);
178
175
  raycaster.set(cameraPosition.clone(), position.clone().sub(cameraPosition).normalize());
179
176
  const [intersection] = five.model.intersectRaycaster(raycaster);
@@ -181,53 +178,60 @@ function instance($$self, $$props, $$invalidate) {
181
178
  return true;
182
179
  }
183
180
 
184
- function getLabelTransform(five, roomLabelItem) {
185
- const position = new Vector3(roomLabelItem.position.x, roomLabelItem.position.y, roomLabelItem.position.z);
181
+ function getLabelTransform(item, rendererSize) {
182
+ const position = new Vector3(item.position.x, item.position.y, item.position.z);
186
183
  const mouse = position.clone().project(five.camera);
187
- const xOffset = Math.ceil((mouse.x + 1) / 2 * containerWidth);
188
- const yOffset = Math.ceil((-mouse.y + 1) / 2 * containerHeight);
184
+ const xOffset = Math.ceil((mouse.x + 1) / 2 * rendererSize.x);
185
+ const yOffset = Math.ceil((-mouse.y + 1) / 2 * rendererSize.y);
189
186
  return `translate(${xOffset}px, ${yOffset}px)`;
190
187
  }
191
188
 
192
- function getFormatedRoomLabels(five, labels) {
193
- const newLabels = labels.map(roomLabelItem => {
194
- // 计算是否可见,如果不可见,不会更新位置
195
- const visible = getLabelVisible(five, roomLabelItem);
189
+ function getFormatedRoomLabels(rendererSize) {
190
+ // 因为 item distance 需要重复计算,所以缓存一下
191
+ const distanceMap = new Map();
192
+
193
+ function getItemDistance(item) {
194
+ const cacheDistance = distanceMap.get(item.id);
195
+ if (cacheDistance) return cacheDistance;
196
+ const { x, y, z } = item.position;
197
+ const distance = new Vector3(x, y, z).clone().distanceTo(five.camera.position);
198
+ distanceMap.set(item.id, distance);
199
+ return distance;
200
+ }
196
201
 
197
- if (!visible) return Object.assign(Object.assign({}, roomLabelItem), { visible });
202
+ const formatedItems = roomLabels.map(item => {
203
+ const visible = getLabelVisible(item);
198
204
 
199
- // 更新位置
200
- const transform = getLabelTransform(five, roomLabelItem);
205
+ const transform = visible
206
+ ? getLabelTransform(item, rendererSize)
207
+ : item.transform;
201
208
 
202
- return Object.assign(Object.assign({}, roomLabelItem), { visible, transform });
203
- });
209
+ const itemDistance = getItemDistance(item);
204
210
 
205
- const sortedRoomLabelItems = newLabels.filter(({ visible }) => visible).map(roomLabelItem => ({
206
- roomLabelItem,
207
- distance: new Vector3(...Object.values(roomLabelItem.position)).clone().distanceTo(five.camera.position)
208
- })).sort((a, b) => a.distance - b.distance);
211
+ // visible === true 的 item 中,distance 比自己小的 item 个数
212
+ const minItemLen = roomLabels.filter(item => item.visible && getItemDistance(item) < itemDistance).length;
209
213
 
210
- return newLabels.map(roomLabelItem => {
211
- const sortIndex = sortedRoomLabelItems.findIndex(item => item.roomLabelItem.id === roomLabelItem.id);
212
- if (sortIndex !== undefined) return Object.assign(Object.assign({}, roomLabelItem), { zIndex: sortIndex * 10 });
213
- return roomLabelItem;
214
+ const zIndex = minItemLen * 10;
215
+ return Object.assign(Object.assign({}, item), { visible, transform, zIndex });
214
216
  });
217
+
218
+ return formatedItems;
215
219
  }
216
220
 
217
221
  function onFiveCameraUpdate() {
218
- $$invalidate(0, roomLabels = getFormatedRoomLabels(five, roomLabels));
222
+ $$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
223
+ }
224
+
225
+ function onFiveModelShownFloorChange(floorIndex) {
226
+ $$invalidate(4, shownFloor = floorIndex);
219
227
  }
220
228
 
221
229
  five.on('cameraUpdate', onFiveCameraUpdate);
222
- five.on('modelShownFloorChange', onFiveCameraUpdate);
230
+ five.on('modelShownFloorChange', onFiveModelShownFloorChange);
223
231
 
224
232
  onDestroy(() => {
225
233
  five.off('cameraUpdate', onFiveCameraUpdate);
226
- five.off('modelShownFloorChange', onFiveCameraUpdate);
227
- });
228
-
229
- onMount(() => {
230
- onFiveCameraUpdate();
234
+ five.off('modelShownFloorChange', onFiveModelShownFloorChange);
231
235
  });
232
236
 
233
237
  function div_elementresize_handler() {
@@ -242,7 +246,39 @@ function instance($$self, $$props, $$invalidate) {
242
246
  if ('roomLabels' in $$props) $$invalidate(0, roomLabels = $$props.roomLabels);
243
247
  };
244
248
 
245
- return [roomLabels, five, containerWidth, containerHeight, div_elementresize_handler];
249
+ $$self.$$.update = () => {
250
+ if ($$self.$$.dirty & /*containerWidth, containerHeight*/ 12) {
251
+ $: $$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
252
+ }
253
+
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
+ $: {
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
+ }));
269
+ }
270
+ }
271
+ };
272
+
273
+ return [
274
+ roomLabels,
275
+ five,
276
+ containerWidth,
277
+ containerHeight,
278
+ shownFloor,
279
+ rendererSize,
280
+ div_elementresize_handler
281
+ ];
246
282
  }
247
283
 
248
284
  class Component extends SvelteComponent {
@@ -0,0 +1,4 @@
1
+ import type { FivePlugin } from '@realsee/five';
2
+ import type { ModelTVVideoPluginExportType, ModelTVVideoPluginParameterType } from "./typings";
3
+ export declare const ModelTVVideoPlugin: FivePlugin<ModelTVVideoPluginParameterType, ModelTVVideoPluginExportType>;
4
+ export default ModelTVVideoPlugin;