@realsee/vreo 0.2.0-alpha.9 → 1.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +16 -5
  3. package/docs/assets/highlight.css +1 -1
  4. package/docs/assets/main.js +2 -2
  5. package/docs/assets/search.js +1 -1
  6. package/docs/assets/style.css +28 -2
  7. package/docs/classes/Player.AudioLike.html +52 -0
  8. package/docs/classes/Player.Controller.html +13 -13
  9. package/docs/classes/Player.Player-1.html +11 -11
  10. package/docs/classes/Player.VideoAgentMesh.html +53 -53
  11. package/docs/classes/Player.VideoAgentScene.html +1 -1
  12. package/docs/demo/assets/AppReact.ea8cbdb3.js +1 -0
  13. package/docs/demo/assets/default.1dd2b2d4.js +3988 -0
  14. package/docs/demo/assets/default.bc4c715d.css +1 -0
  15. package/docs/demo/assets/dynamic.cd7d1da6.js +1 -0
  16. package/docs/demo/assets/examples.98aaf9e2.js +25 -0
  17. package/docs/demo/assets/examples.dac4a6fe.css +1 -0
  18. package/docs/demo/assets/index.9331038f.css +1 -0
  19. package/docs/demo/assets/index.a3d7bd8a.js +1 -0
  20. package/docs/demo/assets/main.f0c47cae.js +1 -0
  21. package/docs/demo/assets/react.2ee8565f.css +1 -0
  22. package/docs/demo/assets/react.5f3bcfc5.js +25 -0
  23. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
  24. package/docs/demo/examples.html +17 -0
  25. package/docs/demo/index-react-dynamic.html +20 -0
  26. package/docs/demo/index-react.html +20 -0
  27. package/docs/demo/index.html +19 -0
  28. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
  29. package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
  30. package/docs/enums/Player.PanoEffectEnum.html +2 -2
  31. package/docs/enums/Player.PanoTagEnum.html +2 -2
  32. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  33. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  34. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  35. package/docs/enums/fivePlugins.Rotation.html +1 -1
  36. package/docs/index.html +13 -6
  37. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  38. package/docs/interfaces/Player.PlayerConfigs.html +4 -3
  39. package/docs/interfaces/Player.Vertex.html +2 -2
  40. package/docs/interfaces/Player.VideoAgentMeshOptions.html +8 -1
  41. package/docs/interfaces/Player.VreoKeyframe.html +2 -2
  42. package/docs/interfaces/Player.VreoUnit.html +2 -2
  43. package/docs/interfaces/Player.VreoVideo.html +2 -2
  44. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
  45. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  46. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  47. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
  48. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  49. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  50. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  51. package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
  52. package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
  53. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  54. package/docs/modules/Player.html +21 -15
  55. package/docs/modules/custom.html +1 -1
  56. package/docs/modules/fivePlugins.html +5 -2
  57. package/docs/modules/react.html +1 -1
  58. package/docs/modules.html +1 -1
  59. package/lib/PlayController/createHTMLAudioElement.js +6 -11
  60. package/lib/PlayController/index.js +19 -85
  61. package/lib/Player/App.js +7 -29
  62. package/lib/Player/Controller.d.ts +29 -8
  63. package/lib/Player/Controller.js +185 -87
  64. package/lib/Player/custom/SpatialScenePanel/index.js +47 -72
  65. package/lib/Player/hooks.js +2 -12
  66. package/lib/Player/index.d.ts +5 -3
  67. package/lib/Player/index.js +108 -122
  68. package/lib/Player/modules/Drawer/index.js +1 -18
  69. package/lib/Player/modules/PopUp/index.js +1 -11
  70. package/lib/Player/modules/ResizeObserver/index.d.ts +2 -0
  71. package/lib/Player/modules/ResizeObserver/index.js +29 -0
  72. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +16 -2
  73. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +124 -145
  74. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +3 -6
  75. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +25 -52
  76. package/lib/Player/modules/VideoAgent/index.js +46 -22
  77. package/lib/Player/modules/Wave/index.d.ts +5 -0
  78. package/lib/Player/modules/Wave/index.js +77 -0
  79. package/lib/Player/modules/keyframes/BgMusic/index.js +3 -16
  80. package/lib/Player/modules/keyframes/CameraMovement/index.js +4 -28
  81. package/lib/Player/modules/keyframes/InfoPanel/index.js +30 -35
  82. package/lib/Player/modules/keyframes/ModelVideo/index.js +40 -29
  83. package/lib/Player/modules/keyframes/PanoEffect/index.js +16 -44
  84. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -8
  85. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -2
  86. package/lib/Player/modules/keyframes/PanoTag/index.js +75 -132
  87. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
  88. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +93 -66
  89. package/lib/Player/modules/keyframes/Prompter/index.js +18 -53
  90. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +22 -25
  91. package/lib/Player/modules/keyframes/VideoEffect/index.js +13 -48
  92. package/lib/Player/typings.d.ts +12 -1
  93. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
  94. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +10 -0
  95. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
  96. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +31 -0
  97. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
  98. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +10 -0
  99. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
  100. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +234 -0
  101. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
  102. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +15 -0
  103. package/lib/fivePlugins/CameraMovementPlugin/index.js +36 -82
  104. package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
  105. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +12 -61
  106. package/lib/index.js +0 -1
  107. package/lib/react/index.d.ts +8 -4
  108. package/lib/react/index.js +10 -37
  109. package/lib/shared-utils/AduioLike.d.ts +37 -0
  110. package/lib/shared-utils/AduioLike.js +132 -0
  111. package/lib/shared-utils/Preloader.js +0 -7
  112. package/lib/shared-utils/addResizeListener.d.ts +4 -0
  113. package/lib/shared-utils/addResizeListener.js +46 -0
  114. package/lib/shared-utils/animationFrame/BetterTween.js +7 -39
  115. package/lib/shared-utils/animationFrame/index.js +2 -10
  116. package/lib/shared-utils/animationFrame/tween.js +3 -16
  117. package/lib/shared-utils/createTransMatrix.d.ts +1 -0
  118. package/lib/shared-utils/createTransMatrix.js +28 -0
  119. package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
  120. package/lib/shared-utils/getFileExpandedName.js +12 -0
  121. package/lib/shared-utils/getMediaInfo.d.ts +9 -0
  122. package/lib/shared-utils/getMediaInfo.js +66 -0
  123. package/lib/shared-utils/setElementDataset.d.ts +1 -0
  124. package/lib/shared-utils/setElementDataset.js +22 -0
  125. package/lib/typings/VreoUnit.d.ts +37 -2
  126. package/lib/typings/VreoUnit.js +10 -13
  127. package/package.json +10 -10
  128. package/resources/PlayController/index.ts +0 -13
  129. package/resources/Player/App.tsx +5 -4
  130. package/resources/Player/Controller.ts +274 -146
  131. package/resources/Player/custom/SpatialScenePanel/index.tsx +5 -5
  132. package/resources/Player/hooks.ts +3 -5
  133. package/resources/Player/index.tsx +190 -140
  134. package/resources/Player/modules/ResizeObserver/index.tsx +23 -0
  135. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +87 -31
  136. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +27 -24
  137. package/resources/Player/modules/VideoAgent/index.tsx +28 -12
  138. package/resources/Player/modules/Wave/index.tsx +64 -0
  139. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +26 -11
  140. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
  141. package/resources/Player/modules/keyframes/PanoTag/index.tsx +52 -97
  142. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +86 -34
  143. package/resources/Player/modules/keyframes/Prompter/index.tsx +6 -16
  144. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +6 -2
  145. package/resources/Player/typings.ts +15 -1
  146. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
  147. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
  148. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
  149. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
  150. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
  151. package/resources/fivePlugins/CameraMovementPlugin/index.ts +19 -12
  152. package/resources/react/index.tsx +7 -3
  153. package/resources/shared-utils/AduioLike.ts +109 -0
  154. package/resources/shared-utils/addResizeListener.ts +46 -0
  155. package/resources/shared-utils/createTransMatrix.ts +12 -0
  156. package/resources/shared-utils/getFileExpandedName.ts +6 -0
  157. package/resources/shared-utils/getMediaInfo.ts +52 -0
  158. package/resources/shared-utils/setElementDataset.ts +18 -0
  159. package/resources/typings/VreoUnit.ts +41 -3
  160. package/stylesheets/custom/SpatialScenePanel.css +2 -1
  161. package/stylesheets/default.css +350 -84
