@realsee/vreo 0.2.0-alpha.2 → 0.2.0-alpha.20

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 (147) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +80 -5
  3. package/docs/assets/custom.css +2 -2
  4. package/docs/assets/highlight.css +1 -1
  5. package/docs/assets/main.js +2 -2
  6. package/docs/assets/search.js +1 -1
  7. package/docs/assets/style.css +28 -2
  8. package/docs/classes/Player.AudioLike.html +52 -0
  9. package/docs/classes/Player.Controller.html +13 -13
  10. package/docs/classes/Player.Player-1.html +11 -11
  11. package/docs/classes/Player.VideoAgentMesh.html +53 -53
  12. package/docs/classes/Player.VideoAgentScene.html +1 -1
  13. package/docs/demo/assets/AppReact.ec0a6e82.js +1 -0
  14. package/docs/demo/assets/default.55c3f308.css +1 -0
  15. package/docs/demo/assets/default.a5d6dd99.js +3952 -0
  16. package/docs/demo/assets/dynamic.8c30b7ae.js +1 -0
  17. package/docs/demo/assets/examples.dac4a6fe.css +1 -0
  18. package/docs/demo/assets/examples.ddb41c97.js +25 -0
  19. package/docs/demo/assets/index.a7bafdff.css +1 -0
  20. package/docs/demo/assets/index.fc42be2b.js +1 -0
  21. package/docs/demo/assets/main.d119ebf7.js +1 -0
  22. package/docs/demo/assets/react.2d403aee.js +25 -0
  23. package/docs/demo/assets/react.855b3d23.css +1 -0
  24. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
  25. package/docs/demo/examples.html +17 -0
  26. package/docs/demo/index-react-dynamic.html +20 -0
  27. package/docs/demo/index-react.html +20 -0
  28. package/docs/demo/index.html +19 -0
  29. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -0
  30. package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
  31. package/docs/enums/Player.PanoEffectEnum.html +2 -2
  32. package/docs/enums/Player.PanoTagEnum.html +2 -2
  33. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  34. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  35. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  36. package/docs/enums/fivePlugins.Rotation.html +1 -1
  37. package/docs/index.html +37 -6
  38. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  39. package/docs/interfaces/Player.PlayerConfigs.html +3 -3
  40. package/docs/interfaces/Player.Vertex.html +2 -2
  41. package/docs/interfaces/Player.VideoAgentMeshOptions.html +8 -1
  42. package/docs/interfaces/Player.VreoKeyframe.html +2 -2
  43. package/docs/interfaces/Player.VreoUnit.html +2 -2
  44. package/docs/interfaces/Player.VreoVideo.html +2 -2
  45. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
  46. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  47. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  48. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
  49. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  50. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  51. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  52. package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
  53. package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
  54. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  55. package/docs/modules/Player.html +21 -15
  56. package/docs/modules/custom.html +1 -1
  57. package/docs/modules/fivePlugins.html +5 -2
  58. package/docs/modules/react.html +1 -1
  59. package/docs/modules.html +1 -1
  60. package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
  61. package/lib/PlayController/createHTMLAudioElement.js +47 -0
  62. package/lib/PlayController/index.d.ts +38 -0
  63. package/lib/PlayController/index.js +300 -0
  64. package/lib/Player/App.js +5 -4
  65. package/lib/Player/Controller.d.ts +5 -1
  66. package/lib/Player/Controller.js +38 -5
  67. package/lib/Player/custom/SpatialScenePanel/index.d.ts +2 -2
  68. package/lib/Player/custom/SpatialScenePanel/index.js +98 -26
  69. package/lib/Player/index.d.ts +3 -2
  70. package/lib/Player/index.js +116 -24
  71. package/lib/Player/modules/Drawer/index.js +1 -1
  72. package/lib/Player/modules/PopUp/index.d.ts +2 -0
  73. package/lib/Player/modules/PopUp/index.js +43 -0
  74. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +17 -2
  75. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +113 -37
  76. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +5 -1
  77. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +9 -4
  78. package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
  79. package/lib/Player/modules/VideoAgent/index.js +2 -2
  80. package/lib/Player/modules/keyframes/BgMusic/index.js +1 -1
  81. package/lib/Player/modules/keyframes/CameraMovement/index.js +42 -6
  82. package/lib/Player/modules/keyframes/InfoPanel/index.js +74 -36
  83. package/lib/Player/modules/keyframes/ModelVideo/index.js +46 -9
  84. package/lib/Player/modules/keyframes/PanoEffect/index.js +1 -1
  85. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -1
  86. package/lib/Player/modules/keyframes/PanoTag/index.js +20 -7
  87. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
  88. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +96 -51
  89. package/lib/Player/modules/keyframes/Prompter/index.js +5 -19
  90. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +31 -19
  91. package/lib/Player/modules/keyframes/VideoEffect/index.js +1 -1
  92. package/lib/Player/typings.d.ts +6 -0
  93. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
  94. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +12 -0
  95. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
  96. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +32 -0
  97. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
  98. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +11 -0
  99. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
  100. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +275 -0
  101. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
  102. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +18 -0
  103. package/lib/fivePlugins/CameraMovementPlugin/index.js +104 -90
  104. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +1 -0
  105. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +1 -1
  106. package/lib/react/index.d.ts +7 -3
  107. package/lib/react/index.js +3 -3
  108. package/lib/shared-utils/AduioLike.d.ts +37 -0
  109. package/lib/shared-utils/AduioLike.js +165 -0
  110. package/lib/shared-utils/animationFrame/BetterTween.js +7 -3
  111. package/lib/shared-utils/animationFrame/tween.js +1 -1
  112. package/lib/shared-utils/createTransMatrix.d.ts +1 -0
  113. package/lib/shared-utils/createTransMatrix.js +43 -0
  114. package/lib/typings/VreoUnit.d.ts +42 -5
  115. package/lib/typings/VreoUnit.js +26 -6
  116. package/package.json +8 -8
  117. package/resources/PlayController/createHTMLAudioElement.ts +53 -0
  118. package/resources/PlayController/index.ts +167 -0
  119. package/resources/Player/App.tsx +2 -0
  120. package/resources/Player/Controller.ts +155 -121
  121. package/resources/Player/custom/SpatialScenePanel/index.tsx +148 -45
  122. package/resources/Player/index.tsx +186 -110
  123. package/resources/Player/modules/PopUp/index.tsx +26 -0
  124. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +66 -14
  125. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +3 -3
  126. package/resources/Player/modules/VideoAgent/index.tsx +3 -2
  127. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
  128. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +79 -34
  129. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
  130. package/resources/Player/modules/keyframes/PanoTag/index.tsx +31 -12
  131. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +87 -34
  132. package/resources/Player/modules/keyframes/Prompter/index.tsx +5 -15
  133. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +25 -16
  134. package/resources/Player/typings.ts +5 -0
  135. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
  136. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
  137. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
  138. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
  139. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
  140. package/resources/fivePlugins/CameraMovementPlugin/index.ts +59 -48
  141. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
  142. package/resources/react/index.tsx +7 -3
  143. package/resources/shared-utils/AduioLike.ts +108 -0
  144. package/resources/shared-utils/createTransMatrix.ts +12 -0
  145. package/resources/typings/VreoUnit.ts +46 -5
  146. package/stylesheets/custom/SpatialScenePanel.css +14 -8
  147. package/stylesheets/default.css +116 -12
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -13,9 +13,9 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
13
13
 
