@realsee/vreo 1.0.0-alpha.17 → 1.0.0-alpha.19

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 (73) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/docs/demo/assets/{AppReact.a3fc45d3.js → AppReact.20163f9a.js} +1 -1
  3. package/docs/demo/assets/default.5069891b.js +3988 -0
  4. package/docs/demo/assets/{dynamic.714b9eb8.js → dynamic.c8118cc9.js} +1 -1
  5. package/docs/demo/assets/{examples.1a6f5a2c.js → examples.5391fc1f.js} +1 -1
  6. package/docs/demo/assets/{index.0ca9e9d3.js → index.2272a9ef.js} +1 -1
  7. package/docs/demo/assets/main.b335b989.js +1 -0
  8. package/docs/demo/assets/{react.fca6a967.js → react.efea3f3f.js} +1 -1
  9. package/docs/demo/examples.html +2 -2
  10. package/docs/demo/index-react-dynamic.html +4 -4
  11. package/docs/demo/index-react.html +4 -4
  12. package/docs/demo/index.html +3 -3
  13. package/lib/PlayController/createHTMLAudioElement.js +11 -6
  14. package/lib/PlayController/index.js +81 -16
  15. package/lib/Player/App.js +24 -0
  16. package/lib/Player/Controller.d.ts +2 -2
  17. package/lib/Player/Controller.js +95 -19
  18. package/lib/Player/custom/SpatialScenePanel/index.js +68 -42
  19. package/lib/Player/hooks.js +10 -0
  20. package/lib/Player/index.js +85 -25
  21. package/lib/Player/modules/Drawer/index.js +17 -0
  22. package/lib/Player/modules/PopUp/index.js +10 -0
  23. package/lib/Player/modules/ResizeObserver/index.js +8 -0
  24. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
  25. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +114 -20
  26. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +24 -2
  27. package/lib/Player/modules/VideoAgent/index.js +17 -0
  28. package/lib/Player/modules/Wave/index.js +32 -7
  29. package/lib/Player/modules/keyframes/BgMusic/index.js +44 -14
  30. package/lib/Player/modules/keyframes/CameraMovement/index.js +27 -3
  31. package/lib/Player/modules/keyframes/InfoPanel/index.js +25 -8
  32. package/lib/Player/modules/keyframes/ModelVideo/index.js +29 -3
  33. package/lib/Player/modules/keyframes/PanoEffect/index.js +43 -15
  34. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +7 -0
  35. package/lib/Player/modules/keyframes/PanoTag/index.js +21 -4
  36. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +47 -22
  37. package/lib/Player/modules/keyframes/Prompter/index.js +32 -10
  38. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +25 -18
  39. package/lib/Player/modules/keyframes/VideoEffect/index.js +47 -12
  40. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +2 -0
  41. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +1 -0
  42. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +1 -0
  43. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +60 -19
  44. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +5 -2
  45. package/lib/fivePlugins/CameraMovementPlugin/index.js +75 -28
  46. package/lib/fivePlugins/CameraMovementPlugin/typings.js +4 -0
  47. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +60 -11
  48. package/lib/index.js +1 -0
  49. package/lib/react/index.js +34 -7
  50. package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
  51. package/lib/shared-utils/{AduioLike.js → AudioLike.js} +43 -11
  52. package/lib/shared-utils/Preloader.js +7 -0
  53. package/lib/shared-utils/addResizeListener.js +5 -0
  54. package/lib/shared-utils/animationFrame/BetterTween.js +38 -2
  55. package/lib/shared-utils/animationFrame/index.js +10 -2
  56. package/lib/shared-utils/animationFrame/tween.js +15 -2
  57. package/lib/shared-utils/createTransMatrix.js +17 -2
  58. package/lib/shared-utils/getFileExpandedName.js +1 -0
  59. package/lib/shared-utils/getMediaInfo.js +9 -0
  60. package/lib/shared-utils/setElementDataset.js +2 -0
  61. package/lib/typings/VreoUnit.d.ts +5 -5
  62. package/lib/typings/VreoUnit.js +15 -0
  63. package/package.json +1 -1
  64. package/resources/PlayController/index.ts +1 -1
  65. package/resources/Player/Controller.ts +3 -3
  66. package/resources/Player/index.tsx +1 -1
  67. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +2 -2
  68. package/resources/Player/modules/keyframes/BgMusic/index.tsx +23 -14
  69. package/resources/Player/modules/keyframes/PanoTag/index.tsx +1 -0
  70. package/resources/shared-utils/{AduioLike.ts → AudioLike.ts} +4 -6
  71. package/resources/typings/VreoUnit.ts +5 -5
  72. package/docs/demo/assets/default.9985006b.js +0 -3988
  73. package/docs/demo/assets/main.7963f418.js +0 -1