@@ -1,62 +1,42 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
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); }
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
-
11
+ var _AduioLike = _interopRequireDefault(require("../../../shared-utils/AduioLike"));
12
+ var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
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); }
17
-
18
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; }
19
-
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; }
20
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); } }
21
-
22
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); }); }; }
23
-
24
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
-
26
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); } }
27
-
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
-
30
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
-
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
-
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; }
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); }
23
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
34
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); }; }
35
-
36
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); }
37
-
38
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
-
40
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; } }
41
-
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
-
28
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
44
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";
45
-
46
30
  var fragmentShaderTpl = function fragmentShaderTpl() {
47
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";
48
32
  };
49
-
50
33
  var cacheInstance = {};
51
-
52
34
  /**
53
35
  * 视频经纪人MESH
54
36
  */
55
37
  var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
56
38
  _inherits(VideoAgentMesh, _THREE$Mesh);
57
-
58
39
  var _super = _createSuper(VideoAgentMesh);
59
-
60
40
  /**
61
41
  *
62
42
  * @param width
@@ -66,18 +46,19 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
66
46
  * @param options
67
47
  */
68
48
  function VideoAgentMesh(width, height, widthSegments, heightSegments) {
49
+ var _this$options$videoIn, _this$options$videoIn2, _this$options$videoIn3;
69
50
  var _this;
70
-
71
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
72
-
51
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
52
+ preload: true
53
+ };
73
54
  _classCallCheck(this, VideoAgentMesh);
