@realsee/vreo 1.0.0-alpha.1 → 1.0.0-alpha.11
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/docs/assets/search.js +1 -1
- package/docs/classes/Player.AudioLike.html +6 -6
- package/docs/classes/Player.Controller.html +12 -12
- package/docs/classes/Player.Player-1.html +11 -11
- package/docs/classes/Player.VideoAgentMesh.html +12 -12
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/demo/assets/{AppReact.d0ee843a.js → AppReact.e6e509fc.js} +1 -1
- package/docs/demo/assets/default.bc4c715d.css +1 -0
- package/docs/demo/assets/default.e9102488.js +3988 -0
- package/docs/demo/assets/{dynamic.76506c2c.js → dynamic.0dd42f6c.js} +1 -1
- package/docs/demo/assets/{examples.3d8323db.js → examples.e70954e5.js} +1 -1
- package/docs/demo/assets/{index.7e31122c.js → index.62e9f091.js} +1 -1
- package/docs/demo/assets/{main.79b11b9d.js → main.c6fa1444.js} +1 -1
- package/docs/demo/assets/{react.c1c07c14.js → react.89edd358.js} +1 -1
- package/docs/demo/examples.html +3 -3
- package/docs/demo/index-react-dynamic.html +5 -5
- package/docs/demo/index-react.html +5 -5
- package/docs/demo/index.html +4 -4
- 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.PanoTagStyleEnum.html +2 -2
- 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/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +4 -3
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +3 -3
- 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.CSS3DRenderPluginExportType.html +2 -2
- 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/fivePlugins.Vector3Position.html +1 -1
- package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +16 -16
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +3 -3
- package/docs/modules/react.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.js +6 -11
- package/lib/PlayController/index.js +16 -82
- package/lib/Player/App.js +6 -28
- package/lib/Player/Controller.d.ts +27 -8
- package/lib/Player/Controller.js +163 -84
- package/lib/Player/custom/SpatialScenePanel/index.js +44 -69
- package/lib/Player/hooks.js +2 -12
- package/lib/Player/index.d.ts +2 -1
- package/lib/Player/index.js +63 -108
- package/lib/Player/modules/Drawer/index.js +0 -17
- package/lib/Player/modules/PopUp/index.js +0 -10
- package/lib/Player/modules/ResizeObserver/index.d.ts +2 -0
- package/lib/Player/modules/ResizeObserver/index.js +29 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +1 -1
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +58 -151
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +3 -7
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +21 -52
- package/lib/Player/modules/VideoAgent/index.js +45 -21
- package/lib/Player/modules/Wave/index.d.ts +5 -0
- package/lib/Player/modules/Wave/index.js +158 -0
- 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 +28 -33
- 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.d.ts +1 -2
- package/lib/Player/modules/keyframes/PanoTag/index.js +74 -144
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +22 -48
- package/lib/Player/modules/keyframes/Prompter/index.js +14 -35
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +18 -25
- package/lib/Player/modules/keyframes/VideoEffect/index.js +12 -47
- package/lib/Player/typings.d.ts +9 -2
- 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 +30 -80
- 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.d.ts +2 -2
- package/lib/react/index.js +7 -34
- package/lib/shared-utils/AduioLike.js +12 -45
- package/lib/shared-utils/Preloader.js +0 -7
- package/lib/shared-utils/addResizeListener.d.ts +4 -0
- package/lib/shared-utils/addResizeListener.js +46 -0
- 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.d.ts +1 -0
- package/lib/shared-utils/getFileExpandedName.js +12 -0
- package/lib/shared-utils/getMediaInfo.d.ts +9 -0
- package/lib/shared-utils/getMediaInfo.js +66 -0
- package/lib/shared-utils/setElementDataset.d.ts +1 -0
- package/lib/shared-utils/setElementDataset.js +22 -0
- package/lib/typings/VreoUnit.d.ts +4 -0
- package/lib/typings/VreoUnit.js +0 -15
- package/package.json +2 -2
- package/resources/Player/Controller.ts +4 -7
- package/resources/Player/index.tsx +2 -0
- package/resources/Player/modules/Wave/index.tsx +133 -12
- package/resources/Player/modules/keyframes/PanoTag/index.tsx +1 -2
- package/resources/typings/VreoUnit.ts +1 -1
- package/stylesheets/default.css +4 -2
- package/docs/demo/assets/default.63925584.js +0 -3984
- package/docs/demo/assets/default.f3f3ca8c.css +0 -1
|
@@ -1,66 +1,42 @@
|
|
|
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.VideoAgentMesh = void 0;
|
|
9
|
-
|
|
10
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
12
9
|
var _Preloader = require("../../../shared-utils/Preloader");
|
|
13
|
-
|
|
14
10
|
var _mobx = require("mobx");
|
|
15
|
-
|
|
16
11
|
var _AduioLike = _interopRequireDefault(require("../../../shared-utils/AduioLike"));
|
|
17
|
-
|
|
12
|
+
var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
|
|
18
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
16
|
+
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; }
|
|
24
17
|
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); } }
|
|
25
|
-
|
|
26
18
|
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); }); }; }
|
|
27
|
-
|
|
28
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
-
|
|
30
20
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
|
-
|
|
32
21
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
|
-
|
|
34
22
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
|
-
|
|
36
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
-
|
|
23
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
38
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
39
|
-
|
|
40
25
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
41
|
-
|
|
42
26
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
-
|
|
44
27
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
|
-
|
|
46
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
47
|
-
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
48
29
|
var vertexShader = "\nvarying vec2 vUv;\nvarying vec2 vColorUv;\nvarying vec2 vMaskUv;\nvoid main(){\n vUv = uv;\n vColorUv = vec2(uv.x / 2.0, uv.y);\n vMaskUv = vec2(0.5 + uv.x / 2.0, uv.y);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
|
|
49
|
-
|
|
50
30
|
var fragmentShaderTpl = function fragmentShaderTpl() {
|
|
51
31
|
return "\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\nvarying vec2 vColorUv;\nvarying vec2 vMaskUv;\n\nvec3 hsv2rgb(vec3 c) {\n const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\nvec3 rgb2hsv(vec3 c) {\n const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + 0.001)), d / (q.x + 0.001), q.x);\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float amask = 1.0;\n\n float ref = color.r;\n if (ref < color.b) ref = color.b;\n amask = color.g - ref + 0.1;\n amask = smoothstep(0.1, 0.3, amask);\n amask = 1.0 - amask;\n\n vec3 target = rgb2hsv(vec3(0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0));\n vec3 hsv = rgb2hsv(color);\n float distance = abs(hsv.x - target.x);\n if (distance < 0.15) {\n hsv.y = 0.0;\n }\n color = hsv2rgb(hsv);\n\n gl_FragColor = vec4(color.rgb, amask * float(enable));\n}\n";
|
|
52
32
|
};
|
|
53
|
-
|
|
54
33
|
var cacheInstance = {};
|
|
55
|
-
|
|
56
34
|
/**
|
|
57
35
|
* 视频经纪人MESH
|
|
58
36
|
*/
|
|
59
37
|
var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
60
38
|
_inherits(VideoAgentMesh, _THREE$Mesh);
|
|
61
|
-
|
|
62
39
|
var _super = _createSuper(VideoAgentMesh);
|
|
63
|
-
|
|
64
40
|
/**
|
|
65
41
|
*
|
|
66
42
|
* @param width
|
|
@@ -71,21 +47,18 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
71
47
|
*/
|
|
72
48
|
function VideoAgentMesh(width, height, widthSegments, heightSegments) {
|
|
73
49
|
var _this$options$videoIn, _this$options$videoIn2, _this$options$videoIn3;
|
|
74
|
-
|
|
75
50
|
var _this;
|
|
76
|
-
|
|
77
51
|
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
78
52
|
preload: true
|
|
79
53
|
};
|
|
80
|
-
|
|
81
54
|
_classCallCheck(this, VideoAgentMesh);
|
|
82
|
-
|
|
83
55
|
if (!options.videoInstance) {
|
|
84
56
|
if (cacheInstance.videoInstance) {
|
|
85
57
|
options.videoInstance = cacheInstance.videoInstance;
|
|
86
58
|
} else {
|
|
87
59
|
var videoInstance = document.createElement('video');
|
|
88
60
|
videoInstance.style.opacity = '0';
|
|
61
|
+
videoInstance.style.pointerEvents = 'none';
|
|
89
62
|
videoInstance.style.display = 'none';
|
|
90
63
|
document.body.append(videoInstance);
|
|
91
64
|
options.videoInstance = videoInstance;
|
|
@@ -94,7 +67,6 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
94
67
|
videoInstance.controls = false;
|
|
95
68
|
}
|
|
96
69
|
}
|
|
97
|
-
|
|
98
70
|
var geometry = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
|
|
99
71
|
var videoTexture = new THREE.VideoTexture(options.videoInstance);
|
|
100
72
|
var material = new THREE.ShaderMaterial({
|
|
@@ -114,19 +86,16 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
114
86
|
_this.options = options;
|
|
115
87
|
_this.freeze = false;
|
|
116
88
|
_this.paused = true;
|
|
117
|
-
|
|
118
89
|
if (!options.audioInstance) {
|
|
119
90
|
if (cacheInstance.audioInstance) {
|
|
120
91
|
_this.audioInstance = cacheInstance.audioInstance;
|
|
121
92
|
} else {
|
|
122
93
|
var audioInstance = document.createElement('audio');
|
|
123
|
-
audioInstance.crossOrigin = '';
|
|
124
|
-
|
|
94
|
+
audioInstance.crossOrigin = '';
|
|
95
|
+
// videoInstance.muted = true
|
|
125
96
|
audioInstance.muted = false;
|
|
126
|
-
audioInstance.
|
|
127
|
-
audioInstance.
|
|
128
|
-
audioInstance.setAttribute('autoplay', 'false');
|
|
129
|
-
audioInstance.setAttribute('style', 'display: none;');
|
|
97
|
+
audioInstance.autoplay = false;
|
|
98
|
+
audioInstance.style.display = 'none';
|
|
130
99
|
document.body.appendChild(audioInstance);
|
|
131
100
|
_this.audioInstance = audioInstance;
|
|
132
101
|
cacheInstance.audioInstance = audioInstance;
|
|
@@ -134,76 +103,52 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
134
103
|
} else {
|
|
135
104
|
_this.audioInstance = options.audioInstance;
|
|
136
105
|
}
|
|
137
|
-
|
|
138
106
|
_this.audioLikeInstance = new _AduioLike["default"]();
|
|
139
107
|
(0, _mobx.makeObservable)(_assertThisInitialized(_this), {
|
|
140
108
|
paused: _mobx.observable
|
|
141
109
|
});
|
|
142
|
-
|
|
143
110
|
var updatePaused = function updatePaused(paused) {
|
|
144
111
|
return (0, _mobx.runInAction)(function () {
|
|
145
112
|
return _this.paused = paused;
|
|
146
113
|
});
|
|
147
114
|
};
|
|
148
|
-
|
|
149
115
|
var onPause = function onPause() {
|
|
150
116
|
return updatePaused(true);
|
|
151
117
|
};
|
|
152
|
-
|
|
153
118
|
var onPlay = function onPlay() {
|
|
154
119
|
return updatePaused(false);
|
|
155
120
|
};
|
|
156
|
-
|
|
157
121
|
var onEnded = function onEnded() {
|
|
158
|
-
console.log('vreo: video 播放结束');
|
|
122
|
+
return console.log('vreo: video 播放结束');
|
|
159
123
|
};
|
|
160
|
-
|
|
161
124
|
_this.audioInstance.addEventListener('pause', onPause);
|
|
162
|
-
|
|
163
125
|
_this.audioInstance.addEventListener('play', onPlay);
|
|
164
|
-
|
|
165
126
|
(_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
|
|
166
127
|
(_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
|
|
167
|
-
|
|
168
128
|
_this.audioLikeInstance.addEventListener('pause', onPause);
|
|
169
|
-
|
|
170
129
|
_this.audioLikeInstance.addEventListener('play', onPlay);
|
|
171
|
-
|
|
172
130
|
(_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.addEventListener('ended', onEnded);
|
|
173
|
-
|
|
174
131
|
_this.$removeEventListener = function () {
|
|
175
132
|
var _this$options$videoIn4, _this$options$videoIn5, _this$options$videoIn6;
|
|
176
|
-
|
|
177
133
|
_this.audioInstance.removeEventListener('pause', onPause);
|
|
178
|
-
|
|
179
134
|
_this.audioInstance.removeEventListener('play', onPlay);
|
|
180
|
-
|
|
181
135
|
(_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('pause', onPause);
|
|
182
136
|
(_this$options$videoIn5 = _this.options.videoInstance) === null || _this$options$videoIn5 === void 0 ? void 0 : _this$options$videoIn5.removeEventListener('play', onPlay);
|
|
183
|
-
|
|
184
137
|
_this.audioLikeInstance.removeEventListener('pause', onPause);
|
|
185
|
-
|
|
186
138
|
_this.audioLikeInstance.removeEventListener('play', onPlay);
|
|
187
|
-
|
|
188
139
|
(_this$options$videoIn6 = _this.options.videoInstance) === null || _this$options$videoIn6 === void 0 ? void 0 : _this$options$videoIn6.removeEventListener('ended', onEnded);
|
|
189
140
|
};
|
|
190
|
-
|
|
191
141
|
return _this;
|
|
192
142
|
}
|
|
193
|
-
|
|
194
143
|
_createClass(VideoAgentMesh, [{
|
|
195
|
-
key: "
|
|
144
|
+
key: "mediaInstance",
|
|
196
145
|
get: function get() {
|
|
197
|
-
var _this$videoUrl;
|
|
198
|
-
|
|
199
146
|
if (!this.videoUrl) {
|
|
200
147
|
return this.audioLikeInstance;
|
|
201
148
|
}
|
|
202
|
-
|
|
203
|
-
if ((_this$videoUrl = this.videoUrl) !== null && _this$videoUrl !== void 0 && _this$videoUrl.endsWith('mp3')) {
|
|
149
|
+
if ((0, _getMediaInfo.getMediaType)(this.videoUrl) === 'audio') {
|
|
204
150
|
return this.audioInstance;
|
|
205
151
|
}
|
|
206
|
-
|
|
207
152
|
var uniforms = this.material.uniforms;
|
|
208
153
|
var videoInstance = uniforms.map.value.image;
|
|
209
154
|
return videoInstance;
|
|
@@ -211,11 +156,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
211
156
|
}, {
|
|
212
157
|
key: "update",
|
|
213
158
|
value: function () {
|
|
214
|
-
var _update = _asyncToGenerator( /*#__PURE__*/
|
|
159
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(videoUrl) {
|
|
215
160
|
var _this2 = this;
|
|
216
|
-
|
|
217
161
|
var uniforms, onStart;
|
|
218
|
-
return
|
|
162
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
219
163
|
while (1) {
|
|
220
164
|
switch (_context.prev = _context.next) {
|
|
221
165
|
case 0:
|
|
@@ -223,58 +167,51 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
223
167
|
_context.next = 2;
|
|
224
168
|
break;
|
|
225
169
|
}
|
|
226
|
-
|
|
227
170
|
return _context.abrupt("return");
|
|
228
|
-
|
|
229
171
|
case 2:
|
|
230
172
|
this.videoUrl = videoUrl;
|
|
173
|
+
|
|
174
|
+
// // 兼容非视频场景
|
|
175
|
+
// if (this.mediaInstance instanceof HTMLAudioElement) {
|
|
176
|
+
// this.mediaInstance.style.display = 'none'
|
|
177
|
+
// } else if (this.mediaInstance instanceof HTMLVideoElement) {
|
|
178
|
+
// this.mediaInstance.style.display = 'block'
|
|
179
|
+
// }
|
|
180
|
+
|
|
231
181
|
this.freeze = true;
|
|
232
182
|
_context.next = 6;
|
|
233
|
-
return this.
|
|
234
|
-
|
|
183
|
+
return this.mediaInstance.pause();
|
|
235
184
|
case 6:
|
|
236
185
|
uniforms = this.material.uniforms;
|
|
237
|
-
this.
|
|
238
|
-
|
|
239
|
-
if (!(this.options.preload || this.options.preload === undefined || this.videoUrl.endsWith('.mp4'))) {
|
|
186
|
+
this.mediaInstance.muted = true;
|
|
187
|
+
if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
|
|
240
188
|
_context.next = 18;
|
|
241
189
|
break;
|
|
242
190
|
}
|
|
243
|
-
|
|
244
191
|
_context.t1 = URL;
|
|
245
192
|
_context.next = 12;
|
|
246
193
|
return _Preloader.Preloader.blob(this.videoUrl);
|
|
247
|
-
|
|
248
194
|
case 12:
|
|
249
195
|
_context.t2 = _context.sent;
|
|
250
196
|
_context.next = 15;
|
|
251
197
|
return _context.t1.createObjectURL.call(_context.t1, _context.t2);
|
|
252
|
-
|
|
253
198
|
case 15:
|
|
254
199
|
_context.t0 = _context.sent;
|
|
255
200
|
_context.next = 19;
|
|
256
201
|
break;
|
|
257
|
-
|
|
258
202
|
case 18:
|
|
259
203
|
_context.t0 = this.videoUrl;
|
|
260
|
-
|
|
261
204
|
case 19:
|
|
262
|
-
this.
|
|
263
|
-
this.
|
|
264
|
-
|
|
205
|
+
this.mediaInstance.src = _context.t0;
|
|
206
|
+
this.mediaInstance.setAttribute('data-src', this.videoUrl);
|
|
265
207
|
onStart = function onStart() {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (_this2.videoInstance.currentTime === 0) return;
|
|
208
|
+
if (_this2.mediaInstance.currentTime === 0) return;
|
|
269
209
|
_this2.freeze = false;
|
|
270
|
-
_this2.
|
|
271
|
-
uniforms.enable.value = (
|
|
272
|
-
|
|
273
|
-
_this2.videoInstance.removeEventListener('timeupdate', onStart, false);
|
|
210
|
+
_this2.mediaInstance.muted = false;
|
|
211
|
+
uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
|
|
212
|
+
_this2.mediaInstance.removeEventListener('timeupdate', onStart, false);
|
|
274
213
|
};
|
|
275
|
-
|
|
276
|
-
this.videoInstance.addEventListener('timeupdate', onStart, false);
|
|
277
|
-
|
|
214
|
+
this.mediaInstance.addEventListener('timeupdate', onStart, false);
|
|
278
215
|
case 23:
|
|
279
216
|
case "end":
|
|
280
217
|
return _context.stop();
|
|
@@ -282,24 +219,21 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
282
219
|
}
|
|
283
220
|
}, _callee, this);
|
|
284
221
|
}));
|
|
285
|
-
|
|
286
222
|
function update(_x) {
|
|
287
223
|
return _update.apply(this, arguments);
|
|
288
224
|
}
|
|
289
|
-
|
|
290
225
|
return update;
|
|
291
226
|
}()
|
|
292
227
|
}, {
|
|
293
228
|
key: "play",
|
|
294
229
|
value: function () {
|
|
295
|
-
var _play = _asyncToGenerator( /*#__PURE__*/
|
|
230
|
+
var _play = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
296
231
|
var _this3 = this;
|
|
297
|
-
|
|
298
232
|
var videoUrl,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return
|
|
233
|
+
currentTime,
|
|
234
|
+
duration,
|
|
235
|
+
_args3 = arguments;
|
|
236
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
303
237
|
while (1) {
|
|
304
238
|
switch (_context3.prev = _context3.next) {
|
|
305
239
|
case 0:
|
|
@@ -307,80 +241,62 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
307
241
|
currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
|
|
308
242
|
duration = _args3.length > 2 ? _args3[2] : undefined;
|
|
309
243
|
videoUrl = videoUrl || '';
|
|
310
|
-
|
|
311
244
|
if (!(duration && !videoUrl)) {
|
|
312
245
|
_context3.next = 10;
|
|
313
246
|
break;
|
|
314
247
|
}
|
|
315
|
-
|
|
316
248
|
if (this.currentTime) {
|
|
317
|
-
this.
|
|
249
|
+
this.mediaInstance.currentTime = currentTime;
|
|
318
250
|
}
|
|
319
|
-
|
|
320
|
-
this.videoInstance.duration = duration;
|
|
251
|
+
this.mediaInstance.duration = duration;
|
|
321
252
|
this.videoUrl = '';
|
|
322
|
-
this.
|
|
253
|
+
this.mediaInstance.play();
|
|
323
254
|
return _context3.abrupt("return", true);
|
|
324
|
-
|
|
325
255
|
case 10:
|
|
326
256
|
if (videoUrl) {
|
|
327
257
|
_context3.next = 18;
|
|
328
258
|
break;
|
|
329
259
|
}
|
|
330
|
-
|
|
331
260
|
if (!this.videoUrl) {
|
|
332
261
|
_context3.next = 16;
|
|
333
262
|
break;
|
|
334
263
|
}
|
|
335
|
-
|
|
336
264
|
_context3.next = 14;
|
|
337
|
-
return this.
|
|
338
|
-
|
|
265
|
+
return this.mediaInstance.play();
|
|
339
266
|
case 14:
|
|
340
267
|
_context3.next = 17;
|
|
341
268
|
break;
|
|
342
|
-
|
|
343
269
|
case 16:
|
|
344
270
|
console.warn('警告:视频资源未初始化。');
|
|
345
|
-
|
|
346
271
|
case 17:
|
|
347
272
|
return _context3.abrupt("return", true);
|
|
348
|
-
|
|
349
273
|
case 18:
|
|
350
|
-
console.log('play', videoUrl, this.videoUrl);
|
|
351
|
-
|
|
352
274
|
if (!(videoUrl === this.videoUrl)) {
|
|
353
|
-
_context3.next =
|
|
275
|
+
_context3.next = 23;
|
|
354
276
|
break;
|
|
355
277
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
case 23:
|
|
278
|
+
this.mediaInstance.currentTime = currentTime;
|
|
279
|
+
_context3.next = 22;
|
|
280
|
+
return this.mediaInstance.play();
|
|
281
|
+
case 22:
|
|
362
282
|
return _context3.abrupt("return", true);
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
_context3.next = 26;
|
|
283
|
+
case 23:
|
|
284
|
+
_context3.next = 25;
|
|
366
285
|
return this.update(videoUrl);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
_context3.next = 29;
|
|
286
|
+
case 25:
|
|
287
|
+
this.mediaInstance.pause();
|
|
288
|
+
_context3.next = 28;
|
|
371
289
|
return new Promise(function (resolve) {
|
|
372
|
-
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
373
|
-
return
|
|
290
|
+
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
291
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
374
292
|
while (1) {
|
|
375
293
|
switch (_context2.prev = _context2.next) {
|
|
376
294
|
case 0:
|
|
377
|
-
_this3.
|
|
295
|
+
_this3.mediaInstance.currentTime = currentTime;
|
|
378
296
|
_context2.next = 3;
|
|
379
|
-
return _this3.
|
|
380
|
-
|
|
297
|
+
return _this3.mediaInstance.play();
|
|
381
298
|
case 3:
|
|
382
299
|
resolve(true);
|
|
383
|
-
|
|
384
300
|
case 4:
|
|
385
301
|
case "end":
|
|
386
302
|
return _context2.stop();
|
|
@@ -389,52 +305,43 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
389
305
|
}, _callee2);
|
|
390
306
|
})), 20);
|
|
391
307
|
});
|
|
392
|
-
|
|
393
|
-
case 29:
|
|
308
|
+
case 28:
|
|
394
309
|
return _context3.abrupt("return", _context3.sent);
|
|
395
|
-
|
|
396
|
-
case 30:
|
|
310
|
+
case 29:
|
|
397
311
|
case "end":
|
|
398
312
|
return _context3.stop();
|
|
399
313
|
}
|
|
400
314
|
}
|
|
401
315
|
}, _callee3, this);
|
|
402
316
|
}));
|
|
403
|
-
|
|
404
317
|
function play() {
|
|
405
318
|
return _play.apply(this, arguments);
|
|
406
319
|
}
|
|
407
|
-
|
|
408
320
|
return play;
|
|
409
321
|
}()
|
|
410
322
|
/**
|
|
411
323
|
* 转成毫秒,保障精准度
|
|
412
324
|
*/
|
|
413
|
-
|
|
414
325
|
}, {
|
|
415
326
|
key: "currentTime",
|
|
416
327
|
get: function get() {
|
|
417
|
-
return this.
|
|
328
|
+
return this.mediaInstance.currentTime * 1000;
|
|
418
329
|
}
|
|
419
330
|
}, {
|
|
420
331
|
key: "dispose",
|
|
421
332
|
value: function dispose() {
|
|
422
333
|
// 销毁事件监听
|
|
423
334
|
this.$removeEventListener();
|
|
424
|
-
|
|
425
335
|
if (cacheInstance.audioInstance) {
|
|
426
336
|
document.body.removeChild(cacheInstance.audioInstance);
|
|
427
337
|
cacheInstance.audioInstance = undefined;
|
|
428
338
|
}
|
|
429
|
-
|
|
430
339
|
if (cacheInstance.videoInstance) {
|
|
431
340
|
document.body.removeChild(cacheInstance.videoInstance);
|
|
432
341
|
cacheInstance.videoInstance = undefined;
|
|
433
342
|
}
|
|
434
343
|
}
|
|
435
344
|
}]);
|
|
436
|
-
|
|
437
345
|
return VideoAgentMesh;
|
|
438
346
|
}(THREE.Mesh);
|
|
439
|
-
|
|
440
347
|
exports.VideoAgentMesh = VideoAgentMesh;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { VideoAgentMesh } from './VideoAgentMesh';
|
|
2
|
+
import { VideoAgentMesh, VideoAgentMeshOptions } from './VideoAgentMesh';
|
|
3
3
|
export declare class VideoAgentScene {
|
|
4
4
|
videoAgentMesh: VideoAgentMesh;
|
|
5
5
|
scene: THREE.Scene;
|
|
6
6
|
camera: THREE.OrthographicCamera;
|
|
7
7
|
renderer: THREE.WebGLRenderer;
|
|
8
|
-
|
|
9
|
-
constructor(container
|
|
10
|
-
videoInstance?: HTMLVideoElement;
|
|
11
|
-
audioInstance?: HTMLAudioElement;
|
|
12
|
-
preload?: boolean;
|
|
13
|
-
});
|
|
8
|
+
disposers: (() => void)[];
|
|
9
|
+
constructor(container?: HTMLElement, options?: VideoAgentMeshOptions);
|
|
14
10
|
run: () => void;
|
|
15
11
|
dispose: () => void;
|
|
16
12
|
}
|
|
@@ -1,91 +1,60 @@
|
|
|
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.VideoAgentScene = void 0;
|
|
9
|
-
|
|
10
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
9
|
+
var _addResizeListener = require("../../../shared-utils/addResizeListener");
|
|
12
10
|
var _VideoAgentMesh = require("./VideoAgentMesh");
|
|
13
|
-
|
|
14
11
|
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); }
|
|
15
|
-
|
|
16
12
|
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; }
|
|
17
|
-
|
|
18
13
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
19
|
-
|
|
20
14
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
-
|
|
22
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
|
|
26
|
-
var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container) {
|
|
17
|
+
var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container, options) {
|
|
27
18
|
var _this = this;
|
|
28
|
-
|
|
29
|
-
var needRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
30
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
31
|
-
|
|
32
19
|
_classCallCheck(this, VideoAgentScene);
|
|
33
|
-
|
|
34
20
|
_defineProperty(this, "scene", new THREE.Scene());
|
|
35
|
-
|
|
36
21
|
_defineProperty(this, "camera", new THREE.OrthographicCamera(-240, 240, 135, -135));
|
|
37
|
-
|
|
38
22
|
_defineProperty(this, "renderer", new THREE.WebGLRenderer({
|
|
39
23
|
alpha: true
|
|
40
24
|
}));
|
|
41
|
-
|
|
25
|
+
_defineProperty(this, "disposers", []);
|
|
42
26
|
_defineProperty(this, "run", function () {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var domElement = _this.renderer.domElement; // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
|
|
46
|
-
|
|
27
|
+
// 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
|
|
47
28
|
if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
|
|
48
29
|
_this.renderer.render(_this.scene, _this.camera);
|
|
49
|
-
} // 兼容非视频场景
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!((_this$videoAgentMesh$ = _this.videoAgentMesh.videoUrl) !== null && _this$videoAgentMesh$ !== void 0 && _this$videoAgentMesh$.endsWith('.mp4'))) {
|
|
53
|
-
if (domElement.style.display !== 'none') domElement.style.display = 'none';
|
|
54
|
-
} else {
|
|
55
|
-
if (domElement.style.display !== 'block') domElement.style.display = 'block';
|
|
56
30
|
}
|
|
57
|
-
|
|
58
31
|
requestAnimationFrame(_this.run);
|
|
59
32
|
});
|
|
60
|
-
|
|
61
33
|
_defineProperty(this, "dispose", function () {
|
|
62
34
|
var _this$videoAgentMesh;
|
|
63
|
-
|
|
64
35
|
(_this$videoAgentMesh = _this.videoAgentMesh) === null || _this$videoAgentMesh === void 0 ? void 0 : _this$videoAgentMesh.dispose();
|
|
36
|
+
_this.disposers.forEach(function (disposer) {
|
|
37
|
+
return disposer === null || disposer === void 0 ? void 0 : disposer();
|
|
38
|
+
});
|
|
65
39
|
});
|
|
66
|
-
|
|
67
|
-
this.container = container;
|
|
68
|
-
this.camera.position.set(0, 0, 10);
|
|
69
|
-
this.camera.lookAt(0, 0, 0);
|
|
70
|
-
var state = {
|
|
71
|
-
width: container.offsetWidth,
|
|
72
|
-
height: container.offsetHeight
|
|
73
|
-
};
|
|
74
|
-
var _domElement = this.renderer.domElement;
|
|
75
|
-
|
|
76
|
-
_domElement.classList.add('VideoAgent-canvas');
|
|
77
|
-
|
|
78
|
-
this.renderer.setSize(state.width * window.devicePixelRatio, state.height * window.devicePixelRatio);
|
|
79
|
-
|
|
80
|
-
_domElement.setAttribute('style', "width: ".concat(state.width, "px;height: ").concat(state.height, "px;"));
|
|
81
|
-
|
|
82
40
|
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
|
|
83
41
|
|
|
84
|
-
|
|
85
|
-
|
|
42
|
+
// const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
|
|
43
|
+
|
|
44
|
+
if (container) {
|
|
45
|
+
this.camera.position.set(0, 0, 10);
|
|
46
|
+
this.camera.lookAt(0, 0, 0);
|
|
47
|
+
var domElement = this.renderer.domElement;
|
|
48
|
+
domElement.classList.add('VideoAgent-canvas');
|
|
49
|
+
var dispose = (0, _addResizeListener.addResizeListener)(container, function (width, height) {
|
|
50
|
+
_this.renderer.setSize(width * window.devicePixelRatio, height * window.devicePixelRatio);
|
|
51
|
+
domElement.style.width = "".concat(width, "px");
|
|
52
|
+
domElement.style.height = "".concat(height, "px");
|
|
53
|
+
});
|
|
54
|
+
this.disposers.push(dispose);
|
|
55
|
+
container.append(domElement);
|
|
86
56
|
this.scene.add(this.videoAgentMesh);
|
|
87
57
|
this.run();
|
|
88
58
|
}
|
|
89
59
|
});
|
|
90
|
-
|
|
91
60
|
exports.VideoAgentScene = VideoAgentScene;
|