@@ -1,42 +1,68 @@
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.VideoAgentMesh = void 0;
9
+
8
10
  var THREE = _interopRequireWildcard(require("three"));
11
+
9
12
  var _Preloader = require("../../../shared-utils/Preloader");
13
+
10
14
  var _mobx = require("mobx");
11
- var _AduioLike = _interopRequireDefault(require("../../../shared-utils/AduioLike"));
15
+
16
+ var _AudioLike = _interopRequireDefault(require("../../../shared-utils/AudioLike"));
17
+
12
18
  var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
19
+
13
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
14
22
  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); }
23
+
15
24
  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; }
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; }
25
+
17
26
  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); } }
27
+
18
28
  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); }); }; }
29
+
19
30
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
+
20
32
  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); } }
33
+
21
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
35
+
22
36
  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); }
37
+
38
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
39
+
24
40
  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); }; }
41
+
25
42
  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); }
43
+
26
44
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
45
+
27
46
  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; } }
28
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
+
48
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
+
29
50
  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";
51
+
30
52
  var fragmentShaderTpl = function fragmentShaderTpl() {
31
53
  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";
32
54
  };
55
+
33
56
  var cacheInstance = {};
57
+
34
58
  /**
35
59
  * 视频经纪人MESH
36
60
  */
37
61
  var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
38
62
  _inherits(VideoAgentMesh, _THREE$Mesh);
63
+
39
64
  var _super = _createSuper(VideoAgentMesh);
65
+
40
66
  /**
41
67
  *
42
68
  * @param width
@@ -47,11 +73,15 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
47
73
  */
48
74
  function VideoAgentMesh(width, height, widthSegments, heightSegments) {
49
75
  var _this$options$videoIn, _this$options$videoIn2, _this$options$videoIn3;
76
+
50
77
  var _this;
78
+
51
79
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
52
80
  preload: true
53
81
  };
82
+
54
83
  _classCallCheck(this, VideoAgentMesh);
84
+
55
85
  if (!options.videoInstance) {
56
86
  if (cacheInstance.videoInstance) {
57
87
  options.videoInstance = cacheInstance.videoInstance;
@@ -67,6 +97,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
67
97
  videoInstance.controls = false;
68
98
  }
69
99
  }
100
+
70
101
  var geometry = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
71
102
  var videoTexture = new THREE.VideoTexture(options.videoInstance);
