@realsee/vreo 0.2.0-alpha.6 → 0.2.0-alpha.9
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/README.md +47 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/Player.Controller.html +3 -3
- package/docs/classes/Player.Player-1.html +3 -3
- package/docs/classes/Player.VideoAgentMesh.html +11 -11
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
- package/docs/enums/Player.PanoEffectEnum.html +1 -1
- package/docs/enums/Player.PanoTagEnum.html +1 -1
- package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +21 -1
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +3 -3
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -1
- package/docs/interfaces/Player.VreoKeyframe.html +1 -1
- package/docs/interfaces/Player.VreoUnit.html +1 -1
- package/docs/interfaces/Player.VreoVideo.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +13 -13
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +2 -2
- package/docs/modules/react.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
- package/lib/PlayController/createHTMLAudioElement.js +47 -0
- package/lib/PlayController/index.d.ts +38 -0
- package/lib/PlayController/index.js +300 -0
- package/lib/Player/App.js +4 -3
- package/lib/Player/custom/SpatialScenePanel/index.js +86 -14
- package/lib/Player/index.d.ts +1 -1
- package/lib/Player/index.js +68 -9
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +1 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +5 -1
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +4 -1
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -1
- package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
- package/lib/Player/modules/VideoAgent/index.js +1 -1
- package/lib/Player/modules/keyframes/CameraMovement/index.js +41 -5
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +23 -15
- package/lib/Player/typings.d.ts +6 -0
- package/lib/fivePlugins/CameraMovementPlugin/index.js +101 -90
- package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +3 -2
- package/lib/typings/VreoUnit.d.ts +4 -3
- package/package.json +2 -2
- package/resources/PlayController/createHTMLAudioElement.ts +53 -0
- package/resources/PlayController/index.ts +167 -0
- package/resources/Player/App.tsx +2 -0
- package/resources/Player/custom/SpatialScenePanel/index.tsx +84 -8
- package/resources/Player/index.tsx +34 -2
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +4 -3
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +2 -2
- package/resources/Player/modules/VideoAgent/index.tsx +3 -2
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +20 -15
- package/resources/Player/typings.ts +5 -0
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +55 -47
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
- package/resources/typings/VreoUnit.ts +5 -4
- package/stylesheets/custom/SpatialScenePanel.css +14 -8
|
@@ -55,7 +55,8 @@ var searchV1 = function searchV1(_ref) {
|
|
|
55
55
|
_five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
|
|
56
56
|
intersect = _five$model$intersect2[0];
|
|
57
57
|
|
|
58
|
-
var point = five.project2d(intersect.point);
|
|
58
|
+
var point = five.project2d(intersect.point);
|
|
59
|
+
var widescreen = window.innerWidth > 560 ? true : false; // const width = dom!.clientWidth
|
|
59
60
|
|
|
60
61
|
var height = dom.clientHeight;
|
|
61
62
|
dom.style.left = point.x + 'px';
|
|
@@ -70,15 +71,16 @@ var searchV1 = function searchV1(_ref) {
|
|
|
70
71
|
var rightTop = new _three.Vector3(right, top);
|
|
71
72
|
var rightBottom = new _three.Vector3(right, bottom);
|
|
72
73
|
var points = [leftBottom, rightBottom, rightTop, leftTop].map(function (point) {
|
|
73
|
-
point.setX(point.x / window.innerWidth * 2 - 1.25);
|
|
74
|
-
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));
|
|
75
76
|
point.setZ(0.5);
|
|
76
77
|
return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2);
|
|
77
78
|
}); // __debug__
|
|
78
79
|
// const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
|
|
79
80
|
// points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
|
|
81
|
+
// 判断是手机 150
|
|
80
82
|
|
|
81
|
-
var ratio = leftBottom.distanceTo(rightBottom) / 150;
|
|
83
|
+
var ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120);
|
|
82
84
|
return {
|
|
83
85
|
points: points,
|
|
84
86
|
ratio: ratio
|
|
@@ -91,6 +93,7 @@ var searchV1 = function searchV1(_ref) {
|
|
|
91
93
|
|
|
92
94
|
|
|
93
95
|
function SpatialScenePanel(props) {
|
|
96
|
+
var timeoutRef = React.useRef(null);
|
|
94
97
|
var ref = React.useRef(null);
|
|
95
98
|
var panelRef = React.useRef(null);
|
|
96
99
|
var rendererRef = React.useRef((0, _CSS3DRenderPlugin.CSS3DRenderPlugin)(props.five));
|
|
@@ -122,6 +125,9 @@ function SpatialScenePanel(props) {
|
|
|
122
125
|
css3DObject = _ref2.css3DObject,
|
|
123
126
|
render = _ref2.render;
|
|
124
127
|
|
|
128
|
+
Object.assign(window, {
|
|
129
|
+
$css3DObject: css3DObject
|
|
130
|
+
});
|
|
125
131
|
if (!container) return;
|
|
126
132
|
|
|
127
133
|
_reactDom["default"].render( /*#__PURE__*/React.createElement(Panel, {
|
|
@@ -137,7 +143,8 @@ function SpatialScenePanel(props) {
|
|
|
137
143
|
var progress = _ref4.progress;
|
|
138
144
|
var needRotateY = Math.PI / 90 * 11 * progress;
|
|
139
145
|
var rotateY = needRotateY - lastRotateY;
|
|
140
|
-
css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY);
|
|
146
|
+
css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY); // css3DObject?.rotateZ
|
|
147
|
+
|
|
141
148
|
lastRotateY = needRotateY;
|
|
142
149
|
}).onStart(function () {
|
|
143
150
|
css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(startRotateY);
|
|
@@ -146,23 +153,35 @@ function SpatialScenePanel(props) {
|
|
|
146
153
|
var _panelRef$current;
|
|
147
154
|
|
|
148
155
|
(_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
|
|
149
|
-
}).play();
|
|
156
|
+
}).play(); // Object.assign(window, { $dispose: () => {
|
|
157
|
+
// panelRef.current?.classList.add('hide')
|
|
158
|
+
// setTimeout(() => dispose?.(), 1500)
|
|
159
|
+
// } })
|
|
160
|
+
|
|
150
161
|
var start = keyframe.start,
|
|
151
162
|
end = keyframe.end;
|
|
152
|
-
setTimeout(function () {
|
|
163
|
+
timeoutRef.current = setTimeout(function () {
|
|
153
164
|
var _panelRef$current2;
|
|
154
165
|
|
|
155
166
|
(_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 ? void 0 : _panelRef$current2.classList.add('hide');
|
|
156
|
-
setTimeout(function () {
|
|
157
|
-
|
|
167
|
+
timeoutRef.current = setTimeout(function () {
|
|
168
|
+
dispose === null || dispose === void 0 ? void 0 : dispose();
|
|
169
|
+
timeoutRef.current = null;
|
|
158
170
|
}, 1500);
|
|
159
171
|
}, end - start);
|
|
160
|
-
};
|
|
172
|
+
};
|
|
161
173
|
|
|
174
|
+
Object.assign(window, {
|
|
175
|
+
$callback: callback
|
|
176
|
+
}); // setTimeout(() => {callback()}, 8000)
|
|
162
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
|
+
// }
|
package/lib/Player/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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): Promise<boolean>;
|
|
10
10
|
get paused(): boolean;
|
|
11
11
|
play(): boolean;
|
|
12
12
|
pause(): void;
|
package/lib/Player/index.js
CHANGED
|
@@ -17,6 +17,8 @@ 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");
|
|
@@ -112,9 +114,14 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
112
114
|
value: function () {
|
|
113
115
|
var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(vreoUnit) {
|
|
114
116
|
var _this$controller$vide,
|
|
117
|
+
_this$configs$imageOp,
|
|
115
118
|
_this2 = this;
|
|
116
119
|
|
|
117
120
|
var currentTime,
|
|
121
|
+
preload,
|
|
122
|
+
panoIndexMap,
|
|
123
|
+
panoIndexs,
|
|
124
|
+
i,
|
|
118
125
|
_this$controller$vide2,
|
|
119
126
|
_this$controller$vide3,
|
|
120
127
|
_args = arguments;
|
|
@@ -124,34 +131,86 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
124
131
|
switch (_context.prev = _context.next) {
|
|
125
132
|
case 0:
|
|
126
133
|
currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
|
|
134
|
+
preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
127
135
|
|
|
128
136
|
if (this.controller.visible) {
|
|
129
|
-
_context.next =
|
|
137
|
+
_context.next = 6;
|
|
130
138
|
break;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
this.controller.setVisible(true); // 延迟 500ms 规避跟 DOM 动画冲突
|
|
134
142
|
|
|
135
|
-
_context.next =
|
|
143
|
+
_context.next = 6;
|
|
136
144
|
return new Promise(function (resolve) {
|
|
137
145
|
setTimeout(function () {
|
|
138
146
|
return resolve(true);
|
|
139
147
|
}, 500);
|
|
140
148
|
});
|
|
141
149
|
|
|
142
|
-
case
|
|
150
|
+
case 6:
|
|
143
151
|
if (this.controller.stopInterval) {
|
|
144
152
|
this.controller.stopInterval();
|
|
145
153
|
this.controller.stopInterval = undefined;
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
this.controller.vreoUnit = vreoUnit;
|
|
149
|
-
(_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); //
|
|
157
|
+
(_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); // 预载逻辑
|
|
158
|
+
// 是否降低图片分辨率
|
|
159
|
+
|
|
160
|
+
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) {
|
|
161
|
+
this.$five.imageOptions.size = this.configs.imageOptions.size;
|
|
162
|
+
} // 预载数据中的点位
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
if (!(preload || preload === undefined && this.configs.autoPreload)) {
|
|
166
|
+
_context.next = 20;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
|
|
171
|
+
if (vreoKeyframe.type !== _VreoUnit.VreoKeyframeEnum.CameraMovement) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var data = vreoKeyframe.data;
|
|
176
|
+
|
|
177
|
+
if (data.panoIndex === undefined) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return true;
|
|
182
|
+
}).reduce(function (accu, curr) {
|
|
183
|
+
var panoIndex = curr.data.panoIndex;
|
|
150
184
|
|
|
185
|
+
if (!accu[panoIndex]) {
|
|
186
|
+
accu[panoIndex] = true;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return accu;
|
|
190
|
+
}, {});
|
|
191
|
+
panoIndexs = Object.keys(panoIndexMap);
|
|
192
|
+
i = 0;
|
|
193
|
+
|
|
194
|
+
case 14:
|
|
195
|
+
if (!(i < panoIndexs.length)) {
|
|
196
|
+
_context.next = 20;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
_context.next = 17;
|
|
201
|
+
return this.$five.preloadPano(Number(panoIndexs[i]));
|
|
202
|
+
|
|
203
|
+
case 17:
|
|
204
|
+
i++;
|
|
205
|
+
_context.next = 14;
|
|
206
|
+
break;
|
|
207
|
+
|
|
208
|
+
case 20:
|
|
209
|
+
// 新数据载入就绪
|
|
151
210
|
this.emit('loaded', vreoUnit);
|
|
152
211
|
|
|
153
212
|
if (!vreoUnit.video.url) {
|
|
154
|
-
_context.next =
|
|
213
|
+
_context.next = 26;
|
|
155
214
|
break;
|
|
156
215
|
}
|
|
157
216
|
|
|
@@ -159,19 +218,19 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
159
218
|
this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000;
|
|
160
219
|
}
|
|
161
220
|
|
|
162
|
-
_context.next =
|
|
221
|
+
_context.next = 25;
|
|
163
222
|
return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url);
|
|
164
223
|
|
|
165
|
-
case
|
|
224
|
+
case 25:
|
|
166
225
|
this.play();
|
|
167
226
|
|
|
168
|
-
case
|
|
227
|
+
case 26:
|
|
169
228
|
this.controller.run(function (type, keyframe) {
|
|
170
229
|
return _this2.emit(type, keyframe);
|
|
171
230
|
});
|
|
172
231
|
return _context.abrupt("return", true);
|
|
173
232
|
|
|
174
|
-
case
|
|
233
|
+
case 28:
|
|
175
234
|
case "end":
|
|
176
235
|
return _context.stop();
|
|
177
236
|
}
|
|
@@ -106,7 +106,8 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
106
106
|
_this.options = options;
|
|
107
107
|
_this.freeze = false;
|
|
108
108
|
_this.paused = true;
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
if (!options.audioInstance) {
|
|
110
111
|
if (cacheInstance.audioInstance) {
|
|
111
112
|
_this.audioInstance = cacheInstance.audioInstance;
|
|
112
113
|
} else {
|
|
@@ -122,7 +123,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
122
123
|
_this.audioInstance = audioInstance;
|
|
123
124
|
cacheInstance.audioInstance = audioInstance;
|
|
124
125
|
}
|
|
126
|
+
} else {
|
|
127
|
+
_this.audioInstance = options.audioInstance;
|
|
125
128
|
}
|
|
129
|
+
|
|
126
130
|
(0, _mobx.makeObservable)(_assertThisInitialized(_this), {
|
|
127
131
|
paused: _mobx.observable
|
|
128
132
|
});
|
|
@@ -6,7 +6,10 @@ export declare class VideoAgentScene {
|
|
|
6
6
|
camera: THREE.OrthographicCamera;
|
|
7
7
|
renderer: THREE.WebGLRenderer;
|
|
8
8
|
container: HTMLElement;
|
|
9
|
-
constructor(container: HTMLElement, needRender?: boolean
|
|
9
|
+
constructor(container: HTMLElement, needRender?: boolean, options?: {
|
|
10
|
+
videoInstance?: HTMLVideoElement;
|
|
11
|
+
audioInstance?: HTMLAudioElement;
|
|
12
|
+
});
|
|
10
13
|
run: () => void;
|
|
11
14
|
dispose: () => void;
|
|
12
15
|
}
|
|
@@ -23,6 +23,7 @@ var VideoAgentScene = function VideoAgentScene(container) {
|
|
|
23
23
|
var _this = this;
|
|
24
24
|
|
|
25
25
|
var needRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
26
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
26
27
|
|
|
27
28
|
_classCallCheck(this, VideoAgentScene);
|
|
28
29
|
|
|
@@ -74,7 +75,7 @@ var VideoAgentScene = function VideoAgentScene(container) {
|
|
|
74
75
|
|
|
75
76
|
_domElement.setAttribute('style', "width: ".concat(state.width, "px;height: ").concat(state.height, "px;"));
|
|
76
77
|
|
|
77
|
-
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1);
|
|
78
|
+
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
|
|
78
79
|
|
|
79
80
|
if (needRender) {
|
|
80
81
|
container.append(_domElement);
|
|
@@ -28,7 +28,7 @@ function VideoAgent(props) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current);
|
|
31
|
+
var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, true, props.options || {});
|
|
32
32
|
controller.videoAgentScene = videoAgentScene;
|
|
33
33
|
return function () {
|
|
34
34
|
var _controller$videoAgen;
|
|
@@ -45,13 +45,49 @@ function CameraMovement() {
|
|
|
45
45
|
cameraMovementData = data;
|
|
46
46
|
effect = cameraMovementData.effect;
|
|
47
47
|
|
|
48
|
-
if (effect === _typings.CameraMovementEffect.Rotate) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ref.current.move(data, end - start);
|
|
48
|
+
if (!(effect === _typings.CameraMovementEffect.Rotate)) {
|
|
49
|
+
_context.next = 9;
|
|
50
|
+
break;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
_context.next = 7;
|
|
54
|
+
return ref.current.rotate(data, end - start);
|
|
55
|
+
|
|
56
|
+
case 7:
|
|
57
|
+
_context.next = 21;
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
case 9:
|
|
61
|
+
if (!(effect === _typings.CameraMovementEffect.Move)) {
|
|
62
|
+
_context.next = 14;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_context.next = 12;
|
|
67
|
+
return ref.current.move(data, end - start);
|
|
68
|
+
|
|
69
|
+
case 12:
|
|
70
|
+
_context.next = 21;
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 14:
|
|
74
|
+
if (!(cameraMovementData.panoIndex !== undefined && cameraMovementData.panoIndex !== five.panoIndex)) {
|
|
75
|
+
_context.next = 19;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_context.next = 17;
|
|
80
|
+
return ref.current.move(data, end - start);
|
|
81
|
+
|
|
82
|
+
case 17:
|
|
83
|
+
_context.next = 21;
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 19:
|
|
87
|
+
_context.next = 21;
|
|
88
|
+
return ref.current.rotate(data, end - start);
|
|
89
|
+
|
|
90
|
+
case 21:
|
|
55
91
|
case "end":
|
|
56
92
|
return _context.stop();
|
|
57
93
|
}
|
|
@@ -22,42 +22,45 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
22
22
|
function UpdateVRPanorama() {
|
|
23
23
|
var controller = (0, _hooks.useController)();
|
|
24
24
|
var five = (0, _hooks.useFiveInstance)();
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var deafultWorkRef = React.useRef(null);
|
|
26
|
+
var updateWorkRef = React.useRef(null);
|
|
27
27
|
var restoreCallback = React.useCallback(function () {
|
|
28
|
-
if (
|
|
29
|
-
var work = (0, _five.parseWork)(
|
|
28
|
+
if (deafultWorkRef.current) {
|
|
29
|
+
var work = (0, _five.parseWork)(deafultWorkRef.current);
|
|
30
30
|
five.load(work);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
updateWorkRef.current = null;
|
|
34
34
|
}, []);
|
|
35
35
|
var pausedCallback = React.useCallback(function () {
|
|
36
|
-
if (
|
|
37
|
-
var work = (0, _five.parseWork)(
|
|
36
|
+
if (deafultWorkRef.current) {
|
|
37
|
+
var work = (0, _five.parseWork)(deafultWorkRef.current);
|
|
38
|
+
Object.assign(window, {
|
|
39
|
+
$rawWork: work
|
|
40
|
+
});
|
|
38
41
|
five.load(work);
|
|
39
42
|
}
|
|
40
43
|
}, []);
|
|
41
44
|
var playingCallback = React.useCallback(function () {
|
|
42
|
-
if (!
|
|
45
|
+
if (!updateWorkRef.current) {
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
five.load(
|
|
49
|
+
five.load(updateWorkRef.current);
|
|
47
50
|
}, []);
|
|
48
51
|
React.useEffect(function () {
|
|
49
52
|
var callback = function callback(keyframe) {
|
|
50
53
|
var _five$work;
|
|
51
54
|
|
|
52
|
-
if (!
|
|
53
|
-
|
|
55
|
+
if (!deafultWorkRef.current) {
|
|
56
|
+
deafultWorkRef.current = five.work.raw.works;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
var data = keyframe.data; // 如果数据中有新 work 数据,则直接载入
|
|
57
60
|
|
|
58
61
|
if (data.work) {
|
|
59
|
-
|
|
60
|
-
five.load(
|
|
62
|
+
updateWorkRef.current = (0, _five.parseWork)(data.work);
|
|
63
|
+
five.load(updateWorkRef.current);
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
|
|
@@ -72,8 +75,13 @@ function UpdateVRPanorama() {
|
|
|
72
75
|
delete data.dynamic_scene;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
Object.assign(window, {
|
|
79
|
+
$work1: JSON.parse(lastRawWork),
|
|
80
|
+
$work2: data,
|
|
81
|
+
parseWork: _five.parseWork
|
|
82
|
+
});
|
|
83
|
+
updateWorkRef.current = (0, _five.parseWork)([lastRawWork, data]);
|
|
84
|
+
five.load(updateWorkRef.current);
|
|
77
85
|
};
|
|
78
86
|
|
|
79
87
|
controller.on(_VreoUnit.VreoKeyframeEnum.UpdateVRPanorama, callback); // 离开 将之前的内容清空
|
package/lib/Player/typings.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { Subscribe, Five } from '@realsee/five';
|
|
3
3
|
import { VreoKeyframeConfigMap, VreoKeyframeEvent } from '../typings/VreoUnit';
|
|
4
|
+
import { VideoAgentMeshOptions } from './modules/VideoAgent/VideoAgentMesh';
|
|
4
5
|
export interface PlayerConfigs {
|
|
5
6
|
containter?: ReactDOM.Container;
|
|
6
7
|
keyframeMap: VreoKeyframeConfigMap;
|
|
@@ -13,11 +14,16 @@ export interface PlayerConfigs {
|
|
|
13
14
|
videoEffect?: HTMLVideoElement;
|
|
14
15
|
modelTVVideo?: HTMLVideoElement;
|
|
15
16
|
};
|
|
17
|
+
videoAgentMeshOptions?: VideoAgentMeshOptions;
|
|
16
18
|
/**
|
|
17
19
|
* 如果需要在 底部面板添加自定义内容,可以传递个 React 组件。
|
|
18
20
|
*/
|
|
19
21
|
customPanelChildren?: ReactNode;
|
|
20
22
|
customKeyframes?: React.FC<CustomVreoKeyframeProps>[];
|
|
23
|
+
imageOptions?: {
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
autoPreload?: boolean;
|
|
21
27
|
}
|
|
22
28
|
export declare type VreoSubscribe = Pick<Subscribe<VreoKeyframeEvent>, 'on' | 'once' | 'off'>;
|
|
23
29
|
export interface CustomVreoKeyframeProps {
|