@realsee/dnalogel 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/CruisePlugin/BaseController.d.ts +159 -0
  2. package/dist/CruisePlugin/Move.d.ts +40 -0
  3. package/dist/CruisePlugin/Work.d.ts +120 -0
  4. package/dist/CruisePlugin/index.d.ts +6 -4
  5. package/dist/CruisePlugin/typing.d.ts +2 -2
  6. package/dist/CruisePlugin/utils/getFiveStateOnCurve.d.ts +11 -0
  7. package/dist/GuideLinePlugin/Controller.d.ts +1 -6
  8. package/dist/index.cjs.js +54 -54
  9. package/dist/index.js +3565 -3466
  10. package/dist/index.umd.js +47 -47
  11. package/dist/shared-utils/five/fiveLoaded.d.ts +2 -0
  12. package/dist/shared-utils/five/fiveReady.d.ts +2 -0
  13. package/libs/CruisePlugin/BaseController.d.ts +159 -0
  14. package/libs/CruisePlugin/BaseController.js +231 -0
  15. package/libs/CruisePlugin/Move.d.ts +40 -0
  16. package/libs/CruisePlugin/Move.js +137 -0
  17. package/libs/CruisePlugin/Work.d.ts +120 -0
  18. package/libs/CruisePlugin/Work.js +598 -0
  19. package/libs/CruisePlugin/index.d.ts +6 -4
  20. package/libs/CruisePlugin/index.js +19 -12
  21. package/libs/CruisePlugin/typing.d.ts +2 -2
  22. package/libs/CruisePlugin/utils/getFiveStateOnCurve.d.ts +11 -0
  23. package/libs/CruisePlugin/utils/getFiveStateOnCurve.js +11 -0
  24. package/libs/GuideLinePlugin/Controller.d.ts +1 -6
  25. package/libs/GuideLinePlugin/Controller.js +49 -62
  26. package/libs/GuideLinePlugin/GuideLineItem/index.js +53 -43
  27. package/libs/GuideLinePlugin/GuideLineItem.js +14 -10
  28. package/libs/GuideLinePlugin/index.js +21 -17
  29. package/libs/base/BasePlugin.js +1 -1
  30. package/libs/index.js +126 -119
  31. package/libs/shared-utils/five/fiveLoaded.d.ts +2 -0
  32. package/libs/shared-utils/five/fiveLoaded.js +30 -0
  33. package/libs/shared-utils/five/fiveReady.d.ts +2 -0
  34. package/libs/shared-utils/five/fiveReady.js +28 -0
  35. package/libs/shared-utils/formatRad.d.ts +7 -0
  36. package/libs/shared-utils/formatRad.js +7 -0
  37. package/libs/shared-utils/logger.js +1 -1
  38. package/package.json +3 -3
  39. package/dist/CruisePlugin/Controller.d.ts +0 -171
  40. package/dist/CruisePlugin/utils/linerValue.d.ts +0 -1
  41. package/libs/CruisePlugin/Controller.d.ts +0 -171
  42. package/libs/CruisePlugin/Controller.js +0 -760
  43. /package/dist/{CruisePlugin/utils → shared-utils}/formatRad.d.ts +0 -0
  44. /package/dist/{CruisePlugin/utils/vectorToCoordinates.d.ts → shared-utils/vectorToCoordinate.d.ts} +0 -0
  45. /package/libs/{CruisePlugin/utils/vectorToCoordinates.d.ts → shared-utils/vectorToCoordinate.d.ts} +0 -0
  46. /package/libs/{CruisePlugin/utils/vectorToCoordinates.js → shared-utils/vectorToCoordinate.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import type { Five } from '@realsee/five';
2
+ export declare function waitFiveLoaded(five: Five): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { Five } from '@realsee/five';
2
+ export default function fiveReady(five: Five): Promise<void>;
@@ -0,0 +1,159 @@
1
+ import type { Five, State } from '@realsee/five';
2
+ import type { BaseOptions } from '../base/BasePlugin';
3
+ import type { GuideLinePluginExportType } from '../GuideLinePlugin';
4
+ import * as BasePlugin from '../base/BasePlugin';
5
+ import type { PluginState, EventMap, MoveEffect } from './typing';
6
+ import type { PartialDeep } from 'type-fest';
7
+ export declare const pluginFlag: (name: string) => string;
8
+ export default abstract class CruiseController<PluginData, Config = unknown> extends BasePlugin.Controller<PluginState, EventMap> {
9
+ state: PluginState;
10
+ protected data?: PluginData & {
11
+ id: string | number;
12
+ };
13
+ protected config?: Config;
14
+ protected privateState: {
15
+ /**
16
+ * privateState.playing 和 state.playing 的区别:
17
+ * state.playing 先为true,然后才 handleplay,handleplay方法内会检查privateState.playing,如果已经开始(privateState.playing === true),就不执行操作,如果为false,就执行操作
18
+ * 其实就是加了一个不允许重复执行handleplay的逻辑
19
+ */
20
+ playing: boolean;
21
+ broke: boolean;
22
+ playId?: string;
23
+ moveToFirstPanoEffect?: MoveEffect;
24
+ moveToFirstPanoDuration?: number;
25
+ modeChanging?: boolean;
26
+ };
27
+ protected GuideLine?: GuideLinePluginExportType;
28
+ constructor(five: Five, config?: Config);
29
+ /**
30
+ * @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
31
+ */
32
+ play(options?: {
33
+ userAction?: boolean;
34
+ }): void;
35
+ /**
36
+ * @description Pause
37
+ */
38
+ pause(options?: {
39
+ userAction?: boolean;
40
+ }): void;
41
+ /**
42
+ * @description Show guide line
43
+ */
44
+ show(options?: {
45
+ userAction?: boolean;
46
+ }): Promise<void>;
47
+ /**
48
+ * @description Hide guide line
49
+ */
50
+ hide(options?: {
51
+ userAction?: boolean;
52
+ }): Promise<void>;
53
+ /**
54
+ * @description Enable
55
+ */
56
+ enable(options?: {
57
+ userAction?: boolean;
58
+ }): void;
59
+ /**
60
+ * @description Disable
61
+ */
62
+ disable(options?: {
63
+ userAction?: boolean;
64
+ }): void;
65
+ /**
66
+ * @description Dispose
67
+ */
68
+ dispose(): void;
69
+ /**
70
+ * @description Set state
71
+ */
72
+ setState(state: PartialDeep<PluginState>, options?: BaseOptions & Record<string, any>): void;
73
+ /**
74
+ * @description Clear pause data
75
+ */
76
+ protected clearPauseData(): boolean;
77
+ protected changePlayState(play: boolean, options?: {
78
+ userAction?: boolean;
79
+ playFromIndex?: number;
80
+ playFromId?: string;
81
+ }): void;
82
+ protected handleEnable(enabled: boolean, userAction?: boolean): void;
83
+ protected handleVisible(visible: boolean, userAction?: boolean): void;
84
+ /**
85
+ * @description: listen interupted by five gesture
86
+ */
87
+ protected addInterruptListener(interrupt: () => void): () => void;
88
+ /**
89
+ * @description Get duration by speed
90
+ */
91
+ protected getSpeededDuration(duration: number): number;
92
+ /**
93
+ * @description Force interupt five updateCamera
94
+ */
95
+ protected forceInteruptUpdateCamera(): void;
96
+ protected getPauseData(): {
97
+ fiveState: Partial<State>;
98
+ id?: string | number;
99
+ playedProgress: number;
100
+ duration?: number;
101
+ };
102
+ /**
103
+ * @description Set pause data
104
+ */
105
+ protected setPauseData(): Map<string | number, {
106
+ fiveState: Partial<State>;
107
+ id?: string | number;
108
+ playedProgress: number;
109
+ duration?: number;
110
+ }>;
111
+ /**
112
+ * @description: Restore state that before loaded
113
+ */
114
+ protected clear(): void;
115
+ protected handleDispose(): void;
116
+ /**
117
+ * @description Action function if plugin is enable
118
+ */
119
+ protected actionIfStateIsEnabled<T = any>(func: () => T, options?: {
120
+ warnLog?: true;
121
+ }): T;
122
+ protected disposedErrorLog: () => void;
123
+ protected disableWarnLog: () => void;
124
+ protected disableErrorLog: () => void;
125
+ /**
126
+ * @description Load Data and State
127
+ */
128
+ abstract load(serverData: unknown, state?: PluginState, userAction?: boolean): Promise<void>;
129
+ /**
130
+ * @description Play from first keyframe
131
+ */
132
+ abstract playFromStart(): void;
133
+ /**
134
+ * @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
135
+ * @param {number} options.playFromIndex play from keyframes index
136
+ * @param {string} options.playFromId play from keyframes id
137
+ */
138
+ protected abstract handlePlay(options?: {
139
+ userAction?: boolean;
140
+ playFromIndex?: number;
141
+ playFromId?: string;
142
+ notEmitEvent?: true;
143
+ }): Promise<string>;
144
+ /**
145
+ * @description: Change play speed
146
+ */
147
+ protected abstract changeSpeed(speed: number): void;
148
+ /**
149
+ * @description Get ratate progress
150
+ */
151
+ protected abstract getProgress(): number;
152
+ /**
153
+ * @description: Pause and record pause state
154
+ */
155
+ protected abstract handlePause(options?: {
156
+ userAction?: boolean;
157
+ notEmitEvent?: true;
158
+ }): void;
159
+ }
@@ -0,0 +1,231 @@
1
+ var v = Object.defineProperty;
2
+ var g = Object.getOwnPropertySymbols;
3
+ var S = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable;
4
+ var u = (a, s, e) => s in a ? v(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e, b = (a, s) => {
5
+ for (var e in s || (s = {}))
6
+ S.call(s, e) && u(a, e, s[e]);
7
+ if (g)
8
+ for (var e of g(s))
9
+ y.call(s, e) && u(a, e, s[e]);
10
+ return a;
11
+ };
12
+ var d = (a, s, e) => (u(a, typeof s != "symbol" ? s + "" : s, e), e);
13
+ var f = (a, s, e) => new Promise((i, t) => {
14
+ var r = (h) => {
15
+ try {
16
+ n(e.next(h));
17
+ } catch (o) {
18
+ t(o);
19
+ }
20
+ }, c = (h) => {
21
+ try {
22
+ n(e.throw(h));
23
+ } catch (o) {
24
+ t(o);
25
+ }
26
+ }, n = (h) => h.done ? i(h.value) : Promise.resolve(h.value).then(r, c);
27
+ n((e = e.apply(a, s)).next());
28
+ });
29
+ import { Controller as L } from "../base/BasePlugin.js";
30
+ import { equal as C } from "../shared-utils/equal.js";
31
+ import { objectAssignDeepExports as P } from "../vendor/object-assign-deep/objectAssignDeep.js";
32
+ import "../shared-utils/Subscribe.js";
33
+ import "hammerjs";
34
+ import "three";
35
+ import "@realsee/five";
36
+ import "../vendor/@tweenjs/tween/dist/tween.esm.js.js";
37
+ import "../CSS3DRenderPlugin/utils/three/CSS3DRender.js";
38
+ import "../shared-utils/positionToVector3.js";
39
+ import "../CSS3DRenderPlugin/utils/three/CSS3DRenderer.js";
40
+ import "three/examples/jsm/renderers/CSS3DRenderer";
41
+ import "../CSS3DRenderPlugin/utils/getAllCSS3DObject.js";
42
+ import "../shared-utils/util.js";
43
+ import "../CSS3DRenderPlugin/utils/createResizeObserver.js";
44
+ import "../CSS3DRenderPlugin/utils/even.js";
45
+ import "../CSS3DRenderPlugin/utils/three/CSS3DObject.js";
46
+ import "../CSS3DRenderPlugin/utils/three/OpacityMesh.js";
47
+ import "../shared-utils/three/centerPoint.js";
48
+ import "../shared-utils/three/getObjectVisible.js";
49
+ import "../CSS3DRenderPlugin/utils/three/CSS3DScene.js";
50
+ import "../CSS3DRenderPlugin/utils/three/CSS3DGroup.js";
51
+ import "../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
52
+ import "../shared-utils/url/absoluteUrl.js";
53
+ import "../shared-utils/isTruelyObject.js";
54
+ const m = "CruisePlugin", l = `${m}`, T = (a) => `${l}--${a}`, p = /* @__PURE__ */ new Map();
55
+ class X extends L {
56
+ constructor(e, i) {
57
+ super(e, i);
58
+ d(this, "state", {
59
+ visible: !0,
60
+ enabled: !0,
61
+ disposed: !1,
62
+ playing: !1,
63
+ speed: 1
64
+ });
65
+ d(this, "data");
66
+ d(this, "config");
67
+ d(this, "privateState", {
68
+ playing: !1,
69
+ broke: !1,
70
+ modeChanging: !1
71
+ });
72
+ d(this, "GuideLine");
73
+ d(this, "disposedErrorLog", () => {
74
+ console.error(`${l} is disposed`);
75
+ });
76
+ d(this, "disableWarnLog", () => {
77
+ console.warn(`${l} is disabled`);
78
+ });
79
+ d(this, "disableErrorLog", () => {
80
+ console.error(`${l} is disabled`);
81
+ });
82
+ this.config = i, Object.assign(window, { [`__${m}_DEBUG__`]: this });
83
+ }
84
+ /**
85
+ * @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
86
+ */
87
+ play(e) {
88
+ this.setState({ playing: !0 }, e);
89
+ }
90
+ /**
91
+ * @description Pause
92
+ */
93
+ pause(e) {
94
+ this.setState({ playing: !1 }, e);
95
+ }
96
+ /**
97
+ * @description Show guide line
98
+ */
99
+ show(e) {
100
+ return f(this, null, function* () {
101
+ this.setState({ visible: !0 }, e);
102
+ });
103
+ }
104
+ /**
105
+ * @description Hide guide line
106
+ */
107
+ hide(e) {
108
+ return f(this, null, function* () {
109
+ this.setState({ visible: !1 }, e);
110
+ });
111
+ }
112
+ /**
113
+ * @description Enable
114
+ */
115
+ enable(e) {
116
+ this.setState({ enabled: !0 }, e);
117
+ }
118
+ /**
119
+ * @description Disable
120
+ */
121
+ disable(e) {
122
+ this.setState({ enabled: !1 }, e);
123
+ }
124
+ /**
125
+ * @description Dispose
126
+ */
127
+ dispose() {
128
+ this.setState({ disposed: !0 });
129
+ }
130
+ /**
131
+ * @description Set state
132
+ */
133
+ setState(e, i) {
134
+ var r;
135
+ if (this.state.disposed)
136
+ return this.disposedErrorLog();
137
+ if (!this.state.enabled && e.enabled !== !0 && e.disposed !== !0)
138
+ return this.disableErrorLog();
139
+ const t = b({}, this.state);
140
+ this.state = P({}, this.state, e), e.disposed !== void 0 && e.disposed !== t.disposed && e.disposed && this.handleDispose(), e.visible !== void 0 && e.visible !== t.visible && this.handleVisible(e.visible, i == null ? void 0 : i.userAction), e.enabled !== void 0 && e.enabled !== t.enabled && this.handleEnable(e.enabled, i == null ? void 0 : i.userAction), e.playing !== void 0 && e.playing !== t.playing && this.changePlayState(e.playing, i), e.speed !== void 0 && e.speed !== t.speed && this.changeSpeed(e.speed), C(t, this.state, { deep: !0 }) || this.hooks.emit("stateChange", { state: this.state, prevState: t, userAction: (r = i == null ? void 0 : i.userAction) != null ? r : !0 });
141
+ }
142
+ /**
143
+ * @description Clear pause data
144
+ */
145
+ clearPauseData() {
146
+ var e, i;
147
+ if ((e = this.data) != null && e.id)
148
+ return p.delete((i = this.data) == null ? void 0 : i.id);
149
+ }
150
+ changePlayState(e, i) {
151
+ this.actionIfStateIsEnabled(
152
+ () => {
153
+ var t;
154
+ return this.hooks.emit("playStateChange", e ? "playing" : "pause", { userAction: (t = i == null ? void 0 : i.userAction) != null ? t : !0 });
155
+ }
156
+ ), e ? this.handlePlay(i) : this.handlePause(i), this.state.playing = e;
157
+ }
158
+ handleEnable(e, i = !0) {
159
+ var t, r;
160
+ e ? ((t = this.GuideLine) == null || t.enable(), this.hooks.emit("enable", { userAction: i })) : ((r = this.GuideLine) == null || r.disable(), this.changePlayState(!1, { userAction: i }), this.hooks.emit("disable", { userAction: i })), this.state.enabled = e;
161
+ }
162
+ handleVisible(e, i = !0) {
163
+ var t, r;
164
+ e ? ((t = this.GuideLine) == null || t.show(), this.actionIfStateIsEnabled(() => this.hooks.emit("show", { userAction: i }))) : ((r = this.GuideLine) == null || r.hide(), this.actionIfStateIsEnabled(() => this.hooks.emit("hide", { userAction: i }))), this.state.visible = e;
165
+ }
166
+ /**
167
+ * @description: listen interupted by five gesture
168
+ */
169
+ addInterruptListener(e) {
170
+ const i = () => {
171
+ this.privateState.modeChanging || e();
172
+ }, t = (r) => {
173
+ r !== "mouseMove" && (e(), this.five.off("gesture", t));
174
+ };
175
+ return this.five.on("gesture", t), this.five.once("wantsChangeMode", i), () => {
176
+ this.five.off("gesture", t), this.five.off("wantsChangeMode", i);
177
+ };
178
+ }
179
+ /**
180
+ * @description Get duration by speed
181
+ */
182
+ getSpeededDuration(e) {
183
+ return e / this.state.speed;
184
+ }
185
+ /**
186
+ * @description Force interupt five updateCamera
187
+ */
188
+ forceInteruptUpdateCamera() {
189
+ this.five.updateCamera({}, 0);
190
+ }
191
+ getPauseData() {
192
+ var e;
193
+ if ((e = this.data) != null && e.id)
194
+ return p.get(this.data.id);
195
+ }
196
+ /**
197
+ * @description Set pause data
198
+ */
199
+ setPauseData() {
200
+ var i;
201
+ const e = (i = this.data) == null ? void 0 : i.id;
202
+ if (e)
203
+ return p.set(e, {
204
+ fiveState: this.five.getCurrentState(),
205
+ playedProgress: this.getProgress()
206
+ });
207
+ }
208
+ /**
209
+ * @description: Restore state that before loaded
210
+ */
211
+ clear() {
212
+ this.clearPauseData();
213
+ }
214
+ // TODO
215
+ handleDispose() {
216
+ var e;
217
+ this.setState({ playing: !1 }), this.clearPauseData(), this.clear(), (e = this.GuideLine) == null || e.dispose(), this.GuideLine = void 0;
218
+ }
219
+ /**
220
+ * @description Action function if plugin is enable
221
+ */
222
+ actionIfStateIsEnabled(e, i) {
223
+ if (this.state.enabled)
224
+ return e();
225
+ i != null && i.warnLog && this.disableWarnLog();
226
+ }
227
+ }
228
+ export {
229
+ X as default,
230
+ T as pluginFlag
231
+ };
@@ -0,0 +1,40 @@
1
+ import type { Five } from '@realsee/five';
2
+ import CruiseController from './BaseController';
3
+ import type { PluginState } from './typing';
4
+ import type { PartialDeep } from 'type-fest';
5
+ import type * as THREE from 'three';
6
+ type Data = {
7
+ path: THREE.CurvePath<THREE.Vector3>;
8
+ offset?: Partial<{
9
+ x: number;
10
+ y: number;
11
+ z: number;
12
+ }>;
13
+ };
14
+ type Config = {
15
+ offset?: Partial<{
16
+ x: number;
17
+ y: number;
18
+ z: number;
19
+ }>;
20
+ allowBroke?: boolean;
21
+ };
22
+ export default class MoveController extends CruiseController<Data, Config> {
23
+ private curve;
24
+ private baseCurveOffset;
25
+ private curveOffset;
26
+ private playStartedTime;
27
+ private duration;
28
+ constructor(five: Five, config?: Config);
29
+ load(data: Data, state?: PartialDeep<PluginState>): Promise<void>;
30
+ changeSpeed: (speed: number, userAction?: boolean) => void;
31
+ moveToStart: () => void;
32
+ playFromStart: () => void;
33
+ protected getDuration: () => number;
34
+ protected getProgress: () => number;
35
+ protected handlePlay(): Promise<string>;
36
+ protected handlePause(options?: {
37
+ userAction?: boolean;
38
+ }): void;
39
+ }
40
+ export {};
@@ -0,0 +1,137 @@
1
+ var y = Object.defineProperty;
2
+ var g = Object.getOwnPropertySymbols;
3
+ var P = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
4
+ var p = (o, e, t) => e in o ? y(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, v = (o, e) => {
5
+ for (var t in e || (e = {}))
6
+ P.call(e, t) && p(o, t, e[t]);
7
+ if (g)
8
+ for (var t of g(e))
9
+ C.call(e, t) && p(o, t, e[t]);
10
+ return o;
11
+ };
12
+ var h = (o, e, t) => (p(o, typeof e != "symbol" ? e + "" : e, t), t);
13
+ var S = (o, e, t) => new Promise((i, a) => {
14
+ var f = (s) => {
15
+ try {
16
+ n(t.next(s));
17
+ } catch (m) {
18
+ a(m);
19
+ }
20
+ }, r = (s) => {
21
+ try {
22
+ n(t.throw(s));
23
+ } catch (m) {
24
+ a(m);
25
+ }
26
+ }, n = (s) => s.done ? i(s.value) : Promise.resolve(s.value).then(f, r);
27
+ n((t = t.apply(o, e)).next());
28
+ });
29
+ import b from "./BaseController.js";
30
+ import { objectAssignDeepExports as u } from "../vendor/object-assign-deep/objectAssignDeep.js";
31
+ import "hammerjs";
32
+ import "three";
33
+ import "@realsee/five";
34
+ import "../vendor/@tweenjs/tween/dist/tween.esm.js.js";
35
+ import "../CSS3DRenderPlugin/utils/three/CSS3DRender.js";
36
+ import "../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
37
+ import { uuid as O } from "../shared-utils/uuid.js";
38
+ import { getFiveStateOnCurve as c } from "./utils/getFiveStateOnCurve.js";
39
+ import { fiveReady as w } from "../shared-utils/five/fiveReady.js";
40
+ import "../base/BasePlugin.js";
41
+ import "../shared-utils/Subscribe.js";
42
+ import "../shared-utils/url/absoluteUrl.js";
43
+ import "../shared-utils/equal.js";
44
+ import "../shared-utils/isTruelyObject.js";
45
+ import "../shared-utils/positionToVector3.js";
46
+ import "../CSS3DRenderPlugin/utils/three/CSS3DRenderer.js";
47
+ import "three/examples/jsm/renderers/CSS3DRenderer";
48
+ import "../CSS3DRenderPlugin/utils/getAllCSS3DObject.js";
49
+ import "../shared-utils/util.js";
50
+ import "../CSS3DRenderPlugin/utils/createResizeObserver.js";
51
+ import "../CSS3DRenderPlugin/utils/even.js";
52
+ import "../CSS3DRenderPlugin/utils/three/CSS3DObject.js";
53
+ import "../CSS3DRenderPlugin/utils/three/OpacityMesh.js";
54
+ import "../shared-utils/three/centerPoint.js";
55
+ import "../shared-utils/three/getObjectVisible.js";
56
+ import "../CSS3DRenderPlugin/utils/three/CSS3DScene.js";
57
+ import "../CSS3DRenderPlugin/utils/three/CSS3DGroup.js";
58
+ import "../shared-utils/vectorToCoordinate.js";
59
+ import "../shared-utils/formatRad.js";
60
+ class it extends b {
61
+ constructor(t, i) {
62
+ var r;
63
+ super(t, i);
64
+ h(this, "curve");
65
+ h(this, "baseCurveOffset");
66
+ h(this, "curveOffset");
67
+ h(this, "playStartedTime", performance.now());
68
+ h(this, "duration");
69
+ h(this, "changeSpeed", (t, i = !0) => {
70
+ this.state.speed = t, this.hooks.emit("speedChange", t, { userAction: i });
71
+ });
72
+ h(this, "moveToStart", () => {
73
+ this.five.setState(c(this.curve, 0, this.curveOffset));
74
+ });
75
+ h(this, "playFromStart", () => {
76
+ this.clearPauseData(), this.setState({ playing: !0 });
77
+ });
78
+ h(this, "getDuration", () => this.getSpeededDuration(this.duration));
79
+ h(this, "getProgress", () => {
80
+ var n;
81
+ const t = this.getPauseData(), i = 1 - ((n = t == null ? void 0 : t.playedProgress) != null ? n : 0), a = this.getDuration(), r = (performance.now() - this.playStartedTime) / a;
82
+ return 1 - i + r;
83
+ });
84
+ const a = {
85
+ config: {
86
+ speedConfig: {
87
+ moveSpeed: 2,
88
+ moveSpeedUnit: "m/s"
89
+ }
90
+ }
91
+ }, f = {
92
+ allowBroke: !0
93
+ };
94
+ this.state = u({}, a, this.state), this.config = u({}, f, this.config), this.baseCurveOffset = u({ x: 0, y: 0, z: 0 }, { y: 2 }, (r = this.config) == null ? void 0 : r.offset);
95
+ }
96
+ load(t, i) {
97
+ var r, n, s, m, d, l;
98
+ if (this.handlePause(), this.clear(), this.data = v({ id: O() }, t), this.curve = this.data.path.curves[0], this.curveOffset = {
99
+ x: this.baseCurveOffset.x + ((n = (r = this.data.offset) == null ? void 0 : r.x) != null ? n : 0),
100
+ y: this.baseCurveOffset.y + ((m = (s = this.data.offset) == null ? void 0 : s.y) != null ? m : 0),
101
+ z: this.baseCurveOffset.z + ((l = (d = this.data.offset) == null ? void 0 : d.z) != null ? l : 0)
102
+ }, !this.curve)
103
+ throw new Error("curve is not defined");
104
+ const a = this.curve.getLength(), f = this.state.config.speedConfig.moveSpeedUnit === "m/ms" ? 1 : 1e3;
105
+ return this.duration = a / (this.state.config.speedConfig.moveSpeed / f), i ? this.setState(i) : (this.setState({ playing: !1 }), this.handleVisible(this.state.visible), this.handleEnable(this.state.enabled), this.changePlayState(this.state.playing), this.changeSpeed(this.state.speed)), Promise.resolve();
106
+ }
107
+ handlePlay() {
108
+ return new Promise((t, i) => S(this, null, function* () {
109
+ var n;
110
+ const a = this.getPauseData(), f = c(this.curve, (n = a == null ? void 0 : a.playedProgress) != null ? n : 0, this.curveOffset);
111
+ if (this.five.setState(f), yield w(this.five), this.playStartedTime = performance.now(), this.config.allowBroke) {
112
+ const s = this.addInterruptListener(() => {
113
+ this.hooks.emit("broke"), this.handlePause(), s(), i(new Error("broke"));
114
+ });
115
+ }
116
+ const r = () => {
117
+ const s = this.getProgress();
118
+ if (s >= 1)
119
+ this.five.off("renderFrame", r), t("end");
120
+ else if (this.state.playing === !1)
121
+ this.five.off("renderFrame", r);
122
+ else if (s >= 0) {
123
+ const m = c(this.curve, s, this.curveOffset);
124
+ this.five.setState(m, !0);
125
+ }
126
+ };
127
+ this.five.on("renderFrame", r);
128
+ }));
129
+ }
130
+ handlePause(t) {
131
+ var i;
132
+ this.state.playing = !1, this.hooks.emit("pause", { userAction: (i = t == null ? void 0 : t.userAction) != null ? i : !0 }), this.setPauseData();
133
+ }
134
+ }
135
+ export {
136
+ it as default
137
+ };
@@ -0,0 +1,120 @@
1
+ import type { Five, State } from '@realsee/five';
2
+ import type { PluginState, PluginServerData, PluginData, CruiseKeyframe, MoveEffect, Config } from './typing';
3
+ import CruiseController from './BaseController';
4
+ export default class WalkController extends CruiseController<PluginData, Config> {
5
+ state: PluginState;
6
+ protected privateState: {
7
+ /**
8
+ * privateState.playing 和 state.playing 的区别:
9
+ * state.playing 先为true,然后才 handleplay,handleplay方法内会检查privateState.playing,如果已经开始(privateState.playing === true),就不执行操作,如果为false,就执行操作
10
+ * 其实就是加了一个不允许重复执行handleplay的逻辑
11
+ */
12
+ playing: boolean;
13
+ currentPlayKeyframe: {
14
+ keyframe: CruiseKeyframe;
15
+ originDuration?: number;
16
+ } | null;
17
+ currentPlayQueue: Promise<any>[];
18
+ broke: boolean;
19
+ playId?: string;
20
+ moveToFirstPanoEffect?: MoveEffect;
21
+ moveToFirstPanoDuration?: number;
22
+ modeChanging?: boolean;
23
+ };
24
+ constructor(five: Five, config?: Config);
25
+ /**
26
+ * @description Load Data and State
27
+ */
28
+ load(serverData: PluginServerData | PluginServerData['data'], state?: PluginState, userAction?: boolean): Promise<void>;
29
+ /**
30
+ * @description If playing, first pause, then play from keyframes index/id
31
+ * @param {number} options.index play from keyframes index
32
+ * @param {string} options.id play from keyframes id
33
+ */
34
+ playFrom(options: {
35
+ userAction?: boolean;
36
+ index?: number;
37
+ id?: string;
38
+ }): void;
39
+ /**
40
+ * @description Play from first keyframe
41
+ */
42
+ playFromStart(options?: {
43
+ userAction?: boolean;
44
+ }): void;
45
+ /**
46
+ * @description Format data
47
+ */
48
+ protected formatData(serverData: PluginServerData | PluginServerData['data']): Promise<PluginData>;
49
+ /**
50
+ * @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing
51
+ * @param {number} options.playFromIndex play from keyframes index
52
+ * @param {string} options.playFromId play from keyframes id
53
+ */
54
+ protected handlePlay(options?: {
55
+ userAction?: boolean;
56
+ playFromIndex?: number;
57
+ playFromId?: string;
58
+ notEmitEvent?: true;
59
+ }): Promise<string>;
60
+ /**
61
+ * @description: Pause and record pause state
62
+ */
63
+ protected handlePause(options?: {
64
+ userAction?: boolean;
65
+ notEmitEvent?: true;
66
+ }): void;
67
+ /**
68
+ * @description: Change play speed
69
+ */
70
+ protected changeSpeed(speed: number, userAction?: boolean): void;
71
+ /**
72
+ * @description Get ratate progress
73
+ */
74
+ protected getProgress(): any;
75
+ /**
76
+ * @description Set pause data
77
+ */
78
+ protected setPauseData(): Map<string, {
79
+ fiveState: Partial<State>;
80
+ id?: string | number;
81
+ playedProgress: number;
82
+ duration?: number;
83
+ }>;
84
+ /**
85
+ * @description: Restore state that before loaded
86
+ */
87
+ protected clear(): void;
88
+ /**
89
+ * @description Play single keyframe
90
+ */
91
+ private playKeyframe;
92
+ /**
93
+ * @description: getPlayPromise
94
+ */
95
+ private getPlayPromise;
96
+ /**
97
+ * @description Action promise queue in sequence
98
+ */
99
+ private actionPromiseQueue;
100
+ /**
101
+ * @description Action move keyframe
102
+ */
103
+ private move;
104
+ /**
105
+ * @description Action rotate keyframe
106
+ */
107
+ private rotate;
108
+ /**
109
+ * @description Update five camera
110
+ */
111
+ private updateCamera;
112
+ /**
113
+ * @description: Change five pano
114
+ */
115
+ private changePano;
116
+ /**
117
+ * @description Change five mode
118
+ */
119
+ private changeMode;
120
+ }