72
103
  var material = new THREE.ShaderMaterial({
@@ -86,13 +117,14 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
86
117
  _this.options = options;
87
118
  _this.freeze = false;
88
119
  _this.paused = true;
120
+
89
121
  if (!options.audioInstance) {
90
122
  if (cacheInstance.audioInstance) {
91
123
  _this.audioInstance = cacheInstance.audioInstance;
92
124
  } else {
93
125
  var audioInstance = document.createElement('audio');
94
- audioInstance.crossOrigin = '';
95
- // videoInstance.muted = true
126
+ audioInstance.crossOrigin = ''; // videoInstance.muted = true
127
+
96
128
  audioInstance.muted = false;
97
129
  audioInstance.autoplay = false;
98
130
  audioInstance.style.display = 'none';
@@ -103,52 +135,74 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
103
135
  } else {
104
136
  _this.audioInstance = options.audioInstance;
105
137
  }
106
- _this.audioLikeInstance = new _AduioLike["default"]();
138
+
139
+ _this.audioLikeInstance = new _AudioLike["default"]();
107
140
  (0, _mobx.makeObservable)(_assertThisInitialized(_this), {
108
141
  paused: _mobx.observable
109
142
  });
143
+
110
144
  var updatePaused = function updatePaused(paused) {
111
145
  return (0, _mobx.runInAction)(function () {
112
146
  return _this.paused = paused;
113
147
  });
114
148
  };
149
+
115
150
  var onPause = function onPause() {
116
151
  return updatePaused(true);
117
152
  };
153
+
118
154
  var onPlay = function onPlay() {
119
155
  return updatePaused(false);
120
156
  };
157
+
121
158
  var onEnded = function onEnded() {
122
159
  return console.log('vreo: video 播放结束');
123
160
  };
161
+
124
162
  _this.audioInstance.addEventListener('pause', onPause);
163
+
125
164
  _this.audioInstance.addEventListener('play', onPlay);
165
+
126
166
  (_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
127
167
  (_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
168
+
128
169
  _this.audioLikeInstance.addEventListener('pause', onPause);
170
+
129
171
  _this.audioLikeInstance.addEventListener('play', onPlay);
172
+
130
173
  (_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.addEventListener('ended', onEnded);
174
+
131
175
  _this.$removeEventListener = function () {
132
176
  var _this$options$videoIn4, _this$options$videoIn5, _this$options$videoIn6;
177
+
133
178
  _this.audioInstance.removeEventListener('pause', onPause);
179
+
134
180
  _this.audioInstance.removeEventListener('play', onPlay);
181
+
135
182
  (_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('pause', onPause);
136
183
  (_this$options$videoIn5 = _this.options.videoInstance) === null || _this$options$videoIn5 === void 0 ? void 0 : _this$options$videoIn5.removeEventListener('play', onPlay);
184
+
137
185
  _this.audioLikeInstance.removeEventListener('pause', onPause);
186
+
138
187
  _this.audioLikeInstance.removeEventListener('play', onPlay);
188
+
139
189
  (_this$options$videoIn6 = _this.options.videoInstance) === null || _this$options$videoIn6 === void 0 ? void 0 : _this$options$videoIn6.removeEventListener('ended', onEnded);
140
190
  };
191
+
141
192
  return _this;
142
193
  }
194
+
143
195
  _createClass(VideoAgentMesh, [{
144
196
  key: "mediaInstance",
145
197
  get: function get() {
146
198
  if (!this.videoUrl) {
147
199
  return this.audioLikeInstance;
148
200
  }
201
+
149
202
  if ((0, _getMediaInfo.getMediaType)(this.videoUrl) === 'audio') {
150
203
  return this.audioInstance;
151
204
  }
205
+
152
206
  var uniforms = this.material.uniforms;
153
207
  var videoInstance = uniforms.map.value.image;
154
208
  return videoInstance;
@@ -156,10 +210,11 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
156
210
  }, {
157
211
  key: "update",
158
212
  value: function () {
159
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(videoUrl) {
213
+ var _update = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(videoUrl) {
160
214
  var _this2 = this;
215
+
161
216
  var uniforms, onStart;
162
- return _regeneratorRuntime().wrap(function _callee$(_context) {
217
+ return regeneratorRuntime.wrap(function _callee$(_context) {
163
218
  while (1) {
164
219
  switch (_context.prev = _context.next) {
165
220
  case 0:
@@ -167,11 +222,11 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
167
222
  _context.next = 2;
168
223
  break;
169
224
  }
225
+
170
226
  return _context.abrupt("return");
171
- case 2:
172
- this.videoUrl = videoUrl;
173
227
 
174
- // // 兼容非视频场景
228
+ case 2:
229
+ this.videoUrl = videoUrl; // // 兼容非视频场景
175
230
  // if (this.mediaInstance instanceof HTMLAudioElement) {
176
231
  // this.mediaInstance.style.display = 'none'
177
232
  // } else if (this.mediaInstance instanceof HTMLVideoElement) {
@@ -181,37 +236,48 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
181
236
  this.freeze = true;
182
237
  _context.next = 6;
183
238
  return this.mediaInstance.pause();
239
+
184
240
  case 6:
185
241
  uniforms = this.material.uniforms;
186
242
  this.mediaInstance.muted = true;
243
+
187
244
  if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
188
245
  _context.next = 18;
189
246
  break;
190
247
  }
248
+
191
249
  _context.t1 = URL;
192
250
  _context.next = 12;
193
251
  return _Preloader.Preloader.blob(this.videoUrl);
252
+
194
253
  case 12:
195
254
  _context.t2 = _context.sent;
196
255
  _context.next = 15;
197
256
  return _context.t1.createObjectURL.call(_context.t1, _context.t2);
257
+
198
258
  case 15:
199
259
  _context.t0 = _context.sent;
200
260
  _context.next = 19;
201
261
  break;
262
+
202
263
  case 18:
203
264
  _context.t0 = this.videoUrl;
265
+
204
266
  case 19:
205
267
  this.mediaInstance.src = _context.t0;
206
268
  this.mediaInstance.setAttribute('data-src', this.videoUrl);
269
+
207
270
  onStart = function onStart() {
208
271
  if (_this2.mediaInstance.currentTime === 0) return;
209
272
  _this2.freeze = false;
210
273
  _this2.mediaInstance.muted = false;
211
274
  uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
275
+
212
276
  _this2.mediaInstance.removeEventListener('timeupdate', onStart, false);
213
277
  };
278
+
214
279
  this.mediaInstance.addEventListener('timeupdate', onStart, false);
280
+
215
281
  case 23:
216
282
  case "end":
217
283
  return _context.stop();
@@ -219,21 +285,24 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
219
285
  }
220
286
  }, _callee, this);
221
287
  }));
288
+
222
289
  function update(_x) {
223
290
  return _update.apply(this, arguments);
224
291
  }
292
+
225
293
  return update;
226
294
  }()
227
295
  }, {
228
296
  key: "play",
229
297
  value: function () {
230
- var _play = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
298
+ var _play = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
231
299
  var _this3 = this;
300
+
232
301
  var videoUrl,
233
- currentTime,
234
- duration,
235
- _args3 = arguments;
236
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
302
+ currentTime,
303
+ duration,
304
+ _args3 = arguments;
305
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
237
306
  while (1) {
238
307
  switch (_context3.prev = _context3.next) {
239
308
  case 0:
@@ -241,62 +310,78 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
241
310
  currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
242
311
  duration = _args3.length > 2 ? _args3[2] : undefined;
243
312
  videoUrl = videoUrl || '';
313
+
244
314
  if (!(duration && !videoUrl)) {
245
315
  _context3.next = 10;
246
316
  break;
247
317
  }
318
+
248
319
  if (this.currentTime) {
249
320
  this.mediaInstance.currentTime = currentTime;
250
321
  }
322
+
251
323
  this.mediaInstance.duration = duration;
252
324
  this.videoUrl = '';
253
325
  this.mediaInstance.play();
254
326
  return _context3.abrupt("return", true);
327
+
255
328
  case 10:
256
329
  if (videoUrl) {
257
330
  _context3.next = 18;
258
331
  break;
259
332
  }
333
+
260
334
  if (!this.videoUrl) {
261
335
  _context3.next = 16;
262
336
  break;
263
337
  }
338
+
264
339
  _context3.next = 14;
265
340
  return this.mediaInstance.play();
341
+
266
342
  case 14:
267
343
  _context3.next = 17;
268
344
  break;
345
+
269
346
  case 16:
270
347
  console.warn('警告:视频资源未初始化。');
348
+
271
349
  case 17:
272
350
  return _context3.abrupt("return", true);
351
+
273
352
  case 18:
274
353
  if (!(videoUrl === this.videoUrl)) {
275
354
  _context3.next = 23;
276
355
  break;
277
356
  }
357
+
278
358
  this.mediaInstance.currentTime = currentTime;
279
359
  _context3.next = 22;
280
360
  return this.mediaInstance.play();
361
+
281
362
  case 22:
282
363
  return _context3.abrupt("return", true);
364
+
283
365
  case 23:
284
366
  _context3.next = 25;
285
367
  return this.update(videoUrl);
368
+
286
369
  case 25:
287
370
  this.mediaInstance.pause();
288
371
  _context3.next = 28;
289
372
  return new Promise(function (resolve) {
290
- return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
291
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
373
+ return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
374
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
292
375
  while (1) {
293
376
  switch (_context2.prev = _context2.next) {
294
377
  case 0:
295
378
  _this3.mediaInstance.currentTime = currentTime;
296
379
  _context2.next = 3;
297
380
  return _this3.mediaInstance.play();
381
+
298
382
  case 3:
299
383
  resolve(true);
384
+
300
385
  case 4:
301
386
  case "end":
302
387
  return _context2.stop();
@@ -305,8 +390,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
305
390
  }, _callee2);
306
391
  })), 20);
307
392
  });
393
+
308
394
  case 28:
309
395
  return _context3.abrupt("return", _context3.sent);
396
+
310
397
  case 29:
311
398
  case "end":
312
399
  return _context3.stop();
@@ -314,14 +401,17 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
314
401
  }
315
402
  }, _callee3, this);
316
403
  }));
404
+
317
405
  function play() {
318
406
  return _play.apply(this, arguments);
319
407
  }
408
+
320
409
  return play;
321
410
  }()
322
411
  /**
323
- * 转成毫秒,保障精准度
412
+ * 秒转成毫秒,保障精准度
324
413
  */
414
+
325
415
  }, {
326
416
  key: "currentTime",
327
417
  get: function get() {
@@ -332,16 +422,20 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
332
422
  value: function dispose() {
333
423
  // 销毁事件监听
334
424
  this.$removeEventListener();
425
+
335
426
  if (cacheInstance.audioInstance) {
336
427
  document.body.removeChild(cacheInstance.audioInstance);
337
428
  cacheInstance.audioInstance = undefined;
338
429
  }
430
+
339
431
  if (cacheInstance.videoInstance) {
340
432
  document.body.removeChild(cacheInstance.videoInstance);
341
433
  cacheInstance.videoInstance = undefined;
342
434
  }
343
435
  }
344
436
  }]);