14
14
  var _three = require("three");
15
15
 
16
- var _BetterTween = require("@realsee/dnalogel/shared-utils/animationFrame/BetterTween");
16
+ var _BetterTween = require("../../../shared-utils/animationFrame/BetterTween");
17
17
 
18
- var _CSS3DRenderPlugin = require("@realsee/dnalogel/plugins/CSS3DRenderPlugin");
18
+ var _CSS3DRenderPlugin = require("../../../fivePlugins/CSS3DRenderPlugin");
19
19
 
20
20
  var _VreoUnit = require("../../../typings/VreoUnit");
21
21
 
@@ -37,10 +37,15 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
37
37
 
38
38
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
39
 
40
+ // const getSphere = (position: Vector3, color = 0xffff00) => {
41
+ // const geometry = new SphereGeometry(0.05, 32, 16)
42
+ // const material = new MeshBasicMaterial({ color })
43
+ // const sphere = new Mesh(geometry, material)
44
+ // sphere.position.copy(position)
45
+ // return sphere
46
+ // }
40
47
  var searchV1 = function searchV1(_ref) {
41
48
  var five = _ref.five,
42
- position = _ref.position,
43
- rotation = _ref.rotation,
44
49
  dom = _ref.dom;
45
50
  var cameraDirection = new _three.Vector3();
46
51
  five.camera.getWorldDirection(cameraDirection);
@@ -50,7 +55,8 @@ var searchV1 = function searchV1(_ref) {
50
55
  _five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
51
56
  intersect = _five$model$intersect2[0];
52
57
 
53
- var point = five.project2d(intersect.point); // const width = dom!.clientWidth
58
+ var point = five.project2d(intersect.point);
59
+ var widescreen = window.innerWidth > 560 ? true : false; // const width = dom!.clientWidth
54
60
 
55
61
  var height = dom.clientHeight;
56
62
  dom.style.left = point.x + 'px';
@@ -65,14 +71,16 @@ var searchV1 = function searchV1(_ref) {
65
71
  var rightTop = new _three.Vector3(right, top);
66
72
  var rightBottom = new _three.Vector3(right, bottom);
67
73
  var points = [leftBottom, rightBottom, rightTop, leftTop].map(function (point) {
68
- point.setX(point.x / window.innerWidth * 2 - 1);
69
- point.setY(-(point.y / window.innerHeight) * 2 + 1);
74
+ point.setX(point.x / window.innerWidth * 2 - (widescreen ? 1.25 : 1.75));
75
+ point.setY(-(point.y / window.innerHeight) * 2 + (widescreen ? 1.35 : 1.125));
70
76
  point.setZ(0.5);
71
77
  return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2);
72
- }); // const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
78
+ }); // __debug__
79
+ // const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
73
80
  // points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
