@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.js
CHANGED
|
@@ -15,6 +15,7 @@ var FBXLoader = require('three/examples/jsm/loaders/FBXLoader');
|
|
|
15
15
|
var TWEEN = require('@tweenjs/tween.js');
|
|
16
16
|
var Hammer = require('hammerjs');
|
|
17
17
|
var classNames = require('classnames');
|
|
18
|
+
var getNormals = require('polyline-normals');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -41,6 +42,7 @@ var TWEEN__namespace = /*#__PURE__*/_interopNamespace(TWEEN);
|
|
|
41
42
|
var TWEEN__default = /*#__PURE__*/_interopDefaultLegacy(TWEEN);
|
|
42
43
|
var Hammer__default = /*#__PURE__*/_interopDefaultLegacy(Hammer);
|
|
43
44
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
45
|
+
var getNormals__default = /*#__PURE__*/_interopDefaultLegacy(getNormals);
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* Five 模型插件
|
|
@@ -4707,7 +4709,7 @@ function getPxmm(five, container, floorIndex, options) {
|
|
|
4707
4709
|
/**
|
|
4708
4710
|
* plugin 的基本控制器
|
|
4709
4711
|
*/
|
|
4710
|
-
class Controller$
|
|
4712
|
+
class Controller$7 {
|
|
4711
4713
|
constructor(five$1) {
|
|
4712
4714
|
Object.defineProperty(this, "five", {
|
|
4713
4715
|
enumerable: true,
|
|
@@ -4734,7 +4736,7 @@ class Controller$6 {
|
|
|
4734
4736
|
}
|
|
4735
4737
|
}
|
|
4736
4738
|
|
|
4737
|
-
class Controller$
|
|
4739
|
+
class Controller$6 extends Controller$7 {
|
|
4738
4740
|
}
|
|
4739
4741
|
|
|
4740
4742
|
var FloorplanErrorType;
|
|
@@ -4886,7 +4888,7 @@ function shouldFloorplanShowWithPose$1(pose) {
|
|
|
4886
4888
|
const longitudeVisible = longitude < 30 * (Math.PI / 180) || longitude > 330 * (Math.PI / 180);
|
|
4887
4889
|
return latitudeVisible && longitudeVisible;
|
|
4888
4890
|
}
|
|
4889
|
-
class Controller$
|
|
4891
|
+
class Controller$5 extends Controller$6 {
|
|
4890
4892
|
constructor(five, params) {
|
|
4891
4893
|
var _a;
|
|
4892
4894
|
super(five);
|
|
@@ -5555,7 +5557,7 @@ class Controller$4 extends Controller$5 {
|
|
|
5555
5557
|
}
|
|
5556
5558
|
|
|
5557
5559
|
const ModelFloorplanPlugin = (five, params) => {
|
|
5558
|
-
return new Controller$
|
|
5560
|
+
return new Controller$5(five, params);
|
|
5559
5561
|
};
|
|
5560
5562
|
|
|
5561
5563
|
/** 当前 five 的相机视角是否满足户型图自动隐藏条件
|
|
@@ -5580,7 +5582,7 @@ function shouldFloorplanShowWithPose(pose) {
|
|
|
5580
5582
|
const longitudeVisible = longitude < 30 * (Math.PI / 180) || longitude > 330 * (Math.PI / 180);
|
|
5581
5583
|
return latitudeVisible && longitudeVisible;
|
|
5582
5584
|
}
|
|
5583
|
-
class Controller$
|
|
5585
|
+
class Controller$4 extends Controller$6 {
|
|
5584
5586
|
constructor(five, params) {
|
|
5585
5587
|
super(five);
|
|
5586
5588
|
// =============== public properties =================
|
|
@@ -6229,10 +6231,10 @@ class Controller$3 extends Controller$5 {
|
|
|
6229
6231
|
}
|
|
6230
6232
|
|
|
6231
6233
|
const MapviewFloorplanPlugin = (five, params) => {
|
|
6232
|
-
return new Controller$
|
|
6234
|
+
return new Controller$4(five, params);
|
|
6233
6235
|
};
|
|
6234
6236
|
|
|
6235
|
-
class Controller$
|
|
6237
|
+
class Controller$3 extends Controller$6 {
|
|
6236
6238
|
constructor(five, params) {
|
|
6237
6239
|
super(five);
|
|
6238
6240
|
// =============== public properties =================
|
|
@@ -6709,7 +6711,7 @@ class Controller$2 extends Controller$5 {
|
|
|
6709
6711
|
}
|
|
6710
6712
|
|
|
6711
6713
|
const TopviewFloorplanPlugin = (five, params) => {
|
|
6712
|
-
return new Controller$
|
|
6714
|
+
return new Controller$3(five, params);
|
|
6713
6715
|
};
|
|
6714
6716
|
|
|
6715
6717
|
/**
|
|
@@ -7588,7 +7590,7 @@ class Main extends internal.SvelteComponent {
|
|
|
7588
7590
|
}
|
|
7589
7591
|
}
|
|
7590
7592
|
|
|
7591
|
-
class Controller$
|
|
7593
|
+
class Controller$2 extends Controller$6 {
|
|
7592
7594
|
constructor(five, params) {
|
|
7593
7595
|
super(five);
|
|
7594
7596
|
// =============== public properties =================
|
|
@@ -7825,7 +7827,7 @@ class Controller$1 extends Controller$5 {
|
|
|
7825
7827
|
}
|
|
7826
7828
|
|
|
7827
7829
|
const PanoFloorplanRadarPlugin = (five, params) => {
|
|
7828
|
-
return new Controller$
|
|
7830
|
+
return new Controller$2(five, params);
|
|
7829
7831
|
};
|
|
7830
7832
|
|
|
7831
7833
|
/** 房屋数据映射表 */
|
|
@@ -9695,7 +9697,7 @@ class RulerItems extends internal.SvelteComponent {
|
|
|
9695
9697
|
}
|
|
9696
9698
|
}
|
|
9697
9699
|
|
|
9698
|
-
class Controller {
|
|
9700
|
+
class Controller$1 {
|
|
9699
9701
|
constructor(five, params) {
|
|
9700
9702
|
var _a, _b;
|
|
9701
9703
|
Object.defineProperty(this, "five", {
|
|
@@ -9809,7 +9811,7 @@ class Controller {
|
|
|
9809
9811
|
* 全景标尺插件
|
|
9810
9812
|
*/
|
|
9811
9813
|
const PanoRulerProPlugin = (five, params) => {
|
|
9812
|
-
return new Controller(five, params);
|
|
9814
|
+
return new Controller$1(five, params);
|
|
9813
9815
|
};
|
|
9814
9816
|
|
|
9815
9817
|
const roomInfoIcon = 'data:image/png;base64,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';
|
|
@@ -9931,7 +9933,7 @@ function tweenProgress(duration, easing = TWEEN__default["default"].Easing.Linea
|
|
|
9931
9933
|
}
|
|
9932
9934
|
|
|
9933
9935
|
const defaultBaseOptions$1 = { userAction: true };
|
|
9934
|
-
class PanoCompassController extends Controller$
|
|
9936
|
+
class PanoCompassController extends Controller$6 {
|
|
9935
9937
|
constructor(five$1, config) {
|
|
9936
9938
|
super(five$1);
|
|
9937
9939
|
/**
|
|
@@ -17383,7 +17385,7 @@ const itemLabelPluginServerParams = {
|
|
|
17383
17385
|
* pano plugin controller 基类
|
|
17384
17386
|
* @author kyleju
|
|
17385
17387
|
*/
|
|
17386
|
-
class BasePanoPluginController extends Controller$
|
|
17388
|
+
class BasePanoPluginController extends Controller$7 {
|
|
17387
17389
|
constructor(five) {
|
|
17388
17390
|
super(five);
|
|
17389
17391
|
Object.defineProperty(this, "state", {
|
|
@@ -18114,12 +18116,1080 @@ const PanoDoorLabelPlugin = (five) => {
|
|
|
18114
18116
|
return new PanoDoorLabelPluginController(five);
|
|
18115
18117
|
};
|
|
18116
18118
|
|
|
18119
|
+
// 定义常量
|
|
18120
|
+
const TRIANGLE_NUMBER_OF_RECTANGLE = 2; // 每个矩形有两个三角形
|
|
18121
|
+
const VERTEX_NUMBER_OF_TRIANGLE = 3; // 每个三角形有三个顶点
|
|
18122
|
+
const AXIS_NUMBER_OF_VERTEX = 3; // 每个顶点有三个轴坐标
|
|
18123
|
+
const UV_NUMBER_OF_VERTEX = 2; // 每个顶点有两个 UV 轴坐标
|
|
18124
|
+
function getLineGeometry(positionList) {
|
|
18125
|
+
if (positionList.length < 2)
|
|
18126
|
+
return;
|
|
18127
|
+
const lineWidth = 1;
|
|
18128
|
+
const halfLineWidth = 1 / 2;
|
|
18129
|
+
const aspect = 1;
|
|
18130
|
+
// 点位向量数组
|
|
18131
|
+
const keyPoints = positionList;
|
|
18132
|
+
// 点位组成的平滑曲线
|
|
18133
|
+
const curve = new THREE__namespace.CatmullRomCurve3(keyPoints, false, 'catmullrom', 0.5);
|
|
18134
|
+
// 求顶点和 UV
|
|
18135
|
+
const divisions = Math.ceil(curve.getLength()); // 曲线切片数
|
|
18136
|
+
const curvePoints = curve.getPoints(divisions);
|
|
18137
|
+
const curvePointsLength = curvePoints.length;
|
|
18138
|
+
const normals = getNormals__default["default"](curvePoints.map((p) => [p.x, p.z])); // curvePoints:每个点切线的向量「二维」
|
|
18139
|
+
const rectangleNumber = curvePoints.length - 1; // 曲线上 N 个点,构成了 N - 1 个矩形
|
|
18140
|
+
const indexNumber = rectangleNumber * TRIANGLE_NUMBER_OF_RECTANGLE * VERTEX_NUMBER_OF_TRIANGLE;
|
|
18141
|
+
const verticesNumber = 2 * curvePointsLength; // 顶点数量(包含公用):每个曲线点对应两个顶点,N 个 点有 2N 个顶点
|
|
18142
|
+
const positionNumber = verticesNumber * AXIS_NUMBER_OF_VERTEX; // 坐标点数量
|
|
18143
|
+
const uvNumber = verticesNumber * UV_NUMBER_OF_VERTEX; // uv 数量
|
|
18144
|
+
const index = new Uint32Array(indexNumber);
|
|
18145
|
+
const positions = new Float32Array(positionNumber);
|
|
18146
|
+
const uv = new Float32Array(uvNumber);
|
|
18147
|
+
let totalLength = 0;
|
|
18148
|
+
for (let i = 0; i < curvePoints.length; i++) {
|
|
18149
|
+
const [nx, nz] = normals[i][0];
|
|
18150
|
+
const curvePoint = curvePoints[i];
|
|
18151
|
+
const { x: curvePointX, y: curvePointY, z: curvePointZ } = curvePoint;
|
|
18152
|
+
// vertices[2i]
|
|
18153
|
+
positions[i * 6 + 0] = curvePointX + nx * halfLineWidth;
|
|
18154
|
+
positions[i * 6 + 1] = curvePointY + 0.05;
|
|
18155
|
+
positions[i * 6 + 2] = curvePointZ + nz * halfLineWidth;
|
|
18156
|
+
// vertices[2i + 1]
|
|
18157
|
+
positions[i * 6 + 3] = curvePointX - nx * halfLineWidth;
|
|
18158
|
+
positions[i * 6 + 4] = curvePointY + 0.05;
|
|
18159
|
+
positions[i * 6 + 5] = curvePointZ - nz * halfLineWidth;
|
|
18160
|
+
totalLength += i > 0 ? curvePoints[i - 1].clone().sub(curvePoints[i]).length() : 0;
|
|
18161
|
+
const end = totalLength / lineWidth / aspect;
|
|
18162
|
+
uv[i * 4 + 0] = 0;
|
|
18163
|
+
uv[i * 4 + 1] = end;
|
|
18164
|
+
uv[i * 4 + 2] = 1;
|
|
18165
|
+
uv[i * 4 + 3] = end;
|
|
18166
|
+
if (i === curvePoints.length - 1)
|
|
18167
|
+
continue;
|
|
18168
|
+
index[i * 6 + 0] = i * 2 + 0;
|
|
18169
|
+
index[i * 6 + 1] = i * 2 + 2;
|
|
18170
|
+
index[i * 6 + 2] = i * 2 + 1;
|
|
18171
|
+
index[i * 6 + 3] = i * 2 + 2;
|
|
18172
|
+
index[i * 6 + 4] = i * 2 + 3;
|
|
18173
|
+
index[i * 6 + 5] = i * 2 + 1;
|
|
18174
|
+
}
|
|
18175
|
+
const geometry = new THREE__namespace.BufferGeometry();
|
|
18176
|
+
geometry.setAttribute('position', new THREE__namespace.BufferAttribute(positions, 3));
|
|
18177
|
+
geometry.setAttribute('uv', new THREE__namespace.BufferAttribute(uv, 2));
|
|
18178
|
+
geometry.setIndex(new THREE__namespace.BufferAttribute(index, 1));
|
|
18179
|
+
return geometry;
|
|
18180
|
+
}
|
|
18181
|
+
|
|
18182
|
+
function getArrowMaterial(params) {
|
|
18183
|
+
var _a;
|
|
18184
|
+
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');
|
|
18185
|
+
texture.wrapS = texture.wrapT = THREE__namespace.RepeatWrapping;
|
|
18186
|
+
texture.encoding = THREE__namespace.sRGBEncoding;
|
|
18187
|
+
const arrowMaterial = new THREE__namespace.MeshBasicMaterial({
|
|
18188
|
+
color: 0xffffff,
|
|
18189
|
+
map: texture,
|
|
18190
|
+
transparent: true,
|
|
18191
|
+
opacity: 0.8,
|
|
18192
|
+
});
|
|
18193
|
+
return arrowMaterial;
|
|
18194
|
+
}
|
|
18195
|
+
|
|
18196
|
+
/**
|
|
18197
|
+
* 判断对象是否为`null`或`undefined`。
|
|
18198
|
+
* @param
|
|
18199
|
+
* @return
|
|
18200
|
+
*/
|
|
18201
|
+
/**
|
|
18202
|
+
* 判断对象不为`null`或`undefined`。
|
|
18203
|
+
*/
|
|
18204
|
+
function notNil(value) {
|
|
18205
|
+
return value !== null && value !== undefined;
|
|
18206
|
+
}
|
|
18207
|
+
|
|
18208
|
+
const VERSION$1 = 'v1.0.1';
|
|
18209
|
+
const PLUGIN_NAME$1 = 'GuideLinePlugin';
|
|
18210
|
+
const PLUGIN$1 = `${PLUGIN_NAME$1}@${VERSION$1}`;
|
|
18211
|
+
const pluginFlag = (name) => `${PLUGIN$1}--${name}`;
|
|
18212
|
+
class Controller extends Controller$6 {
|
|
18213
|
+
constructor(five) {
|
|
18214
|
+
super(five);
|
|
18215
|
+
Object.defineProperty(this, "state", {
|
|
18216
|
+
enumerable: true,
|
|
18217
|
+
configurable: true,
|
|
18218
|
+
writable: true,
|
|
18219
|
+
value: {
|
|
18220
|
+
visible: false,
|
|
18221
|
+
enabled: true,
|
|
18222
|
+
disposed: false,
|
|
18223
|
+
}
|
|
18224
|
+
});
|
|
18225
|
+
Object.defineProperty(this, "data", {
|
|
18226
|
+
enumerable: true,
|
|
18227
|
+
configurable: true,
|
|
18228
|
+
writable: true,
|
|
18229
|
+
value: void 0
|
|
18230
|
+
});
|
|
18231
|
+
Object.defineProperty(this, "linesGroup", {
|
|
18232
|
+
enumerable: true,
|
|
18233
|
+
configurable: true,
|
|
18234
|
+
writable: true,
|
|
18235
|
+
value: void 0
|
|
18236
|
+
});
|
|
18237
|
+
Object.defineProperty(this, "disposedErrorLog", {
|
|
18238
|
+
enumerable: true,
|
|
18239
|
+
configurable: true,
|
|
18240
|
+
writable: true,
|
|
18241
|
+
value: () => {
|
|
18242
|
+
console.error(`${PLUGIN$1} is disposed`);
|
|
18243
|
+
}
|
|
18244
|
+
});
|
|
18245
|
+
Object.defineProperty(this, "actionWhenEnabled", {
|
|
18246
|
+
enumerable: true,
|
|
18247
|
+
configurable: true,
|
|
18248
|
+
writable: true,
|
|
18249
|
+
value: (func) => {
|
|
18250
|
+
if (this.state.enabled)
|
|
18251
|
+
return func();
|
|
18252
|
+
}
|
|
18253
|
+
});
|
|
18254
|
+
Object.assign(window, { [`__${PLUGIN_NAME$1}_DEBUG__`]: this });
|
|
18255
|
+
}
|
|
18256
|
+
async load(serverData, state, userAction = true) {
|
|
18257
|
+
const prevData = this.data ? JSON.parse(JSON.stringify(this.data)) : undefined;
|
|
18258
|
+
// format server data to plugin data
|
|
18259
|
+
const data = await this.formatData(serverData);
|
|
18260
|
+
this.hooks.emit('dataChange', data, prevData);
|
|
18261
|
+
this.data = data;
|
|
18262
|
+
// render line group
|
|
18263
|
+
if (this.linesGroup)
|
|
18264
|
+
this.five.scene.remove(this.linesGroup);
|
|
18265
|
+
const linesGroup = this.getLinesGroup(data.routes);
|
|
18266
|
+
if (!linesGroup)
|
|
18267
|
+
return Promise.reject(new Error('no line'));
|
|
18268
|
+
this.linesGroup = linesGroup;
|
|
18269
|
+
this.five.scene.add(linesGroup);
|
|
18270
|
+
this.handleVisible(this.state.visible);
|
|
18271
|
+
this.handleEnable(this.state.enabled);
|
|
18272
|
+
// initialize plugin state
|
|
18273
|
+
if (state)
|
|
18274
|
+
this.setState(state);
|
|
18275
|
+
// load end
|
|
18276
|
+
this.five.needsRender = true;
|
|
18277
|
+
this.hooks.emit('dataLoaded', data);
|
|
18278
|
+
console.log(`${PLUGIN$1} loaded`, data);
|
|
18279
|
+
}
|
|
18280
|
+
async formatData(serverData) {
|
|
18281
|
+
if (typeof serverData === 'object' && serverData !== null && serverData.version && serverData.data) {
|
|
18282
|
+
return serverData.data;
|
|
18283
|
+
}
|
|
18284
|
+
return serverData;
|
|
18285
|
+
}
|
|
18286
|
+
async show(options) {
|
|
18287
|
+
this.setState({ visible: true }, options);
|
|
18288
|
+
}
|
|
18289
|
+
async hide(options) {
|
|
18290
|
+
this.setState({ visible: false }, options);
|
|
18291
|
+
}
|
|
18292
|
+
enable(options) {
|
|
18293
|
+
this.setState({ enabled: true }, options);
|
|
18294
|
+
}
|
|
18295
|
+
disable(options) {
|
|
18296
|
+
this.setState({ enabled: false }, options);
|
|
18297
|
+
}
|
|
18298
|
+
dispose() {
|
|
18299
|
+
this.setState({ disposed: true });
|
|
18300
|
+
}
|
|
18301
|
+
setState(state, options) {
|
|
18302
|
+
var _a;
|
|
18303
|
+
if (this.state.disposed)
|
|
18304
|
+
return this.disposedErrorLog();
|
|
18305
|
+
const prevState = Object.assign({}, this.state);
|
|
18306
|
+
this.state = Object.assign(Object.assign({}, this.state), state);
|
|
18307
|
+
if (state.disposed !== undefined && state.disposed !== prevState.disposed) {
|
|
18308
|
+
if (state.disposed)
|
|
18309
|
+
this.handleDispose();
|
|
18310
|
+
}
|
|
18311
|
+
if (state.visible !== undefined && state.visible !== prevState.visible) {
|
|
18312
|
+
this.handleVisible(state.visible, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18313
|
+
}
|
|
18314
|
+
if (state.enabled !== undefined && state.enabled !== prevState.enabled) {
|
|
18315
|
+
this.handleEnable(state.enabled, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18316
|
+
}
|
|
18317
|
+
if (!equal(prevState, this.state, { deep: true })) {
|
|
18318
|
+
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 });
|
|
18319
|
+
this.five.needsRender = true;
|
|
18320
|
+
}
|
|
18321
|
+
}
|
|
18322
|
+
handleEnable(enabled, userAction = true) {
|
|
18323
|
+
if (this.linesGroup) {
|
|
18324
|
+
if (enabled) {
|
|
18325
|
+
this.five.scene.add(this.linesGroup);
|
|
18326
|
+
this.actionWhenEnabled(() => this.hooks.emit('enable', { userAction }));
|
|
18327
|
+
}
|
|
18328
|
+
else {
|
|
18329
|
+
this.five.scene.remove(this.linesGroup);
|
|
18330
|
+
this.hooks.emit('disable', { userAction });
|
|
18331
|
+
}
|
|
18332
|
+
}
|
|
18333
|
+
}
|
|
18334
|
+
handleVisible(visible, userAction = true) {
|
|
18335
|
+
if (this.linesGroup) {
|
|
18336
|
+
if (visible) {
|
|
18337
|
+
this.linesGroup.visible = true;
|
|
18338
|
+
this.actionWhenEnabled(() => this.hooks.emit('show', { userAction }));
|
|
18339
|
+
}
|
|
18340
|
+
else {
|
|
18341
|
+
this.linesGroup.visible = false;
|
|
18342
|
+
this.actionWhenEnabled(() => this.hooks.emit('hide', { userAction }));
|
|
18343
|
+
}
|
|
18344
|
+
}
|
|
18345
|
+
}
|
|
18346
|
+
handleDispose() {
|
|
18347
|
+
if (this.linesGroup)
|
|
18348
|
+
this.five.scene.add(this.linesGroup);
|
|
18349
|
+
}
|
|
18350
|
+
/**
|
|
18351
|
+
* 获取多条路线的 Mesh Group
|
|
18352
|
+
*/
|
|
18353
|
+
getLinesGroup(routes) {
|
|
18354
|
+
/** 'as THREE.Mesh[]' for build check */
|
|
18355
|
+
const meshes = routes.map(this.getLineMesh.bind(this)).filter(notNil);
|
|
18356
|
+
const group = new THREE__namespace.Group();
|
|
18357
|
+
group.name = pluginFlag('route-group');
|
|
18358
|
+
if (meshes.length === 0)
|
|
18359
|
+
return;
|
|
18360
|
+
group.add(...meshes);
|
|
18361
|
+
return group;
|
|
18362
|
+
}
|
|
18363
|
+
/**
|
|
18364
|
+
* 获取单条路线的 Mesh
|
|
18365
|
+
*/
|
|
18366
|
+
getLineMesh(data) {
|
|
18367
|
+
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);
|
|
18368
|
+
const geometry = getLineGeometry(positions);
|
|
18369
|
+
if (!geometry)
|
|
18370
|
+
return;
|
|
18371
|
+
const material = getArrowMaterial({ textureUtl: data.arrowTextureUrl });
|
|
18372
|
+
const mesh = new THREE__namespace.Mesh(geometry, material);
|
|
18373
|
+
mesh.name = pluginFlag('route-line-mesh');
|
|
18374
|
+
mesh.renderOrder = 3;
|
|
18375
|
+
return mesh;
|
|
18376
|
+
}
|
|
18377
|
+
}
|
|
18378
|
+
Object.defineProperty(Controller, "lasestVersion", {
|
|
18379
|
+
enumerable: true,
|
|
18380
|
+
configurable: true,
|
|
18381
|
+
writable: true,
|
|
18382
|
+
value: VERSION$1
|
|
18383
|
+
});
|
|
18384
|
+
|
|
18385
|
+
const GuideLinePlugin = (five) => new Controller(five);
|
|
18386
|
+
|
|
18387
|
+
/** 坐标转换成单位向量 */
|
|
18388
|
+
function coordinatesToVector(coordinates) {
|
|
18389
|
+
const distance = Math.abs(Math.cos(coordinates.latitude));
|
|
18390
|
+
return new THREE__namespace.Vector3(
|
|
18391
|
+
/* x */ -Math.sin(coordinates.longitude) * distance,
|
|
18392
|
+
/* y */ -Math.sin(coordinates.latitude),
|
|
18393
|
+
/* z */ -Math.cos(coordinates.longitude) * distance);
|
|
18394
|
+
}
|
|
18395
|
+
|
|
18396
|
+
/**
|
|
18397
|
+
* @description: 获取coordinates间的夹角
|
|
18398
|
+
* @return {number} 夹角角度
|
|
18399
|
+
*/
|
|
18400
|
+
function coordinatesAngle(coordinates1, coordinates2) {
|
|
18401
|
+
const vector1 = coordinatesToVector(coordinates1);
|
|
18402
|
+
const vector2 = coordinatesToVector(coordinates2);
|
|
18403
|
+
const angle = vector1.angleTo(vector2);
|
|
18404
|
+
return angle;
|
|
18405
|
+
}
|
|
18406
|
+
|
|
18407
|
+
const safeCall = async (fn) => {
|
|
18408
|
+
try {
|
|
18409
|
+
// eslint-disable-next-line prettier/prettier
|
|
18410
|
+
fn().then(() => { }, () => { }).catch(() => { });
|
|
18411
|
+
}
|
|
18412
|
+
catch (e) { }
|
|
18413
|
+
};
|
|
18414
|
+
|
|
18415
|
+
const TAU = Math.PI * 2;
|
|
18416
|
+
/**
|
|
18417
|
+
* 将弧度转成 0 - 2PI 中的值
|
|
18418
|
+
* @param rad - 任意弧度值
|
|
18419
|
+
* @return 0 - 2PI 的数值
|
|
18420
|
+
*/
|
|
18421
|
+
function formatRad(rad) {
|
|
18422
|
+
if (rad >= 0 && rad < TAU)
|
|
18423
|
+
return rad;
|
|
18424
|
+
return ((rad % TAU) + TAU) % TAU;
|
|
18425
|
+
}
|
|
18426
|
+
|
|
18427
|
+
/** 单位向量转换成坐标 */
|
|
18428
|
+
function vectorToCoordinates(vector) {
|
|
18429
|
+
return {
|
|
18430
|
+
longitude: formatRad(-Math.atan2(vector.x, -vector.z)),
|
|
18431
|
+
latitude: -Math.asin(vector.y / 1),
|
|
18432
|
+
};
|
|
18433
|
+
}
|
|
18434
|
+
|
|
18435
|
+
// eslint-disable-next-line max-params
|
|
18436
|
+
function linerValue(x0, v0, t1, t) {
|
|
18437
|
+
const a = -x0 / t1;
|
|
18438
|
+
const d = x0;
|
|
18439
|
+
return a * t + d;
|
|
18440
|
+
}
|
|
18441
|
+
|
|
18442
|
+
const VERSION = 'v1.0.5';
|
|
18443
|
+
const PLUGIN_NAME = 'CruisePlugin';
|
|
18444
|
+
const PLUGIN = `${PLUGIN_NAME}@${VERSION}`;
|
|
18445
|
+
const disposedErrorLog = () => {
|
|
18446
|
+
console.error(`${PLUGIN} is disposed`);
|
|
18447
|
+
};
|
|
18448
|
+
const disableWarnLog = () => {
|
|
18449
|
+
console.warn(`${PLUGIN} is disabled`);
|
|
18450
|
+
};
|
|
18451
|
+
const disableErrorLog = () => {
|
|
18452
|
+
console.error(`${PLUGIN} is disabled`);
|
|
18453
|
+
};
|
|
18454
|
+
const pauseDataMap = new Map();
|
|
18455
|
+
class CruisePluginController extends Controller$6 {
|
|
18456
|
+
constructor(five) {
|
|
18457
|
+
super(five);
|
|
18458
|
+
Object.defineProperty(this, "state", {
|
|
18459
|
+
enumerable: true,
|
|
18460
|
+
configurable: true,
|
|
18461
|
+
writable: true,
|
|
18462
|
+
value: {
|
|
18463
|
+
visible: true,
|
|
18464
|
+
enabled: true,
|
|
18465
|
+
disposed: false,
|
|
18466
|
+
playing: false,
|
|
18467
|
+
speed: 1,
|
|
18468
|
+
config: {
|
|
18469
|
+
speedConfig: {
|
|
18470
|
+
rotateSpeed: 0.001,
|
|
18471
|
+
rotateSpeedUnit: 'rad/ms',
|
|
18472
|
+
moveSpeed: 0.003,
|
|
18473
|
+
moveSpeedUnit: 'm/ms',
|
|
18474
|
+
},
|
|
18475
|
+
},
|
|
18476
|
+
}
|
|
18477
|
+
});
|
|
18478
|
+
Object.defineProperty(this, "data", {
|
|
18479
|
+
enumerable: true,
|
|
18480
|
+
configurable: true,
|
|
18481
|
+
writable: true,
|
|
18482
|
+
value: void 0
|
|
18483
|
+
});
|
|
18484
|
+
Object.defineProperty(this, "privateState", {
|
|
18485
|
+
enumerable: true,
|
|
18486
|
+
configurable: true,
|
|
18487
|
+
writable: true,
|
|
18488
|
+
value: {
|
|
18489
|
+
playing: false,
|
|
18490
|
+
currentPlayQueue: [],
|
|
18491
|
+
currentPlayKeyframe: null,
|
|
18492
|
+
broke: false,
|
|
18493
|
+
disposers: [],
|
|
18494
|
+
}
|
|
18495
|
+
});
|
|
18496
|
+
Object.defineProperty(this, "GuideLine", {
|
|
18497
|
+
enumerable: true,
|
|
18498
|
+
configurable: true,
|
|
18499
|
+
writable: true,
|
|
18500
|
+
value: void 0
|
|
18501
|
+
});
|
|
18502
|
+
Object.assign(window, { [`__${PLUGIN_NAME}_DEBUG__`]: this });
|
|
18503
|
+
const setFiveLinearUpdateCamera = this.setFiveLinearUpdateCamera.bind(this);
|
|
18504
|
+
const setFiveOriginUpdateCamera = this.setFiveOriginUpdateCamera.bind(this);
|
|
18505
|
+
this.hooks.on('play', setFiveLinearUpdateCamera);
|
|
18506
|
+
this.hooks.on('broke', setFiveOriginUpdateCamera);
|
|
18507
|
+
this.hooks.on('end', setFiveOriginUpdateCamera);
|
|
18508
|
+
this.hooks.on('pause', setFiveOriginUpdateCamera);
|
|
18509
|
+
this.privateState.disposers.push(() => {
|
|
18510
|
+
this.hooks.off('play', setFiveLinearUpdateCamera);
|
|
18511
|
+
this.hooks.off('broke', setFiveOriginUpdateCamera);
|
|
18512
|
+
this.hooks.off('end', setFiveOriginUpdateCamera);
|
|
18513
|
+
this.hooks.off('pause', setFiveOriginUpdateCamera);
|
|
18514
|
+
});
|
|
18515
|
+
}
|
|
18516
|
+
/**
|
|
18517
|
+
* @description Load Data and State
|
|
18518
|
+
*/
|
|
18519
|
+
async load(serverData, state, userAction) {
|
|
18520
|
+
var _a, _b, _c, _d, _e;
|
|
18521
|
+
if (this.state.disposed)
|
|
18522
|
+
return disposedErrorLog();
|
|
18523
|
+
if (!this.privateState.fiveOriginGetProgress) {
|
|
18524
|
+
if (!((_b = (_a = this.five.controller) === null || _a === void 0 ? void 0 : _a.cameraMotion) === null || _b === void 0 ? void 0 : _b.getProgress)) {
|
|
18525
|
+
await this.waitFiveLoaded();
|
|
18526
|
+
this.privateState.fiveOriginGetProgress = (_d = (_c = this.five.controller) === null || _c === void 0 ? void 0 : _c.cameraMotion) === null || _d === void 0 ? void 0 : _d.getProgress;
|
|
18527
|
+
}
|
|
18528
|
+
}
|
|
18529
|
+
this.clear();
|
|
18530
|
+
// copy this.data
|
|
18531
|
+
const prevData = this.data ? JSON.parse(JSON.stringify(this.data)) : undefined;
|
|
18532
|
+
// format server data to plugin data
|
|
18533
|
+
const data = await this.formatData(serverData);
|
|
18534
|
+
this.data = data;
|
|
18535
|
+
this.hooks.emit('dataChange', data, prevData);
|
|
18536
|
+
let guideLinePanoIndex = [];
|
|
18537
|
+
let tempFloorIndex;
|
|
18538
|
+
// filter panoIndex list Data
|
|
18539
|
+
const hasPanoIndexKeyframes = this.data.keyframes.filter((keyframe) => keyframe.data.panoIndex !== undefined);
|
|
18540
|
+
hasPanoIndexKeyframes
|
|
18541
|
+
.filter((keyframe, index) => { var _a; return keyframe.data.panoIndex !== ((_a = hasPanoIndexKeyframes[index - 1]) === null || _a === void 0 ? void 0 : _a.data.panoIndex); })
|
|
18542
|
+
.map((keyframe) => keyframe.data.panoIndex)
|
|
18543
|
+
.forEach((panoIndex) => {
|
|
18544
|
+
var _a, _b;
|
|
18545
|
+
const floorIndex = (_a = this.five.work.observers[panoIndex]) === null || _a === void 0 ? void 0 : _a.floorIndex;
|
|
18546
|
+
if (floorIndex === undefined)
|
|
18547
|
+
return;
|
|
18548
|
+
if (tempFloorIndex === floorIndex) {
|
|
18549
|
+
const index = guideLinePanoIndex.length - 1;
|
|
18550
|
+
guideLinePanoIndex[index] = [...((_b = guideLinePanoIndex[index]) !== null && _b !== void 0 ? _b : []), panoIndex];
|
|
18551
|
+
}
|
|
18552
|
+
else {
|
|
18553
|
+
tempFloorIndex = floorIndex;
|
|
18554
|
+
const index = guideLinePanoIndex.length;
|
|
18555
|
+
guideLinePanoIndex[index] = [panoIndex];
|
|
18556
|
+
}
|
|
18557
|
+
});
|
|
18558
|
+
// initialize GuideLinePlugin
|
|
18559
|
+
if (!this.GuideLine)
|
|
18560
|
+
this.GuideLine = GuideLinePlugin(this.five);
|
|
18561
|
+
// load GuideLine
|
|
18562
|
+
(_e = this.GuideLine) === null || _e === void 0 ? void 0 : _e.load({ routes: guideLinePanoIndex.map((route) => ({ panoIndexList: route })) });
|
|
18563
|
+
// first pause
|
|
18564
|
+
this.setState({ playing: false });
|
|
18565
|
+
// set state
|
|
18566
|
+
this.handleVisible(this.state.visible);
|
|
18567
|
+
this.handleEnable(this.state.enabled);
|
|
18568
|
+
this.changePlayState(this.state.playing);
|
|
18569
|
+
this.changeSpeed(this.state.speed);
|
|
18570
|
+
// initialize plugin state
|
|
18571
|
+
if (state)
|
|
18572
|
+
this.setState(state, { userAction });
|
|
18573
|
+
// load end
|
|
18574
|
+
console.log(`${PLUGIN} loaded`, data);
|
|
18575
|
+
this.hooks.emit('dataLoaded', data);
|
|
18576
|
+
}
|
|
18577
|
+
/**
|
|
18578
|
+
* @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
|
|
18579
|
+
*/
|
|
18580
|
+
play(options) {
|
|
18581
|
+
this.setState({ playing: true }, options);
|
|
18582
|
+
}
|
|
18583
|
+
/**
|
|
18584
|
+
* @description If playing, first pause, then play from keyframes index/id
|
|
18585
|
+
* @param {number} options.index play from keyframes index
|
|
18586
|
+
* @param {string} options.id play from keyframes id
|
|
18587
|
+
*/
|
|
18588
|
+
playFrom(options) {
|
|
18589
|
+
const { index, id, userAction } = options;
|
|
18590
|
+
if (this.state.playing)
|
|
18591
|
+
this.setState({ playing: false }, { userAction });
|
|
18592
|
+
this.setState({ playing: true }, { userAction, playFromIndex: index, playFromId: id });
|
|
18593
|
+
}
|
|
18594
|
+
/**
|
|
18595
|
+
* @description Play from first keyframe
|
|
18596
|
+
*/
|
|
18597
|
+
playFromStart(options) {
|
|
18598
|
+
return this.playFrom(Object.assign(Object.assign({}, options), { index: 0 }));
|
|
18599
|
+
}
|
|
18600
|
+
/**
|
|
18601
|
+
* @description Pause
|
|
18602
|
+
*/
|
|
18603
|
+
pause(options) {
|
|
18604
|
+
this.setState({ playing: false }, options);
|
|
18605
|
+
}
|
|
18606
|
+
/**
|
|
18607
|
+
* @description Show guide line
|
|
18608
|
+
*/
|
|
18609
|
+
async show(options) {
|
|
18610
|
+
this.setState({ visible: true }, options);
|
|
18611
|
+
}
|
|
18612
|
+
/**
|
|
18613
|
+
* @description Hide guide line
|
|
18614
|
+
*/
|
|
18615
|
+
async hide(options) {
|
|
18616
|
+
this.setState({ visible: false }, options);
|
|
18617
|
+
}
|
|
18618
|
+
/**
|
|
18619
|
+
* @description Enable
|
|
18620
|
+
*/
|
|
18621
|
+
enable(options) {
|
|
18622
|
+
this.setState({ enabled: true }, options);
|
|
18623
|
+
}
|
|
18624
|
+
/**
|
|
18625
|
+
* @description Disable
|
|
18626
|
+
*/
|
|
18627
|
+
disable(options) {
|
|
18628
|
+
this.setState({ enabled: false }, options);
|
|
18629
|
+
}
|
|
18630
|
+
/**
|
|
18631
|
+
* @description Dispose
|
|
18632
|
+
*/
|
|
18633
|
+
dispose() {
|
|
18634
|
+
this.setState({ disposed: true });
|
|
18635
|
+
}
|
|
18636
|
+
/**
|
|
18637
|
+
* @description Set state
|
|
18638
|
+
*/
|
|
18639
|
+
setState(state, options) {
|
|
18640
|
+
var _a;
|
|
18641
|
+
if (this.state.disposed)
|
|
18642
|
+
return disposedErrorLog();
|
|
18643
|
+
if (!this.state.enabled) {
|
|
18644
|
+
// when plugin is disabled, only can change enabled or disposed to true
|
|
18645
|
+
if (state.enabled !== true && state.disposed !== true)
|
|
18646
|
+
return disableErrorLog();
|
|
18647
|
+
}
|
|
18648
|
+
const prevState = Object.assign({}, this.state);
|
|
18649
|
+
this.state = Object.assign(Object.assign({}, this.state), state);
|
|
18650
|
+
if (state.disposed !== undefined && state.disposed !== prevState.disposed) {
|
|
18651
|
+
if (state.disposed)
|
|
18652
|
+
this.handleDispose();
|
|
18653
|
+
}
|
|
18654
|
+
if (state.visible !== undefined && state.visible !== prevState.visible) {
|
|
18655
|
+
this.handleVisible(state.visible, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18656
|
+
}
|
|
18657
|
+
if (state.enabled !== undefined && state.enabled !== prevState.enabled) {
|
|
18658
|
+
this.handleEnable(state.enabled, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18659
|
+
}
|
|
18660
|
+
if (state.playing !== undefined && state.playing !== prevState.playing) {
|
|
18661
|
+
this.changePlayState(state.playing, options);
|
|
18662
|
+
}
|
|
18663
|
+
if (state.speed !== undefined && state.speed !== prevState.speed) {
|
|
18664
|
+
this.changeSpeed(state.speed, options === null || options === void 0 ? void 0 : options.userAction);
|
|
18665
|
+
}
|
|
18666
|
+
if (!equal(prevState, this.state, { deep: true })) {
|
|
18667
|
+
console.log('--emit stateChange--', this.state);
|
|
18668
|
+
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 });
|
|
18669
|
+
}
|
|
18670
|
+
}
|
|
18671
|
+
/**
|
|
18672
|
+
* @description Format data
|
|
18673
|
+
*/
|
|
18674
|
+
async formatData(serverData) {
|
|
18675
|
+
if (!this.five.work)
|
|
18676
|
+
await this.waitFiveLoaded();
|
|
18677
|
+
const observers = this.five.work.observers;
|
|
18678
|
+
const data = (() => {
|
|
18679
|
+
const _serverData = serverData;
|
|
18680
|
+
if (typeof _serverData === 'object' && _serverData !== null && _serverData.version && _serverData.data) {
|
|
18681
|
+
return _serverData.data;
|
|
18682
|
+
}
|
|
18683
|
+
return _serverData;
|
|
18684
|
+
})();
|
|
18685
|
+
if (data.keyframes) {
|
|
18686
|
+
return {
|
|
18687
|
+
keyframesId: uuid(),
|
|
18688
|
+
keyframes: data.keyframes.map((keyframe, index) => { var _a; return (Object.assign({ id: (_a = keyframe.uuid) !== null && _a !== void 0 ? _a : uuid(), index }, keyframe)); }),
|
|
18689
|
+
};
|
|
18690
|
+
}
|
|
18691
|
+
else if (data.panoIndexList) {
|
|
18692
|
+
let keyframes = [];
|
|
18693
|
+
const moveEffect = data.moveEffect;
|
|
18694
|
+
data.panoIndexList
|
|
18695
|
+
.filter((panoIndex, index) => panoIndex !== data.panoIndexList[index - 1])
|
|
18696
|
+
.forEach((panoIndex, index) => {
|
|
18697
|
+
const lookatNextPanoIndex = (() => {
|
|
18698
|
+
var _a, _b, _c, _d;
|
|
18699
|
+
const nextPanoIndex = data.panoIndexList[index + 1];
|
|
18700
|
+
if (nextPanoIndex === undefined)
|
|
18701
|
+
return;
|
|
18702
|
+
const vectorFrom = (_a = observers[panoIndex]) === null || _a === void 0 ? void 0 : _a.position;
|
|
18703
|
+
const vectorTo = (_b = observers[nextPanoIndex]) === null || _b === void 0 ? void 0 : _b.position;
|
|
18704
|
+
if (!vectorTo || !vectorFrom)
|
|
18705
|
+
return;
|
|
18706
|
+
// if panoIndex and next panoIndex isn't in same floor, return
|
|
18707
|
+
if (((_c = observers[panoIndex]) === null || _c === void 0 ? void 0 : _c.floorIndex) !== ((_d = observers[nextPanoIndex]) === null || _d === void 0 ? void 0 : _d.floorIndex))
|
|
18708
|
+
return;
|
|
18709
|
+
const vector = new THREE__namespace.Vector3().subVectors(vectorTo, vectorFrom);
|
|
18710
|
+
return vectorToCoordinates(vector);
|
|
18711
|
+
})();
|
|
18712
|
+
if (data.moveType === undefined || data.moveType === 'justMove') {
|
|
18713
|
+
// move to panoIndex, latitude, longitude
|
|
18714
|
+
keyframes.push({ data: Object.assign({ effect: 'Move', panoIndex, moveEffect }, (lookatNextPanoIndex !== null && lookatNextPanoIndex !== void 0 ? lookatNextPanoIndex : {})) });
|
|
18715
|
+
}
|
|
18716
|
+
else if (data.moveType === 'moveAndRotate') {
|
|
18717
|
+
// move to panoIndex, then rotate to latitude and longitude
|
|
18718
|
+
keyframes.push({ data: { effect: 'Move', panoIndex, moveEffect } });
|
|
18719
|
+
if (lookatNextPanoIndex)
|
|
18720
|
+
keyframes.push({ data: Object.assign({ effect: 'Rotate', panoIndex }, lookatNextPanoIndex) });
|
|
18721
|
+
}
|
|
18722
|
+
});
|
|
18723
|
+
return { keyframesId: uuid(), keyframes: keyframes.map((keyframe, index) => (Object.assign({ id: uuid(), index }, keyframe))) };
|
|
18724
|
+
}
|
|
18725
|
+
else {
|
|
18726
|
+
throw new Error('format error: data no keyframes or no panoIndexList');
|
|
18727
|
+
}
|
|
18728
|
+
}
|
|
18729
|
+
handleEnable(enabled, userAction = true) {
|
|
18730
|
+
var _a, _b;
|
|
18731
|
+
if (enabled) {
|
|
18732
|
+
(_a = this.GuideLine) === null || _a === void 0 ? void 0 : _a.enable();
|
|
18733
|
+
this.hooks.emit('enable', { userAction });
|
|
18734
|
+
}
|
|
18735
|
+
else {
|
|
18736
|
+
(_b = this.GuideLine) === null || _b === void 0 ? void 0 : _b.disable();
|
|
18737
|
+
this.changePlayState(false, { userAction });
|
|
18738
|
+
this.hooks.emit('disable', { userAction });
|
|
18739
|
+
}
|
|
18740
|
+
this.state.enabled = enabled;
|
|
18741
|
+
}
|
|
18742
|
+
handleVisible(visible, userAction = true) {
|
|
18743
|
+
var _a, _b;
|
|
18744
|
+
if (visible) {
|
|
18745
|
+
(_a = this.GuideLine) === null || _a === void 0 ? void 0 : _a.show();
|
|
18746
|
+
this.actionIfStateIsEnabled(() => this.hooks.emit('show', { userAction }));
|
|
18747
|
+
}
|
|
18748
|
+
else {
|
|
18749
|
+
(_b = this.GuideLine) === null || _b === void 0 ? void 0 : _b.hide();
|
|
18750
|
+
this.actionIfStateIsEnabled(() => this.hooks.emit('hide', { userAction }));
|
|
18751
|
+
}
|
|
18752
|
+
this.state.visible = visible;
|
|
18753
|
+
}
|
|
18754
|
+
changePlayState(play, options) {
|
|
18755
|
+
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 }); });
|
|
18756
|
+
play ? this.handlePlay(options) : this.handlePause(options);
|
|
18757
|
+
this.state.playing = play;
|
|
18758
|
+
}
|
|
18759
|
+
/**
|
|
18760
|
+
* @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
|
|
18761
|
+
* @param {number} options.playFromIndex play from keyframes index
|
|
18762
|
+
* @param {string} options.playFromId play from keyframes id
|
|
18763
|
+
*/
|
|
18764
|
+
// eslint-disable-next-line complexity
|
|
18765
|
+
async handlePlay(options) {
|
|
18766
|
+
var _a;
|
|
18767
|
+
const { data, state, privateState, hooks } = this;
|
|
18768
|
+
// check whether keyframes can be played
|
|
18769
|
+
if (privateState.playing)
|
|
18770
|
+
return;
|
|
18771
|
+
if (!(data === null || data === void 0 ? void 0 : data.keyframes) || (data === null || data === void 0 ? void 0 : data.keyframes.length) === 0)
|
|
18772
|
+
return;
|
|
18773
|
+
// set current play id
|
|
18774
|
+
const currentPlayId = uuid();
|
|
18775
|
+
// if handlePlay function is called again before play end, currentPlayId isn't equal to privateState.playId
|
|
18776
|
+
privateState.playId = currentPlayId;
|
|
18777
|
+
// set state
|
|
18778
|
+
privateState.playing = true;
|
|
18779
|
+
privateState.broke = false;
|
|
18780
|
+
const keyframes = data.keyframes;
|
|
18781
|
+
const pauseData = this.getPauseData();
|
|
18782
|
+
if ((options === null || options === void 0 ? void 0 : options.notEmitEvent) !== true) {
|
|
18783
|
+
hooks.emit('play', { userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true });
|
|
18784
|
+
}
|
|
18785
|
+
const getPlayFromIndex = async () => {
|
|
18786
|
+
var _a, _b;
|
|
18787
|
+
// play from index
|
|
18788
|
+
if ((options === null || options === void 0 ? void 0 : options.playFromIndex) !== undefined)
|
|
18789
|
+
return options.playFromIndex;
|
|
18790
|
+
// play from id
|
|
18791
|
+
else if ((options === null || options === void 0 ? void 0 : options.playFromId) !== undefined)
|
|
18792
|
+
return (_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframes.findIndex((keyframe) => keyframe.id === options.playFromId);
|
|
18793
|
+
// play from pause position
|
|
18794
|
+
else if (pauseData === null || pauseData === void 0 ? void 0 : pauseData.keyframeId) {
|
|
18795
|
+
const pausedKeyframe = (_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframes.find((keyframe) => keyframe.id === pauseData.keyframeId);
|
|
18796
|
+
// restore paused state
|
|
18797
|
+
if (pauseData === null || pauseData === void 0 ? void 0 : pauseData.fiveState)
|
|
18798
|
+
await this.move(pauseData.fiveState);
|
|
18799
|
+
if (pausedKeyframe) {
|
|
18800
|
+
if (pausedKeyframe.data.effect === 'Move')
|
|
18801
|
+
return pausedKeyframe.index;
|
|
18802
|
+
else if (pausedKeyframe.data.effect === 'Rotate') {
|
|
18803
|
+
const duration = pauseData.duration !== undefined ? pauseData.duration * (1 - pauseData.playedProgress) : undefined;
|
|
18804
|
+
await this.playKeyframe(pausedKeyframe, duration);
|
|
18805
|
+
// playFromIndex += 1 cause played last part of paused keyframe
|
|
18806
|
+
return pausedKeyframe.index + 1;
|
|
18807
|
+
}
|
|
18808
|
+
}
|
|
18809
|
+
}
|
|
18810
|
+
};
|
|
18811
|
+
const playFromIndex = await getPlayFromIndex();
|
|
18812
|
+
this.clearPauseData();
|
|
18813
|
+
// play keyframes
|
|
18814
|
+
for (const keyframe of keyframes) {
|
|
18815
|
+
if (privateState.broke || !state.playing || !privateState.playing)
|
|
18816
|
+
return;
|
|
18817
|
+
if (currentPlayId !== privateState.playId)
|
|
18818
|
+
return;
|
|
18819
|
+
// jump to start keyframe
|
|
18820
|
+
if (playFromIndex !== undefined && keyframe.index < playFromIndex)
|
|
18821
|
+
continue;
|
|
18822
|
+
// play single keyframe
|
|
18823
|
+
try {
|
|
18824
|
+
console.log('playIndexChange', keyframe.index);
|
|
18825
|
+
hooks.emit('playIndexChange', keyframe.index, keyframe);
|
|
18826
|
+
await this.playKeyframe(keyframe);
|
|
18827
|
+
}
|
|
18828
|
+
catch (error) {
|
|
18829
|
+
return Promise.resolve('broke');
|
|
18830
|
+
// if think play be interupted by five gesture is an error, return Promise.reject(error)
|
|
18831
|
+
// return Promise.reject(error)
|
|
18832
|
+
}
|
|
18833
|
+
}
|
|
18834
|
+
if (state.playing && currentPlayId === privateState.playId) {
|
|
18835
|
+
this.setState({ playing: false }, { userAction: false });
|
|
18836
|
+
console.log('--emit end--');
|
|
18837
|
+
hooks.emit('end');
|
|
18838
|
+
this.clearPauseData();
|
|
18839
|
+
}
|
|
18840
|
+
}
|
|
18841
|
+
/**
|
|
18842
|
+
* @description: Pause and record pause state
|
|
18843
|
+
*/
|
|
18844
|
+
handlePause(options) {
|
|
18845
|
+
var _a;
|
|
18846
|
+
const { state, privateState, hooks } = this;
|
|
18847
|
+
state.playing = false;
|
|
18848
|
+
if (privateState.playing === false)
|
|
18849
|
+
return;
|
|
18850
|
+
privateState.playing = false;
|
|
18851
|
+
this.setPauseData();
|
|
18852
|
+
if (!privateState.broke)
|
|
18853
|
+
this.forceInteruptUpdateCamera();
|
|
18854
|
+
console.log('--emit pause--');
|
|
18855
|
+
if ((options === null || options === void 0 ? void 0 : options.notEmitEvent) !== true) {
|
|
18856
|
+
hooks.emit('pause', { userAction: (_a = options === null || options === void 0 ? void 0 : options.userAction) !== null && _a !== void 0 ? _a : true });
|
|
18857
|
+
}
|
|
18858
|
+
}
|
|
18859
|
+
/**
|
|
18860
|
+
* @description Play single keyframe
|
|
18861
|
+
*/
|
|
18862
|
+
async playKeyframe(keyframe, duration) {
|
|
18863
|
+
var _a;
|
|
18864
|
+
const { privateState } = this;
|
|
18865
|
+
if (((_a = this.privateState.currentPlayKeyframe) === null || _a === void 0 ? void 0 : _a.keyframe.id) !== keyframe.id)
|
|
18866
|
+
this.privateState.currentPlayKeyframe = { keyframe };
|
|
18867
|
+
privateState.currentPlayQueue.push(this.getPlayPromise(keyframe, duration));
|
|
18868
|
+
return this.actionPromiseQueue();
|
|
18869
|
+
}
|
|
18870
|
+
/**
|
|
18871
|
+
* @description: listen interupted by five gesture
|
|
18872
|
+
*/
|
|
18873
|
+
addInterruptListener(callback) {
|
|
18874
|
+
this.five.once('gesture', callback);
|
|
18875
|
+
this.five.once('modeChange', callback);
|
|
18876
|
+
return () => {
|
|
18877
|
+
this.five.off('gesture', callback);
|
|
18878
|
+
this.five.once('modeChange', callback);
|
|
18879
|
+
};
|
|
18880
|
+
}
|
|
18881
|
+
/**
|
|
18882
|
+
* @description: getPlayPromise
|
|
18883
|
+
*/
|
|
18884
|
+
async getPlayPromise(keyframe, paramsDuration) {
|
|
18885
|
+
const data = keyframe.data;
|
|
18886
|
+
const duration = paramsDuration !== null && paramsDuration !== void 0 ? paramsDuration : (keyframe.start !== undefined && keyframe.end !== undefined ? keyframe.end - keyframe.start : undefined);
|
|
18887
|
+
if (!data)
|
|
18888
|
+
return;
|
|
18889
|
+
return new Promise((resolve, reject) => {
|
|
18890
|
+
let fulfilled = false;
|
|
18891
|
+
this.addInterruptListener(() => {
|
|
18892
|
+
if (fulfilled)
|
|
18893
|
+
return;
|
|
18894
|
+
console.log('--emit broke--');
|
|
18895
|
+
this.hooks.emit('broke');
|
|
18896
|
+
this.privateState.broke = true;
|
|
18897
|
+
this.setState({ playing: false });
|
|
18898
|
+
fulfilled = true;
|
|
18899
|
+
return reject(new Error('play is interupted'));
|
|
18900
|
+
});
|
|
18901
|
+
try {
|
|
18902
|
+
if (fulfilled)
|
|
18903
|
+
return;
|
|
18904
|
+
const res = () => {
|
|
18905
|
+
resolve();
|
|
18906
|
+
fulfilled = true;
|
|
18907
|
+
};
|
|
18908
|
+
switch (data.effect) {
|
|
18909
|
+
case 'Move':
|
|
18910
|
+
this.move(data, duration).then(res);
|
|
18911
|
+
break;
|
|
18912
|
+
case 'Rotate':
|
|
18913
|
+
this.rotate(data, duration).then(res);
|
|
18914
|
+
break;
|
|
18915
|
+
default:
|
|
18916
|
+
this.rotate(data, duration).then(res);
|
|
18917
|
+
}
|
|
18918
|
+
}
|
|
18919
|
+
catch (e) { }
|
|
18920
|
+
});
|
|
18921
|
+
}
|
|
18922
|
+
/**
|
|
18923
|
+
* @description Action promise queue in sequence
|
|
18924
|
+
*/
|
|
18925
|
+
async actionPromiseQueue() {
|
|
18926
|
+
const { privateState } = this;
|
|
18927
|
+
return new Promise((resolve, reject) => {
|
|
18928
|
+
if (privateState.currentPlayQueue.length === 0) {
|
|
18929
|
+
resolve();
|
|
18930
|
+
return;
|
|
18931
|
+
}
|
|
18932
|
+
const promise = privateState.currentPlayQueue.shift();
|
|
18933
|
+
if (!promise) {
|
|
18934
|
+
resolve();
|
|
18935
|
+
return;
|
|
18936
|
+
}
|
|
18937
|
+
promise.then(resolve, reject);
|
|
18938
|
+
}).then(() => {
|
|
18939
|
+
if (privateState.currentPlayQueue.length === 0)
|
|
18940
|
+
return Promise.resolve();
|
|
18941
|
+
return this.actionPromiseQueue();
|
|
18942
|
+
});
|
|
18943
|
+
}
|
|
18944
|
+
/**
|
|
18945
|
+
* @description Action move keyframe
|
|
18946
|
+
*/
|
|
18947
|
+
async move(data, duration) {
|
|
18948
|
+
console.log('--move--', data.panoIndex);
|
|
18949
|
+
if (data.mode && data.mode !== this.five.currentMode) {
|
|
18950
|
+
await this.changeMode(data);
|
|
18951
|
+
}
|
|
18952
|
+
else if (data.panoIndex !== this.five.panoIndex) {
|
|
18953
|
+
await this.changePano(data, duration);
|
|
18954
|
+
}
|
|
18955
|
+
else {
|
|
18956
|
+
return Promise.resolve();
|
|
18957
|
+
}
|
|
18958
|
+
// await updateCamera(data)
|
|
18959
|
+
}
|
|
18960
|
+
/**
|
|
18961
|
+
* @description Action rotate keyframe
|
|
18962
|
+
*/
|
|
18963
|
+
async rotate(data, duration) {
|
|
18964
|
+
console.log('--rotate--', data);
|
|
18965
|
+
if (data.mode && data.mode !== this.five.currentMode) {
|
|
18966
|
+
await this.changeMode({ mode: data.mode, panoIndex: data.panoIndex });
|
|
18967
|
+
}
|
|
18968
|
+
else if (data.panoIndex && data.panoIndex !== this.five.panoIndex) {
|
|
18969
|
+
return await this.changePano(data, duration);
|
|
18970
|
+
}
|
|
18971
|
+
await this.updateCamera(data, duration);
|
|
18972
|
+
}
|
|
18973
|
+
/**
|
|
18974
|
+
* @description Update five camera
|
|
18975
|
+
*/
|
|
18976
|
+
async updateCamera(data, paramsDuration = 800) {
|
|
18977
|
+
const { five, privateState, state } = this;
|
|
18978
|
+
let originDuration = paramsDuration;
|
|
18979
|
+
const speed = (() => {
|
|
18980
|
+
var _a, _b;
|
|
18981
|
+
const speedConfig = (_a = state.config) === null || _a === void 0 ? void 0 : _a.speedConfig;
|
|
18982
|
+
const speedValue = (_b = data.rotateSpeed) !== null && _b !== void 0 ? _b : speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.rotateSpeed;
|
|
18983
|
+
if ((speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.rotateSpeedUnit) === undefined)
|
|
18984
|
+
return speedValue;
|
|
18985
|
+
if (speedValue !== undefined) {
|
|
18986
|
+
return speedConfig.rotateSpeedUnit === 'rad/ms' ? speedValue : speedValue / 1000;
|
|
18987
|
+
}
|
|
18988
|
+
})();
|
|
18989
|
+
if (speed) {
|
|
18990
|
+
const coordinates1 = this.five.getCurrentState();
|
|
18991
|
+
const coordinates2 = data;
|
|
18992
|
+
const angle = coordinatesAngle(coordinates1, coordinates2);
|
|
18993
|
+
originDuration = angle / speed;
|
|
18994
|
+
}
|
|
18995
|
+
if (privateState.currentPlayKeyframe)
|
|
18996
|
+
privateState.currentPlayKeyframe.originDuration = originDuration;
|
|
18997
|
+
const duration = this.getSpeededDuration(originDuration);
|
|
18998
|
+
return new Promise((resolve) => {
|
|
18999
|
+
safeCall(() => five.updateCamera(data, duration));
|
|
19000
|
+
setTimeout(() => resolve(), duration);
|
|
19001
|
+
});
|
|
19002
|
+
}
|
|
19003
|
+
/**
|
|
19004
|
+
* @description: Change five pano
|
|
19005
|
+
*/
|
|
19006
|
+
async changePano(data, paramsDuration = 800) {
|
|
19007
|
+
const { five, privateState, state } = this;
|
|
19008
|
+
if (typeof data.panoIndex !== 'number')
|
|
19009
|
+
return;
|
|
19010
|
+
if (data.panoIndex === five.panoIndex)
|
|
19011
|
+
return;
|
|
19012
|
+
let originDuration = paramsDuration;
|
|
19013
|
+
const speed = (() => {
|
|
19014
|
+
var _a, _b;
|
|
19015
|
+
const speedConfig = (_a = state.config) === null || _a === void 0 ? void 0 : _a.speedConfig;
|
|
19016
|
+
const speedValue = (_b = data.moveSpeed) !== null && _b !== void 0 ? _b : speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.moveSpeed;
|
|
19017
|
+
if ((speedConfig === null || speedConfig === void 0 ? void 0 : speedConfig.moveSpeedUnit) === undefined)
|
|
19018
|
+
return speedValue;
|
|
19019
|
+
if (speedValue !== undefined) {
|
|
19020
|
+
return speedConfig.moveSpeedUnit === 'm/ms' ? speedValue : speedValue / 1000;
|
|
19021
|
+
}
|
|
19022
|
+
})();
|
|
19023
|
+
if (speed && typeof five.panoIndex === 'number' && typeof data.panoIndex === 'number') {
|
|
19024
|
+
const postion1 = five.work.observers[five.panoIndex].position;
|
|
19025
|
+
const postion2 = five.work.observers[data.panoIndex].position;
|
|
19026
|
+
const distance = postion1.distanceTo(postion2);
|
|
19027
|
+
originDuration = distance / speed;
|
|
19028
|
+
}
|
|
19029
|
+
if (privateState.currentPlayKeyframe)
|
|
19030
|
+
privateState.currentPlayKeyframe.originDuration = originDuration;
|
|
19031
|
+
const duration = this.getSpeededDuration(originDuration);
|
|
19032
|
+
return new Promise((resolve) => {
|
|
19033
|
+
var _a, _b;
|
|
19034
|
+
five.moveToPano(data.panoIndex, {
|
|
19035
|
+
latitude: data.latitude,
|
|
19036
|
+
longitude: data.longitude,
|
|
19037
|
+
fov: data.fov,
|
|
19038
|
+
duration,
|
|
19039
|
+
effect: (_b = (_a = this.state.config) === null || _a === void 0 ? void 0 : _a.moveEffect) !== null && _b !== void 0 ? _b : data.moveEffect,
|
|
19040
|
+
moveCancelCallback: () => resolve(),
|
|
19041
|
+
moveEndCallback: () => resolve(),
|
|
19042
|
+
});
|
|
19043
|
+
});
|
|
19044
|
+
}
|
|
19045
|
+
/**
|
|
19046
|
+
* @description: Change play speed
|
|
19047
|
+
*/
|
|
19048
|
+
changeSpeed(speed, userAction = true) {
|
|
19049
|
+
const { state, privateState, hooks } = this;
|
|
19050
|
+
const { currentPlayKeyframe } = privateState;
|
|
19051
|
+
hooks.emit('speedChange', speed, { userAction });
|
|
19052
|
+
if (state.playing && currentPlayKeyframe) {
|
|
19053
|
+
try {
|
|
19054
|
+
const duration = currentPlayKeyframe.originDuration !== undefined ? currentPlayKeyframe.originDuration * (1 - this.getProgress()) : undefined;
|
|
19055
|
+
console.log('--speedChange--', speed, { duration });
|
|
19056
|
+
const promise = this.playKeyframe(currentPlayKeyframe.keyframe, duration);
|
|
19057
|
+
privateState.currentPlayQueue.push(promise);
|
|
19058
|
+
}
|
|
19059
|
+
catch (e) { }
|
|
19060
|
+
}
|
|
19061
|
+
}
|
|
19062
|
+
/**
|
|
19063
|
+
* @description Get duration by speed
|
|
19064
|
+
*/
|
|
19065
|
+
getSpeededDuration(duration) {
|
|
19066
|
+
return duration / this.state.speed;
|
|
19067
|
+
}
|
|
19068
|
+
/**
|
|
19069
|
+
* @description Get ratate progress
|
|
19070
|
+
*/
|
|
19071
|
+
getProgress() {
|
|
19072
|
+
return this.five.controller.cameraMotion.progress;
|
|
19073
|
+
}
|
|
19074
|
+
/**
|
|
19075
|
+
* @description Change five mode
|
|
19076
|
+
*/
|
|
19077
|
+
async changeMode(data, duration) {
|
|
19078
|
+
if (data.mode && data.mode !== this.five.currentMode) {
|
|
19079
|
+
await this.five.changeMode(data.mode, data, duration);
|
|
19080
|
+
}
|
|
19081
|
+
}
|
|
19082
|
+
/**
|
|
19083
|
+
* @description Force interupt five updateCamera
|
|
19084
|
+
*/
|
|
19085
|
+
forceInteruptUpdateCamera() {
|
|
19086
|
+
this.five.updateCamera({}, 0);
|
|
19087
|
+
}
|
|
19088
|
+
getPauseData() {
|
|
19089
|
+
var _a, _b;
|
|
19090
|
+
if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframesId)
|
|
19091
|
+
return pauseDataMap.get((_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframesId);
|
|
19092
|
+
}
|
|
19093
|
+
/**
|
|
19094
|
+
* @description Set pause data
|
|
19095
|
+
*/
|
|
19096
|
+
setPauseData() {
|
|
19097
|
+
var _a, _b, _c, _d;
|
|
19098
|
+
if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframesId)
|
|
19099
|
+
return pauseDataMap.set((_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframesId, {
|
|
19100
|
+
keyframeId: (_c = this.privateState.currentPlayKeyframe) === null || _c === void 0 ? void 0 : _c.keyframe.id,
|
|
19101
|
+
fiveState: this.five.getCurrentState(),
|
|
19102
|
+
duration: (_d = this.privateState.currentPlayKeyframe) === null || _d === void 0 ? void 0 : _d.originDuration,
|
|
19103
|
+
playedProgress: this.getProgress(),
|
|
19104
|
+
});
|
|
19105
|
+
}
|
|
19106
|
+
/**
|
|
19107
|
+
* @description Clear pause data
|
|
19108
|
+
*/
|
|
19109
|
+
clearPauseData() {
|
|
19110
|
+
var _a, _b;
|
|
19111
|
+
if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.keyframesId)
|
|
19112
|
+
return pauseDataMap.delete((_b = this.data) === null || _b === void 0 ? void 0 : _b.keyframesId);
|
|
19113
|
+
}
|
|
19114
|
+
/**
|
|
19115
|
+
* @description: Restore state that before loaded
|
|
19116
|
+
*/
|
|
19117
|
+
clear() {
|
|
19118
|
+
this.clearPauseData();
|
|
19119
|
+
this.privateState.currentPlayKeyframe = null;
|
|
19120
|
+
}
|
|
19121
|
+
// TODO
|
|
19122
|
+
handleDispose() {
|
|
19123
|
+
var _a, _b;
|
|
19124
|
+
this.setState({ playing: false });
|
|
19125
|
+
this.clearPauseData();
|
|
19126
|
+
this.clear();
|
|
19127
|
+
(_a = this.GuideLine) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
19128
|
+
this.GuideLine = undefined;
|
|
19129
|
+
(_b = this.privateState.disposers) === null || _b === void 0 ? void 0 : _b.forEach((d) => d === null || d === void 0 ? void 0 : d());
|
|
19130
|
+
}
|
|
19131
|
+
/**
|
|
19132
|
+
* @description Action function if plugin is enable
|
|
19133
|
+
*/
|
|
19134
|
+
actionIfStateIsEnabled(func, options) {
|
|
19135
|
+
if (this.state.enabled)
|
|
19136
|
+
return func();
|
|
19137
|
+
else {
|
|
19138
|
+
if (options === null || options === void 0 ? void 0 : options.warnLog)
|
|
19139
|
+
disableWarnLog();
|
|
19140
|
+
}
|
|
19141
|
+
}
|
|
19142
|
+
/**
|
|
19143
|
+
* @description: Wait for five work ready
|
|
19144
|
+
*/
|
|
19145
|
+
async waitFiveLoaded() {
|
|
19146
|
+
return new Promise((resolve) => {
|
|
19147
|
+
if (this.five.work) {
|
|
19148
|
+
resolve();
|
|
19149
|
+
return;
|
|
19150
|
+
}
|
|
19151
|
+
this.five.once('loaded', () => {
|
|
19152
|
+
resolve();
|
|
19153
|
+
});
|
|
19154
|
+
});
|
|
19155
|
+
}
|
|
19156
|
+
setFiveLinearUpdateCamera() {
|
|
19157
|
+
if (!this.privateState.fiveOriginGetProgress)
|
|
19158
|
+
return;
|
|
19159
|
+
this.five.controller.cameraMotion.getProgress = (time) => {
|
|
19160
|
+
const cameraMotion = this.five.controller.cameraMotion;
|
|
19161
|
+
const deltaTime = time - cameraMotion.startTime;
|
|
19162
|
+
if (deltaTime < 0)
|
|
19163
|
+
return 0;
|
|
19164
|
+
if (deltaTime >= cameraMotion.duration)
|
|
19165
|
+
return 1;
|
|
19166
|
+
return 1 - linerValue(1, cameraMotion.startVelocity, cameraMotion.duration, deltaTime);
|
|
19167
|
+
};
|
|
19168
|
+
}
|
|
19169
|
+
setFiveOriginUpdateCamera() {
|
|
19170
|
+
if (!this.privateState.fiveOriginGetProgress)
|
|
19171
|
+
return;
|
|
19172
|
+
this.five.controller.cameraMotion.getProgress = this.privateState.fiveOriginGetProgress;
|
|
19173
|
+
}
|
|
19174
|
+
}
|
|
19175
|
+
Object.defineProperty(CruisePluginController, "PluginVersion", {
|
|
19176
|
+
enumerable: true,
|
|
19177
|
+
configurable: true,
|
|
19178
|
+
writable: true,
|
|
19179
|
+
value: VERSION
|
|
19180
|
+
});
|
|
19181
|
+
|
|
19182
|
+
const CruisePlugin = (five) => new CruisePluginController(five);
|
|
19183
|
+
|
|
18117
19184
|
const DnalogelVersion = '2.0.0-alpha.49';
|
|
18118
19185
|
|
|
18119
19186
|
exports.CSS3DRenderPlugin = CSS3DRenderPlugin;
|
|
18120
19187
|
exports.CameraMovementPlugin = CameraMovementPlugin;
|
|
19188
|
+
exports.CruisePlugin = CruisePlugin;
|
|
19189
|
+
exports.CruisePluginController = CruisePluginController;
|
|
18121
19190
|
exports.DnalogelVersion = DnalogelVersion;
|
|
18122
19191
|
exports.FLOOR_TYPE_MAP = FLOOR_TYPE_MAP;
|
|
19192
|
+
exports.GuideLinePlugin = GuideLinePlugin;
|
|
18123
19193
|
exports.ItemLabelPlugin = Plugin;
|
|
18124
19194
|
exports.Magnifier = Magnifier;
|
|
18125
19195
|
exports.MapviewFloorplanPlugin = MapviewFloorplanPlugin;
|