437
+
345
438
  return VideoAgentMesh;
346
439
  }(THREE.Mesh);
440
+
347
441
  exports.VideoAgentMesh = VideoAgentMesh;
@@ -1,45 +1,65 @@
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.VideoAgentScene = void 0;
9
+
8
10
  var THREE = _interopRequireWildcard(require("three"));
11
+
9
12
  var _addResizeListener = require("../../../shared-utils/addResizeListener");
13
+
10
14
  var _VideoAgentMesh = require("./VideoAgentMesh");
15
+
11
16
  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
+
12
18
  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
+
13
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); } }
21
+
14
22
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+
15
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
+
16
26
  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; }
27
+
17
28
  var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container, options) {
18
29
  var _this = this;
30
+
19
31
  _classCallCheck(this, VideoAgentScene);
32
+
20
33
  _defineProperty(this, "scene", new THREE.Scene());
34
+
21
35
  _defineProperty(this, "camera", new THREE.OrthographicCamera(-240, 240, 135, -135));
36
+
22
37
  _defineProperty(this, "renderer", new THREE.WebGLRenderer({
23
38
  alpha: true
24
39
  }));
40
+
25
41
  _defineProperty(this, "disposers", []);
42
+
26
43
  _defineProperty(this, "run", function () {
27
44
  // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
28
45
  if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
29
46
  _this.renderer.render(_this.scene, _this.camera);
30
47
  }
48
+
31
49
  requestAnimationFrame(_this.run);
32
50
  });