81
+ // 判断是手机 150
74
82
 
75
- var ratio = leftBottom.distanceTo(rightBottom) / 160;
83
+ var ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120);
76
84
  return {
77
85
  points: points,
78
86
  ratio: ratio
@@ -85,6 +93,7 @@ var searchV1 = function searchV1(_ref) {
85
93
 
86
94
 
87
95
  function SpatialScenePanel(props) {
96
+ var timeoutRef = React.useRef(null);
88
97
  var ref = React.useRef(null);
89
98
  var panelRef = React.useRef(null);
90
99
  var rendererRef = React.useRef((0, _CSS3DRenderPlugin.CSS3DRenderPlugin)(props.five));
@@ -98,19 +107,15 @@ function SpatialScenePanel(props) {
98
107
  return;
99
108
  }
100
109
 
101
- var data = keyframe.data; // const data = mockData as SpatialScenePanelData
110
+ var data = keyframe.data; // const data = mockData
102
111
 
103
112
  var _searchV = searchV1({
104
113
  five: props.five,
105
- position: new _three.Vector3(data.position.x, data.position.y, data.position.z),
106
- quaternion: data.quaternion,
107
114
  dom: ref.current
108
115
  }),
109
116
  points = _searchV.points,
110
117
  ratio = _searchV.ratio;
111
118
 
112
- console.log(points, ratio);
113
-
114
119
  var _ref2 = rendererRef.current.create3DDomContainer(points, {
115
120
  ratio: ratio,
116
121
  autoRender: false
@@ -120,6 +125,9 @@ function SpatialScenePanel(props) {
120
125
  css3DObject = _ref2.css3DObject,
121
126
  render = _ref2.render;
122
127
 
128
+ Object.assign(window, {
129
+ $css3DObject: css3DObject
130
+ });
123
131
  if (!container) return;
124
132
 
125
133
  _reactDom["default"].render( /*#__PURE__*/React.createElement(Panel, {
@@ -135,7 +143,8 @@ function SpatialScenePanel(props) {
135
143
  var progress = _ref4.progress;
136
144
  var needRotateY = Math.PI / 90 * 11 * progress;
137
145
  var rotateY = needRotateY - lastRotateY;
138
- css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY);
146
+ css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY); // css3DObject?.rotateZ
147
+
139
148
  lastRotateY = needRotateY;
140
149
  }).onStart(function () {
141
150
  css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(startRotateY);
@@ -144,25 +153,35 @@ function SpatialScenePanel(props) {
144
153
  var _panelRef$current;
145
154
 
146
155
  (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
147
- }).play();
156
+ }).play(); // Object.assign(window, { $dispose: () => {
157
+ // panelRef.current?.classList.add('hide')
158
+ // setTimeout(() => dispose?.(), 1500)
159
+ // } })
160
+
148
161
  var start = keyframe.start,
149
162
  end = keyframe.end;
150
- setTimeout(function () {
163
+ timeoutRef.current = setTimeout(function () {
151
164
  var _panelRef$current2;
152
165
 
153
166
  (_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 ? void 0 : _panelRef$current2.classList.add('hide');
154
- setTimeout(function () {
155
- return dispose === null || dispose === void 0 ? void 0 : dispose();
167
+ timeoutRef.current = setTimeout(function () {
168
+ dispose === null || dispose === void 0 ? void 0 : dispose();
169
+ timeoutRef.current = null;
156
170
  }, 1500);
157
171
  }, end - start);
158
172
  };
159
173
 
160
174
  Object.assign(window, {
161
- $SpatialScenePanelCallback: callback
162
- });
175
+ $callback: callback
176
+ }); // setTimeout(() => {callback()}, 8000)
177
+
163
178
  props.subscribe.on(_VreoUnit.VreoKeyframeEnum.Custom, callback);
164
179
  return function () {
165
180
  props.subscribe.off(_VreoUnit.VreoKeyframeEnum.Custom, callback);
181
+
182
+ if (timeoutRef.current) {
183
+ clearTimeout(timeoutRef.current);
184
+ }
166
185
  };
167
186
  }, []);
168
187
  return /*#__PURE__*/React.createElement("div", {
@@ -170,6 +189,38 @@ function SpatialScenePanel(props) {
170
189
  ref: ref
171
190
  });
172
191
  }
192
+ /** 背景动画:控制延迟 */
193
+
194
+
195
+ function SpatialScenePanelBg() {
196
+ var ref = React.useRef(null);
197
+ var timeoutRef = React.useRef(null);
198
+ React.useEffect(function () {
199
+ if (!ref.current) return;
200
+
201
+ var listener = function listener() {
202
+ var _ref$current;
203
+
204
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
205
+ timeoutRef.current = setTimeout(function () {
206
+ var _ref$current2;
207
+
208
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation');
209
+ timeoutRef.current = null;
210
+ }, 3000);
211
+ };
212
+
213
+ ref.current.addEventListener('animationend', listener);
214
+ return function () {
215
+ if (ref.current) ref.current.removeEventListener('animationend', listener);
216
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
217
+ };
218
+ }, []);
219
+ return /*#__PURE__*/React.createElement("div", {
220
+ ref: ref,
221
+ className: "SpatialScenePanel-bg SpatialScenePanel-bg--animation"
222
+ });
223
+ }
173
224
 
174
225
  var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
175
226
  var _props$data, _props$data2, _props$data3, _props$data3$stateLis;
@@ -179,9 +230,7 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
179
230
  ref: myRef
180
231
  }, /*#__PURE__*/React.createElement("div", {
181
232
  className: "SpatialScenePanel-show-area"
182
- }, /*#__PURE__*/React.createElement("div", {
183
- className: "SpatialScenePanel-bg"
184
- }), /*#__PURE__*/React.createElement("div", {
233
+ }, /*#__PURE__*/React.createElement(SpatialScenePanelBg, null), /*#__PURE__*/React.createElement("div", {
185
234
  className: "SpatialScenePanel-header"
186
235
  }, /*#__PURE__*/React.createElement("div", {
187
236
  className: "SpatialScenePanel-title"
@@ -204,4 +253,27 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
204
253
  }))), /*#__PURE__*/React.createElement("div", {
205
254
  className: "SpatialScenePanel-disappear-area"
206
255
  }));
207
- });
256
+ }); // export function SpatialScenePanel() {
257
+ // // const data = mockData
258
+ // return (
259
+ // <div className="SpatialScenePanel" >
260
+ // <div className="SpatialScenePanel-show-area">
261
+ // <SpatialScenePanelBg />
262
+ // <div className="SpatialScenePanel-header">
263
+ // <div className="SpatialScenePanel-title">{data?.title}</div>
264
+ // <div className="SpatialScenePanel-temperature">{data?.temperature}℃</div>
265
+ // </div>
266
+ // <div className="SpatialScenePanel-body">
267
+ // {data?.stateList?.map((state, index) => (
268
+ // <div key={`scene-${state.text}`} className={`SpatialScenePanel-item index_${index}`}>
269
+ // <img className="SpatialScenePanel-icon" src={state.icon}></img>
270
+ // <div className="SpatialScenePanel-text">{state.text}</div>
271
+ // <div className="SpatialScenePanel-dot"></div>
272
+ // </div>
273
+ // ))}
274
+ // </div>
275
+ // </div>
276
+ // <div className="SpatialScenePanel-disappear-area"></div>
277
+ // </div>
278
+ // )
279
+ // }
@@ -6,11 +6,12 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
6
6
  private controller;
7
7
  configs: Readonly<PlayerConfigs>;
8
8
  constructor(five: Five, configs?: Partial<PlayerConfigs>);
9
- load(vreoUnit: VreoUnit, currentTime?: number): Promise<boolean>;
9
+ load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean): Promise<boolean>;
10
10
  get paused(): boolean;