74
-
75
55
  if (!options.videoInstance) {
76
56
  if (cacheInstance.videoInstance) {
77
57
  options.videoInstance = cacheInstance.videoInstance;
78
58
  } else {
79
59
  var videoInstance = document.createElement('video');
80
60
  videoInstance.style.opacity = '0';
61
+ videoInstance.style.pointerEvents = 'none';
81
62
  videoInstance.style.display = 'none';
82
63
  document.body.append(videoInstance);
83
64
  options.videoInstance = videoInstance;
@@ -86,7 +67,6 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
86
67
  videoInstance.controls = false;
87
68
  }
88
69
  }
89
-
90
70
  var geometry = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
91
71
  var videoTexture = new THREE.VideoTexture(options.videoInstance);
92
72
  var material = new THREE.ShaderMaterial({
@@ -106,19 +86,16 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
106
86
  _this.options = options;
107
87
  _this.freeze = false;
108
88
  _this.paused = true;
109
-
110
89
  if (!options.audioInstance) {
111
90
  if (cacheInstance.audioInstance) {
112
91
  _this.audioInstance = cacheInstance.audioInstance;
113
92
  } else {
114
93
  var audioInstance = document.createElement('audio');
115
- audioInstance.crossOrigin = ''; // videoInstance.muted = true
116
-
94
+ audioInstance.crossOrigin = '';
95
+ // videoInstance.muted = true
117
96
  audioInstance.muted = false;
118
- audioInstance.setAttribute('playsinline', 'true');
119
- audioInstance.setAttribute('webkit-playsinline', 'true');
120
- audioInstance.setAttribute('autoplay', 'false');
121
- audioInstance.setAttribute('style', 'display: none;');
97
+ audioInstance.autoplay = false;
98
+ audioInstance.style.display = 'none';
122
99
  document.body.appendChild(audioInstance);
123
100
  _this.audioInstance = audioInstance;
124
101
  cacheInstance.audioInstance = audioInstance;
@@ -126,47 +103,52 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
126
103
  } else {
127
104
  _this.audioInstance = options.audioInstance;
128
105
  }
129
-
106
+ _this.audioLikeInstance = new _AduioLike["default"]();
130
107
  (0, _mobx.makeObservable)(_assertThisInitialized(_this), {
131
108
  paused: _mobx.observable
132
109
  });
133
-
134
110
  var updatePaused = function updatePaused(paused) {
135
111
  return (0, _mobx.runInAction)(function () {
136
112
  return _this.paused = paused;
137
113
  });
138
114
  };
139
-
140
115
  var onPause = function onPause() {
141
116
  return updatePaused(true);
142
117
  };
143
-
144
118
  var onPlay = function onPlay() {
145
119
  return updatePaused(false);
146
120
  };
147
-
148
- _this.videoInstance.addEventListener('pause', onPause);
149
-
150
- _this.videoInstance.addEventListener('play', onPlay);
151
-
121
+ var onEnded = function onEnded() {
122
+ return console.log('vreo: video 播放结束');
123
+ };
124
+ _this.audioInstance.addEventListener('pause', onPause);
125
+ _this.audioInstance.addEventListener('play', onPlay);
126
+ (_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
127
+ (_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
128
+ _this.audioLikeInstance.addEventListener('pause', onPause);
129
+ _this.audioLikeInstance.addEventListener('play', onPlay);
130
+ (_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.addEventListener('ended', onEnded);
152
131
  _this.$removeEventListener = function () {
153
- _this.videoInstance.removeEventListener('pause', onPause);
154
-
155
- _this.videoInstance.removeEventListener('play', onPlay);
132
+ var _this$options$videoIn4, _this$options$videoIn5, _this$options$videoIn6;
133
+ _this.audioInstance.removeEventListener('pause', onPause);
134
+ _this.audioInstance.removeEventListener('play', onPlay);
135
+ (_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('pause', onPause);
136
+ (_this$options$videoIn5 = _this.options.videoInstance) === null || _this$options$videoIn5 === void 0 ? void 0 : _this$options$videoIn5.removeEventListener('play', onPlay);
137
+ _this.audioLikeInstance.removeEventListener('pause', onPause);
138
+ _this.audioLikeInstance.removeEventListener('play', onPlay);
139
+ (_this$options$videoIn6 = _this.options.videoInstance) === null || _this$options$videoIn6 === void 0 ? void 0 : _this$options$videoIn6.removeEventListener('ended', onEnded);
156
140
  };
157
-
158
141
  return _this;
159
142
  }
160
-
161
143
  _createClass(VideoAgentMesh, [{
162
- key: "videoInstance",
144
+ key: "mediaInstance",
163
145
  get: function get() {
164
- var _this$videoUrl;
165
-
166
- if ((_this$videoUrl = this.videoUrl) !== null && _this$videoUrl !== void 0 && _this$videoUrl.endsWith('mp3')) {
146
+ if (!this.videoUrl) {
147
+ return this.audioLikeInstance;
148
+ }
149
+ if ((0, _getMediaInfo.getMediaType)(this.videoUrl) === 'audio') {
167
150
  return this.audioInstance;
168
151
  }
169
-
170
152
  var uniforms = this.material.uniforms;
171
153
  var videoInstance = uniforms.map.value.image;
172
154
  return videoInstance;
@@ -174,11 +156,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
174
156
  }, {
175
157
  key: "update",
176
158
  value: function () {
177
- var _update = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(videoUrl) {
159
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(videoUrl) {
178
160
  var _this2 = this;
179
-
180
161
  var uniforms, onStart;
181
- return regeneratorRuntime.wrap(function _callee$(_context) {
162
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
182
163
  while (1) {
183
164
  switch (_context.prev = _context.next) {
184
165
  case 0:
@@ -186,129 +167,136 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
186
167
  _context.next = 2;
187
168
  break;
188
169
  }
189
-
190
170
  return _context.abrupt("return");
191
-
192
171
  case 2:
193
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
+
194
181
  this.freeze = true;
195
182
  _context.next = 6;
196
- return this.videoInstance.pause();
197
-
183
+ return this.mediaInstance.pause();
198
184
  case 6:
199
185
  uniforms = this.material.uniforms;
200
- this.videoInstance.muted = true;
201
- _context.t0 = URL;
202
- _context.next = 11;
186
+ this.mediaInstance.muted = true;
187
+ if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
188
+ _context.next = 18;
189
+ break;
190
+ }
191
+ _context.t1 = URL;
192
+ _context.next = 12;
203
193
  return _Preloader.Preloader.blob(this.videoUrl);
204
-
205
- case 11:
206
- _context.t1 = _context.sent;
207
- _context.next = 14;
208
- return _context.t0.createObjectURL.call(_context.t0, _context.t1);
209
-
210
- case 14:
211
- this.videoInstance.src = _context.sent;
212
- this.videoInstance.setAttribute('data-src', this.videoUrl);
213
-
194
+ case 12:
195
+ _context.t2 = _context.sent;
196
+ _context.next = 15;
197
+ return _context.t1.createObjectURL.call(_context.t1, _context.t2);
198
+ case 15:
199
+ _context.t0 = _context.sent;
200
+ _context.next = 19;
201
+ break;
202
+ case 18:
203
+ _context.t0 = this.videoUrl;
204
+ case 19:
205
+ this.mediaInstance.src = _context.t0;
206
+ this.mediaInstance.setAttribute('data-src', this.videoUrl);
214
207
  onStart = function onStart() {
215
- var _this2$videoUrl;
216
-
217
- if (_this2.videoInstance.currentTime === 0) return;
208
+ if (_this2.mediaInstance.currentTime === 0) return;
218
209
  _this2.freeze = false;
219
- _this2.videoInstance.muted = false;
220
- uniforms.enable.value = (_this2$videoUrl = _this2.videoUrl) !== null && _this2$videoUrl !== void 0 && _this2$videoUrl.endsWith('.mp4') ? 1 : 0;
221
-
222
- _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);
223
213
  };
224
-
225
- this.videoInstance.addEventListener('timeupdate', onStart, false);
226
-
227
- case 18:
214
+ this.mediaInstance.addEventListener('timeupdate', onStart, false);
215
+ case 23:
228
216
  case "end":
229
217
  return _context.stop();
230
218
  }
231
219
  }
232
220
  }, _callee, this);
233
221
  }));
234
-
235
222
  function update(_x) {
236
223
  return _update.apply(this, arguments);
237
224
  }
238
-
239
225
  return update;
240
226
  }()
241
227
  }, {
242
228
  key: "play",
243
229
  value: function () {
244
- var _play = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
230
+ var _play = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
245
231
  var _this3 = this;
246
-
247
232
  var videoUrl,
248
- _args3 = arguments;
249
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
233
+ currentTime,
234
+ duration,
235
+ _args3 = arguments;
236
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
250
237
  while (1) {
251
238
  switch (_context3.prev = _context3.next) {
252
239
  case 0:
253
240
  videoUrl = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : '';
241
+ currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
242
+ duration = _args3.length > 2 ? _args3[2] : undefined;
254
243
  videoUrl = videoUrl || '';
255
-
256
- if (videoUrl) {
244
+ if (!(duration && !videoUrl)) {
257
245
  _context3.next = 10;
258
246
  break;
259
247
  }
260
-
248
+ if (this.currentTime) {
249
+ this.mediaInstance.currentTime = currentTime;
250
+ }
251
+ this.mediaInstance.duration = duration;
252
+ this.videoUrl = '';
253
+ this.mediaInstance.play();
254
+ return _context3.abrupt("return", true);
255
+ case 10:
256
+ if (videoUrl) {
257
+ _context3.next = 18;
258
+ break;
259
+ }
261
260
  if (!this.videoUrl) {
262
- _context3.next = 8;
261
+ _context3.next = 16;
263
262
  break;
264
263
  }
265
-
266
- _context3.next = 6;
267
- return this.videoInstance.play();
268
-
269
- case 6:
270
- _context3.next = 9;
264
+ _context3.next = 14;
265
+ return this.mediaInstance.play();
266
+ case 14:
267
+ _context3.next = 17;
271
268
  break;
272
-
273
- case 8:
269
+ case 16:
274
270
  console.warn('警告:视频资源未初始化。');
275
-
276
- case 9:
271
+ case 17:
277
272
  return _context3.abrupt("return", true);
278
-
279
- case 10:
273
+ case 18:
280
274
  if (!(videoUrl === this.videoUrl)) {
281
- _context3.next = 15;
275
+ _context3.next = 23;
282
276
  break;
283
277
  }
284
-
285
- this.videoInstance.currentTime = 0;
286
- _context3.next = 14;
287
- return this.videoInstance.play();
288
-
289
- case 14:
278
+ this.mediaInstance.currentTime = currentTime;
279
+ _context3.next = 22;
280
+ return this.mediaInstance.play();
281
+ case 22:
290
282
  return _context3.abrupt("return", true);
291
-
292
- case 15:
293
- _context3.next = 17;
283
+ case 23:
284
+ _context3.next = 25;
294
285
  return this.update(videoUrl);
295
-
296
- case 17:
297
- this.videoInstance.pause();
298
- _context3.next = 20;
286
+ case 25:
287
+ this.mediaInstance.pause();
288
+ _context3.next = 28;
299
289
  return new Promise(function (resolve) {
300
- return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
301
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
290
+ return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
291
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
302
292
  while (1) {
303
293
  switch (_context2.prev = _context2.next) {
304
294
  case 0:
305
- _this3.videoInstance.currentTime = 0;
295
+ _this3.mediaInstance.currentTime = currentTime;
306
296
  _context2.next = 3;
307
- return _this3.videoInstance.play();
308
-
297
+ return _this3.mediaInstance.play();
309
298
  case 3:
310
299
  resolve(true);
311
-
312
300
  case 4:
313
301
  case "end":
314
302
  return _context2.stop();
@@ -317,52 +305,43 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
317
305
  }, _callee2);
318
306
  })), 20);
319
307
  });
320
-
321
- case 20:
308
+ case 28:
322
309
  return _context3.abrupt("return", _context3.sent);
323
-
324
- case 21:
310
+ case 29:
325
311
  case "end":
326
312
  return _context3.stop();
327
313
  }
328
314
  }
329
315
  }, _callee3, this);
330
316
  }));