51
+
33
52
  _defineProperty(this, "dispose", function () {
34
53
  var _this$videoAgentMesh;
54
+
35
55
  (_this$videoAgentMesh = _this.videoAgentMesh) === null || _this$videoAgentMesh === void 0 ? void 0 : _this$videoAgentMesh.dispose();
56
+
36
57
  _this.disposers.forEach(function (disposer) {
37
58
  return disposer === null || disposer === void 0 ? void 0 : disposer();
38
59
  });
39
60
  });
40
- this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
41
61
 
42
- // const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
62
+ this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options); // const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
43
63
 
44
64
  if (container) {
45
65
  this.camera.position.set(0, 0, 10);
@@ -48,6 +68,7 @@ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(contain
48
68
  domElement.classList.add('VideoAgent-canvas');
49
69
  var dispose = (0, _addResizeListener.addResizeListener)(container, function (width, height) {
50
70
  _this.renderer.setSize(width * window.devicePixelRatio, height * window.devicePixelRatio);
71
+
51
72
  domElement.style.width = "".concat(width, "px");
52
73
  domElement.style.height = "".concat(height, "px");
53
74
  });
@@ -57,4 +78,5 @@ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(contain
57
78
  this.run();
58
79
  }
59
80
  });
81
+
60
82
  exports.VideoAgentScene = VideoAgentScene;