11
- play(): boolean;
11
+ play(currentTime?: number): boolean;
12
12
  pause(): void;
13
13
  show(): void;
14
14
  hide(): void;
15
+ getCurrentTime(): number;
15
16
  dispose(): void;
16
17
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -17,10 +17,14 @@ var _App = require("./App");
17
17
 
18
18
  var _Controller = require("./Controller");
19
19
 
20
+ var _VreoUnit = require("../typings/VreoUnit");
21
+
20
22
  var _mobx = require("mobx");
21
23
 
22
24
  var _Drawer = require("./modules/Drawer");
23
25
 
26
+ var _PopUp = require("./modules/PopUp");
27
+
24
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
29
 
26
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -33,9 +37,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
33
37
 
34
38
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
35
39
 
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
40
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
41
 
38
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
42
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
43
 
40
44
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
45
 
@@ -66,11 +70,20 @@ var Player = /*#__PURE__*/function (_Subscribe) {
66
70
  _this.$five = _this.controller.$five = five;
67
71
 
68
72
  if (!configs.containter) {
69
- var containter = document.querySelector('#vreo-app') || document.createElement('div');
73
+ var _five$getElement;
74
+
75
+ var containter = document.getElementById('vreo-app') || document.createElement('div');
70
76
  ReactDOM.unmountComponentAtNode(containter);
71
77
  containter.setAttribute('id', 'vreo-app');
72
78
  configs.containter = containter;
73
- document.body.append(containter);
79
+ var fiveCanvasDomParent = (_five$getElement = five.getElement()) === null || _five$getElement === void 0 ? void 0 : _five$getElement.parentNode;
80
+
81
+ if (fiveCanvasDomParent) {
82
+ fiveCanvasDomParent.append(containter);
83
+ } else {
84
+ document.body.append(containter);
85
+ } // document.body.append(containter)
86
+
74
87
  }
75
88
 
76
89
  _this.configs = Object.freeze(Object.assign({
@@ -79,7 +92,7 @@ var Player = /*#__PURE__*/function (_Subscribe) {
79
92
  _this.controller.configs = _this.configs;
80
93
  ReactDOM.render( /*#__PURE__*/React.createElement(_Controller.ControllerContext.Provider, {
81
94
  value: _this.controller
82
- }, /*#__PURE__*/React.createElement(_App.App, null), /*#__PURE__*/React.createElement(_Drawer.Drawer, null), _this.configs.customKeyframes && _this.configs.customKeyframes.map(function (CustomCmpt, key) {
95
+ }, /*#__PURE__*/React.createElement(_App.App, null), /*#__PURE__*/React.createElement(_Drawer.Drawer, null), /*#__PURE__*/React.createElement(_PopUp.PopUp, null), _this.configs.customKeyframes && _this.configs.customKeyframes.map(function (CustomCmpt, key) {
83
96
  return /*#__PURE__*/React.createElement(CustomCmpt, {
84
97
  key: key,
85
98
  subscribe: {
@@ -97,10 +110,19 @@ var Player = /*#__PURE__*/function (_Subscribe) {
97
110
  });
98
111
  })), configs.containter); // 监听播放情况:抛出触发时机
99
112
 
113
+ (0, _mobx.reaction)(function () {
114
+ return _this.controller.ended;
115
+ }, function (ended) {
116
+ if (ended) {
117
+ _this.emit('paused', true);
118
+ }
119
+ });
100
120
  (0, _mobx.reaction)(function () {
101
121
  return _this.controller.playing;
102
122
  }, function (playing) {
103
- _this.emit(playing ? 'playing' : 'paused');
123
+ if (!_this.controller.ended) {
124
+ _this.emit(playing ? 'playing' : 'paused');
125
+ }
104
126
  });
105
127
  return _this;
106
128
  }
@@ -110,66 +132,123 @@ var Player = /*#__PURE__*/function (_Subscribe) {
110
132
  value: function () {
111
133
  var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(vreoUnit) {
112
134
  var _this$controller$vide,
135
+ _this$configs$imageOp,
136
+ _this$controller$vide2,
137
+ _this$controller$vide3,
113
138
  _this2 = this;
114
139
 
115
140
  var currentTime,
116
- _this$controller$vide2,
117
- _this$controller$vide3,
141
+ preload,
142
+ force,
143
+ panoIndexMap,
144
+ panoIndexs,
145
+ i,
118
146
  _args = arguments;
119
-
120
147
  return regeneratorRuntime.wrap(function _callee$(_context) {
121
148
  while (1) {
122
149
  switch (_context.prev = _context.next) {
123
150
  case 0:
124
151
  currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
152
+ preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
153
+ force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
154
+
155
+ if (force) {
156
+ vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
157
+ }
125
158
 
126
159
  if (this.controller.visible) {
127
- _context.next = 5;
160
+ _context.next = 8;
128
161
  break;
129
162
  }
130
163
 
131
164
  this.controller.setVisible(true); // 延迟 500ms 规避跟 DOM 动画冲突
132
165
 
133
- _context.next = 5;
166
+ _context.next = 8;
134
167
  return new Promise(function (resolve) {
135
168
  setTimeout(function () {
136
169
  return resolve(true);
137
170
  }, 500);
138
171
  });
139
172
 
140
- case 5:
173
+ case 8:
141
174
  if (this.controller.stopInterval) {
142
175
  this.controller.stopInterval();
143
176
  this.controller.stopInterval = undefined;
144
177
  }
145
178
 
146
179
  this.controller.vreoUnit = vreoUnit;
147
- (_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); // 新数据载入就绪
180
+ (_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); // 预载逻辑
181
+ // 是否降低图片分辨率
148
182
 
149
- this.emit('loaded', vreoUnit);
183
+ if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
184
+ this.$five.imageOptions.size = this.configs.imageOptions.size;
185
+ } // 预载数据中的点位
186
+
187
+
188
+ if (!(preload || preload === undefined && this.configs.autoPreload)) {
189
+ _context.next = 22;
190
+ break;
191
+ }
192
+
193
+ panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
194
+ if (vreoKeyframe.type !== _VreoUnit.VreoKeyframeEnum.CameraMovement) {
195
+ return false;
196
+ }
197
+
198
+ var data = vreoKeyframe.data;
199
+
200
+ if (data.panoIndex === undefined) {
201
+ return false;
202
+ }
203
+
204
+ return true;
205
+ }).reduce(function (accu, curr) {
206
+ var panoIndex = curr.data.panoIndex;
150
207
 
151
- if (!vreoUnit.video.url) {
152
- _context.next = 14;
208
+ if (!accu[panoIndex]) {
209
+ accu[panoIndex] = true;
210
+ }
211
+
212
+ return accu;
213
+ }, {});
214
+ panoIndexs = Object.keys(panoIndexMap);
215
+ i = 0;
216
+
217
+ case 16:
218
+ if (!(i < panoIndexs.length)) {
219
+ _context.next = 22;
153
220
  break;
154
221
  }
155
222
 
223
+ _context.next = 19;
224
+ return this.$five.preloadPano(Number(panoIndexs[i]));
225
+
226
+ case 19:
227
+ i++;
228
+ _context.next = 16;
229
+ break;
230
+
231
+ case 22:
232
+ // 新数据载入就绪
233
+ this.emit('loaded', vreoUnit);
234
+ this.controller.emit('loaded', vreoUnit);
235
+
156
236
  if ((_this$controller$vide2 = this.controller.videoAgentScene) !== null && _this$controller$vide2 !== void 0 && _this$controller$vide2.videoAgentMesh.videoInstance) {
157
237
  this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000;
158
238
  }
159
239
 
160
- _context.next = 13;
161
- return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url);
240
+ _context.next = 27;
241
+ return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
162
242
 
163
- case 13:
243
+ case 27:
244
+ this.controller.setEnded(false);
164
245
  this.play();
165
-
166
- case 14:
167
246
  this.controller.run(function (type, keyframe) {
168
247
  return _this2.emit(type, keyframe);
169
248
  });
170
249
  return _context.abrupt("return", true);
171
250
 
172
- case 16:
251
+ case 31:
173
252
  case "end":
174
253
  return _context.stop();
175
254
  }
@@ -190,8 +269,16 @@ var Player = /*#__PURE__*/function (_Subscribe) {
190
269
  }
191
270
  }, {
192
271
  key: "play",
193
- value: function play() {
272
+ value: function play(currentTime) {
194
273
  if (this.controller.playing) return true;
274
+
275
+ if (currentTime && this.controller.videoInstance) {
276
+ this.controller.videoInstance.currentTime = currentTime / 1000;
277
+ }
278
+
279
+ Object.assign(window, {
280
+ $vreoController: this.controller
281
+ });
195
282
  this.controller.setPlaying(true);
196
283
  return true;
197
284
  }
@@ -210,6 +297,11 @@ var Player = /*#__PURE__*/function (_Subscribe) {
210
297
  value: function hide() {
211
298
  this.controller.setVisible(false);
212
299
  }
300
+ }, {
301
+ key: "getCurrentTime",
302
+ value: function getCurrentTime() {
303
+ return this.controller.currentTime;
304
+ }
213
305
  }, {
214
306
  key: "dispose",
215
307
  value: function dispose() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function PopUp(): JSX.Element;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.PopUp = PopUp;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
14
+ var _mobxReact = require("mobx-react");
15
+
16
+ var _hooks = require("../../hooks");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ var PopUpView = (0, _mobxReact.observer)(function (_ref) {
25
+ var controller = _ref.controller;
26
+ return /*#__PURE__*/React.createElement("div", {
27
+ className: (0, _classnames["default"])('vreo-PopUp', {
28
+ 'vreo-PopUp-visible': controller.popUp
29
+ }),
30
+ onClick: function onClick() {
31
+ return controller.openPopUp(false);
32
+ }
33
+ }, /*#__PURE__*/React.createElement("div", {
34
+ className: "vreo-PopUp-inner"
35
+ }, controller.popUp || ''));
36
+ });
37
+
38
+ function PopUp() {
39
+ var controller = (0, _hooks.useController)();
40
+ return /*#__PURE__*/React.createElement(PopUpView, {
41
+ controller: controller
42
+ });
43
+ }
@@ -1,6 +1,20 @@
1
1
  import * as THREE from 'three';
2
+ import AudioLike from '../../../shared-utils/AduioLike';
2
3
  export interface VideoAgentMeshOptions {
4
+ /**
5
+ * 自定义视频实例。
6
+ */
3
7
  videoInstance?: HTMLVideoElement;
8
+ /**
9
+ * 自定义音频实例。
10
+ */
11
+ audioInstance?: HTMLAudioElement;
12
+ /**
13
+ * 是否开启音频预载能力。**仅对`.mp3`有效**。
14
+ *
15
+ * @description 开启预载能力后会通过 `Fetch/XHR` 方式将音频文件下载转成二进制 [`Blob`](https://developer.mozilla.org/zh-CN/docs/Web/API/Blob) 提供给多媒体实例。这样的好处是 **能够保障音视频播放过程中不卡顿**。 但在部分 iOS 系统中会存在兼容问题——播 25s 之后会静音(`muted` 为 `false`,但是没有声音)。
16
+ */
17
+ preload?: boolean;
4
18
  }
5
19
  /**
6
20
  * 视频经纪人MESH
@@ -11,8 +25,9 @@ export declare class VideoAgentMesh extends THREE.Mesh {
11
25
  freeze: boolean;
12
26
  paused: boolean;
13
27
  audioInstance: HTMLAudioElement;
28
+ audioLikeInstance: AudioLike;
14
29
  $removeEventListener: () => void;
15
- get videoInstance(): HTMLAudioElement;
30
+ get videoInstance(): HTMLAudioElement | AudioLike;
16
31
  /**
17
32
  *
18
33
  * @param width
@@ -23,7 +38,7 @@ export declare class VideoAgentMesh extends THREE.Mesh {
23
38
  */
24
39
  constructor(width: number, height: number, widthSegments: number, heightSegments: number, options?: VideoAgentMeshOptions);
25
40
  private update;
26
- play(videoUrl?: string): Promise<unknown>;
41
+ play(videoUrl?: string, currentTime?: number, duration?: number): Promise<unknown>;
27
42
  /**
28
43
  * 转成毫秒,保障精准度
29
44
  */