@realsee/vreo 1.0.0-alpha.5 → 1.0.0-alpha.7
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/lib/PlayController/createHTMLAudioElement.js +6 -11
- package/lib/PlayController/index.js +15 -80
- package/lib/Player/App.js +0 -24
- package/lib/Player/Controller.js +17 -93
- package/lib/Player/custom/SpatialScenePanel/index.js +42 -68
- package/lib/Player/hooks.js +0 -10
- package/lib/Player/index.js +24 -84
- package/lib/Player/modules/Drawer/index.js +0 -17
- package/lib/Player/modules/PopUp/index.js +0 -10
- package/lib/Player/modules/ResizeObserver/index.js +0 -8
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +17 -111
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -24
- package/lib/Player/modules/VideoAgent/index.js +0 -17
- package/lib/Player/modules/Wave/index.js +0 -11
- package/lib/Player/modules/keyframes/BgMusic/index.js +2 -15
- package/lib/Player/modules/keyframes/CameraMovement/index.js +3 -27
- package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -25
- package/lib/Player/modules/keyframes/ModelVideo/index.js +3 -29
- package/lib/Player/modules/keyframes/PanoEffect/index.js +15 -43
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +0 -7
- package/lib/Player/modules/keyframes/PanoTag/index.js +6 -23
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +22 -47
- package/lib/Player/modules/keyframes/Prompter/index.js +10 -32
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +18 -25
- package/lib/Player/modules/keyframes/VideoEffect/index.js +12 -47
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -2
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +19 -60
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +2 -5
- package/lib/fivePlugins/CameraMovementPlugin/index.js +28 -75
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +11 -60
- package/lib/index.js +0 -1
- package/lib/react/index.js +7 -34
- package/lib/shared-utils/AduioLike.js +5 -39
- package/lib/shared-utils/Preloader.js +0 -7
- package/lib/shared-utils/addResizeListener.js +0 -5
- package/lib/shared-utils/animationFrame/BetterTween.js +2 -38
- package/lib/shared-utils/animationFrame/index.js +2 -10
- package/lib/shared-utils/animationFrame/tween.js +2 -15
- package/lib/shared-utils/createTransMatrix.js +2 -17
- package/lib/shared-utils/getFileExpandedName.js +0 -1
- package/lib/shared-utils/getMediaInfo.js +0 -9
- package/lib/shared-utils/setElementDataset.js +0 -2
- package/lib/typings/VreoUnit.js +0 -15
- package/package.json +2 -2
- package/resources/Player/modules/keyframes/PanoTag/index.tsx +1 -2
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.CameraMovementPlugin = void 0;
|
|
7
|
-
|
|
8
8
|
var _five = require("@realsee/five");
|
|
9
|
-
|
|
10
9
|
var _typings = require("./typings");
|
|
11
|
-
|
|
12
10
|
var _tween = require("../../shared-utils/animationFrame/tween");
|
|
13
|
-
|
|
11
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
14
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
-
|
|
16
13
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
-
|
|
18
14
|
var PI = Math.PI;
|
|
19
15
|
var PI_2 = PI * 2;
|
|
20
|
-
|
|
21
16
|
function formatLatitude(rad) {
|
|
22
17
|
return rad % PI_2;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
function formatLongitude(rad) {
|
|
26
20
|
return rad % PI_2;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
var getLongitudeParams = function getLongitudeParams(from, to, rotation) {
|
|
30
23
|
from = formatLongitude(from);
|
|
31
|
-
to = formatLongitude(to);
|
|
24
|
+
to = formatLongitude(to);
|
|
25
|
+
|
|
26
|
+
// 逆时针旋转,初始值必须是较大的值
|
|
27
|
+
if (rotation === _typings.Rotation.Anticlockwise && from > to) to += PI_2;
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
else if (rotation === _typings.Rotation.Clockwise && to > from) from += PI_2;
|
|
29
|
+
// 顺时针旋转,结束值必须是较大值
|
|
30
|
+
else if (rotation === _typings.Rotation.Clockwise && to > from) from += PI_2;
|
|
31
|
+
|
|
32
|
+
// Loop 旋转,找锐角旋转
|
|
35
33
|
// 如果 to 比 from 大 180°,逆时针转
|
|
36
34
|
// 如果 from 比 to 大 180°,顺时针转
|
|
37
35
|
else if (rotation !== _typings.Rotation.Anticlockwise && rotation !== _typings.Rotation.Clockwise && to - from > PI) return getLongitudeParams(from, to, _typings.Rotation.Clockwise);else if (rotation !== _typings.Rotation.Anticlockwise && rotation !== _typings.Rotation.Clockwise && from - to > PI) return getLongitudeParams(from, to, _typings.Rotation.Anticlockwise);
|
|
@@ -40,44 +38,38 @@ var getLongitudeParams = function getLongitudeParams(from, to, rotation) {
|
|
|
40
38
|
to: to
|
|
41
39
|
};
|
|
42
40
|
};
|
|
43
|
-
|
|
44
41
|
function progressNumber(from, to, pst) {
|
|
45
42
|
return from + (to - from) * pst;
|
|
46
43
|
}
|
|
44
|
+
|
|
47
45
|
/**
|
|
48
46
|
* **运镜插件** 模拟类似于电影运镜效果。
|
|
49
47
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
48
|
var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
53
49
|
var move = function move(args, duration) {
|
|
54
50
|
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
55
51
|
preload: true
|
|
56
52
|
};
|
|
57
53
|
return new Promise( /*#__PURE__*/function () {
|
|
58
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
|
54
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
|
|
59
55
|
var panoIndex, movePanoOptions;
|
|
60
|
-
return
|
|
56
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
61
57
|
while (1) {
|
|
62
58
|
switch (_context.prev = _context.next) {
|
|
63
59
|
case 0:
|
|
64
60
|
if (opts.asyncStartCallback) {
|
|
65
61
|
opts.asyncStartCallback();
|
|
66
62
|
}
|
|
67
|
-
|
|
68
63
|
if (!(five.panoIndex === undefined)) {
|
|
69
64
|
_context.next = 3;
|
|
70
65
|
break;
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
return _context.abrupt("return", reject(false));
|
|
74
|
-
|
|
75
68
|
case 3:
|
|
76
69
|
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
77
70
|
_context.next = 6;
|
|
78
71
|
break;
|
|
79
72
|
}
|
|
80
|
-
|
|
81
73
|
_context.next = 6;
|
|
82
74
|
return new Promise(function (resolve) {
|
|
83
75
|
if (!args.mode) return;
|
|
@@ -95,44 +87,34 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
95
87
|
panoIndex: args.panoIndex || undefined
|
|
96
88
|
});
|
|
97
89
|
});
|
|
98
|
-
|
|
99
90
|
case 6:
|
|
100
91
|
if (!(args.mode === _five.Five.Mode.Floorplan)) {
|
|
101
92
|
_context.next = 8;
|
|
102
93
|
break;
|
|
103
94
|
}
|
|
104
|
-
|
|
105
95
|
return _context.abrupt("return", resolve(true));
|
|
106
|
-
|
|
107
96
|
case 8:
|
|
108
97
|
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
109
98
|
_context.next = 11;
|
|
110
99
|
break;
|
|
111
100
|
}
|
|
112
|
-
|
|
113
101
|
_context.next = 11;
|
|
114
102
|
return five.preloadPano(args.panoIndex);
|
|
115
|
-
|
|
116
103
|
case 11:
|
|
117
104
|
if (opts.asyncEndCallback) {
|
|
118
105
|
opts.asyncEndCallback();
|
|
119
106
|
}
|
|
120
|
-
|
|
121
107
|
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
122
108
|
_context.next = 14;
|
|
123
109
|
break;
|
|
124
110
|
}
|
|
125
|
-
|
|
126
111
|
return _context.abrupt("return", resolve(true));
|
|
127
|
-
|
|
128
112
|
case 14:
|
|
129
113
|
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
130
|
-
|
|
131
114
|
if (!(panoIndex !== undefined)) {
|
|
132
115
|
_context.next = 21;
|
|
133
116
|
break;
|
|
134
117
|
}
|
|
135
|
-
|
|
136
118
|
movePanoOptions = Object.assign(args, {
|
|
137
119
|
duration: duration,
|
|
138
120
|
// 移动耗时
|
|
@@ -144,18 +126,14 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
144
126
|
resolve(true);
|
|
145
127
|
} // 移动开始
|
|
146
128
|
// effect: args.transEffect || 'fade',
|
|
147
|
-
|
|
148
129
|
});
|
|
149
130
|
_context.next = 19;
|
|
150
131
|
return five.moveToPano(panoIndex, movePanoOptions);
|
|
151
|
-
|
|
152
132
|
case 19:
|
|
153
133
|
_context.next = 22;
|
|
154
134
|
break;
|
|
155
|
-
|
|
156
135
|
case 21:
|
|
157
136
|
reject(false);
|
|
158
|
-
|
|
159
137
|
case 22:
|
|
160
138
|
case "end":
|
|
161
139
|
return _context.stop();
|
|
@@ -163,24 +141,21 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
163
141
|
}
|
|
164
142
|
}, _callee);
|
|
165
143
|
}));
|
|
166
|
-
|
|
167
144
|
return function (_x, _x2) {
|
|
168
145
|
return _ref.apply(this, arguments);
|
|
169
146
|
};
|
|
170
147
|
}());
|
|
171
148
|
};
|
|
172
|
-
|
|
173
149
|
var getAnimeParams = function getAnimeParams(args) {
|
|
174
|
-
var currentFiveState = five.state;
|
|
175
|
-
|
|
150
|
+
var currentFiveState = five.state;
|
|
151
|
+
// latitude
|
|
176
152
|
var fromLatitude = formatLatitude(currentFiveState.latitude);
|
|
177
|
-
var toLatitude = formatLatitude(args.latitude);
|
|
178
|
-
|
|
153
|
+
var toLatitude = formatLatitude(args.latitude);
|
|
154
|
+
// longitude
|
|
179
155
|
var _getLongitudeParams = getLongitudeParams(currentFiveState.longitude, args.longitude, args.rotation || _typings.Rotation.Loop),
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
156
|
+
fromLongitude = _getLongitudeParams.from,
|
|
157
|
+
toLongitude = _getLongitudeParams.to;
|
|
158
|
+
// fov
|
|
184
159
|
var fromFov = currentFiveState.fov;
|
|
185
160
|
var toFov = args.fov;
|
|
186
161
|
return {
|
|
@@ -196,48 +171,40 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
196
171
|
}
|
|
197
172
|
};
|
|
198
173
|
};
|
|
199
|
-
|
|
200
174
|
var rotate = /*#__PURE__*/function () {
|
|
201
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
|
175
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(args, duration) {
|
|
202
176
|
var opts,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
177
|
+
_getAnimeParams,
|
|
178
|
+
from,
|
|
179
|
+
to,
|
|
180
|
+
_args2 = arguments;
|
|
181
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
209
182
|
while (1) {
|
|
210
183
|
switch (_context2.prev = _context2.next) {
|
|
211
184
|
case 0:
|
|
212
185
|
opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
213
|
-
|
|
214
186
|
if (opts.asyncStartCallback) {
|
|
215
187
|
opts.asyncStartCallback();
|
|
216
|
-
}
|
|
217
|
-
|
|
188
|
+
}
|
|
218
189
|
|
|
190
|
+
// 先切换模型再出旋转效果
|
|
219
191
|
if (!(args.mode && five.currentMode !== args.mode)) {
|
|
220
192
|
_context2.next = 5;
|
|
221
193
|
break;
|
|
222
194
|
}
|
|
223
|
-
|
|
224
195
|
_context2.next = 5;
|
|
225
196
|
return five.changeMode(args.mode);
|
|
226
|
-
|
|
227
197
|
case 5:
|
|
228
198
|
if (!(args.mode === _five.Five.Mode.Panorama && five.currentMode === _five.Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
229
199
|
_context2.next = 11;
|
|
230
200
|
break;
|
|
231
201
|
}
|
|
232
|
-
|
|
233
202
|
if (!opts.preload) {
|
|
234
203
|
_context2.next = 9;
|
|
235
204
|
break;
|
|
236
205
|
}
|
|
237
|
-
|
|
238
206
|
_context2.next = 9;
|
|
239
207
|
return five.preloadPano(args.panoIndex);
|
|
240
|
-
|
|
241
208
|
case 9:
|
|
242
209
|
_context2.next = 11;
|
|
243
210
|
return new Promise(function (resolve, reject) {
|
|
@@ -253,12 +220,10 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
253
220
|
effect: 'fade'
|
|
254
221
|
});
|
|
255
222
|
});
|
|
256
|
-
|
|
257
223
|
case 11:
|
|
258
224
|
if (opts.asyncEndCallback) {
|
|
259
225
|
opts.asyncEndCallback();
|
|
260
226
|
}
|
|
261
|
-
|
|
262
227
|
_getAnimeParams = getAnimeParams(args), from = _getAnimeParams.from, to = _getAnimeParams.to;
|
|
263
228
|
_context2.next = 15;
|
|
264
229
|
return new Promise(function (resolve, reject) {
|
|
@@ -270,37 +235,28 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
270
235
|
state.fov = progressNumber(from.fov, to.fov, progress);
|
|
271
236
|
five.setState(state, true);
|
|
272
237
|
};
|
|
273
|
-
|
|
274
238
|
var onComplete = function onComplete() {
|
|
275
239
|
resolve(true);
|
|
276
240
|
};
|
|
277
|
-
|
|
278
241
|
var onDestroy = function onDestroy() {
|
|
279
242
|
resolve(false);
|
|
280
243
|
};
|
|
281
|
-
|
|
282
244
|
var animeDuration = duration;
|
|
283
|
-
|
|
284
245
|
if (args.rotation === _typings.Rotation.Loop) {
|
|
285
246
|
animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
|
|
286
247
|
}
|
|
287
|
-
|
|
288
248
|
var tween = (0, _tween.tweenProgress)(animeDuration, _tween.Easing.Linear.None).onUpdate(onUpdate).onComplete(onComplete).onDestroy(onDestroy);
|
|
289
|
-
|
|
290
249
|
if (args.rotation === _typings.Rotation.Loop) {
|
|
291
250
|
tween.repeat(Infinity).yoyo(true);
|
|
292
251
|
}
|
|
293
|
-
|
|
294
252
|
setTimeout(function () {
|
|
295
253
|
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
296
254
|
tween.destroy();
|
|
297
255
|
resolve(true);
|
|
298
256
|
}, duration);
|
|
299
257
|
});
|
|
300
|
-
|
|
301
258
|
case 15:
|
|
302
259
|
return _context2.abrupt("return", _context2.sent);
|
|
303
|
-
|
|
304
260
|
case 16:
|
|
305
261
|
case "end":
|
|
306
262
|
return _context2.stop();
|
|
@@ -308,16 +264,13 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
308
264
|
}
|
|
309
265
|
}, _callee2);
|
|
310
266
|
}));
|
|
311
|
-
|
|
312
267
|
return function rotate(_x3, _x4) {
|
|
313
268
|
return _ref2.apply(this, arguments);
|
|
314
269
|
};
|
|
315
270
|
}();
|
|
316
|
-
|
|
317
271
|
return {
|
|
318
272
|
move: move,
|
|
319
273
|
rotate: rotate
|
|
320
274
|
};
|
|
321
275
|
};
|
|
322
|
-
|
|
323
276
|
exports.CameraMovementPlugin = CameraMovementPlugin;
|
|
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Rotation = exports.CameraMovementEffect = void 0;
|
|
7
|
-
|
|
8
7
|
/* eslint-disable prettier/prettier */
|
|
9
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
10
9
|
var CameraMovementEffect;
|
|
11
10
|
exports.CameraMovementEffect = CameraMovementEffect;
|
|
12
|
-
|
|
13
11
|
(function (CameraMovementEffect) {
|
|
14
12
|
CameraMovementEffect["Move"] = "Move";
|
|
15
13
|
CameraMovementEffect["Rotate"] = "Rotate";
|
|
16
14
|
})(CameraMovementEffect || (exports.CameraMovementEffect = CameraMovementEffect = {}));
|
|
17
|
-
|
|
18
15
|
var Rotation;
|
|
19
16
|
exports.Rotation = Rotation;
|
|
20
|
-
|
|
21
17
|
(function (Rotation) {
|
|
22
18
|
Rotation["Clockwise"] = "Clockwise";
|
|
23
19
|
Rotation["Anticlockwise"] = "Anticlockwise";
|
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
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
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ModelTVVideoPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
12
9
|
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); }
|
|
13
|
-
|
|
14
10
|
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; }
|
|
15
|
-
|
|
16
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
-
|
|
18
12
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
-
|
|
20
13
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
-
|
|
22
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
-
|
|
24
15
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
25
|
-
|
|
26
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
-
|
|
17
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
28
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
29
|
-
|
|
30
19
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
31
|
-
|
|
32
20
|
var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
33
21
|
var videoElement = _ref.videoElement;
|
|
34
22
|
var state = {
|
|
@@ -39,18 +27,15 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
39
27
|
enabled: false,
|
|
40
28
|
videoElement: videoElement
|
|
41
29
|
};
|
|
42
|
-
|
|
43
30
|
var setMuted = function setMuted(muted) {
|
|
44
31
|
if (state.videoTexture) {
|
|
45
32
|
state.videoTexture.image.muted = muted;
|
|
46
33
|
state.videoTexture.image.play();
|
|
47
34
|
}
|
|
48
35
|
};
|
|
49
|
-
|
|
50
36
|
var getMuted = function getMuted() {
|
|
51
37
|
if (state.videoTexture) return state.videoTexture.image.muted;else return true;
|
|
52
38
|
};
|
|
53
|
-
|
|
54
39
|
var enable = function enable() {
|
|
55
40
|
if (state.enabled) return;
|
|
56
41
|
if (!state.videoTexture) return;
|
|
@@ -59,13 +44,10 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
59
44
|
state.videoMeshes.forEach(function (mesh) {
|
|
60
45
|
return five.scene.add(mesh);
|
|
61
46
|
});
|
|
62
|
-
|
|
63
47
|
var play = function play() {
|
|
64
48
|
if (!state.videoTexture) return;
|
|
65
|
-
|
|
66
49
|
var timeupdate = function timeupdate() {
|
|
67
50
|
var _state$videoTexture;
|
|
68
|
-
|
|
69
51
|
if (!state.videoTexture) return;
|
|
70
52
|
(_state$videoTexture = state.videoTexture) === null || _state$videoTexture === void 0 ? void 0 : _state$videoTexture.image.removeEventListener('timeupdate', timeupdate);
|
|
71
53
|
state.videoTextureEnabled = true;
|
|
@@ -74,21 +56,17 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
74
56
|
});
|
|
75
57
|
five.needsRender = true;
|
|
76
58
|
};
|
|
77
|
-
|
|
78
59
|
state.videoTexture.image.addEventListener('timeupdate', timeupdate);
|
|
79
|
-
|
|
80
60
|
if (state.videoTexture && state.videoMeshes.length) {
|
|
81
61
|
state.videoTexture.image.play();
|
|
82
62
|
}
|
|
83
63
|
};
|
|
84
|
-
|
|
85
64
|
if (five.model.loaded) play();else {
|
|
86
65
|
return five.once('modelLoaded', function () {
|
|
87
66
|
return play();
|
|
88
67
|
});
|
|
89
68
|
}
|
|
90
69
|
};
|
|
91
|
-
|
|
92
70
|
var disable = function disable() {
|
|
93
71
|
if (!state.enabled) return;
|
|
94
72
|
state.enabled = false;
|
|
@@ -101,47 +79,36 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
101
79
|
state.videoMeshes = [];
|
|
102
80
|
five.needsRender = true;
|
|
103
81
|
};
|
|
104
|
-
|
|
105
82
|
var createPanoVideoMeshes = function createPanoVideoMeshes() {
|
|
106
83
|
return state.rectPoints.map(function (points, index) {
|
|
107
84
|
var geometry = new THREE.BufferGeometry();
|
|
108
85
|
var segments = 128;
|
|
109
86
|
var verticesArray = [];
|
|
110
87
|
verticesArray.push(points[0].x, points[0].y, points[0].z);
|
|
111
|
-
|
|
112
88
|
for (var i = 1; i < segments; i++) {
|
|
113
89
|
verticesArray.push(points[0].x + (points[1].x - points[0].x) * i / segments, points[0].y + (points[1].y - points[0].y) * i / segments, points[0].z + (points[1].z - points[0].z) * i / segments);
|
|
114
90
|
}
|
|
115
|
-
|
|
116
91
|
verticesArray.push(points[1].x, points[1].y, points[1].z);
|
|
117
92
|
verticesArray.push(points[2].x, points[2].y, points[2].z);
|
|
118
|
-
|
|
119
93
|
for (var _i = 1; _i < segments; _i++) {
|
|
120
94
|
verticesArray.push(points[2].x + (points[3].x - points[2].x) * _i / segments, points[2].y + (points[3].y - points[2].y) * _i / segments, points[2].z + (points[3].z - points[2].z) * _i / segments);
|
|
121
95
|
}
|
|
122
|
-
|
|
123
96
|
verticesArray.push(points[3].x, points[3].y, points[3].z);
|
|
124
97
|
var uvArray = [];
|
|
125
98
|
uvArray.push(0, 1);
|
|
126
|
-
|
|
127
99
|
for (var _i2 = 1; _i2 < segments; _i2++) {
|
|
128
100
|
uvArray.push(0, 1 - _i2 / segments);
|
|
129
101
|
}
|
|
130
|
-
|
|
131
102
|
uvArray.push(0, 0);
|
|
132
103
|
uvArray.push(1, 0);
|
|
133
|
-
|
|
134
104
|
for (var _i3 = 1; _i3 < segments; _i3++) {
|
|
135
105
|
uvArray.push(1, _i3 / segments);
|
|
136
106
|
}
|
|
137
|
-
|
|
138
107
|
uvArray.push(1, 1);
|
|
139
108
|
var indicesArray = [];
|
|
140
|
-
|
|
141
109
|
for (var _i4 = 0; _i4 < segments; _i4++) {
|
|
142
110
|
indicesArray.push(_i4, _i4 + 1, segments * 2 - _i4, _i4, segments * 2 - _i4, segments * 2 + 1 - _i4);
|
|
143
111
|
}
|
|
144
|
-
|
|
145
112
|
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(verticesArray), 3));
|
|
146
113
|
geometry.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(uvArray), 2));
|
|
147
114
|
geometry.setIndex(new THREE.BufferAttribute(new Uint32Array(indicesArray), 1));
|
|
@@ -155,7 +122,6 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
155
122
|
return mesh;
|
|
156
123
|
});
|
|
157
124
|
};
|
|
158
|
-
|
|
159
125
|
var getImageTexture = function getImageTexture(source) {
|
|
160
126
|
var texture = new THREE.TextureLoader().load(source);
|
|
161
127
|
texture.minFilter = THREE.LinearFilter;
|
|
@@ -163,11 +129,9 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
163
129
|
texture.format = THREE.RGBFormat;
|
|
164
130
|
return texture;
|
|
165
131
|
};
|
|
166
|
-
|
|
167
132
|
var getVideoTexture = function getVideoTexture(source, video) {
|
|
168
133
|
return new Promise(function (resolve, reject) {
|
|
169
134
|
var xhr = new XMLHttpRequest();
|
|
170
|
-
|
|
171
135
|
xhr.onreadystatechange = function () {
|
|
172
136
|
if (xhr.readyState == 4) {
|
|
173
137
|
if (xhr.status == 200) {
|
|
@@ -191,21 +155,18 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
191
155
|
}
|
|
192
156
|
}
|
|
193
157
|
};
|
|
194
|
-
|
|
195
158
|
xhr.onerror = function (error) {
|
|
196
159
|
return reject(error);
|
|
197
160
|
};
|
|
198
|
-
|
|
199
161
|
xhr.open('GET', source);
|
|
200
162
|
xhr.responseType = 'blob';
|
|
201
163
|
xhr.send();
|
|
202
164
|
});
|
|
203
165
|
};
|
|
204
|
-
|
|
205
166
|
var load = /*#__PURE__*/function () {
|
|
206
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
|
167
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, videoElement) {
|
|
207
168
|
var video_src, video_poster_src, points;
|
|
208
|
-
return
|
|
169
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
209
170
|
while (1) {
|
|
210
171
|
switch (_context.prev = _context.next) {
|
|
211
172
|
case 0:
|
|
@@ -214,25 +175,21 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
214
175
|
state.rectPoints = points.map(function (items) {
|
|
215
176
|
return items.map(function (_ref3) {
|
|
216
177
|
var x = _ref3.x,
|
|
217
|
-
|
|
218
|
-
|
|
178
|
+
y = _ref3.y,
|
|
179
|
+
z = _ref3.z;
|
|
219
180
|
return new THREE.Vector3(x, y, z);
|
|
220
181
|
});
|
|
221
182
|
});
|
|
222
183
|
state.imageTexture = getImageTexture(video_poster_src);
|
|
223
|
-
|
|
224
184
|
if (videoElement) {
|
|
225
185
|
state.videoElement = videoElement;
|
|
226
186
|
}
|
|
227
|
-
|
|
228
187
|
_context.next = 7;
|
|
229
188
|
return getVideoTexture(state.videoSource, state.videoElement);
|
|
230
|
-
|
|
231
189
|
case 7:
|
|
232
190
|
state.videoTexture = _context.sent;
|
|
233
191
|
state.enabled = !!data.enable;
|
|
234
192
|
if (state.enabled) enable();
|
|
235
|
-
|
|
236
193
|
case 10:
|
|
237
194
|
case "end":
|
|
238
195
|
return _context.stop();
|
|
@@ -240,22 +197,18 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
240
197
|
}
|
|
241
198
|
}, _callee);
|
|
242
199
|
}));
|
|
243
|
-
|
|
244
200
|
return function load(_x, _x2) {
|
|
245
201
|
return _ref2.apply(this, arguments);
|
|
246
202
|
};
|
|
247
203
|
}();
|
|
248
|
-
|
|
249
204
|
five.on('modeChange', function () {
|
|
250
205
|
return setMuted(true);
|
|
251
206
|
});
|
|
252
207
|
five.on('wantsTapGesture', function (raycaster) {
|
|
253
208
|
if (!state.enabled) return;
|
|
254
|
-
|
|
255
209
|
var _raycaster$intersectO = raycaster.intersectObjects(five.scene.children, true),
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
210
|
+
_raycaster$intersectO2 = _slicedToArray(_raycaster$intersectO, 1),
|
|
211
|
+
intersect = _raycaster$intersectO2[0];
|
|
259
212
|
if (!!intersect && /^video/.test(intersect.object.name)) {
|
|
260
213
|
if (state.videoTexture) setMuted(!state.videoTexture.image.muted);
|
|
261
214
|
return false;
|
|
@@ -274,11 +227,9 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
274
227
|
}).filter(function (vector) {
|
|
275
228
|
vector = vector.clone().sub(cameraPosition).normalize();
|
|
276
229
|
var raycaster = new THREE.Raycaster(cameraPosition, vector);
|
|
277
|
-
|
|
278
230
|
var _raycaster$intersectO3 = raycaster.intersectObjects(five.scene.children, true),
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
231
|
+
_raycaster$intersectO4 = _slicedToArray(_raycaster$intersectO3, 1),
|
|
232
|
+
intersect = _raycaster$intersectO4[0];
|
|
282
233
|
return !!intersect && /^video/.test(intersect.object.name);
|
|
283
234
|
}).length >= 2;
|
|
284
235
|
});
|
|
@@ -286,7 +237,8 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
286
237
|
});
|
|
287
238
|
five.on('renderFrame', function () {
|
|
288
239
|
state.videoMeshes.forEach(function (meshes) {
|
|
289
|
-
if (meshes)
|
|
240
|
+
if (meshes)
|
|
241
|
+
//@ts-ignore
|
|
290
242
|
meshes.needsRender = true;
|
|
291
243
|
});
|
|
292
244
|
});
|
|
@@ -301,5 +253,4 @@ var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
301
253
|
load: load
|
|
302
254
|
};
|
|
303
255
|
};
|
|
304
|
-
|
|
305
256
|
exports.ModelTVVideoPlugin = ModelTVVideoPlugin;
|