331
-
332
317
  function play() {
333
318
  return _play.apply(this, arguments);
334
319
  }
335
-
336
320
  return play;
337
321
  }()
338
322
  /**
339
323
  * 转成毫秒,保障精准度
340
324
  */
341
-
342
325
  }, {
343
326
  key: "currentTime",
344
327
  get: function get() {
345
- return this.videoInstance.currentTime * 1000;
328
+ return this.mediaInstance.currentTime * 1000;
346
329
  }
347
330
  }, {
348
331
  key: "dispose",
349
332
  value: function dispose() {
350
333
  // 销毁事件监听
351
334
  this.$removeEventListener();
352
-
353
335
  if (cacheInstance.audioInstance) {
354
336
  document.body.removeChild(cacheInstance.audioInstance);
355
337
  cacheInstance.audioInstance = undefined;
356
338
  }
357
-
358
339
  if (cacheInstance.videoInstance) {
359
340
  document.body.removeChild(cacheInstance.videoInstance);
360
341
  cacheInstance.videoInstance = undefined;
361
342
  }
362
343
  }
363
344
  }]);
364
-
365
345
  return VideoAgentMesh;
366
346
  }(THREE.Mesh);
367
-
368
347
  exports.VideoAgentMesh = VideoAgentMesh;
@@ -1,15 +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
- container: HTMLElement;
9
- constructor(container: HTMLElement, needRender?: boolean, options?: {
10
- videoInstance?: HTMLVideoElement;
11
- audioInstance?: HTMLAudioElement;
12
- });
8
+ disposers: (() => void)[];
9
+ constructor(container?: HTMLElement, options?: VideoAgentMeshOptions);
13
10
  run: () => void;
