@realsee/dnalogel 2.0.0-alpha.51 → 2.0.0-alpha.52
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/CruisePlugin/index.d.ts +0 -1
- package/dist/CSS3DRenderPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/CameraMovementPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/CameraMovementPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/CruisePlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/CruisePlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/CruisePlugin/index.d.ts +0 -1
- package/dist/GuideLinePlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/GuideLinePlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ItemLabelPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ItemLabelPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ModelChassisCompassPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ModelChassisCompassPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ModelEntryDoorGuidePlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ModelEntryDoorGuidePlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ModelItemLabelPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ModelItemLabelPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ModelRoomLabelPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ModelRoomLabelPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ModelTVVideoPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ModelTVVideoPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/ModelViewPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/ModelViewPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoCompassPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoCompassPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoCursorRaycasterPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoCursorRaycasterPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoDoorLabelPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoDoorLabelPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoMeasurePlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoMeasurePlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoRulerPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoRulerPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoRulerProPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoRulerProPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/PanoSpatialTagPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/PanoSpatialTagPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/floorplan/MapviewFloorplanPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/floorplan/MapviewFloorplanPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/floorplan/ModelFloorplanPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/floorplan/ModelFloorplanPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/floorplan/PanoFloorplanRadarPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/floorplan/PanoFloorplanRadarPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/floorplan/TopviewFloorplanPlugin/CruisePlugin/index.d.ts +0 -1
- package/dist/floorplan/TopviewFloorplanPlugin/GuideLinePlugin/index.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1081 -15
- package/dist/index.js +1084 -14
- package/dist/index.umd.js +1087 -18
- package/docs/assets/search.js +1 -1
- package/docs/classes/CruisePluginController.html +23 -0
- package/docs/classes/Magnifier.html +5 -5
- package/docs/classes/ModelRoomLabelController.html +5 -5
- 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 +3 -3
- package/docs/interfaces/CameraMovementPluginExportType.html +3 -3
- package/docs/interfaces/FloorplanBounding.html +5 -5
- package/docs/interfaces/FloorplanData.html +2 -2
- package/docs/interfaces/FloorplanEntrance.html +8 -8
- package/docs/interfaces/FloorplanExtraObject.html +4 -4
- 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 +7 -7
- package/docs/interfaces/FloorplanRoomLabelItem.html +4 -4
- package/docs/interfaces/FloorplanServerBounding.html +5 -5
- package/docs/interfaces/FloorplanServerComputedData.html +1 -1
- package/docs/interfaces/FloorplanServerData.html +2 -2
- package/docs/interfaces/FloorplanServerDoorItem.html +1 -1
- package/docs/interfaces/FloorplanServerDoorPosition.html +1 -1
- package/docs/interfaces/FloorplanServerEntrance.html +8 -8
- 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 +8 -8
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +4 -4
- 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/CruisePlugin/index.d.ts +0 -1
- package/libs/CruisePlugin/index.js +0 -1
- package/libs/GuideLinePlugin/index.d.ts +1 -1
- package/libs/GuideLinePlugin/index.js +0 -1
- package/libs/index.d.ts +2 -0
- package/libs/index.js +4 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('three/examples/jsm/renderers/CSS3DRenderer'), require('@realsee/five/line'), require('svelte/internal'), require('svelte'), require('svelte/easing'), require('svelte/transition'), require('svelte/store'), require('@realsee/five'), require('three/examples/jsm/loaders/FBXLoader'), require('@tweenjs/tween.js'), require('hammerjs'), require('classnames')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'three', 'three/examples/jsm/renderers/CSS3DRenderer', '@realsee/five/line', 'svelte/internal', 'svelte', 'svelte/easing', 'svelte/transition', 'svelte/store', '@realsee/five', 'three/examples/jsm/loaders/FBXLoader', '@tweenjs/tween.js', 'hammerjs', 'classnames'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.dnalogel = {}, global.THREE, global.CSS3DRenderer, global.FiveSDK_Line, global.internal, global.svelte, global.easing, global.transition, global.store, global.five, global.FBXLoader, global.TWEEN, global.Hammer, global.classNames));
|
|
5
|
-
})(this, (function (exports, THREE, CSS3DRenderer, line, internal, svelte, easing, transition, store, five, FBXLoader, TWEEN, Hammer, classNames) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('three/examples/jsm/renderers/CSS3DRenderer'), require('@realsee/five/line'), require('svelte/internal'), require('svelte'), require('svelte/easing'), require('svelte/transition'), require('svelte/store'), require('@realsee/five'), require('three/examples/jsm/loaders/FBXLoader'), require('@tweenjs/tween.js'), require('hammerjs'), require('classnames'), require('polyline-normals')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'three', 'three/examples/jsm/renderers/CSS3DRenderer', '@realsee/five/line', 'svelte/internal', 'svelte', 'svelte/easing', 'svelte/transition', 'svelte/store', '@realsee/five', 'three/examples/jsm/loaders/FBXLoader', '@tweenjs/tween.js', 'hammerjs', 'classnames', 'polyline-normals'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.dnalogel = {}, global.THREE, global.CSS3DRenderer, global.FiveSDK_Line, global.internal, global.svelte, global.easing, global.transition, global.store, global.five, global.FBXLoader, global.TWEEN, global.Hammer, global.classNames, global.getNormals));
|
|
5
|
+
})(this, (function (exports, THREE, CSS3DRenderer, line, internal, svelte, easing, transition, store, five, FBXLoader, TWEEN, Hammer, classNames, getNormals) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
var TWEEN__default = /*#__PURE__*/_interopDefaultLegacy(TWEEN);
|
|
30
30
|
var Hammer__default = /*#__PURE__*/_interopDefaultLegacy(Hammer);
|
|
31
31
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
32
|
+
var getNormals__default = /*#__PURE__*/_interopDefaultLegacy(getNormals);
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Five 模型插件
|
|
@@ -4695,7 +4696,7 @@
|
|
|
4695
4696
|
/**
|
|
4696
4697
|
* plugin 的基本控制器
|
|
4697
4698
|
*/
|
|
4698
|
-
class Controller$
|
|
4699
|
+
class Controller$7 {
|
|
4699
4700
|
constructor(five$1) {
|
|
4700
4701
|
Object.defineProperty(this, "five", {
|
|
4701
4702
|
enumerable: true,
|
|
@@ -4722,7 +4723,7 @@
|
|
|
4722
4723
|
}
|
|
4723
4724
|
}
|
|
4724
4725
|
|
|
4725
|
-
class Controller$
|
|
4726
|
+
class Controller$6 extends Controller$7 {
|
|
4726
4727
|
}
|
|
4727
4728
|
|
|
4728
4729
|
var FloorplanErrorType;
|
|
@@ -4874,7 +4875,7 @@
|
|
|
4874
4875
|
const longitudeVisible = longitude < 30 * (Math.PI / 180) || longitude > 330 * (Math.PI / 180);
|
|
4875
4876
|
return latitudeVisible && longitudeVisible;
|
|
4876
4877
|
}
|
|
4877
|
-
class Controller$
|
|
4878
|
+
class Controller$5 extends Controller$6 {
|
|
4878
4879
|
constructor(five, params) {
|
|
4879
4880
|
var _a;
|
|
4880
4881
|
super(five);
|
|
@@ -5543,7 +5544,7 @@
|
|
|
5543
5544
|
}
|
|
5544
5545
|
|
|
5545
5546
|
const ModelFloorplanPlugin = (five, params) => {
|
|
5546
|
-
return new Controller$
|
|
5547
|
+
return new Controller$5(five, params);
|
|
5547
5548
|
};
|
|
5548
5549
|
|
|
5549
5550
|
/** 当前 five 的相机视角是否满足户型图自动隐藏条件
|
|
@@ -5568,7 +5569,7 @@
|
|
|
5568
5569
|
const longitudeVisible = longitude < 30 * (Math.PI / 180) || longitude > 330 * (Math.PI / 180);
|
|
5569
5570
|
return latitudeVisible && longitudeVisible;
|
|
5570
5571
|
}
|
|
5571
|
-
class Controller$
|
|
5572
|
+
class Controller$4 extends Controller$6 {
|
|
5572
5573
|
constructor(five, params) {
|
|
5573
5574
|
super(five);
|
|
5574
5575
|
// =============== public properties =================
|
|
@@ -6217,10 +6218,10 @@
|
|
|
6217
6218
|
}
|
|
6218
6219
|
|
|
6219
6220
|
const MapviewFloorplanPlugin = (five, params) => {
|
|
6220
|
-
return new Controller$
|
|
6221
|
+
return new Controller$4(five, params);
|
|
6221
6222
|
};
|
|
6222
6223
|
|
|
6223
|
-
class Controller$
|
|
6224
|
+
class Controller$3 extends Controller$6 {
|
|
6224
6225
|
constructor(five, params) {
|
|
6225
6226
|
super(five);
|
|
6226
6227
|
// =============== public properties =================
|
|
@@ -6697,7 +6698,7 @@
|
|
|
6697
6698
|
}
|
|
6698
6699
|
|
|
6699
6700
|
const TopviewFloorplanPlugin = (five, params) => {
|
|
6700
|
-
return new Controller$
|
|
6701
|
+
return new Controller$3(five, params);
|
|
6701
6702
|
};
|
|
6702
6703
|
|
|
6703
6704
|
/**
|
|
@@ -7576,7 +7577,7 @@
|
|
|
7576
7577
|
}
|
|
7577
7578
|
}
|
|
7578
7579
|
|
|
7579
|
-
class Controller$
|
|
7580
|
+
class Controller$2 extends Controller$6 {
|
|
7580
7581
|
constructor(five, params) {
|
|
7581
7582
|
super(five);
|
|
7582
7583
|
// =============== public properties =================
|
|
@@ -7813,7 +7814,7 @@
|
|
|
7813
7814
|
}
|
|
7814
7815
|
|
|
7815
7816
|
const PanoFloorplanRadarPlugin = (five, params) => {
|
|
7816
|
-
return new Controller$
|
|
7817
|
+
return new Controller$2(five, params);
|
|
7817
7818
|
};
|
|
7818
7819
|
|
|
7819
7820
|
/** 房屋数据映射表 */
|
|
@@ -9683,7 +9684,7 @@
|
|
|
9683
9684
|
}
|
|
9684
9685
|
}
|
|
9685
9686
|
|
|
9686
|
-
class Controller {
|
|
9687
|
+
class Controller$1 {
|
|
9687
9688
|
constructor(five, params) {
|
|
9688
9689
|
var _a, _b;
|
|
9689
9690
|
Object.defineProperty(this, "five", {
|
|
@@ -9797,7 +9798,7 @@
|
|
|
9797
9798
|
* 全景标尺插件
|
|
9798
9799
|
*/
|
|
9799
9800
|
const PanoRulerProPlugin = (five, params) => {
|
|
9800
|
-
return new Controller(five, params);
|
|
9801
|
+
return new Controller$1(five, params);
|
|
9801
9802
|
};
|
|
9802
9803
|
|
|
9803
9804
|
const roomInfoIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZIAAABCCAYAAAB9y1BhAAAAAXNSR0IArs4c6QAADh5JREFUeAHtnVuPLDcVhedwC/dACKAICDxEIBQpygNI/Ab+MX8B8YCQEAjxgBAQLsm5Jjkn58r6Sl4jT52qnu4zXd121dqSx67q7ip7eXsv721XzcVFJAgEgSAQBIJAEAgCQeC4CLx48eKbSu+RH/fKuVoQWB8Cn1tfk9KiIHAUBH6tq/xKiTwSBILADgRCJDvAyUebRuAbpfXxSDatBmn8Pgh8YZ8v5TtBYIMIvFCbSZEgEASuQSBEcg1A+XizCDzfbMvT8CBwIAIhkgMBy9c3g0CIZDNdnYbeFIEQyU0RzO/XikCIZK09m3YdHYEQydEhzQVXgkCIZCUdmWYsj0CIZHmMc4c+EchCe5/9llqfAYEQyRlAzy27QCAeSRfdlEq2gECIpIVeSB1aRAAiudVixVKnINAaAiGS1nok9WkFAUJb8Upa6Y3Uo2kEQiRNd08qd0YEQiJnBD+37guBEElf/ZXang6BEMnpsM6dOkcgRNJ5B66x+nrjLmsTX1J6bSJHZ7+o9HklynWaOse1eKcc+XVlvxYFEnlfaThWfb7mcsn5nPRM6WmVU55KfO+J0mdKj8f5rVu3skNMoET6RSBE0m/fdVNzGWII4StKXy65y18t58aEAVGcUjDkGHsLhIOYfCC1xUT4QDJjgnmkc58qkT8saSiLeCCkSBBoBoEQSTNd0V9FZADRH8iAGfvXS06Zc5CFCePQt0y3EFaq61CX1ayjC56U8br24sKd+kAuJhkI55OSPi75pyIcvKNIEFgcgRDJ4hD3ewMZLDwDXqfOq9RNFCYOCAMPYx851BDjIXiWzky9Tpyvw0kOL/nc+Jh7DyGqko+P+cznVLwMf31Uypz7jZLJ0GEy8jqURnl8zPjyObDEsxknztsDUnFvMfF8e+4X6j88F4hlTDT3de6BiAYsI0HgxgiESG4MYd8XkLEhrARZTKUxUWB0MXrkiA3wdYYQg8Xs2cmzaR977cCE8eSM6wYDsQiXSyOrulDPRUT3AbsxydAnYO9kz87HfH9Kxv3D976lNEk2ujf9ANE8GCe1OeEzgRLZD4EQyX44df8tGQ08iNdHCU+jnhGPDVG9bgAGGD3Iw8TB5xgjz3jr3CTxSEapxxAL7VxcCmGaQPe6n/qScWtSIcdLrD1FhxbtRZn4x/3rtanvlBtffq57UCcI5l6dVF9CaJEgcAWBEMkVOPo+0ODHwGNEIAxIwsRBea6vdxlMPsNwYFAcIoEsnB4WQ6hTqxOMqg1wU40rxEx/kCal6AKejEnGOSFKvE8mFiYaFV8S9AVP5oo3o+syKSA0ZoJxmTWZJvFSXSMLIzBnXBa+bS5/UwQ0oDECEIRDF87n+nSOMDAMkIUNU51v2TjM4SWo2pdi1E34L1W4mnRALFOJtZ0pQe/QNVItT3XNOzpxV8n5fdWjaxzrBqY8j8Cc0Zn/RT45OQIaoPQT3oUHMDnHUzPKuYFLqGJYZFXObNILroSmIi8jMIfjy9/s8EwhGu/0+s+4CdI5vBkmKngv6Bo5x3NbodFFQmQOk6l48VzXQdcgF6d7unePoU7aE5lBIEQyA8y5TmvgEZ5iwBJSeKMkBrHXJVS8lCljZ8IwaZgwFlswvqzNugpT2K6rhTtaI2PPBIN0hWSkn6zJmFSc7yIYSIj0Y6VBdA108nZJd5TjuSQsNqDT558QyZn7rQxMSKNO435hkE0NNEIXzPhIzPiY7cXDEBBHkE0TyRx+0i9vovhf/R3pMR6MPWWTB+syU+JQ2tvlQ8Ji6C/kArHcKfcpHydrHYGxwWq9vl3XT4MFr4JZHO4/3gbkMTXYxkYMEmHtAsJgNsegYxaH9xFZBgH6YMoLXOZunV+1TGCYxHzgpkjfCYPhrUAw5BAMJDLGlbAY44E0iH7LJAlSgVw+UuK5l6nJlD6KnBuBEMmCPaDBwACpiYOBwuCqB0S9xZYBxmfs4YcsGEjkiSsLhBML/VD304lv3//tykTnQ7WENIjGBDYHQoFcSEym2IaMWP/JCaG9VZKyi8f6LaRSE8t4wsX3ImdAIERyRNALcTBIGByeYY13v4yJg+P7SiaOhKcERgMSI7VAJ4hcWGjHwyANonFTh8UYO3gv440kjKPvlqTs4llFLEy4GDfpM5A5g4RIbgi6lNkeh8NV4wEwVm7CUSg+CfLAZR9/R6cjZ0YgfXKiDpD+e2F/CIuVCRnjyh4L5DLeLYbXUu8Sg1gYUwNJ6ZoPVI6cCAE6I3IAAlJW3HCTBl6H3fK5qxCmMnGwiMiWy0jjCKiff6kqDuNDffbbxqu7+uqpP3iAEkJx2mfcOQx2W32YV74sqCUhkmvAlQLjUjMzcqiKxcJdwuwKT2NIUmAWDSOdIaB+/4WrrD78ncvJ20BA/cMmFcalE+GxXcJmFa+x3FWf1iHmXb/LZ3sgkNDWBEhSUhb67DYzA6rDVeOQBy/3gzQGJZWC5nkNgbECGffzCpq0niaUCRqTtH/RqjJmPdmDXMYvtoR4SD9U4kHJOgyWMStQbiLxSISelAoc6rUOFG5O2MnD4ni9xpHdPXNodXpeOvG+qy6j9XuXk7ePQDWeIRQmgizeT9k6zjF2IaRhbUV5thkLhENlCtxDr9Hl96VseGMommcxu7wzwlUmDnaHxC3ustf3r7T04z1/W/39B5eT94eA+pLw9OtKJpZdYTB2ldUhsLzOZY8u32U89/h5X1+RQuHuQhyErVCsmkjrUAazlHtKkEeeshUIGxT0odaPDUKwjiaXiZ/JwWEwL9qP7QBh7DdLkskY3hWGt8KC/eX/qFkHMsdrxeoHihSBbYP2OnBx58RrHZBHvI45lDZyXnrzrpsqA/JHl5OvCwH1s70ViAWPZby2Ujf4vg4GQpJO5K0SFTKrJBIpB1sDUQwIZNcuK2Kjd0v6RMqRtQ6BERnWzX5uHKQXf3I5+XoRkN3AHrLNGEIh7Vor9S4wIhab31q8GiKpyAMCQRmmBKLgOQ68DrYAbl4BpkDKuYFIfiYchvEhPflzMNkeAsWmQCi2KXP2kgkpnspmSWUOmC60Rh3NGg+dTJrzPCAPZg+D5yGjkDinwIjsRkC69VN/QzrzF5eTbxMB6QMhL3sq2Jo524mt8drqZhbq58BoVlvUocQ0WeswebA45pAU7XGZVyTcI8kQbKZD1d7IERCQnr3jy0h//upy8iAg3WACyyI9iccGbEexPbZBnsBCKrype9U7PbvYtaWOgyyYBTAjgET8gCCdxe4ak4c9j9V3nNocWRaBehffsnfK1btCoExMh+dOqokttslRERMLIXbO8QAkC/VERT7W71enW26w2teeCPz6raB4IlPiV5JAHvE8phDKuYMRkO79xD+SXv3N5eRBYA4B6QwTcya6kMrcsyp4JkRKWKPFdq1CmiOSUWfMvZiNRXIYPv/caRVq2F4jpIdvu1Ya8H93OXkQ2AcB6Q+PHUAqpDk7xqtZIJXuJ8FNEIlApx64gYA+t5DFIjnrHrzCIO/GERCR5RCQTv5IVx9CptK3fyx3p1x57QhIl/x/7llPmXpOBT1jNymk0uVjCGclkoq1AXhqvQaAWffA+3ioAe21EB1GgsByCEg3f+CrS+/+6XLyIPCqCEinsLeEvHZNmAnPM2HuKtpyciIpYNr7AFTIwfVwGY8DMFe5MKV2RRpHQHr6lqsoIvnA5eRB4BgISL+8gYhJNB4LYvvnCTN2kEl0816KDTiNWFQEHC4doBG68q6r+p7sZMD7gDzy+oEamZRPjoD09fu66TA+pI//PnkFcsPNICBdYz0Fu3idbSSs3+RzcIsSiQDi+ngdAGTWVfGKsHOB+GBCV1dgycE5EZDufs/31+D9r8vJg8BSCFT2kojN3K4vvBQm3E3Zy0WIRICwVRcwSFPbdu194LKt+kEdtT/SIQLS4Tddbenohy4nDwKnQGAPG4rdZALehA09KpGo8bhou9iUbbs0/jMNTscBdRgJAm0hIF1+wzWSrt52OXkQOCUC0kNsNNuHsatz24iHqI709GxLAjcmktJQEwj5WPA+aCiuWB4YHKOT4yYRkF7zUNkg0lueSI4EgbMiIJ1kZyshL9LUOjNEwkT9sXT2pBP1VyaSQiCse9Coqa27LApBIPE+BEKkLwSk32zRHESDkp0zkSDQBALF9uKdYHunnkthwo7tfXQqQjmYSNQImBACIU2xIuGreB8CIdIvAtJzNogMosHI4mYkCDSHgPTUXspU2ItoEIvzEArlxWRvIlGFWTSnsnWF+b1dKAhk8QrrHpEgsDgC0ndi0oNoEBIuiASBZhGQvnqCz/KCJ/jYZtto7DPRoUU2N11LJIXxqNyUC0VFqeCTpRlP94gEgZMhIL0nbDCIdJswQSQINI9AIRRsNRP+KfvOkgNrKEddr5660YUqw3k8EAhkbvsuCztPVSF7JDqMBIF1IKAxcOl5S8eZLEWCQDcIFBtO2Kv2UOr645lAKkex4VeIpLo5jHbls1KD4eYaWIu4R+UeyYLA2RHQWGAADiJ9P9u2StcheRB4VQSkyzgD2PQppwBH4MaEMpBFRSDcqCYQx9ggDphr0QUb3SMSBJpAQGPiciei9P6oYYAmGphKbA4B6TRrJ+j1HKHYzh8cZbpVBowXZ8bgQhzPNJAOvvD4QjkOAj0hUAbdUOVMoHrqudT1OgSk2zgLkAl2n/LYvh9s900kutYV4UIvQiBXMMlBEAgCQWA1CBRCgUjmHAkI5vk+PACR1BcZmGmfH64GzTQkCASBILBhBAqhgEC9rDFGJI7FGJEcB4EgEASCQBAIAkEgCASBIBAEgkAQCAJBIAgEgSAQBIJAEAgCm0fg/x4jQQWGalpFAAAAAElFTkSuQmCC';
|
|
@@ -9919,7 +9920,7 @@
|
|
|
9919
9920
|
}
|
|
9920
9921
|
|
|
9921
9922
|
const defaultBaseOptions$1 = { userAction: true };
|
|
9922
|
-
class PanoCompassController extends Controller$
|
|
9923
|
+
class PanoCompassController extends Controller$6 {
|
|
9923
9924
|
constructor(five$1, config) {
|
|
9924
9925
|
super(five$1);
|
|
9925
9926
|
/**
|
|
@@ -17371,7 +17372,7 @@ void main() {
|
|
|
17371
17372
|
* pano plugin controller 基类
|
|
17372
17373
|
* @author kyleju
|
|
17373
17374
|
*/
|
|
17374
|
-
class BasePanoPluginController extends Controller$
|
|
17375
|
+
class BasePanoPluginController extends Controller$7 {
|
|
17375
17376
|
constructor(five) {
|
|
17376
17377
|
super(five);
|
|
17377
17378
|
Object.defineProperty(this, "state", {
|
|
@@ -18102,12 +18103,1080 @@ void main() {
|
|
|
18102
18103
|
return new PanoDoorLabelPluginController(five);
|
|
18103
18104
|
};
|
|
18104
18105
|
|
|
18106
|
+
// 定义常量
|
|
18107
|
+
const TRIANGLE_NUMBER_OF_RECTANGLE = 2; // 每个矩形有两个三角形
|
|
18108
|
+
const VERTEX_NUMBER_OF_TRIANGLE = 3; // 每个三角形有三个顶点
|
|
18109
|
+
const AXIS_NUMBER_OF_VERTEX = 3; // 每个顶点有三个轴坐标
|
|
18110
|
+
const UV_NUMBER_OF_VERTEX = 2; // 每个顶点有两个 UV 轴坐标
|
|
18111
|
+
function getLineGeometry(positionList) {
|
|
18112
|
+
if (positionList.length < 2)
|
|
18113
|
+
return;
|
|
18114
|
+
const lineWidth = 1;
|
|
18115
|
+
const halfLineWidth = 1 / 2;
|
|
18116
|
+
const aspect = 1;
|
|
18117
|
+
// 点位向量数组
|
|
18118
|
+
const keyPoints = positionList;
|
|
18119
|
+
// 点位组成的平滑曲线
|
|
18120
|
+
const curve = new THREE__namespace.CatmullRomCurve3(keyPoints, false, 'catmullrom', 0.5);
|
|
18121
|
+
// 求顶点和 UV
|
|
18122
|
+
const divisions = Math.ceil(curve.getLength()); // 曲线切片数
|
|
18123
|
+
const curvePoints = curve.getPoints(divisions);
|
|
18124
|
+
const curvePointsLength = curvePoints.length;
|
|
18125
|
+
const normals = getNormals__default["default"](curvePoints.map((p) => [p.x, p.z])); // curvePoints:每个点切线的向量「二维」
|
|
18126
|
+
const rectangleNumber = curvePoints.length - 1; // 曲线上 N 个点,构成了 N - 1 个矩形
|
|
18127
|
+
const indexNumber = rectangleNumber * TRIANGLE_NUMBER_OF_RECTANGLE * VERTEX_NUMBER_OF_TRIANGLE;
|
|
18128
|
+
const verticesNumber = 2 * curvePointsLength; // 顶点数量(包含公用):每个曲线点对应两个顶点,N 个 点有 2N 个顶点
|
|
18129
|
+
const positionNumber = verticesNumber * AXIS_NUMBER_OF_VERTEX; // 坐标点数量
|
|
18130
|
+
const uvNumber = verticesNumber * UV_NUMBER_OF_VERTEX; // uv 数量
|
|
18131
|
+
const index = new Uint32Array(indexNumber);
|
|
18132
|
+
const positions = new Float32Array(positionNumber);
|
|
18133
|
+
const uv = new Float32Array(uvNumber);
|
|
18134
|
+
let totalLength = 0;
|
|
18135
|
+
for (let i = 0; i < curvePoints.length; i++) {
|
|
18136
|
+
const [nx, nz] = normals[i][0];
|
|
18137
|
+
const curvePoint = curvePoints[i];
|
|
18138
|
+
const { x: curvePointX, y: curvePointY, z: curvePointZ } = curvePoint;
|
|
18139
|
+
// vertices[2i]
|
|
18140
|
+
positions[i * 6 + 0] = curvePointX + nx * halfLineWidth;
|
|
18141
|
+
positions[i * 6 + 1] = curvePointY + 0.05;
|
|
18142
|
+
positions[i * 6 + 2] = curvePointZ + nz * halfLineWidth;
|
|
18143
|
+
// vertices[2i + 1]
|
|
18144
|
+
positions[i * 6 + 3] = curvePointX - nx * halfLineWidth;
|
|
18145
|
+
positions[i * 6 + 4] = curvePointY + 0.05;
|
|
18146
|
+
positions[i * 6 + 5] = curvePointZ - nz * halfLineWidth;
|
|
18147
|
+
totalLength += i > 0 ? curvePoints[i - 1].clone().sub(curvePoints[i]).length() : 0;
|
|
18148
|
+
const end = totalLength / lineWidth / aspect;
|
|
18149
|
+
uv[i * 4 + 0] = 0;
|
|
18150
|
+
uv[i * 4 + 1] = end;
|
|
18151
|
+
uv[i * 4 + 2] = 1;
|
|
18152
|
+
uv[i * 4 + 3] = end;
|
|
18153
|
+
if (i === curvePoints.length - 1)
|
|
18154
|
+
continue;
|
|
18155
|
+
index[i * 6 + 0] = i * 2 + 0;
|
|
18156
|
+
index[i * 6 + 1] = i * 2 + 2;
|
|
18157
|
+
index[i * 6 + 2] = i * 2 + 1;
|
|
18158
|
+
index[i * 6 + 3] = i * 2 + 2;
|
|
18159
|
+
index[i * 6 + 4] = i * 2 + 3;
|
|
18160
|
+
index[i * 6 + 5] = i * 2 + 1;
|
|
18161
|
+
}
|
|
18162
|
+
const geometry = new THREE__namespace.BufferGeometry();
|
|
18163
|
+
geometry.setAttribute('position', new THREE__namespace.BufferAttribute(positions, 3));
|
|
18164
|
+
geometry.setAttribute('uv', new THREE__namespace.BufferAttribute(uv, 2));
|
|
18165
|
+
geometry.setIndex(new THREE__namespace.BufferAttribute(index, 1));
|
|
18166
|
+
return geometry;
|
|
18167
|
+
}
|
|
18168
|
+
|
|
18169
|
+
function getArrowMaterial(params) {
|
|
18170
|
+
var _a;
|
|
18171
|
+
const texture = new THREE__namespace.TextureLoader().load((_a = params === null || params === void 0 ? void 0 : params.textureUtl) !== null && _a !== void 0 ? _a : '//vrlab-static.ljcdn.com/release/web/arrow.c5d028e4.png');
|
|
18172
|
+
texture.wrapS = texture.wrapT = THREE__namespace.RepeatWrapping;
|
|
18173
|
+
texture.encoding = THREE__namespace.sRGBEncoding;
|
|
18174
|
+
const arrowMaterial = new THREE__namespace.MeshBasicMaterial({
|
|
18175
|
+
color: 0xffffff,
|
|
18176
|
+
map: texture,
|
|
18177
|
+
transparent: true,
|
|
18178
|
+
opacity: 0.8,
|
|
18179
|
+
});
|
|
18180
|
+
return arrowMaterial;
|
|
18181
|
+
}
|
|
18182
|
+
|
|
18183
|
+
/**
|
|
18184
|
+
* 判断对象是否为`null`或`undefined`。
|
|
18185
|
+
* @param
|
|
18186
|
+
* @return
|
|
18187
|
+
*/
|
|
18188
|
+
/**
|
|
18189
|
+
* 判断对象不为`null`或`undefined`。
|
|
18190
|
+
*/
|
|
18191
|
+
function notNil(value) {
|
|
18192
|
+
return value !== null && value !== undefined;
|
|
18193
|
+
}
|
|
18194
|
+
|
|
18195
|
+
const VERSION$1 = 'v1.0.1';
|
|
18196
|
+
const PLUGIN_NAME$1 = 'GuideLinePlugin';
|
|
18197
|
+
const PLUGIN$1 = `${PLUGIN_NAME$1}@${VERSION$1}`;
|
|
18198
|
+
const pluginFlag = (name) => `${PLUGIN$1}--${name}`;
|
|
18199
|
+
class Controller extends Controller$6 {
|
|
18200
|
+
constructor(five) {
|
|
18201
|
+
super(five);
|
|
18202
|
+
Object.defineProperty(this, "state", {
|
|
18203
|
+
enumerable: true,
|
|
18204
|
+
configurable: true,
|
|
18205
|
+
writable: true,
|
|
18206
|
+
value: {
|
|
18207
|
+
visible: false,
|
|
18208
|
+
enabled: true,
|
|
18209
|
+
disposed: false,
|
|
18210
|
+
}
|
|
18211
|
+
});
|
|
18212
|
+
Object.defineProperty(this, "data", {
|
|
18213
|
+
enumerable: true,
|
|
18214
|
+
configurable: true,
|
|
18215
|
+
writable: true,
|
|
18216
|
+
value: void 0
|
|
18217
|
+
});
|
|
18218
|
+
Object.defineProperty(this, "linesGroup", {
|
|
18219
|
+
enumerable: true,
|
|
18220
|
+
configurable: true,
|
|
18221
|
+
writable: true,
|
|
18222
|
+
value: void 0
|
|
18223
|
+
});
|
|
18224
|
+
Object.defineProperty(this, "disposedErrorLog", {
|
|
18225
|
+
enumerable: true,
|
|
18226
|
+
configurable: true,
|
|
18227
|
+
writable: true,
|
|
18228
|
+
value: () => {
|
|
18229
|
+
console.error(`${PLUGIN$1} is disposed`);
|
|
18230
|
+
}
|
|
18231
|
+
});
|
|
18232
|
+
Object.defineProperty(this, "actionWhenEnabled", {
|
|
18233
|
+
enumerable: true,
|
|
18234
|
+
configurable: true,
|
|
18235
|
+
writable: true,
|
|
18236
|
+
value: (func) => {
|
|
18237
|
+
if (this.state.enabled)
|
|
18238
|
+
return func();
|
|
18239
|
+
}
|
|
18240
|
+
});
|
|
18241
|
+
Object.assign(window, { [`__${PLUGIN_NAME$1}_DEBUG__`]: this });
|
|
18242
|
+
}
|
|
18243
|
+
async load(serverData, state, userAction = true) {
|
|
18244
|
+
const prevData = this.data ? JSON.parse(JSON.stringify(this.data)) : undefined;
|
|
18245
|
+
// format server data to plugin data
|
|
18246
|
+
const data = await this.formatData(serverData);
|
|
18247
|
+
this.hooks.emit('dataChange', data, prevData);
|
|
18248
|
+
this.data = data;
|
|
18249
|
+
// render line group
|
|
18250
|
+
if (this.linesGroup)
|
|
18251
|
+
this.five.scene.remove(this.linesGroup);
|
|
18252
|
+
const linesGroup = this.getLinesGroup(data.routes);
|
|
18253
|
+
if (!linesGroup)
|
|
18254
|
+
return Promise.reject(new Error('no line'));
|
|
18255
|
+
this.linesGroup = linesGroup;
|
|
18256
|
+
this.five.scene.add(linesGroup);
|
|
18257
|
+
this.handleVisible(this.state.visible);
|
|
18258
|
+
this.handleEnable(this.state.enabled);
|
|
18259
|
+
// initialize plugin state
|
|
18260
|
+
if (state)
|
|
18261
|
+
this.setState(state);
|
|
18262
|
+
// load end
|
|
18263
|
+
this.five.needsRender = true;
|
|
18264
|
+
this.hooks.emit('dataLoaded', data);
|
|
18265
|
+
console.log(`${PLUGIN$1} loaded`, data);
|
|
18266
|
+
}
|
|
18267
|
+
async formatData(serverData) {
|
|
18268
|
+
if (typeof serverData === 'object' && serverData !== null && serverData.version && serverData.data) {
|
|
18269
|
+
return serverData.data;
|
|
18270
|
+
}
|
|
18271
|
+
return serverData;
|
|
18272
|
+
}
|
|
18273
|
+
async show(options) {
|
|
18274
|
+
this.setState({ visible: true }, options);
|
|
18275
|
+
}
|
|
18276
|
+
async hide(options) {
|
|
18277
|
+
this.setState({ visible: false }, options);
|
|
18278
|
+
}
|
|
18279
|
+
enable(options) {
|
|
18280
|
+
this.setState({ enabled: true }, options);
|
|
18281
|
+
}
|
|
18282
|
+
disable(options) {
|
|
18283
|
+
this.setState({ enabled: false }, options);
|
|
18284
|
+
}
|
|
18285
|
+
dispose() {
|
|
18286
|
+
this.setState({ disposed: true });
|
|
18287
|
+
}
|
|
18288
|
+
setState(state, options) {
|
|
18289
|
+
var _a;
|
|
18290
|
+
if (this.state.disposed)
|
|
18291
|
+
return this.disposedErrorLog();
|
|
18292
|
+
const prevState = Object.assign({}, this.state);
|
|
18293
|
+
this.state = Object.assign(Object.assign({}, this.state), state);
|
|
18294
|
+
if (state.disposed !== undefined && state.disposed !== prevState.disposed) {
|
|
18295
|
+
if (state.disposed)
|
|
18296
|
+
this.handleDispose();
|
|
18297
|
+
}
|
|
18298
|
+
if (state.visible !== undefined && state.visible !== prevState.visible) {
|
|
18299
|
+
this.handleVisible(state.visible, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18300
|
+
}
|
|
18301
|
+
if (state.enabled !== undefined && state.enabled !== prevState.enabled) {
|
|
18302
|
+
this.handleEnable(state.enabled, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18303
|
+
}
|
|
18304
|
+
if (!equal(prevState, this.state, { deep: true })) {
|
|
18305
|
+
this.hooks.emit('stateChange', { state: this.state, prevState, userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true });
|
|
18306
|
+
this.five.needsRender = true;
|
|
18307
|
+
}
|
|
18308
|
+
}
|
|
18309
|
+
handleEnable(enabled, userAction = true) {
|
|
18310
|
+
if (this.linesGroup) {
|
|
18311
|
+
if (enabled) {
|
|
18312
|
+
this.five.scene.add(this.linesGroup);
|
|
18313
|
+
this.actionWhenEnabled(() => this.hooks.emit('enable', { userAction }));
|
|
18314
|
+
}
|
|
18315
|
+
else {
|
|
18316
|
+
this.five.scene.remove(this.linesGroup);
|
|
18317
|
+
this.hooks.emit('disable', { userAction });
|
|
18318
|
+
}
|
|
18319
|
+
}
|
|
18320
|
+
}
|
|
18321
|
+
handleVisible(visible, userAction = true) {
|
|
18322
|
+
if (this.linesGroup) {
|
|
18323
|
+
if (visible) {
|
|
18324
|
+
this.linesGroup.visible = true;
|
|
18325
|
+
this.actionWhenEnabled(() => this.hooks.emit('show', { userAction }));
|
|
18326
|
+
}
|
|
18327
|
+
else {
|
|
18328
|
+
this.linesGroup.visible = false;
|
|
18329
|
+
this.actionWhenEnabled(() => this.hooks.emit('hide', { userAction }));
|
|
18330
|
+
}
|
|
18331
|
+
}
|
|
18332
|
+
}
|
|
18333
|
+
handleDispose() {
|
|
18334
|
+
if (this.linesGroup)
|
|
18335
|
+
this.five.scene.add(this.linesGroup);
|
|
18336
|
+
}
|
|
18337
|
+
/**
|
|
18338
|
+
* 获取多条路线的 Mesh Group
|
|
18339
|
+
*/
|
|
18340
|
+
getLinesGroup(routes) {
|
|
18341
|
+
/** 'as THREE.Mesh[]' for build check */
|
|
18342
|
+
const meshes = routes.map(this.getLineMesh.bind(this)).filter(notNil);
|
|
18343
|
+
const group = new THREE__namespace.Group();
|
|
18344
|
+
group.name = pluginFlag('route-group');
|
|
18345
|
+
if (meshes.length === 0)
|
|
18346
|
+
return;
|
|
18347
|
+
group.add(...meshes);
|
|
18348
|
+
return group;
|
|
18349
|
+
}
|
|
18350
|
+
/**
|
|
18351
|
+
* 获取单条路线的 Mesh
|
|
18352
|
+
*/
|
|
18353
|
+
getLineMesh(data) {
|
|
18354
|
+
const positions = data.panoIndexList.map((panoIndex) => { var _a; return (_a = this.five.work.observers[panoIndex]) === null || _a === void 0 ? void 0 : _a.standingPosition; }).filter(notNil);
|
|
18355
|
+
const geometry = getLineGeometry(positions);
|
|
18356
|
+
if (!geometry)
|
|
18357
|
+
return;
|
|
18358
|
+
const material = getArrowMaterial({ textureUtl: data.arrowTextureUrl });
|
|
18359
|
+
const mesh = new THREE__namespace.Mesh(geometry, material);
|
|
18360
|
+
mesh.name = pluginFlag('route-line-mesh');
|
|
18361
|
+
mesh.renderOrder = 3;
|
|
18362
|
+
return mesh;
|
|
18363
|
+
}
|
|
18364
|
+
}
|
|
18365
|
+
Object.defineProperty(Controller, "lasestVersion", {
|
|
18366
|
+
enumerable: true,
|
|
18367
|
+
configurable: true,
|
|
18368
|
+
writable: true,
|
|
18369
|
+
value: VERSION$1
|
|
18370
|
+
});
|
|
18371
|
+
|
|
18372
|
+
const GuideLinePlugin = (five) => new Controller(five);
|
|
18373
|
+
|
|
18374
|
+
/** 坐标转换成单位向量 */
|
|
18375
|
+
function coordinatesToVector(coordinates) {
|
|
18376
|
+
const distance = Math.abs(Math.cos(coordinates.latitude));
|
|
18377
|
+
return new THREE__namespace.Vector3(
|
|
18378
|
+
/* x */ -Math.sin(coordinates.longitude) * distance,
|
|
18379
|
+
/* y */ -Math.sin(coordinates.latitude),
|
|
18380
|
+
/* z */ -Math.cos(coordinates.longitude) * distance);
|
|
18381
|
+
}
|
|
18382
|
+
|
|
18383
|
+
/**
|
|
18384
|
+
* @description: 获取coordinates间的夹角
|
|
18385
|
+
* @return {number} 夹角角度
|
|
18386
|
+
*/
|
|
18387
|
+
function coordinatesAngle(coordinates1, coordinates2) {
|
|
18388
|
+
const vector1 = coordinatesToVector(coordinates1);
|
|
18389
|
+
const vector2 = coordinatesToVector(coordinates2);
|
|
18390
|
+
const angle = vector1.angleTo(vector2);
|
|
18391
|
+
return angle;
|
|
18392
|
+
}
|
|
18393
|
+
|
|
18394
|
+
const safeCall = async (fn) => {
|
|
18395
|
+
try {
|
|
18396
|
+
// eslint-disable-next-line prettier/prettier
|
|
18397
|
+
fn().then(() => { }, () => { }).catch(() => { });
|
|
18398
|
+
}
|
|
18399
|
+
catch (e) { }
|
|
18400
|
+
};
|
|
18401
|
+
|
|
18402
|
+
const TAU = Math.PI * 2;
|
|
18403
|
+
/**
|
|
18404
|
+
* 将弧度转成 0 - 2PI 中的值
|
|
18405
|
+
* @param rad - 任意弧度值
|
|
18406
|
+
* @return 0 - 2PI 的数值
|
|
18407
|
+
*/
|
|
18408
|
+
function formatRad(rad) {
|
|
18409
|
+
if (rad >= 0 && rad < TAU)
|
|
18410
|
+
return rad;
|
|
18411
|
+
return ((rad % TAU) + TAU) % TAU;
|
|
18412
|
+
}
|
|
18413
|
+
|
|
18414
|
+
/** 单位向量转换成坐标 */
|
|
18415
|
+
function vectorToCoordinates(vector) {
|
|
18416
|
+
return {
|
|
18417
|
+
longitude: formatRad(-Math.atan2(vector.x, -vector.z)),
|
|
18418
|
+
latitude: -Math.asin(vector.y / 1),
|
|
18419
|
+
};
|
|
18420
|
+
}
|
|
18421
|
+
|
|
18422
|
+
// eslint-disable-next-line max-params
|
|
18423
|
+
function linerValue(x0, v0, t1, t) {
|
|
18424
|
+
const a = -x0 / t1;
|
|
18425
|
+
const d = x0;
|
|
18426
|
+
return a * t + d;
|
|
18427
|
+
}
|
|
18428
|
+
|
|
18429
|
+
const VERSION = 'v1.0.5';
|
|
18430
|
+
const PLUGIN_NAME = 'CruisePlugin';
|
|
18431
|
+
const PLUGIN = `${PLUGIN_NAME}@${VERSION}`;
|
|
18432
|
+
const disposedErrorLog = () => {
|
|
18433
|
+
console.error(`${PLUGIN} is disposed`);
|
|
18434
|
+
};
|
|
18435
|
+
const disableWarnLog = () => {
|
|
18436
|
+
console.warn(`${PLUGIN} is disabled`);
|
|
18437
|
+
};
|
|
18438
|
+
const disableErrorLog = () => {
|
|
18439
|
+
console.error(`${PLUGIN} is disabled`);
|
|
18440
|
+
};
|
|
18441
|
+
const pauseDataMap = new Map();
|
|
18442
|
+
class CruisePluginController extends Controller$6 {
|
|
18443
|
+
constructor(five) {
|
|
18444
|
+
super(five);
|
|
18445
|
+
Object.defineProperty(this, "state", {
|
|
18446
|
+
enumerable: true,
|
|
18447
|
+
configurable: true,
|
|
18448
|
+
writable: true,
|
|
18449
|
+
value: {
|
|
18450
|
+
visible: true,
|
|
18451
|
+
enabled: true,
|
|
18452
|
+
disposed: false,
|
|
18453
|
+
playing: false,
|
|
18454
|
+
speed: 1,
|
|
18455
|
+
config: {
|
|
18456
|
+
speedConfig: {
|
|
18457
|
+
rotateSpeed: 0.001,
|
|
18458
|
+
rotateSpeedUnit: 'rad/ms',
|
|
18459
|
+
moveSpeed: 0.003,
|
|
18460
|
+
moveSpeedUnit: 'm/ms',
|
|
18461
|
+
},
|
|
18462
|
+
},
|
|
18463
|
+
}
|
|
18464
|
+
});
|
|
18465
|
+
Object.defineProperty(this, "data", {
|
|
18466
|
+
enumerable: true,
|
|
18467
|
+
configurable: true,
|
|
18468
|
+
writable: true,
|
|
18469
|
+
value: void 0
|
|
18470
|
+
});
|
|
18471
|
+
Object.defineProperty(this, "privateState", {
|
|
18472
|
+
enumerable: true,
|
|
18473
|
+
configurable: true,
|
|
18474
|
+
writable: true,
|
|
18475
|
+
value: {
|
|
18476
|
+
playing: false,
|
|
18477
|
+
currentPlayQueue: [],
|
|
18478
|
+
currentPlayKeyframe: null,
|
|
18479
|
+
broke: false,
|
|
18480
|
+
disposers: [],
|
|
18481
|
+
}
|
|
18482
|
+
});
|
|
18483
|
+
Object.defineProperty(this, "GuideLine", {
|
|
18484
|
+
enumerable: true,
|
|
18485
|
+
configurable: true,
|
|
18486
|
+
writable: true,
|
|
18487
|
+
value: void 0
|
|
18488
|
+
});
|
|
18489
|
+
Object.assign(window, { [`__${PLUGIN_NAME}_DEBUG__`]: this });
|
|
18490
|
+
const setFiveLinearUpdateCamera = this.setFiveLinearUpdateCamera.bind(this);
|
|
18491
|
+
const setFiveOriginUpdateCamera = this.setFiveOriginUpdateCamera.bind(this);
|
|
18492
|
+
this.hooks.on('play', setFiveLinearUpdateCamera);
|
|
18493
|
+
this.hooks.on('broke', setFiveOriginUpdateCamera);
|
|
18494
|
+
this.hooks.on('end', setFiveOriginUpdateCamera);
|
|
18495
|
+
this.hooks.on('pause', setFiveOriginUpdateCamera);
|
|
18496
|
+
this.privateState.disposers.push(() => {
|
|
18497
|
+
this.hooks.off('play', setFiveLinearUpdateCamera);
|
|
18498
|
+
this.hooks.off('broke', setFiveOriginUpdateCamera);
|
|
18499
|
+
this.hooks.off('end', setFiveOriginUpdateCamera);
|
|
18500
|
+
this.hooks.off('pause', setFiveOriginUpdateCamera);
|
|
18501
|
+
});
|
|
18502
|
+
}
|
|
18503
|
+
/**
|
|
18504
|
+
* @description Load Data and State
|
|
18505
|
+
*/
|
|
18506
|
+
async load(serverData, state, userAction) {
|
|
18507
|
+
var _a, _b, _c, _d, _e;
|
|
18508
|
+
if (this.state.disposed)
|
|
18509
|
+
return disposedErrorLog();
|
|
18510
|
+
if (!this.privateState.fiveOriginGetProgress) {
|
|
18511
|
+
if (!((_b = (_a = this.five.controller) === null || _a === void 0 ? void 0 : _a.cameraMotion) === null || _b === void 0 ? void 0 : _b.getProgress)) {
|
|
18512
|
+
await this.waitFiveLoaded();
|
|
18513
|
+
this.privateState.fiveOriginGetProgress = (_d = (_c = this.five.controller) === null || _c === void 0 ? void 0 : _c.cameraMotion) === null || _d === void 0 ? void 0 : _d.getProgress;
|
|
18514
|
+
}
|
|
18515
|
+
}
|
|
18516
|
+
this.clear();
|
|
18517
|
+
// copy this.data
|
|
18518
|
+
const prevData = this.data ? JSON.parse(JSON.stringify(this.data)) : undefined;
|
|
18519
|
+
// format server data to plugin data
|
|
18520
|
+
const data = await this.formatData(serverData);
|
|
18521
|
+
this.data = data;
|
|
18522
|
+
this.hooks.emit('dataChange', data, prevData);
|
|
18523
|
+
let guideLinePanoIndex = [];
|
|
18524
|
+
let tempFloorIndex;
|
|
18525
|
+
// filter panoIndex list Data
|
|
18526
|
+
const hasPanoIndexKeyframes = this.data.keyframes.filter((keyframe) => keyframe.data.panoIndex !== undefined);
|
|
18527
|
+
hasPanoIndexKeyframes
|
|
18528
|
+
.filter((keyframe, index) => { var _a; return keyframe.data.panoIndex !== ((_a = hasPanoIndexKeyframes[index - 1]) === null || _a === void 0 ? void 0 : _a.data.panoIndex); })
|
|
18529
|
+
.map((keyframe) => keyframe.data.panoIndex)
|
|
18530
|
+
.forEach((panoIndex) => {
|
|
18531
|
+
var _a, _b;
|
|
18532
|
+
const floorIndex = (_a = this.five.work.observers[panoIndex]) === null || _a === void 0 ? void 0 : _a.floorIndex;
|
|
18533
|
+
if (floorIndex === undefined)
|
|
18534
|
+
return;
|
|
18535
|
+
if (tempFloorIndex === floorIndex) {
|
|
18536
|
+
const index = guideLinePanoIndex.length - 1;
|
|
18537
|
+
guideLinePanoIndex[index] = [...((_b = guideLinePanoIndex[index]) !== null && _b !== void 0 ? _b : []), panoIndex];
|
|
18538
|
+
}
|
|
18539
|
+
else {
|
|
18540
|
+
tempFloorIndex = floorIndex;
|
|
18541
|
+
const index = guideLinePanoIndex.length;
|
|
18542
|
+
guideLinePanoIndex[index] = [panoIndex];
|
|
18543
|
+
}
|
|
18544
|
+
});
|
|
18545
|
+
// initialize GuideLinePlugin
|
|
18546
|
+
if (!this.GuideLine)
|
|
18547
|
+
this.GuideLine = GuideLinePlugin(this.five);
|
|
18548
|
+
// load GuideLine
|
|
18549
|
+
(_e = this.GuideLine) === null || _e === void 0 ? void 0 : _e.load({ routes: guideLinePanoIndex.map((route) => ({ panoIndexList: route })) });
|
|
18550
|
+
// first pause
|
|
18551
|
+
this.setState({ playing: false });
|
|
18552
|
+
// set state
|
|
18553
|
+
this.handleVisible(this.state.visible);
|
|
18554
|
+
this.handleEnable(this.state.enabled);
|
|
18555
|
+
this.changePlayState(this.state.playing);
|
|
18556
|
+
this.changeSpeed(this.state.speed);
|
|
18557
|
+
// initialize plugin state
|
|
18558
|
+
if (state)
|
|
18559
|
+
this.setState(state, { userAction });
|
|
18560
|
+
// load end
|
|
18561
|
+
console.log(`${PLUGIN} loaded`, data);
|
|
18562
|
+
this.hooks.emit('dataLoaded', data);
|
|
18563
|
+
}
|
|
18564
|
+
/**
|
|
18565
|
+
* @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
|
|
18566
|
+
*/
|
|
18567
|
+
play(options) {
|
|
18568
|
+
this.setState({ playing: true }, options);
|
|
18569
|
+
}
|
|
18570
|
+
/**
|
|
18571
|
+
* @description If playing, first pause, then play from keyframes index/id
|
|
18572
|
+
* @param {number} options.index play from keyframes index
|
|
18573
|
+
* @param {string} options.id play from keyframes id
|
|
18574
|
+
*/
|
|
18575
|
+
playFrom(options) {
|
|
18576
|
+
const { index, id, userAction } = options;
|
|
18577
|
+
if (this.state.playing)
|
|
18578
|
+
this.setState({ playing: false }, { userAction });
|
|
18579
|
+
this.setState({ playing: true }, { userAction, playFromIndex: index, playFromId: id });
|
|
18580
|
+
}
|
|
18581
|
+
/**
|
|
18582
|
+
* @description Play from first keyframe
|
|
18583
|
+
*/
|
|
18584
|
+
playFromStart(options) {
|
|
18585
|
+
return this.playFrom(Object.assign(Object.assign({}, options), { index: 0 }));
|
|
18586
|
+
}
|
|
18587
|
+
/**
|
|
18588
|
+
* @description Pause
|
|
18589
|
+
*/
|
|
18590
|
+
pause(options) {
|
|
18591
|
+
this.setState({ playing: false }, options);
|
|
18592
|
+
}
|
|
18593
|
+
/**
|
|
18594
|
+
* @description Show guide line
|
|
18595
|
+
*/
|
|
18596
|
+
async show(options) {
|
|
18597
|
+
this.setState({ visible: true }, options);
|
|
18598
|
+
}
|
|
18599
|
+
/**
|
|
18600
|
+
* @description Hide guide line
|
|
18601
|
+
*/
|
|
18602
|
+
async hide(options) {
|
|
18603
|
+
this.setState({ visible: false }, options);
|
|
18604
|
+
}
|
|
18605
|
+
/**
|
|
18606
|
+
* @description Enable
|
|
18607
|
+
*/
|
|
18608
|
+
enable(options) {
|
|
18609
|
+
this.setState({ enabled: true }, options);
|
|
18610
|
+
}
|
|
18611
|
+
/**
|
|
18612
|
+
* @description Disable
|
|
18613
|
+
*/
|
|
18614
|
+
disable(options) {
|
|
18615
|
+
this.setState({ enabled: false }, options);
|
|
18616
|
+
}
|
|
18617
|
+
/**
|
|
18618
|
+
* @description Dispose
|
|
18619
|
+
*/
|
|
18620
|
+
dispose() {
|
|
18621
|
+
this.setState({ disposed: true });
|
|
18622
|
+
}
|
|
18623
|
+
/**
|
|
18624
|
+
* @description Set state
|
|
18625
|
+
*/
|
|
18626
|
+
setState(state, options) {
|
|
18627
|
+
var _a;
|
|
18628
|
+
if (this.state.disposed)
|
|
18629
|
+
return disposedErrorLog();
|
|
18630
|
+
if (!this.state.enabled) {
|
|
18631
|
+
// when plugin is disabled, only can change enabled or disposed to true
|
|
18632
|
+
if (state.enabled !== true && state.disposed !== true)
|
|
18633
|
+
return disableErrorLog();
|
|
18634
|
+
}
|
|
18635
|
+
const prevState = Object.assign({}, this.state);
|
|
18636
|
+
this.state = Object.assign(Object.assign({}, this.state), state);
|
|
18637
|
+
if (state.disposed !== undefined && state.disposed !== prevState.disposed) {
|
|
18638
|
+
if (state.disposed)
|
|
18639
|
+
this.handleDispose();
|
|
18640
|
+
}
|
|
18641
|
+
if (state.visible !== undefined && state.visible !== prevState.visible) {
|
|
18642
|
+
this.handleVisible(state.visible, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18643
|
+
}
|
|
18644
|
+
if (state.enabled !== undefined && state.enabled !== prevState.enabled) {
|
|
18645
|
+
this.handleEnable(state.enabled, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18646
|
+
}
|
|
18647
|
+
if (state.playing !== undefined && state.playing !== prevState.playing) {
|
|
18648
|
+
this.changePlayState(state.playing, options);
|
|
18649
|
+
}
|
|
18650
|
+
if (state.speed !== undefined && state.speed !== prevState.speed) {
|
|
18651
|
+
this.changeSpeed(state.speed, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18652
|
+
}
|
|
18653
|
+
if (!equal(prevState, this.state, { deep: true })) {
|
|
18654
|
+
console.log('--emit stateChange--', this.state);
|
|
18655
|
+
this.hooks.emit('stateChange', { state: this.state, prevState, userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true });
|
|
18656
|
+
}
|
|
18657
|
+
}
|
|
18658
|
+
/**
|
|
18659
|
+
* @description Format data
|
|
18660
|
+
*/
|
|
18661
|
+
async formatData(serverData) {
|
|
18662
|
+
if (!this.five.work)
|
|
18663
|
+
await this.waitFiveLoaded();
|
|
18664
|
+
const observers = this.five.work.observers;
|
|
18665
|
+
const data = (() => {
|
|
18666
|
+
const _serverData = serverData;
|
|
18667
|
+
if (typeof _serverData === 'object' && _serverData !== null && _serverData.version && _serverData.data) {
|
|
18668
|
+
return _serverData.data;
|
|
18669
|
+
}
|
|
18670
|
+
return _serverData;
|
|
18671
|
+
})();
|
|
18672
|
+
if (data.keyframes) {
|
|
18673
|
+
return {
|
|
18674
|
+
keyframesId: uuid(),
|
|
18675
|
+
keyframes: data.keyframes.map((keyframe, index) => { var _a; return (Object.assign({ id: (_a = keyframe.uuid) !== null && _a !== void 0 ? _a : uuid(), index }, keyframe)); }),
|
|
18676
|
+
};
|
|
18677
|
+
}
|
|
18678
|
+
else if (data.panoIndexList) {
|
|
18679
|
+
let keyframes = [];
|
|
18680
|
+
const moveEffect = data.moveEffect;
|
|
18681
|
+
data.panoIndexList
|
|
18682
|
+
.filter((panoIndex, index) => panoIndex !== data.panoIndexList[index - 1])
|
|
18683
|
+
.forEach((panoIndex, index) => {
|
|
18684
|
+
const lookatNextPanoIndex = (() => {
|
|
18685
|
+
var _a, _b, _c, _d;
|
|
18686
|
+
const nextPanoIndex = data.panoIndexList[index + 1];
|
|
18687
|
+
if (nextPanoIndex === undefined)
|
|
18688
|
+
return;
|
|
18689
|
+
const vectorFrom = (_a = observers[panoIndex]) === null || _a === void 0 ? void 0 : _a.position;
|
|
18690
|
+
const vectorTo = (_b = observers[nextPanoIndex]) === null || _b === void 0 ? void 0 : _b.position;
|
|
18691
|
+
if (!vectorTo || !vectorFrom)
|
|
18692
|
+
return;
|
|
18693
|
+
// if panoIndex and next panoIndex isn't in same floor, return
|
|
18694
|
+
if (((_c = observers[panoIndex]) === null || _c === void 0 ? void 0 : _c.floorIndex) !== ((_d = observers[nextPanoIndex]) === null || _d === void 0 ? void 0 : _d.floorIndex))
|
|
18695
|
+
return;
|
|
18696
|
+
const vector = new THREE__namespace.Vector3().subVectors(vectorTo, vectorFrom);
|
|
18697
|
+
return vectorToCoordinates(vector);
|
|
18698
|
+
})();
|
|
18699
|
+
if (data.moveType === undefined || data.moveType === 'justMove') {
|
|
18700
|
+
// move to panoIndex, latitude, longitude
|
|
18701
|
+
keyframes.push({ data: Object.assign({ effect: 'Move', panoIndex, moveEffect }, (lookatNextPanoIndex !== null && lookatNextPanoIndex !== void 0 ? lookatNextPanoIndex : {})) });
|
|
18702
|
+
}
|
|
18703
|
+
else if (data.moveType === 'moveAndRotate') {
|
|
18704
|
+
// move to panoIndex, then rotate to latitude and longitude
|
|
18705
|
+
keyframes.push({ data: { effect: 'Move', panoIndex, moveEffect } });
|
|
18706
|
+
if (lookatNextPanoIndex)
|
|
18707
|
+
keyframes.push({ data: Object.assign({ effect: 'Rotate', panoIndex }, lookatNextPanoIndex) });
|
|
18708
|
+
}
|
|
18709
|
+
});
|
|
18710
|
+
return { keyframesId: uuid(), keyframes: keyframes.map((keyframe, index) => (Object.assign({ id: uuid(), index }, keyframe))) };
|
|
18711
|
+
}
|
|
18712
|
+
else {
|
|
18713
|
+
throw new Error('format error: data no keyframes or no panoIndexList');
|
|
18714
|
+
}
|
|
18715
|
+
}
|
|
18716
|
+
handleEnable(enabled, userAction = true) {
|
|
18717
|
+
var _a, _b;
|
|
18718
|
+
if (enabled) {
|
|
18719
|
+
(_a = this.GuideLine) === null || _a === void 0 ? void 0 : _a.enable();
|
|
18720
|
+
this.hooks.emit('enable', { userAction });
|
|
18721
|
+
}
|
|
18722
|
+
else {
|
|
18723
|
+
(_b = this.GuideLine) === null || _b === void 0 ? void 0 : _b.disable();
|
|
18724
|
+
this.changePlayState(false, { userAction });
|
|
18725
|
+
this.hooks.emit('disable', { userAction });
|
|
18726
|
+
}
|
|
18727
|
+
this.state.enabled = enabled;
|
|
18728
|
+
}
|
|
18729
|
+
handleVisible(visible, userAction = true) {
|
|
18730
|
+
var _a, _b;
|
|
18731
|
+
if (visible) {
|
|
18732
|
+
(_a = this.GuideLine) === null || _a === void 0 ? void 0 : _a.show();
|
|
18733
|
+
this.actionIfStateIsEnabled(() => this.hooks.emit('show', { userAction }));
|
|
18734
|
+
}
|
|
18735
|
+
else {
|
|
18736
|
+
(_b = this.GuideLine) === null || _b === void 0 ? void 0 : _b.hide();
|
|
18737
|
+
this.actionIfStateIsEnabled(() => this.hooks.emit('hide', { userAction }));
|
|
18738
|
+
}
|
|
18739
|
+
this.state.visible = visible;
|
|
18740
|
+
}
|
|
18741
|
+
changePlayState(play, options) {
|
|
18742
|
+
this.actionIfStateIsEnabled(() => { var _a; return this.hooks.emit('playStateChange', play ? 'playing' : 'pause', { userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true }); });
|
|
18743
|
+
play ? this.handlePlay(options) : this.handlePause(options);
|
|
18744
|
+
this.state.playing = play;
|
|
18745
|
+
}
|
|
18746
|
+
/**
|
|
18747
|
+
* @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
|
|
18748
|
+
* @param {number} options.playFromIndex play from keyframes index
|
|
18749
|
+
* @param {string} options.playFromId play from keyframes id
|
|
18750
|
+
*/
|
|
18751
|
+
// eslint-disable-next-line complexity
|
|
18752
|
+
async handlePlay(options) {
|
|
18753
|
+
var _a;
|
|
18754
|
+
const { data, state, privateState, hooks } = this;
|
|
18755
|
+
// check whether keyframes can be played
|
|
18756
|
+
if (privateState.playing)
|
|
18757
|
+
return;
|
|
18758
|
+
if (!(data === null || data === void 0 ? void 0 : data.keyframes) || (data === null || data === void 0 ? void 0 : data.keyframes.length) === 0)
|
|
18759
|
+
return;
|
|
18760
|
+
// set current play id
|
|
18761
|
+
const currentPlayId = uuid();
|
|
18762
|
+
// if handlePlay function is called again before play end, currentPlayId isn't equal to privateState.playId
|
|
18763
|
+
privateState.playId = currentPlayId;
|
|
18764
|
+
// set state
|
|
18765
|
+
privateState.playing = true;
|
|
18766
|
+
privateState.broke = false;
|
|
18767
|
+
const keyframes = data.keyframes;
|
|
18768
|
+
const pauseData = this.getPauseData();
|
|
18769
|
+
if ((options === null || options === void 0 ? void 0 : options.notEmitEvent) !== true) {
|
|
18770
|
+
hooks.emit('play', { userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true });
|
|
18771
|
+
}
|
|
18772
|
+
const getPlayFromIndex = async () => {
|
|
18773
|
+
var _a, _b;
|
|
18774
|
+
// play from index
|
|
18775
|
+
if ((options === null || options === void 0 ? void 0 : options.playFromIndex) !== undefined)
|
|
18776
|
+
return options.playFromIndex;
|
|
18777
|
+
// play from id
|
|
18778
|
+
else if ((options === null || options === void 0 ? void 0 : options.playFromId) !== undefined)
|
|
18779
|
+
return (_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframes.findIndex((keyframe) => keyframe.id === options.playFromId);
|
|
18780
|
+
// play from pause position
|
|
18781
|
+
else if (pauseData === null || pauseData === void 0 ? void 0 : pauseData.keyframeId) {
|
|
18782
|
+
const pausedKeyframe = (_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframes.find((keyframe) => keyframe.id === pauseData.keyframeId);
|
|
18783
|
+
// restore paused state
|
|
18784
|
+
if (pauseData === null || pauseData === void 0 ? void 0 : pauseData.fiveState)
|
|
18785
|
+
await this.move(pauseData.fiveState);
|
|
18786
|
+
if (pausedKeyframe) {
|
|
18787
|
+
if (pausedKeyframe.data.effect === 'Move')
|
|
18788
|
+
return pausedKeyframe.index;
|
|
18789
|
+
else if (pausedKeyframe.data.effect === 'Rotate') {
|
|
18790
|
+
const duration = pauseData.duration !== undefined ? pauseData.duration * (1 - pauseData.playedProgress) : undefined;
|
|
18791
|
+
await this.playKeyframe(pausedKeyframe, duration);
|
|
18792
|
+
// playFromIndex += 1 cause played last part of paused keyframe
|
|
18793
|
+
return pausedKeyframe.index + 1;
|
|
18794
|
+
}
|
|
18795
|
+
}
|
|
18796
|
+
}
|
|
18797
|
+
};
|
|
18798
|
+
const playFromIndex = await getPlayFromIndex();
|
|
18799
|
+
this.clearPauseData();
|
|
18800
|
+
// play keyframes
|
|
18801
|
+
for (const keyframe of keyframes) {
|
|
18802
|
+
if (privateState.broke || !state.playing || !privateState.playing)
|
|
18803
|
+
return;
|
|
18804
|
+
if (currentPlayId !== privateState.playId)
|
|
18805
|
+
return;
|
|
18806
|
+
// jump to start keyframe
|
|
18807
|
+
if (playFromIndex !== undefined && keyframe.index < playFromIndex)
|
|
18808
|
+
continue;
|
|
18809
|
+
// play single keyframe
|
|
18810
|
+
try {
|
|
18811
|
+
console.log('playIndexChange', keyframe.index);
|
|
18812
|
+
hooks.emit('playIndexChange', keyframe.index, keyframe);
|
|
18813
|
+
await this.playKeyframe(keyframe);
|
|
18814
|
+
}
|
|
18815
|
+
catch (error) {
|
|
18816
|
+
return Promise.resolve('broke');
|
|
18817
|
+
// if think play be interupted by five gesture is an error, return Promise.reject(error)
|
|
18818
|
+
// return Promise.reject(error)
|
|
18819
|
+
}
|
|
18820
|
+
}
|
|
18821
|
+
if (state.playing && currentPlayId === privateState.playId) {
|
|
18822
|
+
this.setState({ playing: false }, { userAction: false });
|
|
18823
|
+
console.log('--emit end--');
|
|
18824
|
+
hooks.emit('end');
|
|
18825
|
+
this.clearPauseData();
|
|
18826
|
+
}
|
|
18827
|
+
}
|
|
18828
|
+
/**
|
|
18829
|
+
* @description: Pause and record pause state
|
|
18830
|
+
*/
|
|
18831
|
+
handlePause(options) {
|
|
18832
|
+
var _a;
|
|
18833
|
+
const { state, privateState, hooks } = this;
|
|
18834
|
+
state.playing = false;
|
|
18835
|
+
if (privateState.playing === false)
|
|
18836
|
+
return;
|
|
18837
|
+
privateState.playing = false;
|
|
18838
|
+
this.setPauseData();
|
|
18839
|
+
if (!privateState.broke)
|
|
18840
|
+
this.forceInteruptUpdateCamera();
|
|
18841
|
+
console.log('--emit pause--');
|
|
18842
|
+
if ((options === null || options === void 0 ? void 0 : options.notEmitEvent) !== true) {
|
|
18843
|
+
hooks.emit('pause', { userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true });
|
|
18844
|
+
}
|
|
18845
|
+
}
|
|
18846
|
+
/**
|
|
18847
|
+
* @description Play single keyframe
|
|
18848
|
+
*/
|
|
18849
|
+
async playKeyframe(keyframe, duration) {
|
|
18850
|
+
var _a;
|
|
18851
|
+
const { privateState } = this;
|
|
18852
|
+
if (((_a = this.privateState.currentPlayKeyframe) === null || _a === void 0 ? void 0 : _a.keyframe.id) !== keyframe.id)
|
|
18853
|
+
this.privateState.currentPlayKeyframe = { keyframe };
|
|
18854
|
+
privateState.currentPlayQueue.push(this.getPlayPromise(keyframe, duration));
|
|
18855
|
+
return this.actionPromiseQueue();
|
|
18856
|
+
}
|
|
18857
|
+
/**
|
|
18858
|
+
* @description: listen interupted by five gesture
|
|
18859
|
+
*/
|
|
18860
|
+
addInterruptListener(callback) {
|
|
18861
|
+
this.five.once('gesture', callback);
|
|
18862
|
+
this.five.once('modeChange', callback);
|
|
18863
|
+
return () => {
|
|
18864
|
+
this.five.off('gesture', callback);
|
|
18865
|
+
this.five.once('modeChange', callback);
|
|
18866
|
+
};
|
|
18867
|
+
}
|
|
18868
|
+
/**
|
|
18869
|
+
* @description: getPlayPromise
|
|
18870
|
+
*/
|
|
18871
|
+
async getPlayPromise(keyframe, paramsDuration) {
|
|
18872
|
+
const data = keyframe.data;
|
|
18873
|
+
const duration = paramsDuration !== null && paramsDuration !== void 0 ? paramsDuration : (keyframe.start !== undefined && keyframe.end !== undefined ? keyframe.end - keyframe.start : undefined);
|
|
18874
|
+
if (!data)
|
|
18875
|
+
return;
|
|
18876
|
+
return new Promise((resolve, reject) => {
|
|
18877
|
+
let fulfilled = false;
|
|
18878
|
+
this.addInterruptListener(() => {
|
|
18879
|
+
if (fulfilled)
|
|
18880
|
+
return;
|
|
18881
|
+
console.log('--emit broke--');
|
|
18882
|
+
this.hooks.emit('broke');
|
|
18883
|
+
this.privateState.broke = true;
|
|
18884
|
+
this.setState({ playing: false });
|
|
18885
|
+
fulfilled = true;
|
|
18886
|
+
return reject(new Error('play is interupted'));
|
|
18887
|
+
});
|
|
18888
|
+
try {
|
|
18889
|
+
if (fulfilled)
|
|
18890
|
+
return;
|
|
18891
|
+
const res = () => {
|
|
18892
|
+
resolve();
|
|
18893
|
+
fulfilled = true;
|
|
18894
|
+
};
|
|
18895
|
+
switch (data.effect) {
|
|
18896
|
+
case 'Move':
|
|
18897
|
+
this.move(data, duration).then(res);
|
|
18898
|
+
break;
|
|
18899
|
+
case 'Rotate':
|
|
18900
|
+
this.rotate(data, duration).then(res);
|
|
18901
|
+
break;
|
|
18902
|
+
default:
|
|
18903
|
+
this.rotate(data, duration).then(res);
|
|
18904
|
+
}
|
|
18905
|
+
}
|
|
18906
|
+
catch (e) { }
|
|
18907
|
+
});
|
|
18908
|
+
}
|
|
18909
|
+
/**
|
|
18910
|
+
* @description Action promise queue in sequence
|
|
18911
|
+
*/
|
|
18912
|
+
async actionPromiseQueue() {
|
|
18913
|
+
const { privateState } = this;
|
|
18914
|
+
return new Promise((resolve, reject) => {
|
|
18915
|
+
if (privateState.currentPlayQueue.length === 0) {
|
|
18916
|
+
resolve();
|
|
18917
|
+
return;
|
|
18918
|
+
}
|
|
18919
|
+
const promise = privateState.currentPlayQueue.shift();
|
|
18920
|
+
if (!promise) {
|
|
18921
|
+
resolve();
|
|
18922
|
+
return;
|
|
18923
|
+
}
|
|
18924
|
+
promise.then(resolve, reject);
|
|
18925
|
+
}).then(() => {
|
|
18926
|
+
if (privateState.currentPlayQueue.length === 0)
|
|
18927
|
+
return Promise.resolve();
|
|
18928
|
+
return this.actionPromiseQueue();
|
|
18929
|
+
});
|
|
18930
|
+
}
|
|
18931
|
+
/**
|
|
18932
|
+
* @description Action move keyframe
|
|
18933
|
+
*/
|
|
18934
|
+
async move(data, duration) {
|
|
18935
|
+
console.log('--move--', data.panoIndex);
|
|
18936
|
+
if (data.mode && data.mode !== this.five.currentMode) {
|
|
18937
|
+
await this.changeMode(data);
|
|
18938
|
+
}
|
|
18939
|
+
else if (data.panoIndex !== this.five.panoIndex) {
|
|
18940
|
+
await this.changePano(data, duration);
|
|
18941
|
+
}
|
|
18942
|
+
else {
|
|
18943
|
+
return Promise.resolve();
|
|
18944
|
+
}
|
|
18945
|
+
// await updateCamera(data)
|
|
18946
|
+
}
|
|
18947
|
+
/**
|
|
18948
|
+
* @description Action rotate keyframe
|
|
18949
|
+
*/
|
|
18950
|
+
async rotate(data, duration) {
|
|
18951
|
+
console.log('--rotate--', data);
|
|
18952
|
+
if (data.mode && data.mode !== this.five.currentMode) {
|
|
18953
|
+
await this.changeMode({ mode: data.mode, panoIndex: data.panoIndex });
|
|
18954
|
+
}
|
|
18955
|
+
else if (data.panoIndex && data.panoIndex !== this.five.panoIndex) {
|
|
18956
|
+
return await this.changePano(data, duration);
|
|
18957
|
+
}
|
|
18958
|
+
await this.updateCamera(data, duration);
|
|
18959
|
+
}
|
|
18960
|
+
/**
|
|
18961
|
+
* @description Update five camera
|
|
18962
|
+
*/
|
|
18963
|
+
async updateCamera(data, paramsDuration = 800) {
|
|
18964
|
+
const { five, privateState, state } = this;
|
|
18965
|
+
let originDuration = paramsDuration;
|
|
18966
|
+
const speed = (() => {
|
|
18967
|
+
var _a, _b;
|
|
18968
|
+
const speedConfig = (_a = state.config) === null || _a === void 0 ? void 0 : _a.speedConfig;
|
|
18969
|
+
const speedValue = (_b = data.rotateSpeed) !== null && _b !== void 0 ? _b : speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.rotateSpeed;
|
|
18970
|
+
if ((speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.rotateSpeedUnit) === undefined)
|
|
18971
|
+
return speedValue;
|
|
18972
|
+
if (speedValue !== undefined) {
|
|
18973
|
+
return speedConfig.rotateSpeedUnit === 'rad/ms' ? speedValue : speedValue / 1000;
|
|
18974
|
+
}
|
|
18975
|
+
})();
|
|
18976
|
+
if (speed) {
|
|
18977
|
+
const coordinates1 = this.five.getCurrentState();
|
|
18978
|
+
const coordinates2 = data;
|
|
18979
|
+
const angle = coordinatesAngle(coordinates1, coordinates2);
|
|
18980
|
+
originDuration = angle / speed;
|
|
18981
|
+
}
|
|
18982
|
+
if (privateState.currentPlayKeyframe)
|
|
18983
|
+
privateState.currentPlayKeyframe.originDuration = originDuration;
|
|
18984
|
+
const duration = this.getSpeededDuration(originDuration);
|
|
18985
|
+
return new Promise((resolve) => {
|
|
18986
|
+
safeCall(() => five.updateCamera(data, duration));
|
|
18987
|
+
setTimeout(() => resolve(), duration);
|
|
18988
|
+
});
|
|
18989
|
+
}
|
|
18990
|
+
/**
|
|
18991
|
+
* @description: Change five pano
|
|
18992
|
+
*/
|
|
18993
|
+
async changePano(data, paramsDuration = 800) {
|
|
18994
|
+
const { five, privateState, state } = this;
|
|
18995
|
+
if (typeof data.panoIndex !== 'number')
|
|
18996
|
+
return;
|
|
18997
|
+
if (data.panoIndex === five.panoIndex)
|
|
18998
|
+
return;
|
|
18999
|
+
let originDuration = paramsDuration;
|
|
19000
|
+
const speed = (() => {
|
|
19001
|
+
var _a, _b;
|
|
19002
|
+
const speedConfig = (_a = state.config) === null || _a === void 0 ? void 0 : _a.speedConfig;
|
|
19003
|
+
const speedValue = (_b = data.moveSpeed) !== null && _b !== void 0 ? _b : speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.moveSpeed;
|
|
19004
|
+
if ((speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.moveSpeedUnit) === undefined)
|
|
19005
|
+
return speedValue;
|
|
19006
|
+
if (speedValue !== undefined) {
|
|
19007
|
+
return speedConfig.moveSpeedUnit === 'm/ms' ? speedValue : speedValue / 1000;
|
|
19008
|
+
}
|
|
19009
|
+
})();
|
|
19010
|
+
if (speed && typeof five.panoIndex === 'number' && typeof data.panoIndex === 'number') {
|
|
19011
|
+
const postion1 = five.work.observers[five.panoIndex].position;
|
|
19012
|
+
const postion2 = five.work.observers[data.panoIndex].position;
|
|
19013
|
+
const distance = postion1.distanceTo(postion2);
|
|
19014
|
+
originDuration = distance / speed;
|
|
19015
|
+
}
|
|
19016
|
+
if (privateState.currentPlayKeyframe)
|
|
19017
|
+
privateState.currentPlayKeyframe.originDuration = originDuration;
|
|
19018
|
+
const duration = this.getSpeededDuration(originDuration);
|
|
19019
|
+
return new Promise((resolve) => {
|
|
19020
|
+
var _a, _b;
|
|
19021
|
+
five.moveToPano(data.panoIndex, {
|
|
19022
|
+
latitude: data.latitude,
|
|
19023
|
+
longitude: data.longitude,
|
|
19024
|
+
fov: data.fov,
|
|
19025
|
+
duration,
|
|
19026
|
+
effect: (_b = (_a = this.state.config) === null || _a === void 0 ? void 0 : _a.moveEffect) !== null && _b !== void 0 ? _b : data.moveEffect,
|
|
19027
|
+
moveCancelCallback: () => resolve(),
|
|
19028
|
+
moveEndCallback: () => resolve(),
|
|
19029
|
+
});
|
|
19030
|
+
});
|
|
19031
|
+
}
|
|
19032
|
+
/**
|
|
19033
|
+
* @description: Change play speed
|
|
19034
|
+
*/
|
|
19035
|
+
changeSpeed(speed, userAction = true) {
|
|
19036
|
+
const { state, privateState, hooks } = this;
|
|
19037
|
+
const { currentPlayKeyframe } = privateState;
|
|
19038
|
+
hooks.emit('speedChange', speed, { userAction });
|
|
19039
|
+
if (state.playing && currentPlayKeyframe) {
|
|
19040
|
+
try {
|
|
19041
|
+
const duration = currentPlayKeyframe.originDuration !== undefined ? currentPlayKeyframe.originDuration * (1 - this.getProgress()) : undefined;
|
|
19042
|
+
console.log('--speedChange--', speed, { duration });
|
|
19043
|
+
const promise = this.playKeyframe(currentPlayKeyframe.keyframe, duration);
|
|
19044
|
+
privateState.currentPlayQueue.push(promise);
|
|
19045
|
+
}
|
|
19046
|
+
catch (e) { }
|
|
19047
|
+
}
|
|
19048
|
+
}
|
|
19049
|
+
/**
|
|
19050
|
+
* @description Get duration by speed
|
|
19051
|
+
*/
|
|
19052
|
+
getSpeededDuration(duration) {
|
|
19053
|
+
return duration / this.state.speed;
|
|
19054
|
+
}
|
|
19055
|
+
/**
|
|
19056
|
+
* @description Get ratate progress
|
|
19057
|
+
*/
|
|
19058
|
+
getProgress() {
|
|
19059
|
+
return this.five.controller.cameraMotion.progress;
|
|
19060
|
+
}
|
|
19061
|
+
/**
|
|
19062
|
+
* @description Change five mode
|
|
19063
|
+
*/
|
|
19064
|
+
async changeMode(data, duration) {
|
|
19065
|
+
if (data.mode && data.mode !== this.five.currentMode) {
|
|
19066
|
+
await this.five.changeMode(data.mode, data, duration);
|
|
19067
|
+
}
|
|
19068
|
+
}
|
|
19069
|
+
/**
|
|
19070
|
+
* @description Force interupt five updateCamera
|
|
19071
|
+
*/
|
|
19072
|
+
forceInteruptUpdateCamera() {
|
|
19073
|
+
this.five.updateCamera({}, 0);
|
|
19074
|
+
}
|
|
19075
|
+
getPauseData() {
|
|
19076
|
+
var _a, _b;
|
|
19077
|
+
if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframesId)
|
|
19078
|
+
return pauseDataMap.get((_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframesId);
|
|
19079
|
+
}
|
|
19080
|
+
/**
|
|
19081
|
+
* @description Set pause data
|
|
19082
|
+
*/
|
|
19083
|
+
setPauseData() {
|
|
19084
|
+
var _a, _b, _c, _d;
|
|
19085
|
+
if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframesId)
|
|
19086
|
+
return pauseDataMap.set((_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframesId, {
|
|
19087
|
+
keyframeId: (_c = this.privateState.currentPlayKeyframe) === null || _c === void 0 ? void 0 : _c.keyframe.id,
|
|
19088
|
+
fiveState: this.five.getCurrentState(),
|
|
19089
|
+
duration: (_d = this.privateState.currentPlayKeyframe) === null || _d === void 0 ? void 0 : _d.originDuration,
|
|
19090
|
+
playedProgress: this.getProgress(),
|
|
19091
|
+
});
|
|
19092
|
+
}
|
|
19093
|
+
/**
|
|
19094
|
+
* @description Clear pause data
|
|
19095
|
+
*/
|
|
19096
|
+
clearPauseData() {
|
|
19097
|
+
var _a, _b;
|
|
19098
|
+
if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframesId)
|
|
19099
|
+
return pauseDataMap.delete((_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframesId);
|
|
19100
|
+
}
|
|
19101
|
+
/**
|
|
19102
|
+
* @description: Restore state that before loaded
|
|
19103
|
+
*/
|
|
19104
|
+
clear() {
|
|
19105
|
+
this.clearPauseData();
|
|
19106
|
+
this.privateState.currentPlayKeyframe = null;
|
|
19107
|
+
}
|
|
19108
|
+
// TODO
|
|
19109
|
+
handleDispose() {
|
|
19110
|
+
var _a, _b;
|
|
19111
|
+
this.setState({ playing: false });
|
|
19112
|
+
this.clearPauseData();
|
|
19113
|
+
this.clear();
|
|
19114
|
+
(_a = this.GuideLine) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
19115
|
+
this.GuideLine = undefined;
|
|
19116
|
+
(_b = this.privateState.disposers) === null || _b === void 0 ? void 0 : _b.forEach((d) => d === null || d === void 0 ? void 0 : d());
|
|
19117
|
+
}
|
|
19118
|
+
/**
|
|
19119
|
+
* @description Action function if plugin is enable
|
|
19120
|
+
*/
|
|
19121
|
+
actionIfStateIsEnabled(func, options) {
|
|
19122
|
+
if (this.state.enabled)
|
|
19123
|
+
return func();
|
|
19124
|
+
else {
|
|
19125
|
+
if (options === null || options === void 0 ? void 0 : options.warnLog)
|
|
19126
|
+
disableWarnLog();
|
|
19127
|
+
}
|
|
19128
|
+
}
|
|
19129
|
+
/**
|
|
19130
|
+
* @description: Wait for five work ready
|
|
19131
|
+
*/
|
|
19132
|
+
async waitFiveLoaded() {
|
|
19133
|
+
return new Promise((resolve) => {
|
|
19134
|
+
if (this.five.work) {
|
|
19135
|
+
resolve();
|
|
19136
|
+
return;
|
|
19137
|
+
}
|
|
19138
|
+
this.five.once('loaded', () => {
|
|
19139
|
+
resolve();
|
|
19140
|
+
});
|
|
19141
|
+
});
|
|
19142
|
+
}
|
|
19143
|
+
setFiveLinearUpdateCamera() {
|
|
19144
|
+
if (!this.privateState.fiveOriginGetProgress)
|
|
19145
|
+
return;
|
|
19146
|
+
this.five.controller.cameraMotion.getProgress = (time) => {
|
|
19147
|
+
const cameraMotion = this.five.controller.cameraMotion;
|
|
19148
|
+
const deltaTime = time - cameraMotion.startTime;
|
|
19149
|
+
if (deltaTime < 0)
|
|
19150
|
+
return 0;
|
|
19151
|
+
if (deltaTime >= cameraMotion.duration)
|
|
19152
|
+
return 1;
|
|
19153
|
+
return 1 - linerValue(1, cameraMotion.startVelocity, cameraMotion.duration, deltaTime);
|
|
19154
|
+
};
|
|
19155
|
+
}
|
|
19156
|
+
setFiveOriginUpdateCamera() {
|
|
19157
|
+
if (!this.privateState.fiveOriginGetProgress)
|
|
19158
|
+
return;
|
|
19159
|
+
this.five.controller.cameraMotion.getProgress = this.privateState.fiveOriginGetProgress;
|
|
19160
|
+
}
|
|
19161
|
+
}
|
|
19162
|
+
Object.defineProperty(CruisePluginController, "PluginVersion", {
|
|
19163
|
+
enumerable: true,
|
|
19164
|
+
configurable: true,
|
|
19165
|
+
writable: true,
|
|
19166
|
+
value: VERSION
|
|
19167
|
+
});
|
|
19168
|
+
|
|
19169
|
+
const CruisePlugin = (five) => new CruisePluginController(five);
|
|
19170
|
+
|
|
18105
19171
|
const DnalogelVersion = '2.0.0-alpha.49';
|
|
18106
19172
|
|
|
18107
19173
|
exports.CSS3DRenderPlugin = CSS3DRenderPlugin;
|
|
18108
19174
|
exports.CameraMovementPlugin = CameraMovementPlugin;
|
|
19175
|
+
exports.CruisePlugin = CruisePlugin;
|
|
19176
|
+
exports.CruisePluginController = CruisePluginController;
|
|
18109
19177
|
exports.DnalogelVersion = DnalogelVersion;
|
|
18110
19178
|
exports.FLOOR_TYPE_MAP = FLOOR_TYPE_MAP;
|
|
19179
|
+
exports.GuideLinePlugin = GuideLinePlugin;
|
|
18111
19180
|
exports.ItemLabelPlugin = Plugin;
|
|
18112
19181
|
exports.Magnifier = Magnifier;
|
|
18113
19182
|
exports.MapviewFloorplanPlugin = MapviewFloorplanPlugin;
|