@realsee/vreo 3.0.0-webgpu.10 → 4.0.0-react19.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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -119
- package/README.md +6 -0
- package/lib/PlayController/index.js +74 -75
- package/lib/PlayController/index.js.map +1 -1
- package/lib/Player/App.d.ts +2 -1
- package/lib/Player/App.d.ts.map +1 -1
- package/lib/Player/custom/SpatialScenePanel/index.d.ts +2 -1
- package/lib/Player/custom/SpatialScenePanel/index.d.ts.map +1 -1
- package/lib/Player/hooks.d.ts.map +1 -1
- package/lib/Player/index.js +1 -1808
- package/lib/Player/modules/Drawer/index.d.ts +2 -1
- package/lib/Player/modules/Drawer/index.d.ts.map +1 -1
- package/lib/Player/modules/PopUp/index.d.ts +2 -1
- package/lib/Player/modules/PopUp/index.d.ts.map +1 -1
- package/lib/Player/modules/ResizeObserver/index.d.ts +2 -1
- package/lib/Player/modules/ResizeObserver/index.d.ts.map +1 -1
- package/lib/Player/modules/VideoAgent/index.d.ts +2 -2
- package/lib/Player/modules/Wave/index.d.ts +2 -1
- package/lib/Player/modules/Wave/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/BgMusic/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/BgMusic/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/CameraMovement/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/CameraMovement/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/InfoPanel/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/InfoPanel/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/ModelVideo/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/ModelVideo/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/PanoEffect/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/PanoEffect/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/Prompter/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/Prompter/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts.map +1 -1
- package/lib/Player/modules/keyframes/VideoEffect/index.d.ts +2 -1
- package/lib/Player/modules/keyframes/VideoEffect/index.d.ts.map +1 -1
- package/lib/chunks/CSS3DRenderPlugin-CtnLUnu7.js +128 -0
- package/lib/chunks/CSS3DRenderPlugin-CtnLUnu7.js.map +1 -0
- package/lib/chunks/CameraMovementPlugin-YCaScSFU.js +77 -0
- package/lib/chunks/CameraMovementPlugin-YCaScSFU.js.map +1 -0
- package/lib/chunks/Player-BzRqdH4q.js +1581 -0
- package/lib/chunks/Player-BzRqdH4q.js.map +1 -0
- package/lib/chunks/VreoUnit-NhH1hdF1.js +17 -0
- package/lib/chunks/VreoUnit-NhH1hdF1.js.map +1 -0
- package/lib/chunks/timeline-DZs_svT3.js +37 -0
- package/lib/chunks/timeline-DZs_svT3.js.map +1 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts.map +1 -1
- package/lib/index.js +4 -12
- package/lib/plugins/CSS3DRenderPlugin.js +1 -115
- package/lib/plugins/CameraMovementPlugin.js +1 -6
- package/lib/plugins/ModelTVVideoPlugin.js +133 -161
- package/lib/plugins/ModelTVVideoPlugin.js.map +1 -1
- package/lib/react/index.js +40 -38
- package/lib/react/index.js.map +1 -1
- package/lib/shared-utils/animationFrame/BetterTween.d.ts.map +1 -1
- package/lib/shared-utils/createTransMatrix.d.ts.map +1 -1
- package/lib/types/index.js +1 -10
- package/package.json +8 -8
- package/LICENSE-UPDATE.txt +0 -5
- package/lib/Player/index.js.map +0 -1
- package/lib/chunks/index-BgPSzRSs.js +0 -93
- package/lib/chunks/index-BgPSzRSs.js.map +0 -1
- package/lib/chunks/index-CunyJn6H.js +0 -51
- package/lib/chunks/index-CunyJn6H.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/plugins/CSS3DRenderPlugin.js.map +0 -1
- package/lib/plugins/CameraMovementPlugin.js.map +0 -1
- package/lib/types/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/Drawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/Drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAmC9B,wBAAgB,MAAM,sBAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/PopUp/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/PopUp/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAsB9B,wBAAgB,KAAK,sBAGpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/ResizeObserver/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/ResizeObserver/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,wBAAgB,cAAc,sBAkB7B"}
|
|
@@ -3,13 +3,13 @@ import { VideoAgentMeshOptions } from './VideoAgentMesh';
|
|
|
3
3
|
export declare const VideoAgent: ((props: {
|
|
4
4
|
onClick?: () => void;
|
|
5
5
|
options?: VideoAgentMeshOptions;
|
|
6
|
-
}) =>
|
|
6
|
+
}) => React.JSX.Element) & React.NamedExoticComponent<{
|
|
7
7
|
onClick?: () => void;
|
|
8
8
|
options?: VideoAgentMeshOptions;
|
|
9
9
|
}> & {
|
|
10
10
|
readonly type: (props: {
|
|
11
11
|
onClick?: () => void;
|
|
12
12
|
options?: VideoAgentMeshOptions;
|
|
13
|
-
}) =>
|
|
13
|
+
}) => React.JSX.Element;
|
|
14
14
|
};
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { WaveAppearance } from '../../typings';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
export declare function Wave(props?: {
|
|
3
4
|
appearance?: WaveAppearance;
|
|
4
5
|
onClick?: () => void;
|
|
5
6
|
staticPrefix?: string;
|
|
6
|
-
}):
|
|
7
|
+
}): React.JSX.Element;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/Wave/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../resources/Player/modules/Wave/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAkE,MAAM,OAAO,CAAC;AAuDvF,wBAAgB,IAAI,CAAC,KAAK,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAC,qBA8BvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/BgMusic/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/BgMusic/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,wBAAgB,OAAO,sBA6CtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/CameraMovement/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/CameraMovement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,wBAAgB,cAAc,sBA8B7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/InfoPanel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/InfoPanel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAiG9B,wBAAgB,SAAS,sBA8ExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/ModelVideo/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/ModelVideo/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,wBAAgB,UAAU,sBAqFzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/PanoEffect/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/PanoEffect/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,wBAAgB,UAAU,sBAyFzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/PanoTextLabel/index.tsx"],"names":[],"mappings":"AA+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/PanoTextLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA+C9B;;GAEG;AACH,wBAAgB,aAAa,sBAyE5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/Prompter/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/Prompter/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,wBAAgB,QAAQ,sBAmDvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,wBAAgB,gBAAgB,sBAgG/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/VideoEffect/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../resources/Player/modules/keyframes/VideoEffect/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,wBAAgB,WAAW,sBA4G1B"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as e from "three/webgpu";
|
|
2
|
+
import { Scene as t, Vector3 as n } from "three/webgpu";
|
|
3
|
+
import { CSS3DObject as r, CSS3DRenderer as i } from "three/addons/renderers/CSS3DRenderer.js";
|
|
4
|
+
// resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts
|
|
5
|
+
function a(e, t) {
|
|
6
|
+
let n = Math.round(e);
|
|
7
|
+
return n % 2 == 0 ? n : n + Number(t?.smaller ? -1 : 1);
|
|
8
|
+
}
|
|
9
|
+
// resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts
|
|
10
|
+
function o(e, t) {
|
|
11
|
+
return new n((e.x + t.x) / 2, (e.y + t.y) / 2, (e.z + t.z) / 2);
|
|
12
|
+
}
|
|
13
|
+
// resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts
|
|
14
|
+
var s = ({ x: e, y: t, z: r }) => new n(e, t, r);
|
|
15
|
+
// resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts
|
|
16
|
+
function c(e, t) {
|
|
17
|
+
let n = !1;
|
|
18
|
+
if (!t || typeof ResizeObserver > "u") return {
|
|
19
|
+
observe() {
|
|
20
|
+
n || (n = !0, window.addEventListener("resize", e));
|
|
21
|
+
},
|
|
22
|
+
unobserve() {
|
|
23
|
+
n && (n = !1, window.removeEventListener("resize", e));
|
|
24
|
+
},
|
|
25
|
+
disconnect() {
|
|
26
|
+
n && (n = !1, window.removeEventListener("resize", e));
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
let r = new ResizeObserver(e);
|
|
30
|
+
return {
|
|
31
|
+
observe() {
|
|
32
|
+
n || (n = !0, r.observe(t));
|
|
33
|
+
},
|
|
34
|
+
unobserve() {
|
|
35
|
+
n && (n = !1, r.unobserve(t));
|
|
36
|
+
},
|
|
37
|
+
disconnect() {
|
|
38
|
+
n = !1, r.disconnect();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// resources/fivePlugins/CSS3DRenderPlugin/index.ts
|
|
43
|
+
var l = (l) => {
|
|
44
|
+
let u = { disposers: /* @__PURE__ */ new Set() }, d = (e, n) => {
|
|
45
|
+
let r = new t(), o = new i(), s = () => o.setSize(a(n.clientWidth, { smaller: !0 }), a(n.clientHeight, { smaller: !0 }));
|
|
46
|
+
s();
|
|
47
|
+
let u = c(s, n);
|
|
48
|
+
o.domElement.style.position = "absolute", o.domElement.style.top = "0", o.domElement.style.userSelect = "none", o.domElement.style.pointerEvents = "none", e.appendChild(o.domElement);
|
|
49
|
+
let d = !1, f, p = {
|
|
50
|
+
scene: r,
|
|
51
|
+
renderer: o,
|
|
52
|
+
entries: /* @__PURE__ */ new Set(),
|
|
53
|
+
start() {
|
|
54
|
+
if (d) return;
|
|
55
|
+
d = !0, u.observe();
|
|
56
|
+
let e = () => {
|
|
57
|
+
d && (o.render(r, l.camera), f = requestAnimationFrame(e));
|
|
58
|
+
};
|
|
59
|
+
e();
|
|
60
|
+
},
|
|
61
|
+
stop() {
|
|
62
|
+
d && (d = !1, f !== void 0 && cancelAnimationFrame(f), f = void 0, u.unobserve());
|
|
63
|
+
},
|
|
64
|
+
dispose() {
|
|
65
|
+
p.stop(), u.disconnect(), o.domElement.remove();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return p;
|
|
69
|
+
}, f = (...e) => {
|
|
70
|
+
let t = e[0].map((e) => e instanceof n ? e : s(e)), r = e[1];
|
|
71
|
+
if (t.length < 4) return console.error("points must be equal or greater than 4");
|
|
72
|
+
if (!l.model.loaded) return console.error("five.model.loaded is false");
|
|
73
|
+
let i = l.getElement();
|
|
74
|
+
if (!i) return console.error("five.getElement() is empty");
|
|
75
|
+
let a = r?.ratio ?? .00216;
|
|
76
|
+
a <= .00215 && console.warn("if you need click css3DElement on safari, ratio must be greater than 0.00215");
|
|
77
|
+
let o = r?.dpr ?? 1, c = r?.mode ?? "front", f = r?.autoRender ?? !0, m = r?.container ?? document.createElement("div");
|
|
78
|
+
m.classList.add("__Dnalogel-plugin--CSS3DRenderPlugin");
|
|
79
|
+
let { css3DObject: h, mesh: g } = p(t, {
|
|
80
|
+
ratio: a,
|
|
81
|
+
dpr: o,
|
|
82
|
+
container: m,
|
|
83
|
+
mode: c
|
|
84
|
+
}), _ = c === "behind" ? u.behind : u.front;
|
|
85
|
+
if (!_) {
|
|
86
|
+
let e = c === "behind" ? r?.behindFiveContainer ?? i.parentElement ?? document.body : i.parentElement ?? document.body;
|
|
87
|
+
_ = d(e, i), c === "behind" ? u.behind = _ : u.front = _;
|
|
88
|
+
}
|
|
89
|
+
let v = {};
|
|
90
|
+
_.entries.add(v);
|
|
91
|
+
let y = !1, b = !1, x = () => {
|
|
92
|
+
b || y || (y = !0, _.scene.add(h), g && l.scene.add(g), _.start());
|
|
93
|
+
}, S = () => {
|
|
94
|
+
b || (b = !0, u.disposers.delete(S), _.entries.delete(v), y && (_.scene.remove(h), g && l.scene.remove(g)), g?.geometry.dispose(), g?.material.dispose(), _.scene.children.length === 0 && _.stop(), _.entries.size === 0 && (_.dispose(), c === "behind" && u.behind === _ && (u.behind = void 0), c === "front" && u.front === _ && (u.front = void 0)));
|
|
95
|
+
};
|
|
96
|
+
return u.disposers.add(S), f && x(), {
|
|
97
|
+
container: m,
|
|
98
|
+
dispose: S,
|
|
99
|
+
css3DObject: h,
|
|
100
|
+
render: f ? void 0 : x
|
|
101
|
+
};
|
|
102
|
+
}, p = (t, i) => {
|
|
103
|
+
let { ratio: s, dpr: c, container: l, mode: u } = i, d = t[0].distanceTo(t[1]), f = t[1].distanceTo(t[2]), p = a(d / s * c), m = a(f / s * c), h = new r(l);
|
|
104
|
+
h.scale.set(s, s, s), l.style.width = p + "px", l.style.height = m + "px", l.style.pointerEvents = "none";
|
|
105
|
+
let g = o(t[0], t[2]), _ = t[1].clone().sub(t[0]), v = t[2].clone().sub(t[1]), y = new n(0, 1, 0).angleTo(new n(0, v.y, v.z)), b = new n(1, 0, 0).angleTo(new n(_.x, 0, _.z)), x = _.angleTo(new n(_.x, 0, _.z)), S = (v.z > 0 ? -1 : 1) * y, C = (_.z < 0 ? 1 : -1) * b, w = (_.x > 0 && _.y < 0 || _.x < 0 && _.y > 0 ? -1 : 1) * x;
|
|
106
|
+
h.rotateOnWorldAxis(new n(1, 0, 0), S), h.rotateOnWorldAxis(new n(0, 1, 0), C), h.rotateOnWorldAxis(new n(0, 0, 1), w), h.position.set(g.x, g.y, g.z);
|
|
107
|
+
let T;
|
|
108
|
+
if (u === "behind") {
|
|
109
|
+
let t = new e.MeshBasicNodeMaterial({
|
|
110
|
+
opacity: 0,
|
|
111
|
+
transparent: !1,
|
|
112
|
+
side: e.DoubleSide
|
|
113
|
+
}), n = new e.PlaneGeometry(p, m);
|
|
114
|
+
T = new e.Mesh(n, t), T.name = "CSS3DRenderPlugin-mesh", T.position.copy(h.position), T.rotation.copy(h.rotation), T.scale.copy(h.scale);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
css3DObject: h,
|
|
118
|
+
mesh: T
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
create3DDomContainer: f,
|
|
123
|
+
disposeAll: () => [...u.disposers].forEach((e) => e())
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export { l as t };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=CSS3DRenderPlugin-CtnLUnu7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CSS3DRenderPlugin-CtnLUnu7.js","names":["THREE","evenNumber","roundNum","num","config","centerPoint","Vector3","point1","point2","transformPositionToVector3","x","y","z","createResizeObserver","observing","element","callback","observer","CSS3DRenderPlugin","state","createLayer","scene","Scene","renderer","CSS3DRenderer","setSize","fiveElement","resize","wrapper","running","frame","layer","render","five","create3DDomContainer","params","points","point","ratio","dpr","mode","autoRender","container","createObject","entry","rendered","disposed","css3DObject","mesh","dispose","planeWidth","planeHeight","domWidthPx","domHeightPx","CSS3DObject","centerPosition","vector01","vector12","rotateXAngle","rotateYAngle","rotateZAngle","rotateX","rotateY","rotateZ","material","geometry"],"sources":["../../resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts","../../resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts","../../resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts","../../resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts","../../resources/fivePlugins/CSS3DRenderPlugin/index.ts"],"sourcesContent":["export default function evenNumber(num: number, config?: { smaller?: boolean }): number {\n const roundNum = Math.round(num)\n return roundNum % 2 === 0 ? roundNum : roundNum + Number(config?.smaller ? -1 : 1)\n}\n","import { Vector3 } from 'three/webgpu'\n\nexport default function centerPoint(point1: Vector3, point2: Vector3): Vector3 {\n return new Vector3((point1.x + point2.x) / 2, (point1.y + point2.y) / 2, (point1.z + point2.z) / 2)\n}\n","import { Vector3 } from 'three/webgpu'\n\nconst transformPositionToVector3 = ({ x, y, z }: { x: number; y: number; z: number }) => new Vector3(x, y, z)\n\nexport default transformPositionToVector3\n","export default function createResizeObserver(callback: () => void, element?: HTMLElement) {\n let observing = false\n if (!element || typeof ResizeObserver === 'undefined') {\n return {\n observe() {\n if (observing) return\n observing = true\n window.addEventListener('resize', callback)\n },\n unobserve() {\n if (!observing) return\n observing = false\n window.removeEventListener('resize', callback)\n },\n disconnect() {\n if (!observing) return\n observing = false\n window.removeEventListener('resize', callback)\n },\n }\n }\n\n const observer = new ResizeObserver(callback)\n return {\n observe() {\n if (observing) return\n observing = true\n observer.observe(element)\n },\n unobserve() {\n if (!observing) return\n observing = false\n observer.unobserve(element)\n },\n disconnect() {\n observing = false\n observer.disconnect()\n },\n }\n}\n","import { FivePlugin } from '@realsee/five-webgpu'\nimport * as THREE from 'three/webgpu'\nimport { Scene, Vector3 } from 'three/webgpu'\nimport { CSS3DObject, CSS3DRenderer } from 'three/addons/renderers/CSS3DRenderer.js'\nimport evenNumber from './evenNumber'\nimport centerPoint from './centerPoint'\nimport transformPositionToVector3 from './transformPositionToVector3'\nimport createResizeObserver from './createResizeObserver'\n\nexport interface Vector3Position {\n x: number\n y: number\n z: number\n}\n\nexport type CSS3DRenderPluginParameterType = undefined\nexport interface CSS3DRenderPluginExportType {\n create3DDomContainer: (\n points: Vector3[] | Vector3Position[],\n config?: { ratio?: number; dpr?: number; autoRender?: boolean; container?: HTMLElement; [key: string]: any } & (\n | { mode?: 'front' }\n | { mode: 'behind'; behindFiveContainer: HTMLElement }\n ),\n ) => { container: HTMLElement; dispose: () => void; css3DObject: CSS3DObject; render?: () => void } | void\n disposeAll: () => void\n}\n\ntype CreateContainer = CSS3DRenderPluginExportType['create3DDomContainer']\ntype CreateContainerConfig = NonNullable<Parameters<CreateContainer>[1]>\ninterface RenderLayer {\n scene: Scene\n renderer: CSS3DRenderer\n entries: Set<object>\n start: () => void\n stop: () => void\n dispose: () => void\n}\ninterface CSS3DRenderPluginState {\n disposers: Set<() => void>\n front?: RenderLayer\n behind?: RenderLayer\n}\n\n/** Renders DOM overlays in a Five scene. One renderer is shared by each front/behind layer. */\nexport const CSS3DRenderPlugin: FivePlugin<CSS3DRenderPluginParameterType, CSS3DRenderPluginExportType> = (five) => {\n const state: CSS3DRenderPluginState = { disposers: new Set() }\n\n const createLayer = (wrapper: HTMLElement, fiveElement: HTMLElement): RenderLayer => {\n const scene = new Scene()\n const renderer = new CSS3DRenderer()\n const setSize = () => renderer.setSize(\n evenNumber(fiveElement.clientWidth, { smaller: true }),\n evenNumber(fiveElement.clientHeight, { smaller: true }),\n )\n setSize()\n const resize = createResizeObserver(setSize, fiveElement)\n renderer.domElement.style.position = 'absolute'\n renderer.domElement.style.top = '0'\n renderer.domElement.style.userSelect = 'none'\n renderer.domElement.style.pointerEvents = 'none'\n wrapper.appendChild(renderer.domElement)\n\n let running = false\n let frame: number | undefined\n const layer: RenderLayer = {\n scene,\n renderer,\n entries: new Set(),\n start() {\n if (running) return\n running = true\n resize.observe()\n const render = () => {\n if (!running) return\n renderer.render(scene, five.camera)\n frame = requestAnimationFrame(render)\n }\n render()\n },\n stop() {\n if (!running) return\n running = false\n if (frame !== undefined) cancelAnimationFrame(frame)\n frame = undefined\n resize.unobserve()\n },\n dispose() {\n layer.stop()\n resize.disconnect()\n renderer.domElement.remove()\n },\n }\n return layer\n }\n\n const create3DDomContainer = (...params: Parameters<CreateContainer>): ReturnType<CreateContainer> => {\n const points = params[0].map(point => point instanceof Vector3 ? point : transformPositionToVector3(point))\n const config = params[1]\n if (points.length < 4) return console.error('points must be equal or greater than 4')\n if (!five.model.loaded) return console.error('five.model.loaded is false')\n const fiveElement = five.getElement()\n if (!fiveElement) return console.error('five.getElement() is empty')\n\n const ratio = config?.ratio ?? 0.00216\n if (ratio <= 0.00215) console.warn('if you need click css3DElement on safari, ratio must be greater than 0.00215')\n const dpr = config?.dpr ?? 1\n const mode = config?.mode ?? 'front'\n const autoRender = config?.autoRender ?? true\n const container = config?.container ?? document.createElement('div')\n container.classList.add('__Dnalogel-plugin--CSS3DRenderPlugin')\n const { css3DObject, mesh } = createObject(points, { ratio, dpr, container, mode })\n\n let layer = mode === 'behind' ? state.behind : state.front\n if (!layer) {\n const wrapper = mode === 'behind'\n ? config?.behindFiveContainer ?? fiveElement.parentElement ?? document.body\n : fiveElement.parentElement ?? document.body\n layer = createLayer(wrapper, fiveElement)\n if (mode === 'behind') state.behind = layer\n else state.front = layer\n }\n\n const entry = {}\n layer.entries.add(entry)\n let rendered = false\n let disposed = false\n const render = () => {\n if (disposed || rendered) return\n rendered = true\n layer!.scene.add(css3DObject)\n if (mesh) five.scene.add(mesh)\n layer!.start()\n }\n const dispose = () => {\n if (disposed) return\n disposed = true\n state.disposers.delete(dispose)\n layer!.entries.delete(entry)\n if (rendered) {\n layer!.scene.remove(css3DObject)\n if (mesh) five.scene.remove(mesh)\n }\n mesh?.geometry.dispose()\n mesh?.material.dispose()\n if (layer!.scene.children.length === 0) layer!.stop()\n if (layer!.entries.size === 0) {\n layer!.dispose()\n if (mode === 'behind' && state.behind === layer) state.behind = undefined\n if (mode === 'front' && state.front === layer) state.front = undefined\n }\n }\n state.disposers.add(dispose)\n if (autoRender) render()\n return { container, dispose, css3DObject, render: autoRender ? undefined : render }\n }\n\n const createObject = (\n points: Vector3[],\n config: Required<Pick<CreateContainerConfig, 'ratio' | 'dpr' | 'container'>> & Pick<CreateContainerConfig, 'mode'>,\n ) => {\n const { ratio, dpr, container: element, mode } = config\n const planeWidth = points[0].distanceTo(points[1])\n const planeHeight = points[1].distanceTo(points[2])\n const domWidthPx = evenNumber((planeWidth / ratio) * dpr)\n const domHeightPx = evenNumber((planeHeight / ratio) * dpr)\n const css3DObject = new CSS3DObject(element)\n css3DObject.scale.set(ratio, ratio, ratio)\n element.style.width = domWidthPx + 'px'\n element.style.height = domHeightPx + 'px'\n element.style.pointerEvents = 'none'\n\n const centerPosition = centerPoint(points[0], points[2])\n const vector01 = points[1].clone().sub(points[0])\n const vector12 = points[2].clone().sub(points[1])\n const rotateXAngle = new Vector3(0, 1, 0).angleTo(new Vector3(0, vector12.y, vector12.z))\n const rotateYAngle = new Vector3(1, 0, 0).angleTo(new Vector3(vector01.x, 0, vector01.z))\n const rotateZAngle = vector01.angleTo(new Vector3(vector01.x, 0, vector01.z))\n const rotateX = (vector12.z > 0 ? -1 : 1) * rotateXAngle\n const rotateY = (vector01.z < 0 ? 1 : -1) * rotateYAngle\n const rotateZ = ((vector01.x > 0 && vector01.y < 0) || (vector01.x < 0 && vector01.y > 0) ? -1 : 1) * rotateZAngle\n css3DObject.rotateOnWorldAxis(new Vector3(1, 0, 0), rotateX)\n css3DObject.rotateOnWorldAxis(new Vector3(0, 1, 0), rotateY)\n css3DObject.rotateOnWorldAxis(new Vector3(0, 0, 1), rotateZ)\n css3DObject.position.set(centerPosition.x, centerPosition.y, centerPosition.z)\n\n let mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.MeshBasicNodeMaterial> | undefined\n if (mode === 'behind') {\n const material = new THREE.MeshBasicNodeMaterial({ opacity: 0, transparent: false, side: THREE.DoubleSide })\n const geometry = new THREE.PlaneGeometry(domWidthPx, domHeightPx)\n mesh = new THREE.Mesh(geometry, material)\n mesh.name = 'CSS3DRenderPlugin-mesh'\n mesh.position.copy(css3DObject.position)\n mesh.rotation.copy(css3DObject.rotation)\n mesh.scale.copy(css3DObject.scale)\n }\n return { css3DObject, mesh }\n }\n\n return {\n create3DDomContainer,\n disposeAll: () => [...state.disposers].forEach(dispose => dispose()),\n }\n}\n\nexport default CSS3DRenderPlugin\n"],"mappings":";;;;AAAA,SAAwBC,EAAW,GAAa,GAAwC;CACtF,IAAMC,IAAW,KAAK,MAAMC,CAAG;CAC/B,OAAOD,IAAW,KAAM,IAAIA,IAAWA,IAAW,OAAOE,GAAQ,UAAU,KAAK,CAAC;AACnF;;ACDA,SAAwBC,EAAY,GAAiB,GAA0B;CAC7E,OAAO,IAAIC,GAASC,EAAO,IAAIC,EAAO,KAAK,IAAID,EAAO,IAAIC,EAAO,KAAK,IAAID,EAAO,IAAIC,EAAO,KAAK,CAAC;AACpG;;ACFA,IAAMC,KAA8B,EAAE,MAAG,MAAG,WAA6C,IAAIH,EAAQI,GAAGC,GAAGC,CAAC;;ACF5G,SAAwBC,EAAqB,GAAsB,GAAuB;CACxF,IAAIC,IAAY;CAChB,IAAI,CAACC,KAAW,OAAO,iBAAmB,KACxC,OAAO;EACL,UAAU;GACR,AAAID,MACJ,IAAY,IACZ,OAAO,iBAAiB,UAAUE,CAAQ;EAC5C;EACA,YAAY;GACV,AAAKF,MACL,IAAY,IACZ,OAAO,oBAAoB,UAAUE,CAAQ;EAC/C;EACA,aAAa;GACX,AAAKF,MACL,IAAY,IACZ,OAAO,oBAAoB,UAAUE,CAAQ;EAC/C;CACF;CAGF,IAAMC,IAAW,IAAI,eAAeD,CAAQ;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A,kBAAkB,CAAC,GAAG5B,EAAM,SAAS,CAAC,CAAC,SAAQ,MAAW8B,EAAQ,CAAC;CACrE;AACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Five as e } from "@realsee/five-webgpu";
|
|
2
|
+
// resources/fivePlugins/CameraMovementPlugin/typings.ts
|
|
3
|
+
var t = /* @__PURE__ */ function(e) {
|
|
4
|
+
return e.Move = "Move", e.Rotate = "Rotate", e;
|
|
5
|
+
}({}), n = /* @__PURE__ */ function(e) {
|
|
6
|
+
return e.Clockwise = "Clockwise", e.Anticlockwise = "Anticlockwise", e.Loop = "Loop", e;
|
|
7
|
+
}({}), r = Math.PI * 2, i = !1;
|
|
8
|
+
function a(e, t, n) {
|
|
9
|
+
return e === t ? e : e + (t - e) * n;
|
|
10
|
+
}
|
|
11
|
+
function o(e, t, i, a) {
|
|
12
|
+
let o = i === n.Clockwise, s = (o ? e - t : t - e) % r, c = s < 0 ? s + r : s;
|
|
13
|
+
return (e + (o ? -c : c) * a) % r;
|
|
14
|
+
}
|
|
15
|
+
var s = (t) => ({
|
|
16
|
+
move: (n, r, a = { preload: !0 }) => new Promise(async (o, s) => {
|
|
17
|
+
if (i = !0, a.asyncStartCallback && a.asyncStartCallback(), t.panoIndex === void 0) return s(!1);
|
|
18
|
+
if (n.mode && n.mode !== t.currentMode) return await t.changeMode(n.mode, n, r), o(!0);
|
|
19
|
+
if (n.mode === e.Mode.Floorplan || (a.preload && n.panoIndex !== void 0 && n.panoIndex !== t.panoIndex && await t.preloadPano(n.panoIndex), a.asyncEndCallback?.(), n.panoIndex === void 0 && n.fov === void 0 && n.latitude === void 0 && n.longitude === void 0)) return o(!0);
|
|
20
|
+
let c = n.panoIndex === void 0 ? t.panoIndex : n.panoIndex;
|
|
21
|
+
if (c !== void 0) {
|
|
22
|
+
let e = performance.now();
|
|
23
|
+
await t.ready();
|
|
24
|
+
let i = Object.assign({}, n, {
|
|
25
|
+
duration: r - (performance.now() - e),
|
|
26
|
+
moveEndCallback: () => o(!0),
|
|
27
|
+
moveCancelCallback: () => {
|
|
28
|
+
o(!0);
|
|
29
|
+
},
|
|
30
|
+
effect: n.transEffect || "fly"
|
|
31
|
+
});
|
|
32
|
+
await t.moveToPano(c, i);
|
|
33
|
+
} else s(!1);
|
|
34
|
+
}),
|
|
35
|
+
rotate: async (r, s, c = {}) => {
|
|
36
|
+
i = !1, c.asyncStartCallback?.(), r.mode && t.currentMode !== r.mode && await t.changeMode(r.mode, r.mode === e.Mode.Panorama ? { latitude: 0 } : void 0), r.mode === e.Mode.Panorama && t.currentMode === e.Mode.Panorama && r.panoIndex !== void 0 && r.panoIndex !== t.panoIndex && (c.preload && await t.preloadPano(r.panoIndex), await new Promise((e, n) => {
|
|
37
|
+
t.moveToPano(r.panoIndex, {
|
|
38
|
+
moveEndCallback: () => e(!0),
|
|
39
|
+
moveCancelCallback: () => n(!1),
|
|
40
|
+
effect: "fade"
|
|
41
|
+
});
|
|
42
|
+
})), await t.ready(), c.asyncEndCallback?.();
|
|
43
|
+
let l = t.getCurrentState(), u = r, d = !1, f = performance.now(), p = s;
|
|
44
|
+
r.rotation === n.Loop && (p = r.rotateSpeed ? Math.ceil(Math.abs(u.longitude - l.longitude) / r.rotateSpeed * 1e3) : s, p = Math.min(s, p));
|
|
45
|
+
let m = () => {
|
|
46
|
+
if (d || i) {
|
|
47
|
+
t.off("renderFrame", m);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let e = {};
|
|
51
|
+
if (r.rotation !== n.Loop) {
|
|
52
|
+
let t = (performance.now() - f) / s;
|
|
53
|
+
e = {
|
|
54
|
+
fov: a(l.fov, u.fov, t),
|
|
55
|
+
latitude: a(l.latitude, u.latitude, t),
|
|
56
|
+
longitude: o(l.longitude, u.longitude, r.rotation, t)
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
let t = (performance.now() - f) / p, n = Math.floor(t), r = t - n, i = n % 2 == 1 ? 1 - r : r;
|
|
60
|
+
e = {
|
|
61
|
+
fov: a(l.fov, u.fov, i),
|
|
62
|
+
latitude: a(l.latitude, u.latitude, i),
|
|
63
|
+
longitude: a(l.longitude, u.longitude, i)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
t.setState(e, !0);
|
|
67
|
+
};
|
|
68
|
+
return t.on("renderFrame", m), await new Promise((e) => {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
d = !0, t.off("renderFrame", m), e(!0);
|
|
71
|
+
}, s);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
export { t as n, s as t };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=CameraMovementPlugin-YCaScSFU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraMovementPlugin-YCaScSFU.js","names":["CameraMovementEffect","\"Move\"","\"Rotate\"","Rotation","\"Clockwise\"","\"Anticlockwise\"","\"Loop\"","PI_2","moving","progressNumber","from","to","pst","progressLongitude","clockwise","rotation","deltaMod","fromLongitude","toLongitude","deltaMod2","progress","CameraMovementPlugin","opts","five","reject","args","duration","resolve","Five","panoIndex","start","movePanoOptions","timeEnd","animeDuration","onFiveRenderFrame","targetState","times","progress2","resultProgress"],"sources":["../../resources/fivePlugins/CameraMovementPlugin/typings.ts","../../resources/fivePlugins/CameraMovementPlugin/index.ts"],"sourcesContent":["/* eslint-disable prettier/prettier */\nimport { Mode, MovePanoOptions, Pose } from '@realsee/five-webgpu'\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface CameraMovementPluginParameterType { }\n\nexport interface CameraMovementPluginExportType {\n /**\n * 运镜:移动\n * @param moveArgs\n * @param duration\n * @param opts\n */\n move(moveArgs: Partial<MoveArgs>, duration: number, opts?: MoveOpts): Promise<boolean>\n /**\n * 运镜:旋转\n * @param args\n * @param duration\n * @param opts\n */\n rotate(args: RotateArgs, duration: number, opts?: RotateOpts): Promise<boolean>\n}\n\nexport enum CameraMovementEffect {\n Move = 'Move',\n Rotate = 'Rotate',\n}\nexport enum Rotation {\n Clockwise = 'Clockwise',\n Anticlockwise = 'Anticlockwise',\n Loop = 'Loop',\n}\n\nexport interface CameraMovementOptsCallback {\n asyncStartCallback?: () => void\n asyncEndCallback?: () => void\n}\n\nexport type MoveArgs = {\n mode: Mode\n panoIndex: number\n transEffect?: \"fly\" | \"fade\" | \"instant\"\n} & Pose\n\nexport type MoveOpts = {\n preload?: boolean\n} & CameraMovementOptsCallback\n\nexport type RotateArgs = {\n mode?: Mode\n panoIndex: number\n loop: boolean\n rotateSpeed: number\n rotation: Rotation\n} & Pose\n\nexport type RotateOpts = {\n preload?: boolean\n} & CameraMovementOptsCallback\n","import { Five, MovePanoOptions } from '@realsee/five-webgpu'\nimport type { FivePlugin } from '@realsee/five-webgpu'\n\nimport {\n CameraMovementPluginParameterType,\n CameraMovementPluginExportType,\n MoveArgs,\n MoveOpts,\n RotateArgs,\n RotateOpts,\n Rotation,\n} from './typings'\n\nconst PI = Math.PI\nconst PI_2 = PI * 2\nlet moving = false // five 6 神秘bug, move 的时候不能 setState\n\nfunction progressNumber(from: number, to: number, pst: number) {\n if (from === to) return from\n return from + (to - from) * pst\n}\n\nfunction progressLongitude(fromLongitude: number, toLongitude: number, rotation: Rotation, progress: number): number {\n const clockwise = rotation === Rotation.Clockwise\n const delta = clockwise ? fromLongitude - toLongitude : toLongitude - fromLongitude\n const deltaMod = delta % PI_2\n const deltaMod2 = deltaMod < 0 ? deltaMod + PI_2 : deltaMod\n const deltaMod3 = clockwise ? -deltaMod2 : deltaMod2\n const progressLongitude = fromLongitude + deltaMod3 * progress\n return progressLongitude % PI_2\n}\n\n/**\n * **运镜插件** 模拟类似于电影运镜效果。\n */\nexport const CameraMovementPlugin: FivePlugin<CameraMovementPluginParameterType, CameraMovementPluginExportType> = (\n five: Five,\n) => {\n\n const move = (args: Partial<MoveArgs>, duration: number, opts: MoveOpts = { preload: true }) => {\n return new Promise<boolean>(async (resolve, reject) => {\n moving = true\n if (opts.asyncStartCallback) {\n opts.asyncStartCallback()\n }\n\n if (five.panoIndex === undefined) {\n return reject(false)\n }\n\n if (args.mode && args.mode !== five.currentMode) {\n await five.changeMode(args.mode, args, duration)\n return resolve(true)\n }\n\n // 模型态不能 move\n if (args.mode === Five.Mode.Floorplan) {\n return resolve(true)\n }\n\n if (opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex) {\n await five.preloadPano(args.panoIndex)\n }\n\n opts.asyncEndCallback?.()\n\n if (\n args.panoIndex === undefined &&\n args.fov === undefined &&\n args.latitude === undefined &&\n args.longitude === undefined\n ) {\n return resolve(true)\n }\n\n\n const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex\n\n if (panoIndex !== undefined) {\n const start = performance.now()\n await five.ready()\n const movePanoOptions: MovePanoOptions = Object.assign({}, args, {\n duration: duration - (performance.now() - start), // 移动耗时\n moveEndCallback: () => resolve(true), // 移动结束\n moveCancelCallback: () => {\n resolve(true)\n }, // 移动开始\n effect: args.transEffect || 'fly',\n })\n await five.moveToPano(\n panoIndex,\n movePanoOptions,\n )\n } else {\n reject(false)\n }\n })\n }\n\n const rotate = async (args: RotateArgs, duration: number, opts: RotateOpts = {}) => {\n moving = false\n opts.asyncStartCallback?.()\n\n // 先切换模型再出旋转效果\n if (args.mode && five.currentMode !== args.mode) {\n await five.changeMode(args.mode, args.mode === Five.Mode.Panorama ? {latitude: 0} : undefined)\n }\n\n // 全景状态下,需要点位对齐\n if (args.mode === Five.Mode.Panorama &&\n five.currentMode === Five.Mode.Panorama &&\n args.panoIndex !== undefined &&\n args.panoIndex !== five.panoIndex) {\n if (opts.preload) await five.preloadPano(args.panoIndex)\n await new Promise((resolve, reject) => {\n five.moveToPano(args.panoIndex, {\n moveEndCallback: () => resolve(true), // 移动结束\n moveCancelCallback: () => reject(false), // 移动开始\n effect: 'fade',\n })\n })\n }\n\n await five.ready()\n\n opts.asyncEndCallback?.()\n\n // 计算to\n const from = five.getCurrentState()\n const to = (() => {\n return args\n })()\n\n let timeEnd = false\n\n // 开始时间\n const start = performance.now()\n\n let animeDuration = duration\n\n if (args.rotation === Rotation.Loop) {\n animeDuration = args.rotateSpeed\n ? Math.ceil((Math.abs(to.longitude - from.longitude) / args.rotateSpeed) * 1000)\n : duration\n animeDuration = Math.min(duration, animeDuration)\n }\n\n const onFiveRenderFrame = () => {\n if (timeEnd || moving) {\n five.off('renderFrame', onFiveRenderFrame)\n return\n }\n \n let targetState = {}\n \n if (args.rotation !== Rotation.Loop) {\n const progress = (performance.now() - start) / duration\n targetState = {\n fov: progressNumber(from.fov, to.fov, progress),\n latitude: progressNumber(from.latitude, to.latitude, progress),\n longitude: progressLongitude(from.longitude, to.longitude, args.rotation, progress)\n }\n } else {\n const progress = (performance.now() - start) / animeDuration // 可能大于1\n const times = Math.floor(progress)\n const progress2 = progress - times // 一定小于1\n const isNegative = times % 2 === 1 // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推\n const resultProgress = isNegative ? 1 - progress2 : progress2\n targetState = {\n fov: progressNumber(from.fov, to.fov, resultProgress),\n latitude: progressNumber(from.latitude, to.latitude, resultProgress),\n longitude: progressNumber(from.longitude, to.longitude, resultProgress)\n }\n }\n\n five.setState(targetState, true)\n }\n \n five.on('renderFrame', onFiveRenderFrame)\n\n return await new Promise<boolean>((resolve) => {\n setTimeout(() => {\n timeEnd = true\n five.off('renderFrame', onFiveRenderFrame)\n // 总时间到了之后强制结束,同时也是 Loop 模式的结束方式\n resolve(true)\n }, duration)\n })\n }\n\n return {\n move,\n rotate,\n }\n}\n"],"mappings":";;AAuBA,IAAYA,IAAL,yBAAA,GAAA;C,OACL,EAAAC,OAAA,QACA,EAAAC,SAAA,U;AACF,EAAA,CAAA,CAAA,GACYC,IAAL,yBAAA,GAAA;C,OACL,EAAAC,YAAA,aACA,EAAAC,gBAAA,iBACA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA,GCjBMC,IADK,KAAK,KACE,GACdC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