@@ -1,40 +1,55 @@
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.VideoAgent = VideoAgent;
9
+
8
10
  var React = _interopRequireWildcard(require("react"));
11
+
9
12
  var _hooks = require("../../hooks");
13
+
10
14
  var _VideoAgentScene = require("./VideoAgentScene");
15
+
11
16
  var _classnames = _interopRequireDefault(require("classnames"));
17
+
12
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
13
20
  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
+
14
22
  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
+
15
24
  function VideoAgent(props) {
16
25
  var _controller$avatar2;
26
+
17
27
  var ref = React.useRef(null);
18
28
  var controller = (0, _hooks.useController)();
19
29
  var showAvatar = React.useMemo(function () {
20
30
  var _controller$avatar;
31
+
21
32
  return ((_controller$avatar = controller.avatar) === null || _controller$avatar === void 0 ? void 0 : _controller$avatar.url) && controller.avatar.force === true;
22
33
  }, [controller.avatar]);
23
34
  var showVideoAgent = React.useMemo(function () {
24
35
  var _controller$videoAgen;
36
+
25
37
  if (showAvatar) return false;
26
38
  return ((_controller$videoAgen = controller.videoAgentScene) === null || _controller$videoAgen === void 0 ? void 0 : _controller$videoAgen.videoAgentMesh.mediaInstance) instanceof HTMLVideoElement;
27
39
  }, [controller.videoAgentScene, showAvatar]);
28
40
  React.useEffect(function () {
29
41
  if (!ref.current) throw new Error('React 渲染异常,请稍后重试 ...');
42
+
30
43
  if (controller.videoAgentScene) {
31
44
  console.warn('VideoAgentScene" 重复初始化,已被过滤');
32
45
  return;
33
46
  }
47
+
34
48
  var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, props.options);
35
49
  controller.videoAgentScene = videoAgentScene;
36
50
  return function () {
37
51
  var _controller$videoAgen2;
52
+
38
53
  controller.dispose();
39
54
  (_controller$videoAgen2 = controller.videoAgentScene) === null || _controller$videoAgen2 === void 0 ? void 0 : _controller$videoAgen2.dispose();
40
55
  };
@@ -51,6 +66,7 @@ function VideoAgent(props) {
51
66
  src: (_controller$avatar2 = controller.avatar) === null || _controller$avatar2 === void 0 ? void 0 : _controller$avatar2.url,
52
67
  onClick: function onClick() {
53
68
  var _props$onClick;
69
+
54
70
  return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props);
55
71
  }
56
72
  }))), /*#__PURE__*/React.createElement("div", {
@@ -68,6 +84,7 @@ function VideoAgent(props) {
68
84
  className: "VideoAgent-play",
69
85
  onClick: function onClick() {
70
86
  var _props$onClick2;
87
+
71
88
  return (_props$onClick2 = props.onClick) === null || _props$onClick2 === void 0 ? void 0 : _props$onClick2.call(props);
72
89
  }
73
90
  }))))));