14
11
  dispose: () => void;
15
12
  }
@@ -1,87 +1,60 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
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); }
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
-
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); } }
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; }
18
15
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
-
20
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; }
21
-
22
- var VideoAgentScene = function VideoAgentScene(container) {
17
+ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container, options) {
23
18
  var _this = this;
24
-
25
- var needRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
26
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
27
-
28
19
  _classCallCheck(this, VideoAgentScene);
29
-
30
20
  _defineProperty(this, "scene", new THREE.Scene());
31
-
32
21
  _defineProperty(this, "camera", new THREE.OrthographicCamera(-240, 240, 135, -135));
33
-
34
22
  _defineProperty(this, "renderer", new THREE.WebGLRenderer({
35
23
  alpha: true
36
24
  }));
37
-
25
+ _defineProperty(this, "disposers", []);
38
26
  _defineProperty(this, "run", function () {
39
- var _this$videoAgentMesh$;
40
-
41
- var domElement = _this.renderer.domElement; // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
42
-
27
+ // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
43
28
  if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
44
29
  _this.renderer.render(_this.scene, _this.camera);
45
- } // 兼容非视频场景
46
-
47
-
48
- if (!((_this$videoAgentMesh$ = _this.videoAgentMesh.videoUrl) !== null && _this$videoAgentMesh$ !== void 0 && _this$videoAgentMesh$.endsWith('.mp4'))) {
49
- if (domElement.style.display !== 'none') domElement.style.display = 'none';
50
- } else {
51
- if (domElement.style.display !== 'block') domElement.style.display = 'block';
52
30
  }
53
-
54
31
  requestAnimationFrame(_this.run);
55
32
  });
56
-
57
33
  _defineProperty(this, "dispose", function () {
58
34
  var _this$videoAgentMesh;
59
-
60
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
+ });
61
39
  });
62
-
63
- this.container = container;
64
- this.camera.position.set(0, 0, 10);
65
- this.camera.lookAt(0, 0, 0);
66
- var state = {
67
- width: container.offsetWidth,
68
- height: container.offsetHeight
69
- };
70
- var _domElement = this.renderer.domElement;
71
-
72
- _domElement.classList.add('VideoAgent-canvas');
73
-
74
- this.renderer.setSize(state.width * window.devicePixelRatio, state.height * window.devicePixelRatio);
75
-
76
- _domElement.setAttribute('style', "width: ".concat(state.width, "px;height: ").concat(state.height, "px;"));
77
-
78
40
  this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
79
41
 
80
- if (needRender) {
81
- container.append(_domElement);
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);
82
56
  this.scene.add(this.videoAgentMesh);
83
57
  this.run();
84
58
  }
85
- };
86
-
59
+ });
87
60
  exports.VideoAgentScene = VideoAgentScene;