@realsee/dnalogel 2.0.0-alpha.42 → 2.0.0-alpha.43
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/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/CameraMovementPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/CameraMovementPlugin/index.js +15 -40
- package/dist/ItemLabelPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/ModelChassisCompassPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/ModelChassisCompassPlugin/index.js +5 -30
- package/dist/ModelEntryDoorGuidePlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/ModelEntryDoorGuidePlugin/index.js +8 -33
- package/dist/ModelItemLabelPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/ModelRoomLabelPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/ModelTVVideoPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/ModelTVVideoPlugin/index.js +3 -28
- package/dist/ModelViewPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoCompassPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoCompassPlugin/index.js +64 -99
- package/dist/PanoCursorRaycasterPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoMeasurePlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoRulerPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoRulerPlugin/index.js +3 -28
- package/dist/PanoRulerProPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/PanoRulerProPlugin/index.js +29 -58
- package/dist/PanoSpatialTagPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/floorplan/ModelFloorplanPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/floorplan/ModelFloorplanPlugin/index.js +115 -156
- package/dist/floorplan/PanoFloorplanRadarPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +71 -110
- package/dist/floorplan/TopviewFloorplanPlugin/PanoCompassPlugin/index.d.ts +1 -1
- package/dist/floorplan/TopviewFloorplanPlugin/index.js +114 -159
- package/dist/index.es.js +341 -416
- package/dist/index.js +341 -416
- package/dist/index.umd.js +341 -416
- package/docs/assets/search.js +1 -1
- package/docs/classes/Magnifier.html +4 -4
- package/docs/classes/ModelRoomLabelController.html +4 -4
- package/docs/enums/CameraMovementEffect.html +2 -2
- package/docs/enums/DIRECTION.html +1 -1
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/Rotation.html +2 -2
- package/docs/index.html +2 -2
- package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
- package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/FloorplanBounding.html +4 -4
- package/docs/interfaces/FloorplanData.html +2 -2
- package/docs/interfaces/FloorplanEntrance.html +7 -7
- package/docs/interfaces/FloorplanExtraObject.html +3 -3
- package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
- package/docs/interfaces/FloorplanFloorData.html +2 -2
- package/docs/interfaces/FloorplanImagePosition.html +2 -2
- package/docs/interfaces/FloorplanObserver.html +2 -2
- package/docs/interfaces/FloorplanOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanPosition.html +2 -2
- package/docs/interfaces/FloorplanRoomItem.html +6 -6
- package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
- package/docs/interfaces/FloorplanServerBounding.html +4 -4
- package/docs/interfaces/FloorplanServerComputedData.html +1 -1
- package/docs/interfaces/FloorplanServerData.html +2 -2
- package/docs/interfaces/FloorplanServerEntrance.html +7 -7
- package/docs/interfaces/FloorplanServerFloorData.html +2 -2
- package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
- package/docs/interfaces/FloorplanServerObserver.html +2 -2
- package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanServerPosition.html +2 -2
- package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
- package/docs/interfaces/ItemLabelPluginData.html +1 -1
- package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ItemLabelPluginParametersType.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/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -1
- package/docs/interfaces/OpenParameter.html +2 -2
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
- package/docs/interfaces/PanoMeasureParameterType.html +1 -1
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginState.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
- package/docs/interfaces/Point.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -1
- package/docs/interfaces/RoomInfo.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/RoomRules.html +1 -1
- package/docs/interfaces/Rooms.html +1 -1
- package/docs/modules.html +18 -18
- package/libs/CameraMovementPlugin/CameraMovementPlugin.js +15 -24
- package/libs/ModelChassisCompassPlugin/Plugin.js +5 -14
- package/libs/ModelEntryDoorGuidePlugin/Plugin.js +8 -17
- package/libs/ModelTVVideoPlugin/Plugin.js +3 -12
- package/libs/PanoCompassPlugin/controller.js +56 -73
- package/libs/PanoCompassPlugin/index.d.ts +1 -1
- package/libs/PanoRulerPlugin/Plugin.js +3 -12
- package/libs/PanoRulerProPlugin/Controller.js +29 -42
- package/libs/floorplan/ModelFloorplanPlugin/Controller.js +29 -42
- package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +43 -60
- package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +58 -79
- package/libs/floorplan/utils/correctFiveState.js +20 -31
- package/libs/floorplan/utils/formatData.js +28 -43
- package/libs/shared-utils/five/changeMode.js +28 -39
- package/libs/shared-utils/three/loadFbxObj.js +9 -20
- package/libs/shared-utils/three/loadTexture.js +6 -17
- package/libs/shared-utils/to.js +10 -21
- package/package.json +14 -14
|
@@ -1,12 +1,3 @@
|
|
|
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
|
-
};
|
|
10
1
|
import to from '../../shared-utils/to';
|
|
11
2
|
import equal from '../../shared-utils/equal';
|
|
12
3
|
import Main from '../Components/Main';
|
|
@@ -185,7 +176,7 @@ export class Controller extends BasePlugin.Controller {
|
|
|
185
176
|
enumerable: true,
|
|
186
177
|
configurable: true,
|
|
187
178
|
writable: true,
|
|
188
|
-
value: (options = {}) =>
|
|
179
|
+
value: async (options = {}) => {
|
|
189
180
|
if (!this.state.enabled)
|
|
190
181
|
return;
|
|
191
182
|
// 已经展示完成了,不做任何操作
|
|
@@ -194,14 +185,14 @@ export class Controller extends BasePlugin.Controller {
|
|
|
194
185
|
const userAction = options.userAction !== undefined ? options.userAction : true;
|
|
195
186
|
this.updateState({ visible: true }, userAction);
|
|
196
187
|
this._show(options);
|
|
197
|
-
}
|
|
188
|
+
}
|
|
198
189
|
});
|
|
199
190
|
/** 隐藏户型图 */
|
|
200
191
|
Object.defineProperty(this, "hide", {
|
|
201
192
|
enumerable: true,
|
|
202
193
|
configurable: true,
|
|
203
194
|
writable: true,
|
|
204
|
-
value: (options = {}) =>
|
|
195
|
+
value: async (options = {}) => {
|
|
205
196
|
if (!this.state.enabled)
|
|
206
197
|
return;
|
|
207
198
|
this.isHiddenByHideFunc = true;
|
|
@@ -209,7 +200,7 @@ export class Controller extends BasePlugin.Controller {
|
|
|
209
200
|
return;
|
|
210
201
|
this.updateState({ visible: false }, options.userAction || true);
|
|
211
202
|
this._hide(options);
|
|
212
|
-
}
|
|
203
|
+
}
|
|
213
204
|
});
|
|
214
205
|
/** 更新户型图大小 */
|
|
215
206
|
Object.defineProperty(this, "updateSize", {
|
|
@@ -275,11 +266,11 @@ export class Controller extends BasePlugin.Controller {
|
|
|
275
266
|
enumerable: true,
|
|
276
267
|
configurable: true,
|
|
277
268
|
writable: true,
|
|
278
|
-
value: (options) =>
|
|
279
|
-
var
|
|
269
|
+
value: async (options) => {
|
|
270
|
+
var _a;
|
|
280
271
|
if (!this.state.enabled)
|
|
281
272
|
return;
|
|
282
|
-
if (!((
|
|
273
|
+
if (!((_a = this.five.model) === null || _a === void 0 ? void 0 : _a.loaded))
|
|
283
274
|
throw new Error(FloorplanErrorType.ModelNotLoaded);
|
|
284
275
|
if (!this.data)
|
|
285
276
|
throw new Error(FloorplanErrorType.DataNotLoaded);
|
|
@@ -293,7 +284,7 @@ export class Controller extends BasePlugin.Controller {
|
|
|
293
284
|
userAction: true,
|
|
294
285
|
};
|
|
295
286
|
const mergedOptions = Object.assign(Object.assign({}, baseShowOpts), options);
|
|
296
|
-
const getShowPromise = () =>
|
|
287
|
+
const getShowPromise = async () => {
|
|
297
288
|
this.hooks.emit('show', { userAction: mergedOptions.userAction, auto: mergedOptions.isAutoShow });
|
|
298
289
|
let hasRejected = false;
|
|
299
290
|
let externalErrorMsg;
|
|
@@ -301,7 +292,7 @@ export class Controller extends BasePlugin.Controller {
|
|
|
301
292
|
hasRejected = true;
|
|
302
293
|
externalErrorMsg = errorMsg;
|
|
303
294
|
};
|
|
304
|
-
const [correctError] =
|
|
295
|
+
const [correctError] = await to(correctFiveState(this.five, this.showState, mergedOptions.userAction));
|
|
305
296
|
if (correctError)
|
|
306
297
|
throw correctError;
|
|
307
298
|
// 异步结束要判断当前是不是被中断了
|
|
@@ -319,7 +310,7 @@ export class Controller extends BasePlugin.Controller {
|
|
|
319
310
|
const renderDuration = mergedOptions.immediately ? 0 : SHOW_ANIME_DURATION;
|
|
320
311
|
changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
|
|
321
312
|
this.render(renderDuration);
|
|
322
|
-
}
|
|
313
|
+
};
|
|
323
314
|
this.showPromise = getShowPromise()
|
|
324
315
|
.then(() => {
|
|
325
316
|
this.hooks.emit('showAnimationEnded', {
|
|
@@ -341,7 +332,7 @@ export class Controller extends BasePlugin.Controller {
|
|
|
341
332
|
this.showRejection = undefined;
|
|
342
333
|
});
|
|
343
334
|
return this.showPromise;
|
|
344
|
-
}
|
|
335
|
+
}
|
|
345
336
|
});
|
|
346
337
|
Object.defineProperty(this, "_hide", {
|
|
347
338
|
enumerable: true,
|
|
@@ -575,24 +566,22 @@ export class Controller extends BasePlugin.Controller {
|
|
|
575
566
|
five.once('dispose', this.dispose);
|
|
576
567
|
this.addEventListener();
|
|
577
568
|
}
|
|
578
|
-
load(serverData, state, userAction = true) {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
this.render();
|
|
595
|
-
});
|
|
569
|
+
async load(serverData, state, userAction = true) {
|
|
570
|
+
function isPluginServerData(serverData) {
|
|
571
|
+
return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
|
|
572
|
+
}
|
|
573
|
+
const _data = serverData;
|
|
574
|
+
if (_data && !_data.version)
|
|
575
|
+
console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
|
|
576
|
+
const copyData = JSON.parse(JSON.stringify(serverData));
|
|
577
|
+
const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
|
|
578
|
+
const prevData = this.data;
|
|
579
|
+
this.data = await formatData(_serverData);
|
|
580
|
+
this.hooks.emit('dataLoaded', this.data);
|
|
581
|
+
this.hooks.emit('dataChange', this.data, prevData);
|
|
582
|
+
if (state)
|
|
583
|
+
this.updateState(state, userAction);
|
|
584
|
+
this.render();
|
|
596
585
|
}
|
|
597
586
|
/** 把插件的渲染DOM插入到对应的容器中去 */
|
|
598
587
|
appendTo(wrapper) {
|
|
@@ -640,10 +629,8 @@ export class Controller extends BasePlugin.Controller {
|
|
|
640
629
|
return;
|
|
641
630
|
this.render();
|
|
642
631
|
}
|
|
643
|
-
formatData(serverData) {
|
|
644
|
-
return
|
|
645
|
-
return yield formatData(serverData.data);
|
|
646
|
-
});
|
|
632
|
+
async formatData(serverData) {
|
|
633
|
+
return await formatData(serverData.data);
|
|
647
634
|
}
|
|
648
635
|
updateState(state, userAction) {
|
|
649
636
|
const prevState = this.state;
|
|
@@ -1,12 +1,3 @@
|
|
|
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
|
-
};
|
|
10
1
|
import Main from './Components/Main';
|
|
11
2
|
import equal from '../../shared-utils/equal';
|
|
12
3
|
import { CAMERA_IMAGE } from '../Assets/camera';
|
|
@@ -110,55 +101,49 @@ export class Controller extends BasePlugin.Controller {
|
|
|
110
101
|
// =============== init Listener ===============
|
|
111
102
|
five.once('dispose', this.dispose);
|
|
112
103
|
}
|
|
113
|
-
load(serverData, state, userAction = true) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.render();
|
|
142
|
-
});
|
|
104
|
+
async load(serverData, state, userAction = true) {
|
|
105
|
+
// const loadImage = async () => {
|
|
106
|
+
// const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
|
|
107
|
+
// // 当有 svgString 时,没有加载过程
|
|
108
|
+
// if (floorplanData.outlines[floorIndex]?.svgContent) return
|
|
109
|
+
// // 如果当前楼层图片不存在,不存在加载过程
|
|
110
|
+
// const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
|
|
111
|
+
// if (!nowFloorImageSrc) return
|
|
112
|
+
// // 图片加载完成时再 render
|
|
113
|
+
// await new Promise<void>((resolve) => {
|
|
114
|
+
// const nowFloorImage = new Image()
|
|
115
|
+
// nowFloorImage.src = nowFloorImageSrc
|
|
116
|
+
// nowFloorImage.onload = () => resolve()
|
|
117
|
+
// })
|
|
118
|
+
// }
|
|
119
|
+
// await loadImage()
|
|
120
|
+
function isPluginServerData(serverData) {
|
|
121
|
+
return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
|
|
122
|
+
}
|
|
123
|
+
const copyData = JSON.parse(JSON.stringify(serverData));
|
|
124
|
+
const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
|
|
125
|
+
const prevData = this.data;
|
|
126
|
+
this.data = await formatData(_serverData);
|
|
127
|
+
this.hooks.emit('dataLoaded', this.data);
|
|
128
|
+
this.hooks.emit('dataChange', this.data, prevData);
|
|
129
|
+
if (state)
|
|
130
|
+
this.updateState(state, userAction);
|
|
131
|
+
this.render();
|
|
143
132
|
}
|
|
144
|
-
show(options = {}) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this._show({ userAction });
|
|
152
|
-
});
|
|
133
|
+
async show(options = {}) {
|
|
134
|
+
// 已经展示完成了,不做任何操作
|
|
135
|
+
if (this.state.visible)
|
|
136
|
+
return;
|
|
137
|
+
const userAction = options.userAction !== undefined ? options.userAction : true;
|
|
138
|
+
this.updateState({ visible: true }, userAction);
|
|
139
|
+
this._show({ userAction });
|
|
153
140
|
}
|
|
154
|
-
hide(options = {}) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this._hide({ userAction });
|
|
161
|
-
});
|
|
141
|
+
async hide(options = {}) {
|
|
142
|
+
if (!this.state.visible)
|
|
143
|
+
return;
|
|
144
|
+
const userAction = options.userAction !== undefined ? options.userAction : true;
|
|
145
|
+
this.updateState({ visible: false }, userAction);
|
|
146
|
+
this._hide({ userAction });
|
|
162
147
|
}
|
|
163
148
|
enable(options = {}) {
|
|
164
149
|
if (this.state.enabled)
|
|
@@ -203,10 +188,8 @@ export class Controller extends BasePlugin.Controller {
|
|
|
203
188
|
this.extraObjects = formatExtraObjects(data, this.five, this.data);
|
|
204
189
|
this.render();
|
|
205
190
|
}
|
|
206
|
-
formatData(serverData) {
|
|
207
|
-
return
|
|
208
|
-
return yield formatData(serverData.data);
|
|
209
|
-
});
|
|
191
|
+
async formatData(serverData) {
|
|
192
|
+
return await formatData(serverData.data);
|
|
210
193
|
}
|
|
211
194
|
_enable(options) {
|
|
212
195
|
const { userAction } = options;
|
|
@@ -1,12 +1,3 @@
|
|
|
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
|
-
};
|
|
10
1
|
import * as THREE from 'three';
|
|
11
2
|
import equal from '../../shared-utils/equal';
|
|
12
3
|
import Main from '../Components/Main';
|
|
@@ -306,24 +297,22 @@ export class Controller extends BasePlugin.Controller {
|
|
|
306
297
|
five.once('dispose', this.dispose);
|
|
307
298
|
this.addEventListener();
|
|
308
299
|
}
|
|
309
|
-
load(serverData, state, userAction = true) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
this.render();
|
|
326
|
-
});
|
|
300
|
+
async load(serverData, state, userAction = true) {
|
|
301
|
+
function isPluginServerData(serverData) {
|
|
302
|
+
return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
|
|
303
|
+
}
|
|
304
|
+
const _data = serverData;
|
|
305
|
+
if (_data && !_data.version)
|
|
306
|
+
console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
|
|
307
|
+
const copyData = JSON.parse(JSON.stringify(serverData));
|
|
308
|
+
const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
|
|
309
|
+
const prevData = this.data;
|
|
310
|
+
this.data = await formatData(_serverData);
|
|
311
|
+
this.hooks.emit('dataLoaded', this.data);
|
|
312
|
+
this.hooks.emit('dataChange', this.data, prevData);
|
|
313
|
+
if (state)
|
|
314
|
+
this.updateState(state, userAction);
|
|
315
|
+
this.render();
|
|
327
316
|
}
|
|
328
317
|
/** 更新户型图位置 */
|
|
329
318
|
updatePosition() {
|
|
@@ -348,25 +337,21 @@ export class Controller extends BasePlugin.Controller {
|
|
|
348
337
|
this.render();
|
|
349
338
|
return this;
|
|
350
339
|
}
|
|
351
|
-
show(options = {}) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
this._show({ userAction });
|
|
359
|
-
});
|
|
340
|
+
async show(options = {}) {
|
|
341
|
+
// 已经展示完成了,不做任何操作
|
|
342
|
+
if (this.state.visible)
|
|
343
|
+
return;
|
|
344
|
+
const userAction = options.userAction !== undefined ? options.userAction : true;
|
|
345
|
+
this.updateState({ visible: true }, userAction);
|
|
346
|
+
this._show({ userAction });
|
|
360
347
|
}
|
|
361
|
-
hide(options = {}) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this._hide({ userAction });
|
|
369
|
-
});
|
|
348
|
+
async hide(options = {}) {
|
|
349
|
+
this.isHiddenByHideFunc = true;
|
|
350
|
+
if (!this.state.visible)
|
|
351
|
+
return;
|
|
352
|
+
const userAction = options.userAction !== undefined ? options.userAction : true;
|
|
353
|
+
this.updateState({ visible: false }, userAction);
|
|
354
|
+
this._hide({ userAction });
|
|
370
355
|
}
|
|
371
356
|
enable(options = {}) {
|
|
372
357
|
if (this.state.enabled)
|
|
@@ -396,42 +381,36 @@ export class Controller extends BasePlugin.Controller {
|
|
|
396
381
|
state.visible ? this._show(options) : this._hide(options);
|
|
397
382
|
}
|
|
398
383
|
}
|
|
399
|
-
formatData(serverData) {
|
|
400
|
-
return
|
|
401
|
-
return yield formatData(serverData.data);
|
|
402
|
-
});
|
|
384
|
+
async formatData(serverData) {
|
|
385
|
+
return await formatData(serverData.data);
|
|
403
386
|
}
|
|
404
|
-
_show(options) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
this.render();
|
|
422
|
-
});
|
|
387
|
+
async _show(options) {
|
|
388
|
+
if (!this.state.enabled)
|
|
389
|
+
return;
|
|
390
|
+
this.isHiddenByHideFunc = false;
|
|
391
|
+
const { userAction } = options;
|
|
392
|
+
this.hooks.emit('show', { userAction });
|
|
393
|
+
if (this.five.getCurrentState().mode !== 'Topview') {
|
|
394
|
+
await changeMode(this.five, ['Topview', undefined, undefined, userAction]);
|
|
395
|
+
}
|
|
396
|
+
this.five.model.show(this.floorIndex);
|
|
397
|
+
this.updatePosition();
|
|
398
|
+
this.updateSize();
|
|
399
|
+
const renderDuration = 500;
|
|
400
|
+
const modelOpacity = this.state.config.modelOpacity;
|
|
401
|
+
changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
|
|
402
|
+
this.hooks.emit('showAnimationEnded', { userAction });
|
|
403
|
+
this.render();
|
|
423
404
|
}
|
|
424
|
-
_hide(options) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
this.render();
|
|
434
|
-
});
|
|
405
|
+
async _hide(options) {
|
|
406
|
+
if (!this.state.enabled)
|
|
407
|
+
return;
|
|
408
|
+
const { userAction } = options;
|
|
409
|
+
this.hooks.emit('hide', { userAction });
|
|
410
|
+
const modelOpacity = 1;
|
|
411
|
+
const renderDuration = 0;
|
|
412
|
+
changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
|
|
413
|
+
this.render();
|
|
435
414
|
}
|
|
436
415
|
_enable(options) {
|
|
437
416
|
const { userAction } = options;
|
|
@@ -1,12 +1,3 @@
|
|
|
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
|
-
};
|
|
10
1
|
import to from '../../shared-utils/to';
|
|
11
2
|
import { FloorplanErrorType } from '../utils/constant';
|
|
12
3
|
import nearlyEqual from '../../shared-utils/nearlyEqual';
|
|
@@ -31,27 +22,25 @@ export function checkShowState(five, showState) {
|
|
|
31
22
|
* 2. 内置了相应的动画时间计算
|
|
32
23
|
* 3. 纠正成功会返回 true,失败「可能会被用户行为中断」会返回 false
|
|
33
24
|
*/
|
|
34
|
-
export default function correctFiveState(five, showState, userAction = true) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (result === true)
|
|
39
|
-
return;
|
|
40
|
-
const currentFiveState = five.getCurrentState();
|
|
41
|
-
// 纠正 mode
|
|
42
|
-
if (currentFiveState.mode !== showState.mode) {
|
|
43
|
-
const [changeModeError] = yield to(changeMode(five, [showState.mode, showState, undefined, userAction]));
|
|
44
|
-
if (changeModeError)
|
|
45
|
-
throw new Error(FloorplanErrorType.ChangeModeError);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
// 纠正相机状态
|
|
49
|
-
// 根据 latitude、longitude、fov 计算动画时间,最多 1s
|
|
50
|
-
const { latitude, longitude, fov } = currentFiveState;
|
|
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);
|
|
25
|
+
export default async function correctFiveState(five, showState, userAction = true) {
|
|
26
|
+
// 当前已满足状态,不需要变更
|
|
27
|
+
const result = checkShowState(five, showState);
|
|
28
|
+
if (result === true)
|
|
55
29
|
return;
|
|
56
|
-
|
|
30
|
+
const currentFiveState = five.getCurrentState();
|
|
31
|
+
// 纠正 mode
|
|
32
|
+
if (currentFiveState.mode !== showState.mode) {
|
|
33
|
+
const [changeModeError] = await to(changeMode(five, [showState.mode, showState, undefined, userAction]));
|
|
34
|
+
if (changeModeError)
|
|
35
|
+
throw new Error(FloorplanErrorType.ChangeModeError);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// 纠正相机状态
|
|
39
|
+
// 根据 latitude、longitude、fov 计算动画时间,最多 1s
|
|
40
|
+
const { latitude, longitude, fov } = currentFiveState;
|
|
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;
|
|
57
46
|
}
|
|
@@ -1,34 +1,21 @@
|
|
|
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
|
-
};
|
|
10
1
|
import { FLOORPLAN_EXTRA_OBJECT_IMAGE } from '../Assets/floorplanExtraObject';
|
|
11
2
|
import { floorplanPosition2ImagePosition, getFloorIndexFromModelPosition, modelPosition2FloorplanPosition, } from './formatPosition';
|
|
12
|
-
function formatOutlines(outlines) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
url: item.url,
|
|
20
|
-
svgUrl: item.svg_url,
|
|
21
|
-
};
|
|
22
|
-
if (item.svg_url) {
|
|
23
|
-
const svgContent = yield fetch(item.svg_url, { headers }).then((res) => res.text());
|
|
24
|
-
outlineItem.svgContent = svgContent;
|
|
25
|
-
}
|
|
26
|
-
return outlineItem;
|
|
27
|
-
});
|
|
3
|
+
async function formatOutlines(outlines) {
|
|
4
|
+
const headers = new Headers({ 'Content-Type': 'text/plain' });
|
|
5
|
+
const getOutlineItem = async function (item) {
|
|
6
|
+
const outlineItem = {
|
|
7
|
+
index: item.index,
|
|
8
|
+
url: item.url,
|
|
9
|
+
svgUrl: item.svg_url,
|
|
28
10
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
if (item.svg_url) {
|
|
12
|
+
const svgContent = await fetch(item.svg_url, { headers }).then((res) => res.text());
|
|
13
|
+
outlineItem.svgContent = svgContent;
|
|
14
|
+
}
|
|
15
|
+
return outlineItem;
|
|
16
|
+
};
|
|
17
|
+
const svgOutlineItems = await Promise.all(outlines.map(getOutlineItem));
|
|
18
|
+
return svgOutlineItems;
|
|
32
19
|
}
|
|
33
20
|
function formatRoom(data) {
|
|
34
21
|
const floorplanRoomItem = {
|
|
@@ -74,21 +61,19 @@ function formatFloorplanEntrance(data) {
|
|
|
74
61
|
};
|
|
75
62
|
return floorplanEntrance;
|
|
76
63
|
}
|
|
77
|
-
export default function formatData(data) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return floorplanData;
|
|
91
|
-
});
|
|
64
|
+
export default async function formatData(data) {
|
|
65
|
+
const outlines = await formatOutlines(data.outlines);
|
|
66
|
+
const bounding = data.computed_data.bounding;
|
|
67
|
+
const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
|
|
68
|
+
const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
|
|
69
|
+
const floorplanData = {
|
|
70
|
+
outlines,
|
|
71
|
+
entrance,
|
|
72
|
+
bounding,
|
|
73
|
+
floorDatas,
|
|
74
|
+
observers: data.computed_data.observers.map(formateFloorplanObserver),
|
|
75
|
+
};
|
|
76
|
+
return floorplanData;
|
|
92
77
|
}
|
|
93
78
|
export function formatExtraObjects(data, five, floorplanData) {
|
|
94
79
|
const extraObjects = data.map((object) => {
|