@realsee/vreo 2.6.4-alpha.4 → 2.6.4
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/lib/PlayController/createHTMLAudioElement.js +14 -10
- package/lib/PlayController/index.js +73 -63
- package/lib/Player/Controller.js +56 -50
- package/lib/Player/PlaybackLifecycle.js +7 -6
- package/lib/Player/custom/SpatialScenePanel/index.js +11 -34
- package/lib/Player/index.js +166 -160
- package/lib/Player/modules/Drawer/index.js +2 -1
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +157 -146
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +1 -1
- package/lib/Player/modules/VideoAgent/index.js +3 -3
- package/lib/Player/modules/keyframes/BgMusic/index.js +12 -12
- package/lib/Player/modules/keyframes/CameraMovement/index.js +45 -43
- package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -8
- package/lib/Player/modules/keyframes/ModelVideo/index.js +83 -81
- package/lib/Player/modules/keyframes/PanoTag/index.js +1 -1
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +3 -3
- package/lib/Player/modules/keyframes/VideoEffect/index.js +71 -69
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +6 -6
- package/lib/fivePlugins/CameraMovementPlugin/index.js +180 -173
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +59 -57
- package/lib/react/index.js +1 -1
- package/lib/shared-utils/Audio.js +56 -52
- package/lib/shared-utils/AudioLike.js +14 -11
- package/lib/shared-utils/animationFrame/BetterTween.js +15 -13
- package/lib/shared-utils/animationFrame/tween.js +3 -1
- package/lib/shared-utils/getMediaInfo.js +1 -0
- package/lib/typings/VreoUnit.js +27 -134
- package/package.json +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
|
|
3
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
3
|
import { Five } from '@realsee/five';
|
|
5
4
|
import { Rotation } from "./typings.js";
|
|
6
5
|
var PI = Math.PI;
|
|
@@ -29,83 +28,86 @@ export var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
29
28
|
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
30
29
|
preload: true
|
|
31
30
|
};
|
|
32
|
-
return new Promise(/*#__PURE__*/function () {
|
|
33
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
31
|
+
return new Promise( /*#__PURE__*/function () {
|
|
32
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
|
|
34
33
|
var _opts$asyncEndCallbac;
|
|
35
34
|
var panoIndex, start, movePanoOptions;
|
|
36
|
-
return
|
|
37
|
-
while (1)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
opts.asyncStartCallback
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
35
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
|
+
while (1) {
|
|
37
|
+
switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
moving = true;
|
|
40
|
+
if (opts.asyncStartCallback) {
|
|
41
|
+
opts.asyncStartCallback();
|
|
42
|
+
}
|
|
43
|
+
if (!(five.panoIndex === undefined)) {
|
|
44
|
+
_context.next = 4;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
return _context.abrupt("return", reject(false));
|
|
48
|
+
case 4:
|
|
49
|
+
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
50
|
+
_context.next = 8;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
_context.next = 7;
|
|
54
|
+
return five.changeMode(args.mode, args, duration);
|
|
55
|
+
case 7:
|
|
56
|
+
return _context.abrupt("return", resolve(true));
|
|
57
|
+
case 8:
|
|
58
|
+
if (!(args.mode === Five.Mode.Floorplan)) {
|
|
59
|
+
_context.next = 10;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
return _context.abrupt("return", resolve(true));
|
|
63
|
+
case 10:
|
|
64
|
+
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
65
|
+
_context.next = 13;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
_context.next = 13;
|
|
69
|
+
return five.preloadPano(args.panoIndex);
|
|
70
|
+
case 13:
|
|
71
|
+
(_opts$asyncEndCallbac = opts.asyncEndCallback) === null || _opts$asyncEndCallbac === void 0 ? void 0 : _opts$asyncEndCallbac.call(opts);
|
|
72
|
+
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
73
|
+
_context.next = 16;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return _context.abrupt("return", resolve(true));
|
|
77
|
+
case 16:
|
|
78
|
+
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
79
|
+
if (!(panoIndex !== undefined)) {
|
|
80
|
+
_context.next = 26;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
start = performance.now();
|
|
84
|
+
_context.next = 21;
|
|
85
|
+
return five.ready();
|
|
86
|
+
case 21:
|
|
87
|
+
movePanoOptions = Object.assign({}, args, {
|
|
88
|
+
duration: duration - (performance.now() - start),
|
|
89
|
+
// 移动耗时
|
|
90
|
+
moveEndCallback: function moveEndCallback() {
|
|
91
|
+
return resolve(true);
|
|
92
|
+
},
|
|
93
|
+
// 移动结束
|
|
94
|
+
moveCancelCallback: function moveCancelCallback() {
|
|
95
|
+
resolve(true);
|
|
96
|
+
},
|
|
97
|
+
// 移动开始
|
|
98
|
+
effect: args.transEffect || 'fly'
|
|
99
|
+
});
|
|
100
|
+
_context.next = 24;
|
|
101
|
+
return five.moveToPano(panoIndex, movePanoOptions);
|
|
102
|
+
case 24:
|
|
103
|
+
_context.next = 27;
|
|
74
104
|
break;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
start = performance.now();
|
|
84
|
-
_context.n = 7;
|
|
85
|
-
return five.ready();
|
|
86
|
-
case 7:
|
|
87
|
-
movePanoOptions = Object.assign({}, args, {
|
|
88
|
-
duration: duration - (performance.now() - start),
|
|
89
|
-
// 移动耗时
|
|
90
|
-
moveEndCallback: function moveEndCallback() {
|
|
91
|
-
return resolve(true);
|
|
92
|
-
},
|
|
93
|
-
// 移动结束
|
|
94
|
-
moveCancelCallback: function moveCancelCallback() {
|
|
95
|
-
resolve(true);
|
|
96
|
-
},
|
|
97
|
-
// 移动开始
|
|
98
|
-
effect: args.transEffect || 'fly'
|
|
99
|
-
});
|
|
100
|
-
_context.n = 8;
|
|
101
|
-
return five.moveToPano(panoIndex, movePanoOptions);
|
|
102
|
-
case 8:
|
|
103
|
-
_context.n = 10;
|
|
104
|
-
break;
|
|
105
|
-
case 9:
|
|
106
|
-
reject(false);
|
|
107
|
-
case 10:
|
|
108
|
-
return _context.a(2);
|
|
105
|
+
case 26:
|
|
106
|
+
reject(false);
|
|
107
|
+
case 27:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
109
111
|
}
|
|
110
112
|
}, _callee);
|
|
111
113
|
}));
|
|
@@ -115,7 +117,7 @@ export var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
115
117
|
}());
|
|
116
118
|
};
|
|
117
119
|
var rotate = /*#__PURE__*/function () {
|
|
118
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
120
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(args, duration) {
|
|
119
121
|
var _opts$asyncStartCallb, _opts$asyncEndCallbac2;
|
|
120
122
|
var opts,
|
|
121
123
|
from,
|
|
@@ -123,107 +125,112 @@ export var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
123
125
|
timeEnd,
|
|
124
126
|
start,
|
|
125
127
|
animeDuration,
|
|
126
|
-
|
|
128
|
+
onFiveRenderFrame,
|
|
127
129
|
_args2 = arguments;
|
|
128
|
-
return
|
|
129
|
-
while (1)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
131
|
+
while (1) {
|
|
132
|
+
switch (_context2.prev = _context2.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
135
|
+
moving = false;
|
|
136
|
+
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 ? void 0 : _opts$asyncStartCallb.call(opts);
|
|
134
137
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
138
|
+
// 先切换模型再出旋转效果
|
|
139
|
+
if (!(args.mode && five.currentMode !== args.mode)) {
|
|
140
|
+
_context2.next = 6;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
_context2.next = 6;
|
|
144
|
+
return five.changeMode(args.mode, args.mode === Five.Mode.Panorama ? {
|
|
145
|
+
latitude: 0
|
|
146
|
+
} : undefined);
|
|
147
|
+
case 6:
|
|
148
|
+
if (!(args.mode === Five.Mode.Panorama && five.currentMode === Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
149
|
+
_context2.next = 12;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (!opts.preload) {
|
|
153
|
+
_context2.next = 10;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
_context2.next = 10;
|
|
157
|
+
return five.preloadPano(args.panoIndex);
|
|
158
|
+
case 10:
|
|
159
|
+
_context2.next = 12;
|
|
160
|
+
return new Promise(function (resolve, reject) {
|
|
161
|
+
five.moveToPano(args.panoIndex, {
|
|
162
|
+
moveEndCallback: function moveEndCallback() {
|
|
163
|
+
return resolve(true);
|
|
164
|
+
},
|
|
165
|
+
// 移动结束
|
|
166
|
+
moveCancelCallback: function moveCancelCallback() {
|
|
167
|
+
return reject(false);
|
|
168
|
+
},
|
|
169
|
+
// 移动开始
|
|
170
|
+
effect: 'fade'
|
|
171
|
+
});
|
|
168
172
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 || _opts$asyncEndCallbac2.call(opts);
|
|
173
|
+
case 12:
|
|
174
|
+
_context2.next = 14;
|
|
175
|
+
return five.ready();
|
|
176
|
+
case 14:
|
|
177
|
+
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 ? void 0 : _opts$asyncEndCallbac2.call(opts);
|
|
175
178
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
_onFiveRenderFrame = function onFiveRenderFrame() {
|
|
189
|
-
if (timeEnd || moving) {
|
|
190
|
-
five.off('renderFrame', _onFiveRenderFrame);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
var targetState = {};
|
|
194
|
-
if (args.rotation !== Rotation.Loop) {
|
|
195
|
-
var progress = (performance.now() - start) / duration;
|
|
196
|
-
targetState = {
|
|
197
|
-
fov: progressNumber(from.fov, to.fov, progress),
|
|
198
|
-
latitude: progressNumber(from.latitude, to.latitude, progress),
|
|
199
|
-
longitude: progressLongitude(from.longitude, to.longitude, args.rotation, progress)
|
|
200
|
-
};
|
|
201
|
-
} else {
|
|
202
|
-
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
203
|
-
var times = Math.floor(_progress);
|
|
204
|
-
var progress2 = _progress - times; // 一定小于1
|
|
205
|
-
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
206
|
-
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
207
|
-
targetState = {
|
|
208
|
-
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
209
|
-
latitude: progressNumber(from.latitude, to.latitude, resultProgress),
|
|
210
|
-
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
211
|
-
};
|
|
179
|
+
// 计算to
|
|
180
|
+
from = five.getCurrentState();
|
|
181
|
+
to = function () {
|
|
182
|
+
return args;
|
|
183
|
+
}();
|
|
184
|
+
timeEnd = false; // 开始时间
|
|
185
|
+
start = performance.now();
|
|
186
|
+
animeDuration = duration;
|
|
187
|
+
if (args.rotation === Rotation.Loop) {
|
|
188
|
+
animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
|
|
189
|
+
animeDuration = Math.min(duration, animeDuration);
|
|
212
190
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
191
|
+
onFiveRenderFrame = function onFiveRenderFrame() {
|
|
192
|
+
if (timeEnd || moving) {
|
|
193
|
+
five.off('renderFrame', onFiveRenderFrame);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var targetState = {};
|
|
197
|
+
if (args.rotation !== Rotation.Loop) {
|
|
198
|
+
var progress = (performance.now() - start) / duration;
|
|
199
|
+
targetState = {
|
|
200
|
+
fov: progressNumber(from.fov, to.fov, progress),
|
|
201
|
+
latitude: progressNumber(from.latitude, to.latitude, progress),
|
|
202
|
+
longitude: progressLongitude(from.longitude, to.longitude, args.rotation, progress)
|
|
203
|
+
};
|
|
204
|
+
} else {
|
|
205
|
+
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
206
|
+
var times = Math.floor(_progress);
|
|
207
|
+
var progress2 = _progress - times; // 一定小于1
|
|
208
|
+
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
209
|
+
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
210
|
+
targetState = {
|
|
211
|
+
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
212
|
+
latitude: progressNumber(from.latitude, to.latitude, resultProgress),
|
|
213
|
+
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
five.setState(targetState, true);
|
|
217
|
+
};
|
|
218
|
+
five.on('renderFrame', onFiveRenderFrame);
|
|
219
|
+
_context2.next = 25;
|
|
220
|
+
return new Promise(function (resolve) {
|
|
221
|
+
setTimeout(function () {
|
|
222
|
+
timeEnd = true;
|
|
223
|
+
five.off('renderFrame', onFiveRenderFrame);
|
|
224
|
+
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
225
|
+
resolve(true);
|
|
226
|
+
}, duration);
|
|
227
|
+
});
|
|
228
|
+
case 25:
|
|
229
|
+
return _context2.abrupt("return", _context2.sent);
|
|
230
|
+
case 26:
|
|
231
|
+
case "end":
|
|
232
|
+
return _context2.stop();
|
|
233
|
+
}
|
|
227
234
|
}
|
|
228
235
|
}, _callee2);
|
|
229
236
|
}));
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
4
4
|
|
|
5
|
-
export var CameraMovementEffect
|
|
5
|
+
export var CameraMovementEffect;
|
|
6
|
+
(function (CameraMovementEffect) {
|
|
6
7
|
CameraMovementEffect["Move"] = "Move";
|
|
7
8
|
CameraMovementEffect["Rotate"] = "Rotate";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
})(CameraMovementEffect || (CameraMovementEffect = {}));
|
|
10
|
+
export var Rotation;
|
|
11
|
+
(function (Rotation) {
|
|
11
12
|
Rotation["Clockwise"] = "Clockwise";
|
|
12
13
|
Rotation["Anticlockwise"] = "Anticlockwise";
|
|
13
14
|
Rotation["Loop"] = "Loop";
|
|
14
|
-
|
|
15
|
-
}({});
|
|
15
|
+
})(Rotation || (Rotation = {}));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
|
|
4
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
4
|
import * as THREE from 'three';
|
|
6
5
|
export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
7
6
|
var videoElement = _ref.videoElement,
|
|
@@ -29,7 +28,7 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
29
28
|
var stop = function stop() {
|
|
30
29
|
var _removeReady;
|
|
31
30
|
++generation;
|
|
32
|
-
(_removeReady = removeReady) === null || _removeReady === void 0
|
|
31
|
+
(_removeReady = removeReady) === null || _removeReady === void 0 ? void 0 : _removeReady();
|
|
33
32
|
removeReady = undefined;
|
|
34
33
|
if (output) {
|
|
35
34
|
output.muted = true;
|
|
@@ -103,8 +102,8 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
103
102
|
state.videoMeshes.forEach(function (mesh) {
|
|
104
103
|
return five.scene.add(mesh);
|
|
105
104
|
});
|
|
106
|
-
var
|
|
107
|
-
element.removeEventListener('timeupdate',
|
|
105
|
+
var timeupdate = function timeupdate() {
|
|
106
|
+
element.removeEventListener('timeupdate', timeupdate);
|
|
108
107
|
if (!valid()) return;
|
|
109
108
|
state.videoTextureEnabled = true;
|
|
110
109
|
state.videoMeshes.forEach(function (mesh) {
|
|
@@ -112,10 +111,10 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
112
111
|
});
|
|
113
112
|
five.needsRender = true;
|
|
114
113
|
};
|
|
115
|
-
var
|
|
116
|
-
five.off('modelLoaded',
|
|
114
|
+
var play = function play() {
|
|
115
|
+
five.off('modelLoaded', play);
|
|
117
116
|
if (!valid()) return;
|
|
118
|
-
element.addEventListener('timeupdate',
|
|
117
|
+
element.addEventListener('timeupdate', timeupdate);
|
|
119
118
|
void media.play().catch(function (error) {
|
|
120
119
|
if (valid()) {
|
|
121
120
|
disable();
|
|
@@ -124,13 +123,13 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
124
123
|
});
|
|
125
124
|
};
|
|
126
125
|
removeReady = function removeReady() {
|
|
127
|
-
five.off('modelLoaded',
|
|
128
|
-
element.removeEventListener('timeupdate',
|
|
126
|
+
five.off('modelLoaded', play);
|
|
127
|
+
element.removeEventListener('timeupdate', timeupdate);
|
|
129
128
|
};
|
|
130
|
-
if (five.model.loaded)
|
|
129
|
+
if (five.model.loaded) play();else five.on('modelLoaded', play);
|
|
131
130
|
};
|
|
132
131
|
var disable = function disable() {
|
|
133
|
-
controller === null || controller === void 0
|
|
132
|
+
controller === null || controller === void 0 ? void 0 : controller.cancel();
|
|
134
133
|
stop();
|
|
135
134
|
};
|
|
136
135
|
var createPanoVideoMeshes = function createPanoVideoMeshes() {
|
|
@@ -225,51 +224,54 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
225
224
|
});
|
|
226
225
|
};
|
|
227
226
|
var load = /*#__PURE__*/function () {
|
|
228
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
227
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, videoElement) {
|
|
229
228
|
var current, video_src, video_poster_src, points, texture;
|
|
230
|
-
return
|
|
231
|
-
while (1)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
229
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
230
|
+
while (1) {
|
|
231
|
+
switch (_context.prev = _context.next) {
|
|
232
|
+
case 0:
|
|
233
|
+
current = ++generation;
|
|
234
|
+
video_src = data.video_src, video_poster_src = data.video_poster_src, points = data.points;
|
|
235
|
+
state.videoSource = video_src;
|
|
236
|
+
state.rectPoints = points.map(function (items) {
|
|
237
|
+
return items.map(function (_ref3) {
|
|
238
|
+
var x = _ref3.x,
|
|
239
|
+
y = _ref3.y,
|
|
240
|
+
z = _ref3.z;
|
|
241
|
+
return new THREE.Vector3(x, y, z);
|
|
242
|
+
});
|
|
242
243
|
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
244
|
+
state.imageTexture = getImageTexture(video_poster_src);
|
|
245
|
+
if (videoElement) {
|
|
246
|
+
state.videoElement = videoElement;
|
|
247
|
+
}
|
|
248
|
+
_context.next = 8;
|
|
249
|
+
return getVideoTexture(state.videoSource, state.videoElement, function () {
|
|
250
|
+
return !disposed && current === generation;
|
|
251
|
+
});
|
|
252
|
+
case 8:
|
|
253
|
+
texture = _context.sent;
|
|
254
|
+
if (!(disposed || current !== generation)) {
|
|
255
|
+
_context.next = 15;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
texture.image.muted = true;
|
|
259
|
+
texture.image.pause();
|
|
260
|
+
URL.revokeObjectURL(texture.image.src);
|
|
261
|
+
texture.dispose();
|
|
262
|
+
return _context.abrupt("return");
|
|
263
|
+
case 15:
|
|
264
|
+
if (state.videoTexture) {
|
|
265
|
+
state.videoTexture.image.pause();
|
|
266
|
+
URL.revokeObjectURL(state.videoTexture.image.src);
|
|
267
|
+
state.videoTexture.dispose();
|
|
268
|
+
}
|
|
269
|
+
state.videoTexture = texture;
|
|
270
|
+
if (data.enable) enable();
|
|
271
|
+
case 18:
|
|
272
|
+
case "end":
|
|
273
|
+
return _context.stop();
|
|
274
|
+
}
|
|
273
275
|
}
|
|
274
276
|
}, _callee);
|
|
275
277
|
}));
|
|
@@ -328,11 +330,11 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
328
330
|
disposed = true;
|
|
329
331
|
++generation;
|
|
330
332
|
disable();
|
|
331
|
-
controller === null || controller === void 0
|
|
333
|
+
controller === null || controller === void 0 ? void 0 : controller.dispose();
|
|
332
334
|
listeners.splice(0).forEach(function (remove) {
|
|
333
335
|
return remove();
|
|
334
336
|
});
|
|
335
|
-
(_state$imageTexture = state.imageTexture) === null || _state$imageTexture === void 0
|
|
337
|
+
(_state$imageTexture = state.imageTexture) === null || _state$imageTexture === void 0 ? void 0 : _state$imageTexture.dispose();
|
|
336
338
|
if (state.videoTexture) {
|
|
337
339
|
URL.revokeObjectURL(state.videoTexture.image.src);
|
|
338
340
|
state.videoTexture.dispose();
|
package/lib/react/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export var VreoProvider = function VreoProvider(props) {
|
|
|
38
38
|
setPlayer(playerRef.current);
|
|
39
39
|
return function () {
|
|
40
40
|
var _playerRef$current;
|
|
41
|
-
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0
|
|
41
|
+
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.dispose();
|
|
42
42
|
};
|
|
43
43
|
}, []);
|
|
44
44
|
if (!player) return /*#__PURE__*/React.createElement(React.Fragment, null);
|