@realsee/dnalogel 2.0.0-alpha.12 → 2.0.0-alpha.13
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.
- package/dist/CSS3DRenderPlugin/index.js +17 -14
- package/dist/CameraMovementPlugin/index.js +40 -15
- package/dist/ModelChassisCompassPlugin/index.js +32 -6
- package/dist/ModelEntryDoorGuidePlugin/index.js +48 -18
- package/dist/ModelItemLabelPlugin/index.js +18 -17
- package/dist/ModelRoomLabelPlugin/index.js +67 -26
- package/dist/PanoCompassPlugin/index.js +311 -164
- package/dist/PanoCursorRaycasterPlugin/index.js +5 -3
- package/dist/PanoMeasurePlugin/index.js +1337 -583
- package/dist/PanoRulerPlugin/index.js +32 -5
- package/dist/PanoSpatialTagPlugin/index.js +64 -29
- package/dist/floorplan/ModelFloorplanPlugin/index.js +586 -362
- package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +164 -72
- package/dist/floorplan/TopviewFloorplanPlugin/index.js +311 -153
- package/dist/index.es.js +2663 -1341
- package/dist/index.js +2667 -1345
- package/dist/index.umd.js +2667 -1345
- package/docs/assets/main.js +1 -1
- package/docs/classes/ModelRoomLabelController.html +6 -6
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ModelFloorplanErrorType.html +1 -1
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
- package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -1
- package/docs/modules.html +12 -12
- package/libs/CSS3DRenderPlugin/index.js +16 -13
- package/libs/CameraMovementPlugin/index.js +24 -15
- package/libs/ModelChassisCompassPlugin/index.js +14 -5
- package/libs/ModelEntryDoorGuidePlugin/index.js +24 -12
- package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +12 -10
- package/libs/ModelItemLabelPlugin/index.js +5 -3
- package/libs/ModelItemLabelPlugin/utils/parseData.js +1 -4
- package/libs/ModelRoomLabelPlugin/Controller.js +64 -23
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +3 -3
- package/libs/PanoCompassPlugin/index.js +225 -128
- package/libs/PanoCursorRaycasterPlugin/index.js +5 -3
- package/libs/PanoMeasurePlugin/Controller/BaseController.js +68 -13
- package/libs/PanoMeasurePlugin/Controller/EditController.js +267 -154
- package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.js +40 -20
- package/libs/PanoMeasurePlugin/Controller/WatchController.js +234 -152
- package/libs/PanoMeasurePlugin/Controller/index.js +131 -47
- package/libs/PanoMeasurePlugin/Model/index.js +30 -5
- package/libs/PanoMeasurePlugin/Model/line.js +60 -10
- package/libs/PanoMeasurePlugin/Model/point.js +24 -4
- package/libs/PanoMeasurePlugin/Model/polyline.js +20 -3
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.js +59 -14
- package/libs/PanoMeasurePlugin/Modules/FiveHelper.js +23 -8
- package/libs/PanoMeasurePlugin/Modules/GuideController.js +61 -26
- package/libs/PanoMeasurePlugin/Modules/Magnifier.js +60 -10
- package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +83 -37
- package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +52 -17
- package/libs/PanoMeasurePlugin/Modules/UIController/index.js +61 -30
- package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -2
- package/libs/PanoMeasurePlugin/utils/line.js +8 -7
- package/libs/PanoRulerPlugin/index.js +16 -5
- package/libs/PanoSpatialTagPlugin/index.js +11 -9
- package/libs/floorplan/Components/BaseImage.js +10 -5
- package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +3 -1
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +5 -6
- package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +7 -2
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +3 -1
- package/libs/floorplan/ModelFloorplanPlugin/Controller.js +456 -273
- package/libs/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +33 -22
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.js +3 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +97 -36
- package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +231 -108
- package/libs/floorplan/utils/formatData.js +43 -28
- package/libs/floorplan/utils/formatPosition.js +1 -1
- package/libs/shared-utils/Subscribe.js +8 -1
- package/libs/shared-utils/animationFrame/BetterTween.js +47 -18
- package/libs/shared-utils/createCanvasTextTexture.js +6 -5
- package/libs/shared-utils/five/changeMode.js +23 -12
- package/libs/shared-utils/getPxmm.js +1 -1
- package/libs/shared-utils/math/evenNumber.js +1 -1
- package/libs/shared-utils/three/loadFbxObj.js +20 -9
- package/libs/shared-utils/three/loadTexture.js +17 -6
- package/libs/shared-utils/three/transfromToMeshBasicMaterial.js +2 -1
- package/libs/shared-utils/tinyEJSrender.js +36 -6
- package/libs/shared-utils/to.js +21 -10
- package/libs/shared-utils/useDebounce.js +1 -1
- package/libs/shared-utils/useThrottle.js +2 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -41
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { Five } from '@realsee/five';
|
|
2
11
|
import changeMode from '../../../shared-utils/five/changeMode';
|
|
3
12
|
import { FloorplanErrorType } from './constant';
|
|
@@ -19,28 +28,30 @@ export function checkShowState(five, showState) {
|
|
|
19
28
|
* 2. 内置了相应的动画时间计算
|
|
20
29
|
* 3. 纠正成功会返回 true,失败「可能会被用户行为中断」会返回 false
|
|
21
30
|
*/
|
|
22
|
-
export default
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (result === true)
|
|
26
|
-
return;
|
|
27
|
-
// 纠正 mode
|
|
28
|
-
if (five.currentMode !== Five.Mode.Floorplan) {
|
|
29
|
-
const [changeModeError] = await to(changeMode(five, Five.Mode.Floorplan, showState, undefined, userAction));
|
|
30
|
-
if (changeModeError)
|
|
31
|
-
throw changeModeError;
|
|
32
|
-
// changeMode 是异步行为,可能会被打断,需要在结束后加一次判断
|
|
31
|
+
export default function correctFiveState(five, showState, userAction = true) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
// 当前已满足状态,不需要变更
|
|
33
34
|
const result = checkShowState(five, showState);
|
|
34
|
-
if (result ===
|
|
35
|
-
|
|
35
|
+
if (result === true)
|
|
36
|
+
return;
|
|
37
|
+
// 纠正 mode
|
|
38
|
+
if (five.currentMode !== Five.Mode.Floorplan) {
|
|
39
|
+
const [changeModeError] = yield to(changeMode(five, Five.Mode.Floorplan, showState, undefined, userAction));
|
|
40
|
+
if (changeModeError)
|
|
41
|
+
throw changeModeError;
|
|
42
|
+
// changeMode 是异步行为,可能会被打断,需要在结束后加一次判断
|
|
43
|
+
const result = checkShowState(five, showState);
|
|
44
|
+
if (result === false)
|
|
45
|
+
throw new Error(FloorplanErrorType.ChangeModeError);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// 纠正相机状态
|
|
49
|
+
// 根据 latitude、longitude、fov 计算动画时间,最多 1s
|
|
50
|
+
const { latitude, longitude, fov } = five.getCurrentState();
|
|
51
|
+
const time = Math.min(1000, Math.max(200, Math.abs(latitude - Math.PI / 2) * 1000, (longitude > Math.PI ? 2 * Math.PI - longitude : longitude) * 500, Math.abs(fov - showState.fov) * 10));
|
|
52
|
+
const [updateCameraError] = yield to(five.updateCamera(showState, time, userAction));
|
|
53
|
+
if (updateCameraError)
|
|
54
|
+
throw new Error(FloorplanErrorType.UpdateCameraError);
|
|
36
55
|
return;
|
|
37
|
-
}
|
|
38
|
-
// 纠正相机状态
|
|
39
|
-
// 根据 latitude、longitude、fov 计算动画时间,最多 1s
|
|
40
|
-
const { latitude, longitude, fov } = five.getCurrentState();
|
|
41
|
-
const time = Math.min(1000, Math.max(200, Math.abs(latitude - Math.PI / 2) * 1000, (longitude > Math.PI ? 2 * Math.PI - longitude : longitude) * 500, Math.abs(fov - showState.fov) * 10));
|
|
42
|
-
const [updateCameraError] = await to(five.updateCamera(showState, time, userAction));
|
|
43
|
-
if (updateCameraError)
|
|
44
|
-
throw new Error(FloorplanErrorType.UpdateCameraError);
|
|
45
|
-
return;
|
|
56
|
+
});
|
|
46
57
|
}
|
|
@@ -214,7 +214,9 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
214
214
|
|
|
215
215
|
$$self.$$.update = () => {
|
|
216
216
|
if ($$self.$$.dirty & /*extraObjects, floorIndex*/ 132) {
|
|
217
|
-
$: $$invalidate(5, currentFloorExtraObjects = extraObjects
|
|
217
|
+
$: $$invalidate(5, currentFloorExtraObjects = extraObjects === null || extraObjects === void 0
|
|
218
|
+
? void 0
|
|
219
|
+
: extraObjects.filter(object => object.floorIndex === floorIndex));
|
|
218
220
|
}
|
|
219
221
|
};
|
|
220
222
|
|
|
@@ -1,47 +1,107 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import Main from './Components/Main';
|
|
2
11
|
import formatData, { formatExtraObjects } from '../utils/formatData';
|
|
3
12
|
export default class PanoFloorplanRadarPluginController {
|
|
4
|
-
app;
|
|
5
|
-
five;
|
|
6
|
-
wrapperSelector = '';
|
|
7
|
-
data;
|
|
8
|
-
wrapper = null;
|
|
9
|
-
extraObjects;
|
|
10
|
-
originExtraObjects;
|
|
11
|
-
configs = {};
|
|
12
13
|
constructor(five, params) {
|
|
14
|
+
Object.defineProperty(this, "app", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "five", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "wrapperSelector", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: ''
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "data", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "wrapper", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: null
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "extraObjects", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "originExtraObjects", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "configs", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: {}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(this, "dispose", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: () => {
|
|
67
|
+
var _a;
|
|
68
|
+
(_a = this.app) === null || _a === void 0 ? void 0 : _a.$destroy();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, "load", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const copyData = JSON.parse(JSON.stringify(data));
|
|
77
|
+
const floorplanData = yield formatData(copyData);
|
|
78
|
+
this.data = floorplanData;
|
|
79
|
+
// const loadImage = async () => {
|
|
80
|
+
// const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
|
|
81
|
+
// // 当有 svgString 时,没有加载过程
|
|
82
|
+
// if (floorplanData.outlines[floorIndex]?.svgContent) return
|
|
83
|
+
// // 如果当前楼层图片不存在,不存在加载过程
|
|
84
|
+
// const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
|
|
85
|
+
// if (!nowFloorImageSrc) return
|
|
86
|
+
// // 图片加载完成时再 render
|
|
87
|
+
// await new Promise<void>((resolve) => {
|
|
88
|
+
// const nowFloorImage = new Image()
|
|
89
|
+
// nowFloorImage.src = nowFloorImageSrc
|
|
90
|
+
// nowFloorImage.onload = () => resolve()
|
|
91
|
+
// })
|
|
92
|
+
// }
|
|
93
|
+
// await loadImage()
|
|
94
|
+
this.render();
|
|
95
|
+
})
|
|
96
|
+
});
|
|
13
97
|
this.five = five;
|
|
14
|
-
params
|
|
15
|
-
if (typeof params
|
|
98
|
+
(params === null || params === void 0 ? void 0 : params.configs) && Object.assign(this.configs, params.configs);
|
|
99
|
+
if (typeof (params === null || params === void 0 ? void 0 : params.wrapper) === 'string')
|
|
16
100
|
this.wrapperSelector = params.wrapper;
|
|
17
|
-
else if (params
|
|
101
|
+
else if ((params === null || params === void 0 ? void 0 : params.wrapper) instanceof Element)
|
|
18
102
|
this.wrapper = params.wrapper;
|
|
19
103
|
five.once('dispose', this.dispose);
|
|
20
104
|
}
|
|
21
|
-
dispose = () => {
|
|
22
|
-
this.app?.$destroy();
|
|
23
|
-
};
|
|
24
|
-
load = async (data) => {
|
|
25
|
-
const copyData = JSON.parse(JSON.stringify(data));
|
|
26
|
-
const floorplanData = await formatData(copyData);
|
|
27
|
-
this.data = floorplanData;
|
|
28
|
-
// const loadImage = async () => {
|
|
29
|
-
// const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
|
|
30
|
-
// // 当有 svgString 时,没有加载过程
|
|
31
|
-
// if (floorplanData.outlines[floorIndex]?.svgContent) return
|
|
32
|
-
// // 如果当前楼层图片不存在,不存在加载过程
|
|
33
|
-
// const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
|
|
34
|
-
// if (!nowFloorImageSrc) return
|
|
35
|
-
// // 图片加载完成时再 render
|
|
36
|
-
// await new Promise<void>((resolve) => {
|
|
37
|
-
// const nowFloorImage = new Image()
|
|
38
|
-
// nowFloorImage.src = nowFloorImageSrc
|
|
39
|
-
// nowFloorImage.onload = () => resolve()
|
|
40
|
-
// })
|
|
41
|
-
// }
|
|
42
|
-
// await loadImage()
|
|
43
|
-
this.render();
|
|
44
|
-
};
|
|
45
105
|
/** 把插件的渲染DOM插入到对应的容器中去 */
|
|
46
106
|
appendTo(wrapper) {
|
|
47
107
|
this.wrapper = wrapper;
|
|
@@ -59,6 +119,7 @@ export default class PanoFloorplanRadarPluginController {
|
|
|
59
119
|
this.render();
|
|
60
120
|
}
|
|
61
121
|
render() {
|
|
122
|
+
var _a;
|
|
62
123
|
// 处理 wrapper
|
|
63
124
|
if (!this.wrapper) {
|
|
64
125
|
const _wrapper = document.querySelector(this.wrapperSelector);
|
|
@@ -74,7 +135,7 @@ export default class PanoFloorplanRadarPluginController {
|
|
|
74
135
|
floorplanData: this.data,
|
|
75
136
|
extraObjects: this.extraObjects,
|
|
76
137
|
cameraImageUrl: this.configs.cameraImageUrl,
|
|
77
|
-
hoverEnable: this.configs.hoverEnable
|
|
138
|
+
hoverEnable: (_a = this.configs.hoverEnable) !== null && _a !== void 0 ? _a : false,
|
|
78
139
|
};
|
|
79
140
|
if (!this.app) {
|
|
80
141
|
this.app = new Main({
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { pluginStyle } from './style';
|
|
2
11
|
import formatData from '../utils/formatData';
|
|
3
12
|
import { omit } from '../../shared-utils/filter';
|
|
@@ -5,20 +14,217 @@ import getPxmm from '../../shared-utils/getPxmm';
|
|
|
5
14
|
import Main from "../ModelFloorplanPlugin/Components/Main";
|
|
6
15
|
import changeModelCanvasOpacity from '../../shared-utils/changeModelCanvasOpacity';
|
|
7
16
|
export class TopviewFloorplanPluginController {
|
|
8
|
-
size = { width: 0, height: 0 };
|
|
9
|
-
visible = false;
|
|
10
|
-
pxmm = 0;
|
|
11
|
-
app;
|
|
12
|
-
five;
|
|
13
|
-
panoIndex = 0;
|
|
14
|
-
floorIndex = 0;
|
|
15
|
-
configs = {};
|
|
16
|
-
lastPanoramaLongitude = 0;
|
|
17
|
-
selector;
|
|
18
|
-
floorplanData;
|
|
19
|
-
wrapper;
|
|
20
|
-
container = document.createElement('div');
|
|
21
17
|
constructor(five, params) {
|
|
18
|
+
Object.defineProperty(this, "size", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: { width: 0, height: 0 }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "visible", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: false
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "pxmm", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: 0
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "app", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(this, "five", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(this, "panoIndex", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: 0
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(this, "floorIndex", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: 0
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(this, "configs", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
value: {}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(this, "lastPanoramaLongitude", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: 0
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(this, "selector", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
writable: true,
|
|
76
|
+
value: void 0
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(this, "floorplanData", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true,
|
|
81
|
+
writable: true,
|
|
82
|
+
value: void 0
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(this, "wrapper", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(this, "container", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
value: document.createElement('div')
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(this, "dispose", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
configurable: true,
|
|
99
|
+
writable: true,
|
|
100
|
+
value: () => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
this.hide();
|
|
103
|
+
(_a = this.container) === null || _a === void 0 ? void 0 : _a.remove();
|
|
104
|
+
(_b = this.app) === null || _b === void 0 ? void 0 : _b.$destroy();
|
|
105
|
+
this.five.off('modeChange', this.handleModeChange);
|
|
106
|
+
this.five.off('panoArrived', this.handlePanoArrived);
|
|
107
|
+
this.five.off('modelLoaded', this.handleModelLoaded);
|
|
108
|
+
this.five.off('wantsMoveToPano', this.handleWantsMoveToPano);
|
|
109
|
+
this.five.off('wantsPanGesture', this.handleWantsPanGesture);
|
|
110
|
+
this.five.off('initAnimationEnded', this.handleInitAnimationEnded);
|
|
111
|
+
this.five.off('modelShownFloorChange', this.onModelShownFloorChange);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
/** 模型楼层高亮改变时,自动进行楼层切换 */
|
|
115
|
+
Object.defineProperty(this, "onModelShownFloorChange", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
configurable: true,
|
|
118
|
+
writable: true,
|
|
119
|
+
value: (shownFloor) => {
|
|
120
|
+
if (shownFloor === null)
|
|
121
|
+
return;
|
|
122
|
+
this.floorIndex = shownFloor;
|
|
123
|
+
this.updateSize();
|
|
124
|
+
this.render();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
/** panoIndex 改变时,更新 floorIndex */
|
|
128
|
+
Object.defineProperty(this, "handlePanoArrived", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
value: (index) => {
|
|
133
|
+
var _a;
|
|
134
|
+
if (!((_a = this.five) === null || _a === void 0 ? void 0 : _a.work))
|
|
135
|
+
return;
|
|
136
|
+
this.panoIndex = index;
|
|
137
|
+
this.floorIndex = this.five.work.observers[index].floorIndex;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
/** 配置了 preventRoomClick 后,在户型图展示时阻止 Five 走点 */
|
|
141
|
+
Object.defineProperty(this, "handleWantsMoveToPano", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true,
|
|
144
|
+
writable: true,
|
|
145
|
+
value: () => {
|
|
146
|
+
if (!this.visible)
|
|
147
|
+
return;
|
|
148
|
+
if (this.configs.preventRoomClick)
|
|
149
|
+
return false;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
/** 在户型图展示时阻止 Five 滑动行为 */
|
|
154
|
+
Object.defineProperty(this, "handleWantsPanGesture", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: () => {
|
|
159
|
+
if (!this.visible)
|
|
160
|
+
return;
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(this, "handleModelLoaded", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: () => {
|
|
169
|
+
if (this.wrapper)
|
|
170
|
+
return;
|
|
171
|
+
if (!this.selector)
|
|
172
|
+
return;
|
|
173
|
+
const wrapper = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
|
|
174
|
+
if (!wrapper)
|
|
175
|
+
throw new Error('不正确的父容器选择器');
|
|
176
|
+
this.wrapper = wrapper;
|
|
177
|
+
wrapper.append(this.container);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
/** 非 Topview 态隐藏户型图 */
|
|
181
|
+
Object.defineProperty(this, "handleModeChange", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
configurable: true,
|
|
184
|
+
writable: true,
|
|
185
|
+
value: (mode) => {
|
|
186
|
+
if (mode !== 'Topview')
|
|
187
|
+
return this.hide();
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
/** 动画结束后是 Topview 态就展示户型图 */
|
|
191
|
+
Object.defineProperty(this, "handleInitAnimationEnded", {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
configurable: true,
|
|
194
|
+
writable: true,
|
|
195
|
+
value: () => {
|
|
196
|
+
const { mode } = this.five.getCurrentState();
|
|
197
|
+
if (mode === 'Topview')
|
|
198
|
+
this.show();
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
/** 更新户型图大小 */
|
|
202
|
+
Object.defineProperty(this, "updateSize", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
configurable: true,
|
|
205
|
+
writable: true,
|
|
206
|
+
value: () => {
|
|
207
|
+
if (!this.floorplanData)
|
|
208
|
+
return;
|
|
209
|
+
if (!this.container || !this.wrapper)
|
|
210
|
+
return;
|
|
211
|
+
if (this.five.getCurrentState().mode !== 'Topview')
|
|
212
|
+
return;
|
|
213
|
+
// 计算户型图展示大小
|
|
214
|
+
const { min, max } = this.floorplanData.bounding;
|
|
215
|
+
const width = max.x - min.x;
|
|
216
|
+
const height = max.y - min.y;
|
|
217
|
+
// 每毫米对应的 px 值
|
|
218
|
+
const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : undefined;
|
|
219
|
+
const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
|
|
220
|
+
const _width = Math.ceil(width * pxmm);
|
|
221
|
+
const _height = Math.ceil(height * pxmm);
|
|
222
|
+
this.pxmm = pxmm;
|
|
223
|
+
this.size = { width: _width, height: _height };
|
|
224
|
+
this.container.style.width = _width + 'px';
|
|
225
|
+
this.container.style.height = _height + 'px';
|
|
226
|
+
}
|
|
227
|
+
});
|
|
22
228
|
this.five = five;
|
|
23
229
|
this.selector = params.selector;
|
|
24
230
|
this.configs = omit(params, ['selector']);
|
|
@@ -34,10 +240,12 @@ export class TopviewFloorplanPluginController {
|
|
|
34
240
|
this.five.on('modelShownFloorChange', this.onModelShownFloorChange);
|
|
35
241
|
}
|
|
36
242
|
/** 加载户型图数据 */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
243
|
+
load(data) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
const copyData = JSON.parse(JSON.stringify(data));
|
|
246
|
+
this.floorplanData = yield formatData(copyData);
|
|
247
|
+
this.render();
|
|
248
|
+
});
|
|
41
249
|
}
|
|
42
250
|
/** 把插件的渲染DOM插入到对应的容器中去 */
|
|
43
251
|
appendTo(wrapper) {
|
|
@@ -45,69 +253,6 @@ export class TopviewFloorplanPluginController {
|
|
|
45
253
|
wrapper.appendChild(this.container);
|
|
46
254
|
return this;
|
|
47
255
|
}
|
|
48
|
-
dispose = () => {
|
|
49
|
-
this.hide();
|
|
50
|
-
this.container?.remove();
|
|
51
|
-
this.app?.$destroy();
|
|
52
|
-
this.five.off('modeChange', this.handleModeChange);
|
|
53
|
-
this.five.off('panoArrived', this.handlePanoArrived);
|
|
54
|
-
this.five.off('modelLoaded', this.handleModelLoaded);
|
|
55
|
-
this.five.off('wantsMoveToPano', this.handleWantsMoveToPano);
|
|
56
|
-
this.five.off('wantsPanGesture', this.handleWantsPanGesture);
|
|
57
|
-
this.five.off('initAnimationEnded', this.handleInitAnimationEnded);
|
|
58
|
-
this.five.off('modelShownFloorChange', this.onModelShownFloorChange);
|
|
59
|
-
};
|
|
60
|
-
/** 模型楼层高亮改变时,自动进行楼层切换 */
|
|
61
|
-
onModelShownFloorChange = (shownFloor) => {
|
|
62
|
-
if (shownFloor === null)
|
|
63
|
-
return;
|
|
64
|
-
this.floorIndex = shownFloor;
|
|
65
|
-
this.updateSize();
|
|
66
|
-
this.render();
|
|
67
|
-
};
|
|
68
|
-
/** panoIndex 改变时,更新 floorIndex */
|
|
69
|
-
handlePanoArrived = (index) => {
|
|
70
|
-
if (!this.five?.work)
|
|
71
|
-
return;
|
|
72
|
-
this.panoIndex = index;
|
|
73
|
-
this.floorIndex = this.five.work.observers[index].floorIndex;
|
|
74
|
-
};
|
|
75
|
-
/** 配置了 preventRoomClick 后,在户型图展示时阻止 Five 走点 */
|
|
76
|
-
handleWantsMoveToPano = () => {
|
|
77
|
-
if (!this.visible)
|
|
78
|
-
return;
|
|
79
|
-
if (this.configs.preventRoomClick)
|
|
80
|
-
return false;
|
|
81
|
-
return;
|
|
82
|
-
};
|
|
83
|
-
/** 在户型图展示时阻止 Five 滑动行为 */
|
|
84
|
-
handleWantsPanGesture = () => {
|
|
85
|
-
if (!this.visible)
|
|
86
|
-
return;
|
|
87
|
-
return false;
|
|
88
|
-
};
|
|
89
|
-
handleModelLoaded = () => {
|
|
90
|
-
if (this.wrapper)
|
|
91
|
-
return;
|
|
92
|
-
if (!this.selector)
|
|
93
|
-
return;
|
|
94
|
-
const wrapper = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
|
|
95
|
-
if (!wrapper)
|
|
96
|
-
throw new Error('不正确的父容器选择器');
|
|
97
|
-
this.wrapper = wrapper;
|
|
98
|
-
wrapper.append(this.container);
|
|
99
|
-
};
|
|
100
|
-
/** 非 Topview 态隐藏户型图 */
|
|
101
|
-
handleModeChange = (mode) => {
|
|
102
|
-
if (mode !== 'Topview')
|
|
103
|
-
return this.hide();
|
|
104
|
-
};
|
|
105
|
-
/** 动画结束后是 Topview 态就展示户型图 */
|
|
106
|
-
handleInitAnimationEnded = () => {
|
|
107
|
-
const { mode } = this.five.getCurrentState();
|
|
108
|
-
if (mode === 'Topview')
|
|
109
|
-
this.show();
|
|
110
|
-
};
|
|
111
256
|
show() {
|
|
112
257
|
this.visible = true;
|
|
113
258
|
this.five.model.show(this.floorIndex);
|
|
@@ -130,28 +275,6 @@ export class TopviewFloorplanPluginController {
|
|
|
130
275
|
this.five.on('wantsMoveToPano', this.handleWantsMoveToPano);
|
|
131
276
|
this.five.on('wantsPanGesture', this.handleWantsPanGesture);
|
|
132
277
|
}
|
|
133
|
-
/** 更新户型图大小 */
|
|
134
|
-
updateSize = () => {
|
|
135
|
-
if (!this.floorplanData)
|
|
136
|
-
return;
|
|
137
|
-
if (!this.container || !this.wrapper)
|
|
138
|
-
return;
|
|
139
|
-
if (this.five.getCurrentState().mode !== 'Topview')
|
|
140
|
-
return;
|
|
141
|
-
// 计算户型图展示大小
|
|
142
|
-
const { min, max } = this.floorplanData.bounding;
|
|
143
|
-
const width = max.x - min.x;
|
|
144
|
-
const height = max.y - min.y;
|
|
145
|
-
// 每毫米对应的 px 值
|
|
146
|
-
const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : undefined;
|
|
147
|
-
const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
|
|
148
|
-
const _width = Math.ceil(width * pxmm);
|
|
149
|
-
const _height = Math.ceil(height * pxmm);
|
|
150
|
-
this.pxmm = pxmm;
|
|
151
|
-
this.size = { width: _width, height: _height };
|
|
152
|
-
this.container.style.width = _width + 'px';
|
|
153
|
-
this.container.style.height = _height + 'px';
|
|
154
|
-
};
|
|
155
278
|
render(duration) {
|
|
156
279
|
if (!this.container || !this.floorplanData)
|
|
157
280
|
return;
|
|
@@ -160,19 +283,19 @@ export class TopviewFloorplanPluginController {
|
|
|
160
283
|
const { northDesc, getLabelElement, cameraImageUrl, preventRoomClick, hoverEnable, compassEnable, roomLabelsEnable, ruleLabelsEnable, } = this.configs;
|
|
161
284
|
const handleClick = preventRoomClick ? () => false : undefined;
|
|
162
285
|
const props = {
|
|
163
|
-
northDesc: northDesc
|
|
286
|
+
northDesc: northDesc !== null && northDesc !== void 0 ? northDesc : '北',
|
|
164
287
|
five: this.five,
|
|
165
288
|
pxmm: this.pxmm,
|
|
166
289
|
cameraImageUrl,
|
|
167
290
|
visible: this.visible,
|
|
168
|
-
duration: duration
|
|
291
|
+
duration: duration !== null && duration !== void 0 ? duration : 0,
|
|
169
292
|
panoIndex: this.panoIndex,
|
|
170
293
|
floorIndex: this.floorIndex,
|
|
171
294
|
floorplanData: this.floorplanData,
|
|
172
|
-
hoverEnable: hoverEnable
|
|
173
|
-
compassEnable: compassEnable
|
|
174
|
-
ruleLabelsEnable: ruleLabelsEnable
|
|
175
|
-
roomLabelsEnable: roomLabelsEnable
|
|
295
|
+
hoverEnable: hoverEnable !== null && hoverEnable !== void 0 ? hoverEnable : false,
|
|
296
|
+
compassEnable: compassEnable !== null && compassEnable !== void 0 ? compassEnable : true,
|
|
297
|
+
ruleLabelsEnable: ruleLabelsEnable !== null && ruleLabelsEnable !== void 0 ? ruleLabelsEnable : true,
|
|
298
|
+
roomLabelsEnable: roomLabelsEnable !== null && roomLabelsEnable !== void 0 ? roomLabelsEnable : true,
|
|
176
299
|
lastPanoramaLongitude: this.lastPanoramaLongitude,
|
|
177
300
|
getLabelElement,
|
|
178
301
|
onRoomHeightClick: handleClick,
|